Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

marekdedic
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Sep 4, 2025

🦋 Changeset detected

Latest commit: 8ab5c4c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-svelte Patch

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

Copy link
Contributor

github-actions bot commented Sep 4, 2025

Try the Instant Preview in Online Playground

ESLint Online Playground

Install the Instant Preview to Your Local

npm i https://pkg.pr.new/eslint-plugin-svelte@8ab5c4c

Published Instant Preview Packages:

View Commit

@marekdedic marekdedic force-pushed the no-navigation-without-resolve-absolute-fragment-variables branch from 58f35a4 to 671e1a6 Compare September 5, 2025 10:04
@marekdedic marekdedic requested a review from ota-meshi September 5, 2025 10:15
variable.identifiers.length === 0 ||
variable.identifiers[0].parent.type !== 'VariableDeclarator' ||
variable.identifiers[0].parent.init === null ||
variable.identifiers[0].parent.init === node
Copy link
Member

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;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, you are right...

@marekdedic
Copy link
Contributor Author

marekdedic commented Sep 7, 2025

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 consistent-selector-style rule with the following code:

<script>
  const a = derived;
  const derived = a;
</script>

<a id={derived}>Click me!</a>

My proposal is:

  • Merge this PR as-is. It's a really niche edge case and it is blocking most of the work on fixing up the no-navigation-without-resolve rule, which I'd like to fix ASAP.
  • I'll then make a PR in which I add a utility function for this pattern of searching the AST like in this PR and the above linked expression-affixes file. This utility function will include the prevention of infinite loops. I'll try to look for all instances of this pattern and convert them to this utility function, so there are no loops anywhere.

What do you think? We can also do it the other way around, but I think fixing all the edge-cases of no-navigation-without-resolve should come first as there are multiple issues open. And also, the infinite loop wasn't introduced in this PR, we've just noticed now (but it should be fixed!)

Thanks!

@baseballyama
Copy link
Member

I have no objections, but I would like to wait for @ota-meshi 's opinion.
The best approach would be to address this immediately in this PR.
Basically, I believe it should be relatively easy to detect mutual recursion by keeping a set of visited nodes.

@ota-meshi
Copy link
Member

It's a really niche edge case

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.

@ota-meshi
Copy link
Member

I don't think a utility function is necessary yet, because this is a bug fix and shouldn't involve another rule refactoring.

@marekdedic
Copy link
Contributor Author

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.

@marekdedic marekdedic force-pushed the no-navigation-without-resolve-absolute-fragment-variables branch 3 times, most recently from bbbf86a to 8534223 Compare September 14, 2025 19:52
@marekdedic
Copy link
Contributor Author

Okay, this one is rebased and ready for re-review :)

@marekdedic marekdedic force-pushed the no-navigation-without-resolve-absolute-fragment-variables branch from 8534223 to 8ab5c4c Compare September 14, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants