-
Notifications
You must be signed in to change notification settings - Fork 84
fix: no-*-definitions rules show original label and identifier #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: no-*-definitions rules show original label and identifier #515
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm +1 with exposing the label in the message, but I'm not sure removing the identifier entirely from message is the best approach.
Could we expose both the identifier and the label in the message? Here are some reasons:
Identifiers may be normalized in non-English languages (and, for English, all letters are converted to lowercase). For example:
markdown/tests/rules/no-duplicate-definitions.test.js
Lines 162 to 173 in 4d4f124
| code: ` | |
| [Grüsse]: https://example.com/ | |
| [Grüsse]: https://example.com/ | |
| `, | |
| options: [{ allowDefinitions: ["GRÜẞE"] }], | |
| }, | |
| { | |
| code: ` | |
| [^Grüsse]: Grüsse | |
| [^Grüsse]: Grüsse | |
| `, | |
| options: [{ allowFootnoteDefinitions: ["GRÜẞE"] }], |
If we write Grüsse and GRÜẞE, the rule reports them as the same definition identifier.
That could be confusing if only labels are shown. For example, a user might intentionally create one definition as Grüsse and another as GRÜẞE (Actually, there are many cases like this), yet the rule flags a conflict because the identifier is normalized. This may confuse users who aren't aware that definition identifiers are normalized.
So, If others agree, I’d like to suggest using a message format like the following:
- Unexpected duplicate definition `{{ identifier }}` found.
+ Unexpected duplicate definition `{{ identifier }}` (label: `{{ label }}`) found.(The message format may vary if other suggestions are available.)
Sounds good to me to include both |
How about this phrasing? |
Looks good to me 👍 |
mdjermanovic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Leaving open for @lumirlumir to verify.
lumirlumir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks.
Would like @mdjermanovic to verify the changes before merging.
mdjermanovic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request?
The purpose is to improve the clarity and usability of linting feedback by ensuring messages reflect the exact labels written in Markdown, helping users quickly identify and fix issues without confusion.
What changes did you make? (Give an overview)
Updated the
no-*-definitionsrules so that reported messages display the original label as written in the Markdown source, instead of the normalized identifier. This makes error messages clearer and consistent with user expectations.Related Issues
Closes #514
Is there anything you'd like reviewers to focus on?