Skip to content

$page is an illegal variable name #652

Closed
@huntabyte

Description

@huntabyte

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.56.0

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

2.36.0-next.3

What did you do?

Configuration
/** @type { import("eslint").Linter.FlatConfig } */
module.exports = {
	root: true,
	extends: [
		'eslint:recommended',
		'plugin:@typescript-eslint/recommended',
		'plugin:svelte/recommended'
	],
	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'
			}
		}
	]
};
  1. pnpm create svelte@latest
  2. Choose Skeleton Project, Typescript, Eslint, Svelte 5
  3. install dependencies
  4. Realize eslint-plugin-svelte@next isn't installed, so pnpm i -D eslint-plugin-svelte@next
<!-- src/routes/+page.svelte -->
<script lang="ts">
	import { page } from "$app/stores"
	console.log($page.data) // $page is an illegal variable name.
</script>

What did you expect to happen?

$page to be a legal variable name

What actually happened?

$page is an illegal variable name. To reference a global variable called $page, use globalThis.$page(illegal-global)eslint[svelte/valid-compile](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-compile/)
let $page: Page<Record<string, string>, string | null>

4:14 error $page is an illegal variable name. To reference a global variable called $page, use globalThis.$page(illegal-global) svelte/valid-compile

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/huntabyte/s5-illegal-variable-repro

Additional comments

I noticed this only occurs when using Typescript. If I go through the create svelte flow and choose "Javascript with JSDoc" everything is good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions