diff --git a/eslint.config.js b/eslint.config.js index f4d678a4b0..9a2dcb0114 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,6 @@ -// eslint-disable-next-line no-undef const prettier = require('eslint-config-prettier'); +const globals = require('globals'); -// eslint-disable-next-line no-undef module.exports = [ prettier, { @@ -93,8 +92,8 @@ module.exports = [ globals: { axe: true, Promise: true, - node: true, - es6: true + ...globals.node, + ...globals.es2015 } } }, @@ -104,10 +103,9 @@ module.exports = [ sourceType: 'module', globals: { window: true, - node: true, - es6: true, - // do not access global window properties without going through window - browser: false + document: true, + ...globals.node, + ...globals.es2015 } }, rules: { @@ -117,26 +115,26 @@ module.exports = [ } }, { - // after functions and reporters will not be run inside the same context as axe.run so should not access browser globals that require context specific information (window.location, window.getComputedStyles, etc.) - files: ['lib/**/*-after.js', 'lib/core/reporters/**/*.js'], + files: ['doc/examples/chrome-debugging-protocol/axe-cdp.js'], languageOptions: { - sourceType: 'module', globals: { - browser: false + window: true } } }, + { + // after functions and reporters will not be run inside the same context as axe.run so should not access browser globals that require context specific information (window.location, window.getComputedStyles, etc.) + files: ['lib/**/*-after.js', 'lib/core/reporters/**/*.js'], + languageOptions: { + sourceType: 'module' + } + }, { // polyfills are mostly copy-pasted from sources so we don't control their styling files: [ 'lib/core/imports/polyfills.js', 'lib/core/utils/pollyfill-elements-from-point.js' ], - languageOptions: { - globals: { - browser: false - } - }, rules: { 'func-names': 0, 'no-bitwise': 0, @@ -148,7 +146,7 @@ module.exports = [ files: ['test/act-rules/**/*.js', 'test/aria-practices/**/*.js'], languageOptions: { globals: { - mocha: true + ...globals.mocha } }, rules: { @@ -160,9 +158,10 @@ module.exports = [ files: ['test/**/*.js'], languageOptions: { globals: { - mocha: true, - browser: true, - es6: false, + ...globals.mocha, + ...globals.browser, + ...globals.es2015, + ...globals.node, assert: true, helpers: true, checks: true, diff --git a/package-lock.json b/package-lock.json index 3f2e7e2a1b..1b7b0e4658 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "eslint-plugin-mocha-no-only": "^1.1.1", "execa": "5.x", "glob": "^10.3.10", + "globals": "^15.2.0", "grunt": "^1.5.3", "grunt-babel": "^8.0.0", "grunt-bytesize": "^0.2.0", @@ -1093,6 +1094,15 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-classes/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/plugin-transform-computed-properties": { "version": "7.24.1", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.24.1.tgz", @@ -1904,6 +1914,15 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.24.0", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz", @@ -6288,12 +6307,15 @@ } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.2.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.2.0.tgz", + "integrity": "sha512-FQ5YwCHZM3nCmtb5FzEWwdUc9K5d3V/w9mzcz8iGD1gC/aOTHc6PouYu0kkKipNJqHAT7m51sqzQjEjIP+cK0A==", "dev": true, "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globule": { @@ -13910,6 +13932,14 @@ "@babel/helper-replace-supers": "^7.24.1", "@babel/helper-split-export-declaration": "^7.22.6", "globals": "^11.1.0" + }, + "dependencies": { + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + } } }, "@babel/plugin-transform-computed-properties": { @@ -14460,6 +14490,14 @@ "@babel/types": "^7.24.0", "debug": "^4.3.1", "globals": "^11.1.0" + }, + "dependencies": { + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + } } }, "@babel/types": { @@ -17826,9 +17864,9 @@ } }, "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.2.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.2.0.tgz", + "integrity": "sha512-FQ5YwCHZM3nCmtb5FzEWwdUc9K5d3V/w9mzcz8iGD1gC/aOTHc6PouYu0kkKipNJqHAT7m51sqzQjEjIP+cK0A==", "dev": true }, "globule": { diff --git a/package.json b/package.json index b5977cb39a..aad4c11c5d 100644 --- a/package.json +++ b/package.json @@ -142,6 +142,7 @@ "eslint-plugin-mocha-no-only": "^1.1.1", "execa": "5.x", "glob": "^10.3.10", + "globals": "^15.2.0", "grunt": "^1.5.3", "grunt-babel": "^8.0.0", "grunt-bytesize": "^0.2.0",