-
-
Notifications
You must be signed in to change notification settings - Fork 56
fix: preventing infinite loops #1344
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
Conversation
🦋 Changeset detectedLatest commit: 70bbe35 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:
|
This is exactly the kind of implementation I had in mind for managing visited nodes. |
Thanks for the quick PR. My thoughts comparing it to #1344:
|
At least nobody is opposed to this change, so I'll mark it as ready.
Yeah, I think it's worth considering. In this PR, I wanted to minimize the difference and check that it can be checked with an internal custom rule.
In my experience, I don't think the internal implementation of ReferenceTracker is very common in normal rule implementations. In other words, I currently think that maintaining the current implementation method as much as possible will make it easier for people with experience with eslint-plugins other than eslint-plugin-svelte to follow.
In my experience, I've never seen an infinite recursion issue like this outside of identifier tracking. This PR owes a lot to your PR #1338, which gave me a lot of inspiration. Thank you so much! |
packages/eslint-plugin-svelte/internal-rules/prefer-find-variable-safe.ts
Show resolved
Hide resolved
packages/eslint-plugin-svelte/src/rules/no-dynamic-slot-name.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin-svelte/src/rules/no-not-function-handler.ts
Outdated
Show resolved
Hide resolved
@@ -1,5 +1,12 @@ | |||
import * as myPlugin from '@ota-meshi/eslint-plugin'; | |||
import * as tseslint from 'typescript-eslint'; | |||
import { createJiti } from 'jiti'; |
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.
Is jiti really needed here? I don't understand this much, but why not just import the rule straight away?
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.
The rule is implemented in Typescript, so we need to import them via jiti
. This will no longer be necessary once we drop support for older Node.
import type { TSESTree } from '@typescript-eslint/types'; | ||
import type { Variable } from '@typescript-eslint/scope-manager'; | ||
|
||
export default { |
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'd still prefer just merging findVariableSafe
into findVariable
. Then the whole complication with this, and jiti
can go away. And if I understand correctly, it's entirely possible, especially if we switch to marker: Symbol
or marker: string
.
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 it's redundant to have more arguments that we won't use.
So I think it's better to leave it as it is.
When I was testing this, I found that the second lookup to the same identifier node (which is not recursive) returned null, which didn't work 😓 |
I've done a major rewrite to solve the problem. |
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.
Thank you!
Hi @ota-meshi , I just found out the internal rule doesn't trigger here, is that correct? |
Yeah, if there is no recursion it will not be reported. |
No description provided.