-
-
Notifications
You must be signed in to change notification settings - Fork 56
fix(no-navigation-without-resolve): properly detecting absolute and fragment URLs in variables #1322
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 8ab5c4c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Try the Instant Preview in Online PlaygroundInstall the Instant Preview to Your Local
Published Instant Preview Packages:
|
14ef67b
to
640b41b
Compare
packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-svelte/src/rules/no-navigation-without-resolve.ts
Outdated
Show resolved
Hide resolved
58f35a4
to
671e1a6
Compare
variable.identifiers.length === 0 || | ||
variable.identifiers[0].parent.type !== 'VariableDeclarator' || | ||
variable.identifiers[0].parent.init === null || | ||
variable.identifiers[0].parent.init === node |
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 think still we can not guard mutual recursion.
const a = b;
const b = a;
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.
Unfortunately, you are right...
Ok, regarding the possible infinite loop: I think what remains now is a pretty niche edge case. However, I recognised that I previously used a similar pattern of traversing the AST based on node types, namely in https://github.com/sveltejs/eslint-plugin-svelte/blob/9d952fd865b1dd9ead04bd485d6c419cd07278e0/packages/eslint-plugin-svelte/src/utils/expression-affixes.ts With that knowledge, I was able to create an infinite recursion loop in the <script>
const a = derived;
const derived = a;
</script>
<a id={derived}>Click me!</a> My proposal is:
What do you think? We can also do it the other way around, but I think fixing all the edge-cases of Thanks! |
I have no objections, but I would like to wait for @ota-meshi 's opinion. |
I don't think it's an edge case. I think it happens frequently when rewriting in the editor. It could potentially cause an infinite loop and crash the editor extension. |
I don't think a utility function is necessary yet, because this is a bug fix and shouldn't involve another rule refactoring. |
Okay, but since I don't want to implement something here that would be almost immediately replaced, I'm going to make a PR fixing consistent-selector-style, then rebase this on top of that and then continue fixing this rule. |
bbbf86a
to
8534223
Compare
Okay, this one is rebased and ready for re-review :) |
…agment URLs in variables
…ragment URLs in variables
8534223
to
8ab5c4c
Compare
No description provided.