Updated MD047 name, desription and adjusted tests

This commit is contained in:
KitoW 2019-04-08 22:52:38 +02:00
parent 33eaf0bdda
commit cf259d4099
9 changed files with 27 additions and 49 deletions

View file

@ -3,20 +3,17 @@
"use strict";
const shared = require("./shared");
const { isBlankLine } = shared;
const { addError, isBlankLine } = shared;
module.exports = {
"names": [ "MD047", "new-line-eof" ],
"description": "New lines at the end of file",
"names": [ "MD047", "single-trailing-newline" ],
"description": "Files should end with a single newline character",
"tags": [ "blank_lines" ],
"function": function rule(params, onError) {
"function": function MD047(params, onError) {
const lastLineNumber = params.lines.length;
const lastLine = params.lines[lastLineNumber - 1];
if (!isBlankLine(lastLine)) {
onError({
"lineNumber": lastLineNumber,
"detail": "file does not end with new line"
});
addError(onError, lastLineNumber);
}
}
};