Environment
ESLint version: 10.8.0
@eslint/markdown version: 8.0.3
Node version: 22.18.0
npm version: 10.9.3
Which language are you using?
commonmark
What did you do?
Configuration
import { defineConfig } from "eslint/config";
import markdown from "@eslint/markdown";
export default defineConfig([
{
files: ["**/*.md"],
plugins: {
markdown,
},
language: "markdown/commonmark",
rules: {
"markdown/no-invalid-label-refs": "error",
},
},
]);
<!-- eslint markdown/no-invalid-label-refs: "error" -->
<!-- OK -->
\[foo][ ]
\\\[foo][ ]
<!-- NOT OK -->
[foo][ ]
\\[foo][ ]
\\\\[foo][ ]
What did you expect to happen?
he rule should not report the cases with an odd number of backslashes before the opening bracket:
In these cases, the opening bracket is escaped, so the text does not form a label reference.
The rule should report only the cases where the opening bracket is not escaped:
[foo][ ]
\\[foo][ ]
\\\\[foo][ ]
An even number of backslashes does not escape the opening bracket,
so these cases still form invalid label references.
What actually happened?
no-invalid-label-refs reports the cases where the opening bracket is escaped:
5:7 error Label reference 'foo' is invalid due to white space between [ and ] markdown/no-invalid-la...
The rule appears to detect the ][ ] portion and search backward for an opening bracket without checking whether that bracket is escaped. As a result, escaped text is incorrectly treated as an invalid label reference.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/vitejs-vite-ddfg51us?file=eslint.config.js,test.md
Participation
AI acknowledgment
Additional comments
Disclosure: I'm a participant of open source contribution program OSSCA
A related case was addressed in #490, which updated several rules to distinguish escaped syntax based on whether it is preceded by an odd or even number of consecutive backslashes.
That change covered no-missing-label-refs, no-reversed-media-syntax, and no-missing-atx-heading-space. However, no-invalid-label-refs appears to perform a separate label-reference check that does not account for whether the opening bracket is escaped.
Environment
ESLint version: 10.8.0
@eslint/markdown version: 8.0.3
Node version: 22.18.0
npm version: 10.9.3
Which language are you using?
commonmark
What did you do?
Configuration
What did you expect to happen?
he rule should not report the cases with an odd number of backslashes before the opening bracket:
In these cases, the opening bracket is escaped, so the text does not form a label reference.
The rule should report only the cases where the opening bracket is not escaped:
An even number of backslashes does not escape the opening bracket,
so these cases still form invalid label references.
What actually happened?
no-invalid-label-refs reports the cases where the opening bracket is escaped:
The rule appears to detect the
][ ]portion and search backward for an opening bracket without checking whether that bracket is escaped. As a result, escaped text is incorrectly treated as an invalid label reference.Link to Minimal Reproducible Example
https://stackblitz.com/edit/vitejs-vite-ddfg51us?file=eslint.config.js,test.md
Participation
AI acknowledgment
Additional comments
A related case was addressed in #490, which updated several rules to distinguish escaped syntax based on whether it is preceded by an odd or even number of consecutive backslashes.
That change covered no-missing-label-refs, no-reversed-media-syntax, and no-missing-atx-heading-space. However, no-invalid-label-refs appears to perform a separate label-reference check that does not account for whether the opening bracket is escaped.