Environment
ESLint version: v10.7.0
@eslint/markdown version: 8.0.3
Node version: v22.18.0
npm version: v10.9.3
Operating System: darwin 24.6.0
What problem do you want to solve?
The following four rules currently use normalizeIdentifier(value).toLowerCase() in a total of seven places to compare reference identifiers:
- no-duplicate-definitions
- no-unused-definitions
- no-empty-definitions
- no-reference-like-urls
This expression converts identifiers in allowlists or link destinations into a form that can be compared with the AST’s identifier.
These rules share the same comparison behavior, but each call site handles normalization and lowercase conversion separately.
The current behavior is correct.
I’d like to make the purpose of this shared transformation explicit and make it easier to keep the rules consistent
when updating the related code.
What do you think is the correct solution?
I’d suggest adding a normalizeReferenceIdentifier() function to src/util.js and replacing the repeated expression with calls to that function.
export function normalizeReferenceIdentifier(value) {
return normalizeIdentifier(value).toLowerCase();
}
This would preserve the existing operations and their order, with no changes to rule options, diagnostic messages, or lint results.
The existing tests for the affected rules can help verify that case handling, whitespace normalization,
and Unicode identifier handling remain unchanged.
Participation
AI acknowledgment
Additional comments
Disclosure: I'm a participant of open source contribution program OSSCA
Environment
ESLint version: v10.7.0
@eslint/markdown version: 8.0.3
Node version: v22.18.0
npm version: v10.9.3
Operating System: darwin 24.6.0
What problem do you want to solve?
The following four rules currently use
normalizeIdentifier(value).toLowerCase()in a total of seven places to compare reference identifiers:This expression converts identifiers in allowlists or link destinations into a form that can be compared with the AST’s identifier.
These rules share the same comparison behavior, but each call site handles normalization and lowercase conversion separately.
The current behavior is correct.
I’d like to make the purpose of this shared transformation explicit and make it easier to keep the rules consistent
when updating the related code.
What do you think is the correct solution?
I’d suggest adding a
normalizeReferenceIdentifier()function tosrc/util.jsand replacing the repeated expression with calls to that function.This would preserve the existing operations and their order, with no changes to rule options, diagnostic messages, or lint results.
The existing tests for the affected rules can help verify that case handling, whitespace normalization,
and Unicode identifier handling remain unchanged.
Participation
AI acknowledgment
Additional comments