-
Notifications
You must be signed in to change notification settings - Fork 80
refactor: use getLocFromIndex in no-invalid-label-refs
#546
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
refactor: use getLocFromIndex in no-invalid-label-refs
#546
Conversation
src/rules/no-invalid-label-refs.js
Outdated
| * @import { Position } from "unist"; | ||
| * @import { Text } from "mdast"; | ||
| * @import { MarkdownRuleDefinition } from "../types.js"; | ||
| * @import { MarkdownSourceCode } from "../index.js"; |
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.
This change was motivated by #366 (comment).
The Parameters<MarkdownRuleDefinition['create']>[0]['sourceCode'] expression was needed due to a collision between rollup and tools/dedupe-types at the time, but since @eslint/markdown no longer uses rollup, it's now safe to use ../index.js.
| "![foo][]\n\n[foo]: http://bar.com/image.jpg", | ||
| "[ foo ][]\n\n[foo]: http://bar.com/image.jpg", | ||
| "[eslint][\n\n]", | ||
| "[*eslint*][]\n\n[*eslint*]: http://bar.com", |
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.
Using strong or emphasis inside a label is an easy-to-forget edge case and often leads to unintended side effects when the check is missed, so I've added one more test.
This is a valid label according to the AST:
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
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?
This PR originated from #536. While working on that, I found the scope had become too large, so I split this refactoring into a separate PR.
In this PR, I've used the native
getLocFromIndexmethod added in #376 instead of the customfindOffsetsutil.Notable changes:
findOffsetsutil with the nativegetLocFromIndex.What changes did you make? (Give an overview)
In this PR, I've used the native
getLocFromIndexmethod added in #376 instead of the customfindOffsetsutil.Related Issues
Ref: #376, #536
Is there anything you'd like reviewers to focus on?
N/A