diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 42ddb9f0e..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; - -module.exports = { - "env": { - "browser": true, - "es2021": true, - }, - "extends": ["google"], - "overrides": [{ - // eslint-plugin-html handles eol-last slightly different - it applies to - // each set of script tags, so we turn it off here. - "files": "**/*.*php", - "rules": { - "eol-last": "off", - "indent": "off", - }, - }], - "plugins": [ - "html", - "php-markup", - ], - "rules": { - "no-invalid-this": "off", - "camelcase": "off", - "comma-dangle": "off", - "guard-for-in": "off", - "operator-linebreak": "off", - "max-len": "off", - "new-cap": ["error", { - capIsNewExceptions: ["Error", "Warning", "Debug", "Polygon_calcArea", "Play", "Stop", "Panzoom"], - newIsCapExceptionPattern: "^Asset\.." - }], - "no-array-constructor": "off", - "no-unused-vars": ["error", { - "vars": "local", - "args": "none", - "ignoreRestSiblings": false - }], - "no-var": "off", - "prefer-rest-params": "off", - "quotes": "off", - "require-jsdoc": "off", - "spaced-comment": "off", - }, - "settings": { - "php/php-extensions": [".php"], - "php/markup-replacement": {"php": "", "=": "0"}, - "php/keep-eol": false, - "php/remove-whitespace": false, - "php/remove-empty-line": false, - "php/remove-php-lint": false - } -}; diff --git a/.github/workflows/ci-eslint.yml b/.github/workflows/ci-eslint.yml index 3bdf8f471..2ad64e3e5 100644 --- a/.github/workflows/ci-eslint.yml +++ b/.github/workflows/ci-eslint.yml @@ -19,6 +19,6 @@ jobs: with: submodules: recursive - name: Install ESLint - run: npm install eslint@8.7.0 eslint-config-google@0.14.0 eslint-plugin-html@6.2.0 eslint-plugin-php-markup@6.0.0 + run: npm install eslint@9 @eslint/eslintrc @eslint/js globals eslint-config-google@0.14.0 eslint-plugin-html eslint-plugin-php-markup@6.0.0 - name: Run ESLint run: npx eslint --ext .js.php,.js . diff --git a/AGENTS.md b/AGENTS.md index 6842cd335..eb3bfc3a1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -183,7 +183,7 @@ npx eslint --ext .js.php,.js . # Lint all npx eslint --fix web/js/ # Auto-fix ``` -ESLint config: `.eslintrc.js` (Google style guide). Runs in CI via `.github/workflows/ci-eslint.yml`. +ESLint config: `eslint.config.js` (ESLint 9 flat config, Google style guide). Runs in CI via `.github/workflows/ci-eslint.yml`. ### PHP/API Testing diff --git a/eslint.config.js b/eslint.config.js index 076deef6c..e077f3b6d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,8 +1,8 @@ "use strict"; const { - defineConfig, - globalIgnores, + defineConfig, + globalIgnores, } = require("eslint/config"); const globals = require("globals"); @@ -11,100 +11,102 @@ const phpMarkup = require("eslint-plugin-php-markup"); const js = require("@eslint/js"); const { - FlatCompat, + FlatCompat, } = require("@eslint/eslintrc"); const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all }); module.exports = defineConfig([{ - languageOptions: { - globals: { - ...globals.browser, - }, + "languageOptions": { + globals: { + ...globals.browser, + }, + }, + + "extends": compat.extends("google"), + + "plugins": { + html, + "php-markup": phpMarkup, + }, + + "rules": { + "valid-jsdoc": "off", + "no-invalid-this": "off", + "camelcase": "off", + "comma-dangle": "off", + "guard-for-in": "off", + "operator-linebreak": "off", + "max-len": "off", + + "new-cap": ["error", { + capIsNewExceptions: ["Error", "Warning", "Debug", "Polygon_calcArea", "Play", "Stop", "Panzoom"], + newIsCapExceptionPattern: "^Asset..", + }], + + "no-array-constructor": "off", + + "no-unused-vars": ["error", { + "vars": "local", + "args": "none", + "ignoreRestSiblings": false, + }], + + "no-var": "off", + "prefer-rest-params": "off", + "quotes": "off", + "require-jsdoc": "off", + "spaced-comment": "off", + }, + + "settings": { + "php/php-extensions": [".php"], + + "php/markup-replacement": { + "php": "", + "=": "0", }, - extends: compat.extends("google"), - - plugins: { - html, - "php-markup": phpMarkup, - }, - - "rules": { - "no-invalid-this": "off", - "camelcase": "off", - "comma-dangle": "off", - "guard-for-in": "off", - "max-len": "off", - - "new-cap": ["error", { - capIsNewExceptions: ["Error", "Warning", "Debug", "Polygon_calcArea", "Play", "Stop", "Panzoom"], - newIsCapExceptionPattern: "^Asset..", - }], - - "no-array-constructor": "off", - - "no-unused-vars": ["error", { - "vars": "local", - "args": "none", - "ignoreRestSiblings": false, - }], - - "no-var": "off", - "prefer-rest-params": "off", - "quotes": "off", - "require-jsdoc": "off", - "spaced-comment": "off", - }, - - "settings": { - "php/php-extensions": [".php"], - - "php/markup-replacement": { - "php": "", - "=": "0", - }, - - "php/keep-eol": false, - "php/remove-whitespace": false, - "php/remove-empty-line": false, - "php/remove-php-lint": false, - }, + "php/keep-eol": false, + "php/remove-whitespace": false, + "php/remove-empty-line": false, + "php/remove-php-lint": false, + }, }, { - files: ["**/*.*php"], + "files": ["**/*.*php"], - "rules": { - "eol-last": "off", - "indent": "off", - }, + "rules": { + "eol-last": "off", + "indent": "off", + }, }, globalIgnores([ - "**/*.min.js", - "web/api/lib", - "web/includes/csrf/", - "web/js/videojs.zoomrotate.js", - "web/js/video-stream.js", - "web/js/video-rtc.js", - "web/js/fontfaceobserver.standalone.js", - "web/skins/classic/js/bootstrap-4.5.0.js", - "web/skins/classic/js/bootstrap.bundle.min.js", - "web/skins/classic/js/bootstrap-table-1.23.5", - "web/skins/classic/js/chosen", - "web/skins/classic/js/dateTimePicker", - "web/skins/classic/js/jquery-*.js", - "web/skins/classic/js/jquery-ui-*", - "web/skins/classic/js/jquery.js", - "web/skins/classic/js/moment.js", - "web/skins/classic/js/video.js", - "web/skins/classic/assets", - "web/js/janus.js", - "web/js/ajaxQueue.js", - "web/js/hls-1.5.20/", - "web/js/noUiSlider-15.8.1/", - "web/js/dms.js", - "web/skins/classic/includes/export_functions.php", - "web/skins/classic/views/events.php", + "**/*.min.js", + "web/api/lib", + "web/includes/csrf/", + "web/js/videojs.zoomrotate.js", + "web/js/video-stream.js", + "web/js/video-rtc.js", + "web/js/fontfaceobserver.standalone.js", + "web/skins/classic/js/bootstrap-4.5.0.js", + "web/skins/classic/js/bootstrap.bundle.min.js", + "web/skins/classic/js/bootstrap-table-1.23.5", + "web/skins/classic/js/chosen", + "web/skins/classic/js/dateTimePicker", + "web/skins/classic/js/jquery-*.js", + "web/skins/classic/js/jquery-ui-*", + "web/skins/classic/js/jquery.js", + "web/skins/classic/js/moment.js", + "web/skins/classic/js/video.js", + "web/skins/classic/assets", + "web/js/janus.js", + "web/js/ajaxQueue.js", + "web/js/hls-1.6.13/", + "web/js/noUiSlider-15.8.1/", + "web/js/dms.js", + "web/skins/classic/includes/export_functions.php", + "web/skins/classic/views/events.php", ])]);