Skip to content

Commit 54acae8

Browse files
authored
Update MD009/no-trailing-spaces to remove unnecessary sorting, add additional test cases.
1 parent f284233 commit 54acae8

5 files changed

+79
-4
lines changed

demo/markdownlint-browser.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,6 @@ module.exports = {
26722672
paragraphLineNumbers.push(i + 1);
26732673
}
26742674
});
2675-
paragraphLineNumbers.sort(numericSortAscending);
26762675
filterTokens(params, "inline", (token) => {
26772676
if (token.children.some((child) => child.type === "code_inline")) {
26782677
const tokenLines = params.lines.slice(token.map[0], token.map[1]);
@@ -2684,7 +2683,6 @@ module.exports = {
26842683
});
26852684
}
26862685
});
2687-
codeInlineLineNumbers.sort(numericSortAscending);
26882686
}
26892687
const expected = (brSpaces < 2) ? 0 : brSpaces;
26902688
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {

lib/md009.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ module.exports = {
3232
paragraphLineNumbers.push(i + 1);
3333
}
3434
});
35-
paragraphLineNumbers.sort(numericSortAscending);
3635
filterTokens(params, "inline", (token) => {
3736
if (token.children.some((child) => child.type === "code_inline")) {
3837
const tokenLines = params.lines.slice(token.map[0], token.map[1]);
@@ -44,7 +43,6 @@ module.exports = {
4443
});
4544
}
4645
});
47-
codeInlineLineNumbers.sort(numericSortAscending);
4846
}
4947
const expected = (brSpaces < 2) ? 0 : brSpaces;
5048
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {

test/hard-line-breaks.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ text `code
6262
span code
6363
span` text
6464

65+
Text text
66+
67+
Text `code span` text
68+
69+
Text text
70+
`code span`
71+
text text
72+
6573
{MD009:9}
6674
{MD009:24}
6775
{MD009:32}
@@ -75,3 +83,6 @@ span` text
7583
{MD009:61}
7684
{MD009:62}
7785
{MD009:63}
86+
{MD009:65}
87+
{MD009:67}
88+
{MD009:71}

test/snapshots/markdownlint-test-scenarios.js.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12167,6 +12167,63 @@ Generated by [AVA](https://avajs.dev).
1216712167
'no-trailing-spaces',
1216812168
],
1216912169
},
12170+
{
12171+
errorContext: null,
12172+
errorDetail: 'Expected: 0 or 2; Actual: 2',
12173+
errorRange: [
12174+
10,
12175+
2,
12176+
],
12177+
fixInfo: {
12178+
deleteCount: 2,
12179+
editColumn: 10,
12180+
},
12181+
lineNumber: 65,
12182+
ruleDescription: 'Trailing spaces',
12183+
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009',
12184+
ruleNames: [
12185+
'MD009',
12186+
'no-trailing-spaces',
12187+
],
12188+
},
12189+
{
12190+
errorContext: null,
12191+
errorDetail: 'Expected: 0 or 2; Actual: 2',
12192+
errorRange: [
12193+
22,
12194+
2,
12195+
],
12196+
fixInfo: {
12197+
deleteCount: 2,
12198+
editColumn: 22,
12199+
},
12200+
lineNumber: 67,
12201+
ruleDescription: 'Trailing spaces',
12202+
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009',
12203+
ruleNames: [
12204+
'MD009',
12205+
'no-trailing-spaces',
12206+
],
12207+
},
12208+
{
12209+
errorContext: null,
12210+
errorDetail: 'Expected: 0 or 2; Actual: 2',
12211+
errorRange: [
12212+
10,
12213+
2,
12214+
],
12215+
fixInfo: {
12216+
deleteCount: 2,
12217+
editColumn: 10,
12218+
},
12219+
lineNumber: 71,
12220+
ruleDescription: 'Trailing spaces',
12221+
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009',
12222+
ruleNames: [
12223+
'MD009',
12224+
'no-trailing-spaces',
12225+
],
12226+
},
1217012227
],
1217112228
fixed: `# Hard Line Breaks␊
1217212229
@@ -12232,6 +12289,14 @@ Generated by [AVA](https://avajs.dev).
1223212289
span code␊
1223312290
span\` text␊
1223412291
12292+
Text text␊
12293+
12294+
Text \`code span\` text␊
12295+
12296+
Text text ␊
12297+
\`code span\` ␊
12298+
text text␊
12299+
1223512300
{MD009:9}␊
1223612301
{MD009:24}␊
1223712302
{MD009:32}␊
@@ -12245,6 +12310,9 @@ Generated by [AVA](https://avajs.dev).
1224512310
{MD009:61}␊
1224612311
{MD009:62}␊
1224712312
{MD009:63}␊
12313+
{MD009:65}␊
12314+
{MD009:67}␊
12315+
{MD009:71}␊
1224812316
`,
1224912317
}
1225012318

317 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)