mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-01-19 05:46:09 +01:00
Adding new rule for enforcing new lines at the end of file, fixes #89
This commit is contained in:
parent
827e1acb56
commit
12a51da282
39 changed files with 142 additions and 52 deletions
22
lib/md046.js
Normal file
22
lib/md046.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { isBlankLine } = shared;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD046", "new-line-eof" ],
|
||||
"description": "New lines at the end of file",
|
||||
"tags": [ "blank_lines" ],
|
||||
"function": function rule(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"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -48,7 +48,8 @@ const rules = [
|
|||
require("./md042"),
|
||||
require("./md043"),
|
||||
require("./md044"),
|
||||
require("./md045")
|
||||
require("./md045"),
|
||||
require("./md046")
|
||||
];
|
||||
rules.forEach((rule) => {
|
||||
const name = rule.names[0].toLowerCase();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue