Add more test cases for trailing spaces.

This commit is contained in:
David Anson 2022-06-13 22:53:48 -07:00
parent ac38a614e9
commit 28b273e798
5 changed files with 106 additions and 4 deletions

View file

@ -2678,7 +2678,7 @@ module.exports = {
const tokenLines = params.lines.slice(token.map[0], token.map[1]);
forEachInlineCodeSpan(tokenLines.join("\n"), (code, lineIndex) => {
const codeLineCount = code.split(newLineRe).length;
for (let i = 0; i < codeLineCount; i++) {
for (let i = 0; i < codeLineCount - 1; i++) {
codeInlineLineNumbers.push(token.lineNumber + lineIndex + i);
}
});
@ -2699,7 +2699,7 @@ module.exports = {
includesSorted(codeInlineLineNumbers, lineNumber))))) {
const column = line.length - trailingSpaces + 1;
addError(onError, lineNumber, "Expected: " + (expected === 0 ? "" : "0 or ") +
expected + "; Actual: " + trailingSpaces, null, [column, trailingSpaces], {
expected + "; Actual: " + trailingSpaces, undefined, [column, trailingSpaces], {
"editColumn": column,
"deleteCount": trailingSpaces
});

View file

@ -38,7 +38,7 @@ module.exports = {
const tokenLines = params.lines.slice(token.map[0], token.map[1]);
forEachInlineCodeSpan(tokenLines.join("\n"), (code, lineIndex) => {
const codeLineCount = code.split(newLineRe).length;
for (let i = 0; i < codeLineCount; i++) {
for (let i = 0; i < codeLineCount - 1; i++) {
codeInlineLineNumbers.push(token.lineNumber + lineIndex + i);
}
});
@ -67,7 +67,7 @@ module.exports = {
lineNumber,
"Expected: " + (expected === 0 ? "" : "0 or ") +
expected + "; Actual: " + trailingSpaces,
null,
undefined,
[ column, trailingSpaces ],
{
"editColumn": column,

View file

@ -53,6 +53,15 @@ Text text
text text
text
Text text
text `code
span` text
Text text
text `code
span code
span` text
{MD009:9}
{MD009:24}
{MD009:32}
@ -62,3 +71,7 @@ text
{MD009:43}
{MD009:48}
{MD009:54}
{MD009:58}
{MD009:61}
{MD009:62}
{MD009:63}

View file

@ -11940,6 +11940,82 @@ Generated by [AVA](https://avajs.dev).
'no-trailing-spaces',
],
},
{
errorContext: null,
errorDetail: 'Expected: 0 or 2; Actual: 2',
errorRange: [
11,
2,
],
fixInfo: {
deleteCount: 2,
editColumn: 11,
},
lineNumber: 58,
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: [
11,
2,
],
fixInfo: {
deleteCount: 2,
editColumn: 11,
},
lineNumber: 61,
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: 62,
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: [
11,
2,
],
fixInfo: {
deleteCount: 2,
editColumn: 11,
},
lineNumber: 63,
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␊
@ -11996,6 +12072,15 @@ Generated by [AVA](https://avajs.dev).
text text␊
text␊
Text text␊
text \`code␊
span\` text␊
Text text␊
text \`code␊
span code␊
span\` text␊
{MD009:9}␊
{MD009:24}␊
{MD009:32}␊
@ -12005,6 +12090,10 @@ Generated by [AVA](https://avajs.dev).
{MD009:43}␊
{MD009:48}␊
{MD009:54}␊
{MD009:58}␊
{MD009:61}␊
{MD009:62}␊
{MD009:63}␊
`,
}