Update MD009/no-trailing-spaces to remove unnecessary sorting, add additional test cases.

This commit is contained in:
David Anson 2022-06-16 04:48:51 +00:00 committed by GitHub
parent f284233f9a
commit 54acae87ea
5 changed files with 79 additions and 4 deletions

View file

@ -2672,7 +2672,6 @@ module.exports = {
paragraphLineNumbers.push(i + 1);
}
});
paragraphLineNumbers.sort(numericSortAscending);
filterTokens(params, "inline", (token) => {
if (token.children.some((child) => child.type === "code_inline")) {
const tokenLines = params.lines.slice(token.map[0], token.map[1]);
@ -2684,7 +2683,6 @@ module.exports = {
});
}
});
codeInlineLineNumbers.sort(numericSortAscending);
}
const expected = (brSpaces < 2) ? 0 : brSpaces;
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {

View file

@ -32,7 +32,6 @@ module.exports = {
paragraphLineNumbers.push(i + 1);
}
});
paragraphLineNumbers.sort(numericSortAscending);
filterTokens(params, "inline", (token) => {
if (token.children.some((child) => child.type === "code_inline")) {
const tokenLines = params.lines.slice(token.map[0], token.map[1]);
@ -44,7 +43,6 @@ module.exports = {
});
}
});
codeInlineLineNumbers.sort(numericSortAscending);
}
const expected = (brSpaces < 2) ? 0 : brSpaces;
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {

View file

@ -62,6 +62,14 @@ text `code
span code
span` text
Text text
Text `code span` text
Text text
`code span`
text text
{MD009:9}
{MD009:24}
{MD009:32}
@ -75,3 +83,6 @@ span` text
{MD009:61}
{MD009:62}
{MD009:63}
{MD009:65}
{MD009:67}
{MD009:71}

View file

@ -12167,6 +12167,63 @@ Generated by [AVA](https://avajs.dev).
'no-trailing-spaces',
],
},
{
errorContext: null,
errorDetail: 'Expected: 0 or 2; Actual: 2',
errorRange: [
10,
2,
],
fixInfo: {
deleteCount: 2,
editColumn: 10,
},
lineNumber: 65,
ruleDescription: 'Trailing spaces',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009',
ruleNames: [
'MD009',
'no-trailing-spaces',
],
},
{
errorContext: null,
errorDetail: 'Expected: 0 or 2; Actual: 2',
errorRange: [
22,
2,
],
fixInfo: {
deleteCount: 2,
editColumn: 22,
},
lineNumber: 67,
ruleDescription: 'Trailing spaces',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009',
ruleNames: [
'MD009',
'no-trailing-spaces',
],
},
{
errorContext: null,
errorDetail: 'Expected: 0 or 2; Actual: 2',
errorRange: [
10,
2,
],
fixInfo: {
deleteCount: 2,
editColumn: 10,
},
lineNumber: 71,
ruleDescription: 'Trailing spaces',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009',
ruleNames: [
'MD009',
'no-trailing-spaces',
],
},
],
fixed: `# Hard Line Breaks␊
@ -12232,6 +12289,14 @@ Generated by [AVA](https://avajs.dev).
span code␊
span\` text␊
Text text␊
Text \`code span\` text␊
Text text ␊
\`code span\` ␊
text text␊
{MD009:9}␊
{MD009:24}␊
{MD009:32}␊
@ -12245,6 +12310,9 @@ Generated by [AVA](https://avajs.dev).
{MD009:61}␊
{MD009:62}␊
{MD009:63}␊
{MD009:65}␊
{MD009:67}␊
{MD009:71}␊
`,
}