From 20d2ddabdbc70c3f8f15807ace5bd226082f6a50 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Mon, 13 Oct 2025 02:22:33 +0000 Subject: [PATCH] Handle browser globals in a much better way for ESLint. --- eslint.config.js | 26 ++------------------------ package-lock.json | 20 +++++++++++++++++--- package.json | 1 + 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 9b54e36af..4902b2f0d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,3 +1,4 @@ +import globals from 'globals'; import js from '@eslint/js'; export default [ @@ -9,30 +10,7 @@ export default [ ecmaVersion: 2022, sourceType: 'script', globals: { - // Browser - window: 'readonly', - document: 'readonly', - console: 'readonly', - alert: 'readonly', - confirm: 'readonly', - setTimeout: 'readonly', - setInterval: 'readonly', - clearTimeout: 'readonly', - clearInterval: 'readonly', - fetch: 'readonly', - XMLHttpRequest: 'readonly', - FormData: 'readonly', - URLSearchParams: 'readonly', - localStorage: 'readonly', - sessionStorage: 'readonly', - location: 'readonly', - history: 'readonly', - navigator: 'readonly', - Event: 'readonly', - CustomEvent: 'readonly', - Element: 'readonly', - IntersectionObserver: 'readonly', - MutationObserver: 'readonly', + ...globals.browser, // Dojo dojo: 'readonly', diff --git a/package-lock.json b/package-lock.json index 3ac0644fd..e33ceb57a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "devDependencies": { "eslint": "^9.37.0", + "globals": "^16.4.0", "gulp": "^5.0.1", "gulp-less": "^5.0.0", "gulp-touch-fd": "^2.0.0", @@ -122,6 +123,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/js": { "version": "9.37.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.37.0.tgz", @@ -1360,9 +1374,9 @@ } }, "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "version": "16.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.4.0.tgz", + "integrity": "sha512-ob/2LcVVaVGCYN+r14cnwnoDPUufjiYgSqRhiFD0Q1iI4Odora5RE8Iv1D24hAz5oMophRGkGz+yuvQmmUMnMw==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 31dcfbd7e..7c0815d09 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "type": "module", "devDependencies": { "eslint": "^9.37.0", + "globals": "^16.4.0", "gulp": "^5.0.1", "gulp-less": "^5.0.0", "gulp-touch-fd": "^2.0.0",