2018-02-15 21:35:58 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
"names": [ "every-n-lines" ],
|
|
|
|
|
"description": "Rule that reports an error every N lines",
|
|
|
|
|
"tags": [ "test" ],
|
|
|
|
|
"function": function rule(params, onError) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const n = params.config.n || 2;
|
2018-02-15 21:35:58 -08:00
|
|
|
params.lines.forEach(function forLine(line, lineIndex) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const lineNumber = lineIndex + 1;
|
2018-02-15 21:35:58 -08:00
|
|
|
if ((lineNumber % n) === 0) {
|
|
|
|
|
onError({
|
|
|
|
|
"lineNumber": lineNumber,
|
2018-02-27 21:14:02 -08:00
|
|
|
"detail": "Line number " + lineNumber
|
2018-02-15 21:35:58 -08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|