Handle browser globals in a much better way for ESLint.

This commit is contained in:
supahgreg 2025-10-13 02:22:33 +00:00
parent 54b69728d0
commit 20d2ddabdb
No known key found for this signature in database
3 changed files with 20 additions and 27 deletions

View File

@ -1,3 +1,4 @@
import globals from 'globals';
import js from '@eslint/js'; import js from '@eslint/js';
export default [ export default [
@ -9,30 +10,7 @@ export default [
ecmaVersion: 2022, ecmaVersion: 2022,
sourceType: 'script', sourceType: 'script',
globals: { globals: {
// Browser ...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',
// Dojo // Dojo
dojo: 'readonly', dojo: 'readonly',

20
package-lock.json generated
View File

@ -9,6 +9,7 @@
"version": "1.0.0", "version": "1.0.0",
"devDependencies": { "devDependencies": {
"eslint": "^9.37.0", "eslint": "^9.37.0",
"globals": "^16.4.0",
"gulp": "^5.0.1", "gulp": "^5.0.1",
"gulp-less": "^5.0.0", "gulp-less": "^5.0.0",
"gulp-touch-fd": "^2.0.0", "gulp-touch-fd": "^2.0.0",
@ -122,6 +123,19 @@
"url": "https://opencollective.com/eslint" "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": { "node_modules/@eslint/js": {
"version": "9.37.0", "version": "9.37.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.37.0.tgz", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.37.0.tgz",
@ -1360,9 +1374,9 @@
} }
}, },
"node_modules/globals": { "node_modules/globals": {
"version": "14.0.0", "version": "16.4.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", "resolved": "https://registry.npmjs.org/globals/-/globals-16.4.0.tgz",
"integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "integrity": "sha512-ob/2LcVVaVGCYN+r14cnwnoDPUufjiYgSqRhiFD0Q1iI4Odora5RE8Iv1D24hAz5oMophRGkGz+yuvQmmUMnMw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {

View File

@ -5,6 +5,7 @@
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {
"eslint": "^9.37.0", "eslint": "^9.37.0",
"globals": "^16.4.0",
"gulp": "^5.0.1", "gulp": "^5.0.1",
"gulp-less": "^5.0.0", "gulp-less": "^5.0.0",
"gulp-touch-fd": "^2.0.0", "gulp-touch-fd": "^2.0.0",