mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-03-11 04:42:33 +01:00
Updated MD047 name, desription and adjusted tests
This commit is contained in:
parent
33eaf0bdda
commit
cf259d4099
9 changed files with 27 additions and 49 deletions
|
|
@ -87,7 +87,7 @@ playground for learning and exploring.
|
||||||
* **[MD043](doc/Rules.md#md043)** *required-headings/required-headers* - Required heading structure
|
* **[MD043](doc/Rules.md#md043)** *required-headings/required-headers* - Required heading structure
|
||||||
* **[MD044](doc/Rules.md#md044)** *proper-names* - Proper names should have the correct capitalization
|
* **[MD044](doc/Rules.md#md044)** *proper-names* - Proper names should have the correct capitalization
|
||||||
* **[MD045](doc/Rules.md#md045)** *no-alt-text* - Images should have alternate text (alt text)
|
* **[MD045](doc/Rules.md#md045)** *no-alt-text* - Images should have alternate text (alt text)
|
||||||
* **[MD047](doc/Rules.md#md047)** *new-line-eof* - New lines at the end of file
|
* **[MD047](doc/Rules.md#md047)** *single-trailing-newline* - Files should end with a single newline character
|
||||||
|
|
||||||
See [Rules.md](doc/Rules.md) for more details.
|
See [Rules.md](doc/Rules.md) for more details.
|
||||||
|
|
||||||
|
|
|
||||||
11
doc/Rules.md
11
doc/Rules.md
|
|
@ -1545,15 +1545,15 @@ Guidance for writing alternate text is available from the [W3C](https://www.w3.o
|
||||||
[Wikipedia](https://en.wikipedia.org/wiki/Alt_attribute), and
|
[Wikipedia](https://en.wikipedia.org/wiki/Alt_attribute), and
|
||||||
[other locations](https://www.phase2technology.com/blog/no-more-excuses-definitive-guide-alt-text-field).
|
[other locations](https://www.phase2technology.com/blog/no-more-excuses-definitive-guide-alt-text-field).
|
||||||
|
|
||||||
<a name="md045"></a>
|
<a name="md047"></a>
|
||||||
|
|
||||||
## MD047 - New lines at the end of file
|
## MD047 - Files should end with a single newline character
|
||||||
|
|
||||||
Tags: blank_lines
|
Tags: blank_lines
|
||||||
|
|
||||||
Aliases: new-line-eof
|
Aliases: single-trailing-newline
|
||||||
|
|
||||||
This rule is triggered when there is no new line at the end of the file.
|
This rule is triggered when there is no single newline character at the end of the file.
|
||||||
|
|
||||||
Example that triggers the rule:
|
Example that triggers the rule:
|
||||||
|
|
||||||
|
|
@ -1568,6 +1568,5 @@ To fix the violation, add new line at the end of the file:
|
||||||
```markdown
|
```markdown
|
||||||
# File ending with new line
|
# File ending with new line
|
||||||
|
|
||||||
This file ends with new line.
|
This file ends with new line.\n
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
13
lib/md047.js
13
lib/md047.js
|
|
@ -3,20 +3,17 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const shared = require("./shared");
|
const shared = require("./shared");
|
||||||
const { isBlankLine } = shared;
|
const { addError, isBlankLine } = shared;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"names": [ "MD047", "new-line-eof" ],
|
"names": [ "MD047", "single-trailing-newline" ],
|
||||||
"description": "New lines at the end of file",
|
"description": "Files should end with a single newline character",
|
||||||
"tags": [ "blank_lines" ],
|
"tags": [ "blank_lines" ],
|
||||||
"function": function rule(params, onError) {
|
"function": function MD047(params, onError) {
|
||||||
const lastLineNumber = params.lines.length;
|
const lastLineNumber = params.lines.length;
|
||||||
const lastLine = params.lines[lastLineNumber - 1];
|
const lastLine = params.lines[lastLineNumber - 1];
|
||||||
if (!isBlankLine(lastLine)) {
|
if (!isBlankLine(lastLine)) {
|
||||||
onError({
|
addError(onError, lastLineNumber);
|
||||||
"lineNumber": lastLineNumber,
|
|
||||||
"detail": "file does not end with new line"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -78,4 +78,4 @@ code fence without language {MD040:73}
|
||||||
|
|
||||||
markdownLint {MD044}
|
markdownLint {MD044}
|
||||||
|
|
||||||
 {MD045}
|
 {MD045} {MD047}
|
||||||
|
|
@ -16,4 +16,4 @@ MarkDownLint.
|
||||||
|
|
||||||
A [normal](link) and an [empty one]() and a [fragment](#one).
|
A [normal](link) and an [empty one]() and a [fragment](#one).
|
||||||
|
|
||||||
An image without alternate text 
|
An image without alternate text 
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
"errorRange": [25, 13]
|
"errorRange": [25, 13]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lineNumber": 20,
|
"lineNumber": 19,
|
||||||
"ruleNames": [ "MD043", "required-headings", "required-headers" ],
|
"ruleNames": [ "MD043", "required-headings", "required-headers" ],
|
||||||
"ruleDescription": "Required heading structure",
|
"ruleDescription": "Required heading structure",
|
||||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md043",
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md043",
|
||||||
|
|
@ -88,5 +88,14 @@
|
||||||
"errorDetail": null,
|
"errorDetail": null,
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 19,
|
||||||
|
"ruleNames": [ "MD047", "single-trailing-newline" ],
|
||||||
|
"ruleDescription": "Files should end with a single newline character",
|
||||||
|
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md047",
|
||||||
|
"errorDetail": null,
|
||||||
|
"errorContext": null,
|
||||||
|
"errorRange": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -808,7 +808,8 @@ module.exports.styleAll = function styleAll(test) {
|
||||||
"MD040": [ 73 ],
|
"MD040": [ 73 ],
|
||||||
"MD041": [ 1 ],
|
"MD041": [ 1 ],
|
||||||
"MD042": [ 77 ],
|
"MD042": [ 77 ],
|
||||||
"MD045": [ 81 ]
|
"MD045": [ 81 ],
|
||||||
|
"MD047": [ 81 ]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
||||||
|
|
@ -847,7 +848,8 @@ module.exports.styleRelaxed = function styleRelaxed(test) {
|
||||||
"MD035": [ 61 ],
|
"MD035": [ 61 ],
|
||||||
"MD036": [ 65 ],
|
"MD036": [ 65 ],
|
||||||
"MD042": [ 77 ],
|
"MD042": [ 77 ],
|
||||||
"MD045": [ 81 ]
|
"MD045": [ 81 ],
|
||||||
|
"MD047": [ 81 ]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
||||||
|
|
@ -2719,25 +2721,3 @@ $$\n`
|
||||||
test.done();
|
test.done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.newLineAtTheEndOfFile =
|
|
||||||
function newLineAtTheEndOfFile(test) {
|
|
||||||
test.expect(2);
|
|
||||||
markdownlint({
|
|
||||||
"files": "./test/new_line_EOF.md"
|
|
||||||
}, function callback(err, actual) {
|
|
||||||
test.ifError(err);
|
|
||||||
const expected = { "./test/new_line_EOF.md":
|
|
||||||
[
|
|
||||||
{ "lineNumber": 3,
|
|
||||||
"ruleNames": [ "MD047", "new-line-eof" ],
|
|
||||||
"ruleDescription": "New lines at the end of file",
|
|
||||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`,
|
|
||||||
"errorDetail": "file does not end with new line",
|
|
||||||
"errorContext": null,
|
|
||||||
"errorRange": null }
|
|
||||||
] };
|
|
||||||
test.deepEqual(actual, expected, "Unexpected issues.");
|
|
||||||
test.done();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"default": true,
|
|
||||||
"MD047": false
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# File ending without new line
|
|
||||||
|
|
||||||
This file ends without new line.
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue