mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-22 17:00:13 +01:00
Update MD009/no-trailing-spaces default configuration to allow 2 spaces for hard break (fixes #114).
This commit is contained in:
parent
36dc946f46
commit
3e1317709a
7 changed files with 29 additions and 26 deletions
18
lib/md009.js
18
lib/md009.js
|
|
@ -11,7 +11,10 @@ module.exports = {
|
|||
"description": "Trailing spaces",
|
||||
"tags": [ "whitespace" ],
|
||||
"function": function MD009(params, onError) {
|
||||
const brSpaces = params.config.br_spaces || 0;
|
||||
let brSpaces = params.config.br_spaces;
|
||||
if (brSpaces === undefined) {
|
||||
brSpaces = 2;
|
||||
}
|
||||
const listItemEmptyLines = params.config.list_item_empty_lines;
|
||||
const allowListItemEmptyLines =
|
||||
(listItemEmptyLines === undefined) ? false : !!listItemEmptyLines;
|
||||
|
|
@ -23,14 +26,19 @@ module.exports = {
|
|||
}
|
||||
});
|
||||
}
|
||||
const expected = (brSpaces < 2) ? 0 : brSpaces;
|
||||
shared.forEachLine(function forLine(line, lineIndex) {
|
||||
const lineNumber = lineIndex + 1;
|
||||
if (trailingSpaceRe.test(line) &&
|
||||
(listItemLineNumbers.indexOf(lineNumber) === -1)) {
|
||||
const expected = (brSpaces < 2) ? 0 : brSpaces;
|
||||
shared.addErrorDetailIf(onError, lineNumber,
|
||||
expected, line.length - shared.trimRight(line).length, null,
|
||||
shared.rangeFromRegExp(line, trailingSpaceRe));
|
||||
const actual = line.length - shared.trimRight(line).length;
|
||||
if (expected !== actual) {
|
||||
shared.addError(onError, lineNumber,
|
||||
"Expected: " + (expected === 0 ? "" : "0 or ") +
|
||||
expected + "; Actual: " + actual,
|
||||
null,
|
||||
shared.rangeFromRegExp(line, trailingSpaceRe));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue