mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Fix possible exceptions due to addError's range/editColumn out of range, update test-extra to use test.serial() for better progress.
This commit is contained in:
parent
e7d3708056
commit
9b5f6a28f9
8 changed files with 19 additions and 18 deletions
|
|
@ -3441,14 +3441,14 @@ module.exports = {
|
|||
var listItemPrefix = _step2.value;
|
||||
var lineNumber = listItemPrefix.startLine;
|
||||
var actualIndent = listItemPrefix.startColumn - 1;
|
||||
var markerLength = listItemPrefix.text.trim().length;
|
||||
var range = [1, listItemPrefix.startColumn + markerLength];
|
||||
var range = [1, listItemPrefix.endColumn - 1];
|
||||
if (list.type === "listUnordered") {
|
||||
addErrorDetailIf(onError, lineNumber, expectedIndent, actualIndent, null, null, range
|
||||
// No fixInfo; MD007 handles this scenario better
|
||||
);
|
||||
} else {
|
||||
var actualEnd = range[1] - 1;
|
||||
var markerLength = listItemPrefix.text.trim().length;
|
||||
var actualEnd = listItemPrefix.startColumn + markerLength - 1;
|
||||
expectedEnd = expectedEnd || actualEnd;
|
||||
if (expectedIndent !== actualIndent || endMatching) {
|
||||
if (expectedEnd === actualEnd) {
|
||||
|
|
@ -3525,7 +3525,8 @@ module.exports = {
|
|||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
var token = _step.value;
|
||||
var parent = token.parent,
|
||||
var endColumn = token.endColumn,
|
||||
parent = token.parent,
|
||||
startColumn = token.startColumn,
|
||||
startLine = token.startLine,
|
||||
type = token.type;
|
||||
|
|
@ -3556,7 +3557,7 @@ module.exports = {
|
|||
var expectedIndent = (startIndented ? startIndent : 0) + _nesting * indent;
|
||||
var blockQuoteAdjustment = ((_lastBlockQuotePrefix = lastBlockQuotePrefix) === null || _lastBlockQuotePrefix === void 0 ? void 0 : _lastBlockQuotePrefix.endLine) === startLine ? lastBlockQuotePrefix.endColumn - 1 : 0;
|
||||
var actualIndent = startColumn - 1 - blockQuoteAdjustment;
|
||||
var range = [1, startColumn + 1];
|
||||
var range = [1, endColumn - 1];
|
||||
var fixInfo = {
|
||||
"editColumn": startColumn - actualIndent,
|
||||
"deleteCount": Math.max(actualIndent - expectedIndent, 0),
|
||||
|
|
@ -4499,14 +4500,14 @@ module.exports = {
|
|||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
var heading = _step.value;
|
||||
var endLine = heading.endLine,
|
||||
startColumn = heading.startColumn,
|
||||
var endColumn = heading.endColumn,
|
||||
endLine = heading.endLine,
|
||||
text = heading.text;
|
||||
var match = trailingPunctuationRe.exec(text);
|
||||
if (match && !endOfLineHtmlEntityRe.test(text) && !endOfLineGemojiCodeRe.test(text)) {
|
||||
var fullMatch = match[0];
|
||||
var column = startColumn + match.index;
|
||||
var length = fullMatch.length;
|
||||
var column = endColumn - length;
|
||||
addError(onError, endLine, "Punctuation: '".concat(fullMatch, "'"), undefined, [column, length], {
|
||||
"editColumn": column,
|
||||
"deleteCount": length
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ module.exports = {
|
|||
for (const listItemPrefix of listItemPrefixes) {
|
||||
const lineNumber = listItemPrefix.startLine;
|
||||
const actualIndent = listItemPrefix.startColumn - 1;
|
||||
const markerLength = listItemPrefix.text.trim().length;
|
||||
const range = [ 1, listItemPrefix.startColumn + markerLength ];
|
||||
const range = [ 1, listItemPrefix.endColumn - 1 ];
|
||||
if (list.type === "listUnordered") {
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
|
|
@ -37,7 +36,8 @@ module.exports = {
|
|||
// No fixInfo; MD007 handles this scenario better
|
||||
);
|
||||
} else {
|
||||
const actualEnd = range[1] - 1;
|
||||
const markerLength = listItemPrefix.text.trim().length;
|
||||
const actualEnd = listItemPrefix.startColumn + markerLength - 1;
|
||||
expectedEnd = expectedEnd || actualEnd;
|
||||
if ((expectedIndent !== actualIndent) || endMatching) {
|
||||
if (expectedEnd === actualEnd) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ module.exports = {
|
|||
unorderedListTypes
|
||||
);
|
||||
for (const token of tokens) {
|
||||
const { parent, startColumn, startLine, type } = token;
|
||||
const { endColumn, parent, startColumn, startLine, type } = token;
|
||||
if (type === "blockQuotePrefix") {
|
||||
lastBlockQuotePrefix = token;
|
||||
} else if (type === "listUnordered") {
|
||||
|
|
@ -63,7 +63,7 @@ module.exports = {
|
|||
(lastBlockQuotePrefix.endColumn - 1) :
|
||||
0;
|
||||
const actualIndent = startColumn - 1 - blockQuoteAdjustment;
|
||||
const range = [ 1, startColumn + 1 ];
|
||||
const range = [ 1, endColumn - 1 ];
|
||||
const fixInfo = {
|
||||
"editColumn": startColumn - actualIndent,
|
||||
"deleteCount": Math.max(actualIndent - expectedIndent, 0),
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module.exports = {
|
|||
[ "atxHeadingText", "setextHeadingText" ]
|
||||
);
|
||||
for (const heading of headings) {
|
||||
const { endLine, startColumn, text } = heading;
|
||||
const { endColumn, endLine, text } = heading;
|
||||
const match = trailingPunctuationRe.exec(text);
|
||||
if (
|
||||
match &&
|
||||
|
|
@ -31,8 +31,8 @@ module.exports = {
|
|||
!endOfLineGemojiCodeRe.test(text)
|
||||
) {
|
||||
const fullMatch = match[0];
|
||||
const column = startColumn + match.index;
|
||||
const length = fullMatch.length;
|
||||
const column = endColumn - length;
|
||||
addError(
|
||||
onError,
|
||||
endLine,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
"test": "ava --timeout=30s test/markdownlint-test.js test/markdownlint-test-config.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js",
|
||||
"test-cover": "c8 --100 npm test",
|
||||
"test-declaration": "cd example/typescript && tsc && node type-check.js",
|
||||
"test-extra": "ava --timeout=5m test/markdownlint-test-extra-parse.js test/markdownlint-test-extra-type.js",
|
||||
"test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.js test/markdownlint-test-extra-type.js",
|
||||
"update-snapshots": "ava --update-snapshots test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.js",
|
||||
"update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.js",
|
||||
"upgrade": "npx --yes npm-check-updates --upgrade"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ for (const file of files) {
|
|||
strings[content.length.toString()] = content;
|
||||
content = content.slice(0, -1);
|
||||
}
|
||||
test(`type ${file}`, (t) => {
|
||||
test.serial(`type ${file}`, (t) => {
|
||||
t.plan(1);
|
||||
markdownlint.sync({
|
||||
// @ts-ignore
|
||||
|
|
|
|||
|
|
@ -6521,7 +6521,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
errorDetail: 'Expected: 0; Actual: 1',
|
||||
errorRange: [
|
||||
1,
|
||||
3,
|
||||
4,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: 1,
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue