-
- Notifications
You must be signed in to change notification settings - Fork 58
Closed
Description
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?
9.33.0
What version of eslint-plugin-svelte
are you using?
3.11.0
What did you do?
Configuration
import js from "@eslint/js"; import sveltePlugin from "eslint-plugin-svelte"; import svelteParser from "svelte-eslint-parser"; import tseslint from "typescript-eslint"; export default tseslint.config( js.configs.recommended, ...tseslint.configs.recommended, ...sveltePlugin.configs["flat/recommended"], { files: ["**/*.svelte", "*.svelte"], languageOptions: { globals: { window: false, console: false, }, parser: svelteParser, parserOptions: { parser: { ts: "@typescript-eslint/parser", }, extraFileExtensions: [".svelte"], }, }, rules: { 'svelte/no-top-level-browser-globals': 'error', } } );
<script> import { browser, dev } from '$app/environment'; const notification = browser && dev ? 'Notification' in window : false if (notification) console.log('hi'); </script> {#if browser && dev} <div> <pre>Notification: {'Notification' in window}</pre> </div> {/if}
What did you expect to happen?
No errors to be reported since the access is guarded by {#if browser}
What actually happened?
✕Unexpected top-level browser global variable "window". [(svelte/no-top-level-browser-globals)](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-top-level-browser-globals/) [5:25-31] ✕Unexpected top-level browser global variable "window". [(svelte/no-top-level-browser-globals)](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-top-level-browser-globals/) [13:43-49]
Link to GitHub Repo with Minimal Reproducible Example
Additional comments
Metadata
Metadata
Assignees
Labels
No labels