mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-24 09:50:13 +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
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
## Heading 2 {MD019}
|
||||
|
||||
## Heading 3 {MD019}
|
||||
## Heading 3 {MD019}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
* Test X
|
||||
* Test Y {MD007}
|
||||
* Test Z {MD007}
|
||||
* Test Z {MD007}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ Some text
|
|||
Some more text
|
||||
|
||||
* Item {MD006}
|
||||
* Item
|
||||
* Item
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ Some text {MD012:3}
|
|||
|
||||
with two blank lines in it
|
||||
|
||||
Some more text
|
||||
Some more text
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
* Item
|
||||
* Item
|
||||
* Item
|
||||
* Item
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
- Item
|
||||
- Item
|
||||
- Item
|
||||
- Item
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
+ Item
|
||||
+ Item
|
||||
+ Item
|
||||
+ Item
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@
|
|||
|
||||
- a
|
||||
|
||||
1. a
|
||||
1. a
|
||||
|
|
|
|||
|
|
@ -39,4 +39,4 @@ text
|
|||
|
||||
```
|
||||
code at end of file without newline
|
||||
```
|
||||
``` {MD046}
|
||||
|
|
@ -1 +1 @@
|
|||
## Heading
|
||||
## Heading
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
Heading
|
||||
-------
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
# Heading
|
||||
# Heading
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
Heading
|
||||
=======
|
||||
=======
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@
|
|||
|
||||
## Heading 3
|
||||
|
||||
{MD024:5} {MD024:7}
|
||||
{MD024:5} {MD024:7}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
# Heading 1
|
||||
|
||||
# Heading 2 {MD025}
|
||||
# Heading 2 {MD025}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ Some introductory text
|
|||
|
||||
# Heading 1
|
||||
|
||||
# Heading 2
|
||||
# Heading 2
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@
|
|||
|
||||
## Heading 5 {MD026};
|
||||
|
||||
## Heading 6 {MD026}?
|
||||
## Heading 6 {MD026}?
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
## Heading 2
|
||||
|
||||
#### Heading 4 {MD001}
|
||||
#### Heading 4 {MD001}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
## Heading 2
|
||||
|
||||
## Heading 3
|
||||
## Heading 3
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ Heading 4
|
|||
Some text
|
||||
|
||||
Heading 5
|
||||
---------
|
||||
---------
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
* Item
|
||||
* Item {MD007}
|
||||
* Item {MD005}
|
||||
* Item {MD007}
|
||||
* Item {MD007}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
* Item
|
||||
+ Item {MD004}
|
||||
- Item {MD004}
|
||||
- Item {MD004}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
- Item
|
||||
* Item {MD004}
|
||||
+ Item {MD004}
|
||||
+ Item {MD004}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
+ Item
|
||||
* Item {MD004}
|
||||
- Item {MD004}
|
||||
- Item {MD004}
|
||||
|
|
|
|||
|
|
@ -72,4 +72,4 @@ code
|
|||
|
||||
text
|
||||
|
||||
* list (on last line without newline)
|
||||
* list (on last line without newline) {MD046}
|
||||
|
|
@ -248,7 +248,7 @@ module.exports.resultFormattingV1 = function resultFormattingV1(test) {
|
|||
const options = {
|
||||
"strings": {
|
||||
"truncate":
|
||||
"# Multiple spaces inside hashes on closed atx style heading #"
|
||||
"# Multiple spaces inside hashes on closed atx style heading #\n"
|
||||
},
|
||||
"files": [
|
||||
"./test/atx_heading_spacing.md",
|
||||
|
|
@ -350,7 +350,7 @@ module.exports.resultFormattingV2 = function resultFormattingV2(test) {
|
|||
const options = {
|
||||
"strings": {
|
||||
"truncate":
|
||||
"# Multiple spaces inside hashes on closed atx style heading #"
|
||||
"# Multiple spaces inside hashes on closed atx style heading #\n"
|
||||
},
|
||||
"files": [
|
||||
"./test/atx_heading_spacing.md",
|
||||
|
|
@ -446,14 +446,14 @@ module.exports.stringInputLineEndings = function stringInputLineEndings(test) {
|
|||
test.expect(2);
|
||||
const options = {
|
||||
"strings": {
|
||||
"cr": "One\rTwo\r#Three",
|
||||
"lf": "One\nTwo\n#Three",
|
||||
"crlf": "One\r\nTwo\r\n#Three",
|
||||
"mixed": "One\rTwo\n#Three",
|
||||
"crnel": "One\r\u0085Two\r\u0085#Three",
|
||||
"snl": "One\u2424Two\u2424#Three",
|
||||
"lsep": "One\u2028Two\u2028#Three",
|
||||
"nel": "One\u0085Two\u0085#Three"
|
||||
"cr": "One\rTwo\r#Three\n",
|
||||
"lf": "One\nTwo\n#Three\n",
|
||||
"crlf": "One\r\nTwo\r\n#Three\n",
|
||||
"mixed": "One\rTwo\n#Three\n",
|
||||
"crnel": "One\r\u0085Two\r\u0085#Three\n",
|
||||
"snl": "One\u2424Two\u2424#Three\n",
|
||||
"lsep": "One\u2028Two\u2028#Three\n",
|
||||
"nel": "One\u0085Two\u0085#Three\n"
|
||||
},
|
||||
"config": defaultConfig,
|
||||
"resultVersion": 0
|
||||
|
|
@ -913,7 +913,7 @@ module.exports.noInlineConfig = function noInlineConfig(test) {
|
|||
"",
|
||||
"<!-- markdownlint-enable-->",
|
||||
"",
|
||||
"\tTab"
|
||||
"\tTab\n"
|
||||
].join("\n")
|
||||
},
|
||||
"noInlineConfig": true,
|
||||
|
|
@ -1089,7 +1089,7 @@ module.exports.missingStringValue = function missingStringValue(test) {
|
|||
};
|
||||
|
||||
module.exports.readme = function readme(test) {
|
||||
test.expect(109);
|
||||
test.expect(111);
|
||||
const tagToRules = {};
|
||||
rules.forEach(function forRule(rule) {
|
||||
rule.tags.forEach(function forTag(tag) {
|
||||
|
|
@ -1155,7 +1155,7 @@ module.exports.readme = function readme(test) {
|
|||
};
|
||||
|
||||
module.exports.doc = function doc(test) {
|
||||
test.expect(312);
|
||||
test.expect(319);
|
||||
fs.readFile("doc/Rules.md", shared.utf8Encoding,
|
||||
function readFile(err, contents) {
|
||||
test.ifError(err);
|
||||
|
|
@ -1883,7 +1883,7 @@ module.exports.configBadHybridSync = function configBadHybridSync(test) {
|
|||
|
||||
module.exports.allBuiltInRulesHaveValidUrl =
|
||||
function allBuiltInRulesHaveValidUrl(test) {
|
||||
test.expect(123);
|
||||
test.expect(126);
|
||||
rules.forEach(function forRule(rule) {
|
||||
test.ok(rule.information);
|
||||
test.ok(Object.getPrototypeOf(rule.information) === URL.prototype);
|
||||
|
|
@ -2240,7 +2240,7 @@ module.exports.customRulesNpmPackage = function customRulesNpmPackage(test) {
|
|||
const options = {
|
||||
"customRules": [ require("./rules/npm") ],
|
||||
"strings": {
|
||||
"string": "# Text\n\n---\n\nText"
|
||||
"string": "# Text\n\n---\n\nText\n"
|
||||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
|
|
@ -2539,7 +2539,7 @@ module.exports.customRulesOnErrorLazy = function customRulesOnErrorLazy(test) {
|
|||
}
|
||||
],
|
||||
"strings": {
|
||||
"string": "# Heading"
|
||||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
|
|
@ -2626,7 +2626,7 @@ module.exports.markdownItPluginsSingle =
|
|||
test.expect(2);
|
||||
markdownlint({
|
||||
"strings": {
|
||||
"string": "# Heading\n\nText [ link ](https://example.com)"
|
||||
"string": "# Heading\n\nText [ link ](https://example.com)\n"
|
||||
},
|
||||
"markdownItPlugins": [
|
||||
[
|
||||
|
|
@ -2651,7 +2651,7 @@ module.exports.markdownItPluginsMultiple =
|
|||
test.expect(4);
|
||||
markdownlint({
|
||||
"strings": {
|
||||
"string": "# Heading\n\nText H~2~0 text 29^th^ text"
|
||||
"string": "# Heading\n\nText H~2~0 text 29^th^ text\n"
|
||||
},
|
||||
"markdownItPlugins": [
|
||||
[ pluginSub ],
|
||||
|
|
@ -2704,7 +2704,7 @@ $$
|
|||
1
|
||||
$$$$
|
||||
2
|
||||
$$`
|
||||
$$\n`
|
||||
},
|
||||
"markdownItPlugins": [ [ pluginKatex ] ],
|
||||
"resultVersion": 0
|
||||
|
|
@ -2719,3 +2719,25 @@ $$`
|
|||
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": [ "MD046", "new-line-eof" ],
|
||||
"ruleDescription": "New lines at the end of file",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md046`,
|
||||
"errorDetail": "file does not end with new line",
|
||||
"errorContext": null,
|
||||
"errorRange": null }
|
||||
] };
|
||||
test.deepEqual(actual, expected, "Unexpected issues.");
|
||||
test.done();
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
--
|
||||
--
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
## Heading 2 {MD003} ##
|
||||
|
||||
Heading 3 {MD003}
|
||||
-----------------
|
||||
-----------------
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
## Heading 2 {MD003}
|
||||
|
||||
Heading 3 {MD003}
|
||||
-----------------
|
||||
-----------------
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ Heading 1
|
|||
|
||||
## Heading 2 {MD003}
|
||||
|
||||
## Heading 3 {MD003} ##
|
||||
## Heading 3 {MD003} ##
|
||||
|
|
|
|||
4
test/new_line_EOF.json
Normal file
4
test/new_line_EOF.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"default": true,
|
||||
"MD046": false
|
||||
}
|
||||
3
test/new_line_EOF.md
Normal file
3
test/new_line_EOF.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# File ending without new line
|
||||
|
||||
This file ends without new line.
|
||||
|
|
@ -4,4 +4,4 @@ One
|
|||
Two
|
||||
---
|
||||
|
||||
{MD043}
|
||||
{MD043} {MD046}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
Some text {MD009}
|
||||
Some more text {MD010}
|
||||
Some more text
|
||||
Some more text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue