Skip to content

infinite-reactive-loop - "Maximum call stack size exceeded" when reactive statement defines a function that can recursively call itself #412

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

Closed
2 tasks done
DetachHead opened this issue Mar 20, 2023 · 0 comments · Fixed by #418
Labels
bug Something isn't working

Comments

@DetachHead
Copy link
Contributor

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.33.0

What version of eslint-plugin-svelte are you using?

2.22.0

What did you do?

Configuration
module.exports = {
    extends: ['plugin:svelte/all', 'plugin:svelte/prettier']
}
<script>
    $: {
        const foo = (recurse) => (recurse ? foo(false) : undefined)
    }
</script>

What did you expect to happen?

no error

What actually happened?

> eslint foo.svelte

Oops! Something went wrong! :(

ESLint: 8.33.0

RangeError: Maximum call stack size exceeded
Occurred while linting C:\project\foo.svelte:2
Rule: "svelte/infinite-reactive-loop"
    at getNodes (C:\project\node_modules\svelte-eslint-parser\lib\traverse.js:47:19)
    at getNodes.next (<anonymous>)
    at C:\project\node_modules\svelte-eslint-parser\lib\traverse.js:40:54
    at Array.filter (<anonymous>)
    at getKeys (C:\project\node_modules\svelte-eslint-parser\lib\traverse.js:40:17)
    at traverse (C:\project\node_modules\svelte-eslint-parser\lib\traverse.js:77:18)
    at traverseNodes (C:\project\node_modules\svelte-eslint-parser\lib\traverse.js:91:5)
    at doLint (C:\project\node_modules\eslint-plugin-svelte\lib\rules\infinite-reactive-loop.js:171:46)
    at Object.enterNode (C:\project\node_modules\eslint-plugin-svelte\lib\rules\infinite-reactive-loop.js:195:21)
    at traverse (C:\project\node_modules\svelte-eslint-parser\lib\traverse.js:76:13)

Link to GitHub Repo with Minimal Reproducible Example

https://ota-meshi.github.io/eslint-plugin-svelte/playground/#eJyrVkrOT0lVslKyKU4uyiwosYvJUwACFSuFaggLBJLz84pLFNLy8xVsFTSKUpNLi4pTNRVs7eAcBXuQrEZaYg5IwkqhNC8lNS0zLzVFE2JIbUyejT7cAqVaADzVJK0=

check the devtools console to see the errors:
image

Additional comments

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants