Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I'm using eslint-plugin-svelte. (
*.svelte
file linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.) - I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-svelte repo and open the issue in eslint-plugin-svelte repo if there is no solution.
- 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.34.0
What version of eslint-plugin-svelte
and svelte-eslint-parser
are you using?
- svelte-eslint-parser@0.23.0
- eslint-plugin-svelte@2.19.0
What did you do?
Configuration
{ parserOptions: { sourceType: 'module' } }
<script>
import imported from "mod";
const local = true;
</script>
What did you expect to happen?
When writing an ESLint rule I expect to get a module scope for visitors with selectors ImportDeclaration
or VariableDeclaration
or any other top-level statement.
What actually happened?
context.getScope
returns the global scope and not the expected module scope.
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/DMartens/svelte-eslint-parser-scope-bug
The test is in the scope.js
file
Additional comments
The default scope manager and other custom parser / scope manager return a module scope.
They only return the global scope for Program
(which for svelte would be the SvelteScriptElement
).
I am willing to provide a PR to fix this.