mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Fix array indexing for markdownlint-disable-next-line when front matter is present.
This commit is contained in:
parent
7a76f1d22d
commit
5253669495
3 changed files with 26 additions and 4 deletions
|
|
@ -1305,8 +1305,9 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
|
||||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||||
function disableNextLine(action, parameter, lineNumber) {
|
function disableNextLine(action, parameter, lineNumber) {
|
||||||
if (action === "DISABLE-NEXT-LINE") {
|
if (action === "DISABLE-NEXT-LINE") {
|
||||||
enabledRulesPerLineNumber[lineNumber + 1] =
|
var nextLineNumber = frontMatterLines.length + lineNumber + 1;
|
||||||
applyEnableDisable(action, parameter, enabledRulesPerLineNumber[lineNumber + 1] || {});
|
enabledRulesPerLineNumber[nextLineNumber] =
|
||||||
|
applyEnableDisable(action, parameter, enabledRulesPerLineNumber[nextLineNumber] || {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle inline comments
|
// Handle inline comments
|
||||||
|
|
|
||||||
|
|
@ -403,11 +403,12 @@ function getEnabledRulesPerLineNumber(
|
||||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||||
function disableNextLine(action, parameter, lineNumber) {
|
function disableNextLine(action, parameter, lineNumber) {
|
||||||
if (action === "DISABLE-NEXT-LINE") {
|
if (action === "DISABLE-NEXT-LINE") {
|
||||||
enabledRulesPerLineNumber[lineNumber + 1] =
|
const nextLineNumber = frontMatterLines.length + lineNumber + 1;
|
||||||
|
enabledRulesPerLineNumber[nextLineNumber] =
|
||||||
applyEnableDisable(
|
applyEnableDisable(
|
||||||
action,
|
action,
|
||||||
parameter,
|
parameter,
|
||||||
enabledRulesPerLineNumber[lineNumber + 1] || {}
|
enabledRulesPerLineNumber[nextLineNumber] || {}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
test/front-matter-with-disable-next-line.md
Normal file
20
test/front-matter-with-disable-next-line.md
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
front: matter
|
||||||
|
---
|
||||||
|
|
||||||
|
# Front Matter with Disable-Next-Line
|
||||||
|
|
||||||
|
<!-- markdownlint-disable-next-line no-inline-html -->
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<hr/> {MD033}
|
||||||
|
|
||||||
|
<!-- markdownlint-disable-next-line -->
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<hr/> {MD033}
|
||||||
|
<hr/> {MD033}
|
||||||
|
<!-- markdownlint-disable-next-line -->
|
||||||
|
<hr/>
|
||||||
|
<hr/> {MD033}
|
||||||
|
<hr/> {MD033}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue