2019-04-05 12:36:12 +02:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const shared = require("./shared");
|
2019-04-08 22:52:38 +02:00
|
|
|
const { addError, isBlankLine } = shared;
|
2019-04-05 12:36:12 +02:00
|
|
|
|
|
|
|
|
module.exports = {
|
2019-04-08 22:52:38 +02:00
|
|
|
"names": [ "MD047", "single-trailing-newline" ],
|
|
|
|
|
"description": "Files should end with a single newline character",
|
2019-04-05 12:36:12 +02:00
|
|
|
"tags": [ "blank_lines" ],
|
2019-04-08 22:52:38 +02:00
|
|
|
"function": function MD047(params, onError) {
|
2019-04-05 12:36:12 +02:00
|
|
|
const lastLineNumber = params.lines.length;
|
|
|
|
|
const lastLine = params.lines[lastLineNumber - 1];
|
|
|
|
|
if (!isBlankLine(lastLine)) {
|
2019-04-08 22:52:38 +02:00
|
|
|
addError(onError, lastLineNumber);
|
2019-04-05 12:36:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|