Add MD047/single-trailing-newline for enforcing new lines at the end of file (fixes #89).

This commit is contained in:
KitoW 2019-04-05 12:36:12 +02:00 committed by David Anson
parent 73511ff677
commit a977d0dcbc
40 changed files with 130 additions and 56 deletions

View file

@ -2,4 +2,4 @@
## Heading 2 {MD019}
## Heading 3 {MD019}
## Heading 3 {MD019}

View file

@ -78,4 +78,4 @@ code fence without language {MD040:73} {MD046:73}
markdownLint {MD044}
![](image.jpg) {MD045}
![](image.jpg) {MD045} {MD047}

View file

@ -1,3 +1,3 @@
* Test X
* Test Y {MD007}
* Test Z {MD007}
* Test Z {MD007}

View file

@ -11,4 +11,4 @@ Some text
Some more text
* Item {MD006}
* Item
* Item

View file

@ -8,4 +8,4 @@ Some text {MD012:3}
with two blank lines in it
Some more text
Some more text

View file

@ -1,3 +1,3 @@
* Item
* Item
* Item
* Item

View file

@ -1,3 +1,3 @@
- Item
- Item
- Item
- Item

View file

@ -1,3 +1,3 @@
+ Item
+ Item
+ Item
+ Item

View file

@ -10,4 +10,4 @@
- a
1. a
1. a

View file

@ -23,3 +23,5 @@ Fenced code
```
Indented code
Missing newline character

View file

@ -45,7 +45,7 @@
"errorRange": [25, 13]
},
{
"lineNumber": 26,
"lineNumber": 27,
"ruleNames": [ "MD043", "required-headings", "required-headers" ],
"ruleDescription": "Required heading structure",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md043",
@ -97,5 +97,14 @@
"errorDetail": "Expected: fenced; Actual: indented",
"errorContext": null,
"errorRange": null
},
{
"lineNumber": 27,
"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
}
]

View file

@ -38,5 +38,5 @@ code
text
```
code at end of file without newline
code at end of file without newline {MD047:42}
```

View file

@ -1 +1 @@
## Heading
## Heading

View file

@ -1,2 +1,2 @@
Heading
-------
-------

View file

@ -1 +1 @@
# Heading
# Heading

View file

@ -1,2 +1,2 @@
Heading
=======
=======

View file

@ -8,4 +8,4 @@
## Heading 3
{MD024:5} {MD024:7}
{MD024:5} {MD024:7}

View file

@ -1,3 +1,3 @@
# Heading 1
# Heading 2 {MD025}
# Heading 2 {MD025}

View file

@ -2,4 +2,4 @@ Some introductory text
# Heading 1
# Heading 2
# Heading 2

View file

@ -8,4 +8,4 @@
## Heading 5 {MD026};
## Heading 6 {MD026}?
## Heading 6 {MD026}?

View file

@ -4,4 +4,4 @@
## Heading 2
#### Heading 4 {MD001}
#### Heading 4 {MD001}

View file

@ -2,4 +2,4 @@
## Heading 2
## Heading 3
## Heading 3

View file

@ -12,4 +12,4 @@ Heading 4
Some text
Heading 5
---------
---------

View file

@ -1,4 +1,4 @@
* Item
* Item {MD007}
* Item {MD005}
* Item {MD007}
* Item {MD007}

View file

@ -1,3 +1,3 @@
* Item
+ Item {MD004}
- Item {MD004}
- Item {MD004}

View file

@ -1,3 +1,3 @@
- Item
* Item {MD004}
+ Item {MD004}
+ Item {MD004}

View file

@ -1,3 +1,3 @@
+ Item
* Item {MD004}
- Item {MD004}
- Item {MD004}

View file

@ -72,4 +72,4 @@ code
text
* list (on last line without newline)
* list (on last line without newline) {MD047}

View file

@ -250,7 +250,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",
@ -352,7 +352,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",
@ -448,14 +448,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
@ -811,7 +811,8 @@ module.exports.styleAll = function styleAll(test) {
"MD041": [ 1 ],
"MD042": [ 77 ],
"MD045": [ 81 ],
"MD046": [ 49, 73 ]
"MD046": [ 49, 73 ],
"MD047": [ 81 ]
}
};
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
@ -851,7 +852,8 @@ module.exports.styleRelaxed = function styleRelaxed(test) {
"MD036": [ 65 ],
"MD042": [ 77 ],
"MD045": [ 81 ],
"MD046": [ 49, 73 ]
"MD046": [ 49, 73 ],
"MD047": [ 81 ]
}
};
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
@ -917,7 +919,7 @@ module.exports.noInlineConfig = function noInlineConfig(test) {
"",
"<!-- markdownlint-enable-->",
"",
"\tTab"
"\tTab\n"
].join("\n")
},
"noInlineConfig": true,
@ -1093,7 +1095,7 @@ module.exports.missingStringValue = function missingStringValue(test) {
};
module.exports.readme = function readme(test) {
test.expect(111);
test.expect(113);
const tagToRules = {};
rules.forEach(function forRule(rule) {
rule.tags.forEach(function forTag(tag) {
@ -1159,7 +1161,7 @@ module.exports.readme = function readme(test) {
};
module.exports.doc = function doc(test) {
test.expect(320);
test.expect(327);
fs.readFile("doc/Rules.md", helpers.utf8Encoding,
function readFile(err, contents) {
test.ifError(err);
@ -1859,7 +1861,7 @@ module.exports.configBadHybridSync = function configBadHybridSync(test) {
module.exports.allBuiltInRulesHaveValidUrl =
function allBuiltInRulesHaveValidUrl(test) {
test.expect(126);
test.expect(129);
rules.forEach(function forRule(rule) {
test.ok(rule.information);
test.ok(Object.getPrototypeOf(rule.information) === URL.prototype);
@ -2216,7 +2218,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
};
@ -2515,7 +2517,7 @@ module.exports.customRulesOnErrorLazy = function customRulesOnErrorLazy(test) {
}
],
"strings": {
"string": "# Heading"
"string": "# Heading\n"
}
};
markdownlint(options, function callback(err, actualResult) {
@ -2602,7 +2604,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": [
[
@ -2627,7 +2629,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 ],
@ -2680,7 +2682,7 @@ $$
1
$$$$
2
$$`
$$\n`
},
"markdownItPlugins": [ [ pluginKatex ] ],
"resultVersion": 0

View file

@ -0,0 +1,4 @@
{
"default": true,
"MD047": false
}

View file

@ -3,4 +3,4 @@
## Heading 2 {MD003} ##
Heading 3 {MD003}
-----------------
-----------------

View file

@ -3,4 +3,4 @@
## Heading 2 {MD003}
Heading 3 {MD003}
-----------------
-----------------

View file

@ -3,4 +3,4 @@ Heading 1
## Heading 2 {MD003}
## Heading 3 {MD003} ##
## Heading 3 {MD003} ##

View file

@ -4,4 +4,4 @@ One
Two
---
{MD043}
{MD043} {MD047}

View file

@ -1,3 +1,3 @@
Some text {MD009}
Some more text {MD010}
Some more text
Some more text