sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
276 stars 29 forks source link

Using stores causes an error in `svelte/valid-compile` #761

Closed Serator closed 1 month ago

Serator commented 1 month ago

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

What version of ESLint are you using?

8.57.0

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

2.39.0

What did you do?

Configuration `.eslintrc.cjs` ``` /** @type { import("eslint").Linter.Config } */ module.exports = { root: true, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:svelte/recommended', 'prettier' ], parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint'], parserOptions: { sourceType: 'module', ecmaVersion: 2020, extraFileExtensions: ['.svelte'] }, env: { browser: true, es2017: true, node: true }, overrides: [ { files: ['*.svelte'], parser: 'svelte-eslint-parser', parserOptions: { parser: '@typescript-eslint/parser' } } ] }; ``` `svelte.config.js` ``` const config = { compilerOptions: { runes: true, }, ... ```
<script lang="ts">
  import {page} from '$app/stores'
  $inspect($page)
</script>
image

What did you expect to happen?

No errors.

What actually happened?

When using SvelteKit's inbuilt $page store, I get the following error:

`$page` is an illegal variable name. To reference a global variable called `$page`, use `globalThis.$page`(global_reference_invalid)  svelte/valid-compile

Link to GitHub Repo with Minimal Reproducible Example

https://stackblitz.com/edit/vitejs-vite-dnsppf?file=src%2Froutes%2F%2Bpage.svelte

Additional comments

No response

baseballyama commented 1 month ago

duplicate of https://github.com/sveltejs/eslint-plugin-svelte/issues/652