Skip to content

Change Request: Extract reference identifier normalization into a shared utility #731

Description

@KumJungMin

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
Image

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

  • I am willing to submit a pull request for this change.

AI acknowledgment

  • I did not use AI to generate this issue report.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

Additional comments

Disclosure: I'm a participant of open source contribution program OSSCA

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions