diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 16e926154f8..00000000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -res/controllers/lodash.mixxx.js -res/controllers/Novation-Launchpad MK2-scripts.js -res/controllers/Novation-Launchpad Mini MK3-scripts.js -res/controllers/Novation-Launchpad-scripts.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 5b871fcb9b9..00000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "extends": [ "eslint:recommended", - "plugin:jsdoc/recommended", - "plugin:diff/diff"], - - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 7, - "sourceType": "script" - }, - "env": { - "es6": true - }, - "plugins": [ "jsdoc", "@typescript-eslint" ], - "settings": { - "jsdoc": { - "preferredTypes": { - "object": "Object" - } - } - }, - "rules": { - "array-bracket-spacing": "warn", - "block-spacing": "warn", - "brace-style": [ - "warn", - "1tbs", - { - "allowSingleLine": true - } - ], - "curly": "warn", - "camelcase": "warn", - "comma-spacing": "warn", - "computed-property-spacing": [ - "warn", - "never", - { - "enforceForClassMembers": true - } - ], - "dot-location": [ "warn", "property" ], - "dot-notation": "warn", - "eqeqeq": [ "error", "always" ], - "func-call-spacing": "warn", - "func-style": [ - "error", - "expression", - { - "allowArrowFunctions": true - } - ], - "indent": [ "warn", 4 ], - "key-spacing": "warn", - "keyword-spacing": "warn", - "linebreak-style": [ "warn", "unix" ], - "newline-per-chained-call": "warn", - "no-constructor-return": "warn", - "no-extra-bind": "warn", - "no-sequences": "warn", - "no-useless-call": "warn", - "no-useless-return": "warn", - "no-trailing-spaces": "warn", - "no-unneeded-ternary": [ - "warn", - { - "defaultAssignment": false - } - ], - "no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_" - } - ], - "no-var": "warn", - "object-curly-newline": [ - "warn", - { - "consistent": true, - "multiline": true - } - ], - "object-curly-spacing": "warn", - "prefer-const": "warn", - "prefer-regex-literals": "warn", - "prefer-template": "warn", - "quotes": [ "warn", "double" ], - "require-atomic-updates": "error", - "semi": "warn", - "semi-spacing": "warn", - "space-before-blocks": [ "warn", "always" ], - "space-before-function-paren": [ "warn", "never" ], - "space-in-parens": "warn", - "yoda": "warn" - }, - "globals": { - "console": "readonly" - }, - "overrides": [ - { - "files": [ "res/controllers/*.d.ts" ], - "extends": [ "plugin:@typescript-eslint/recommended" ], - "rules": { - "no-unused-vars": "off" - } - }, - { - "files": [ "**/*.mjs" ], - "parserOptions": { - "sourceType": "module" - } - }, - { - "files": [ "res/controllers/common-hid-packet-parser.js" ], - "globals": { - "console": "readonly" - }, - "rules": { - "camelcase": "off" - } - }, - { - "files": [ "res/controllers/*.js" ], - "excludedFiles": "res/controllers/common-hid-packet-parser.js", - "globals": { - "console": "readonly", - "svg": "writable", - "HIDController": "writable", - "HIDDebug": "writable", - "HIDPacket": "writable", - "controller": "writable" - } - } - ] -} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f2c010c51e..3c868a826b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,6 +77,8 @@ repos: - manual additional_dependencies: - eslint@^9.14.0 + - "@eslint/js" + - "@eslint/eslintrc" - eslint-plugin-jsdoc@^v50.4.3 - "@typescript-eslint/eslint-plugin" - "@typescript-eslint/parser" diff --git a/eslint.config.cjs b/eslint.config.cjs new file mode 100644 index 00000000000..943fbc87b59 --- /dev/null +++ b/eslint.config.cjs @@ -0,0 +1,154 @@ +const jsdoc = require("eslint-plugin-jsdoc"); +const typescriptEslint = require("@typescript-eslint/eslint-plugin"); +const tsParser = require("@typescript-eslint/parser"); +const js = require("@eslint/js"); + +const { + FlatCompat, +} = require("@eslint/eslintrc"); + +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +module.exports = [{ + ignores: [ + "res/controllers/lodash.mixxx.js", + "res/controllers/Novation-Launchpad MK2-scripts.js", + "res/controllers/Novation-Launchpad Mini MK3-scripts.js", + "res/controllers/Novation-Launchpad-scripts.js", + ], +}, ...compat.extends("eslint:recommended", "plugin:jsdoc/recommended", "plugin:diff/diff"), { + plugins: { + jsdoc, + "@typescript-eslint": typescriptEslint, + }, + + languageOptions: { + globals: { + console: "readonly", + }, + + parser: tsParser, + ecmaVersion: 7, + sourceType: "script", + }, + + settings: { + jsdoc: { + preferredTypes: { + object: "Object", + }, + }, + }, + + rules: { + "array-bracket-spacing": "warn", + "block-spacing": "warn", + + "brace-style": ["warn", "1tbs", { + allowSingleLine: true, + }], + + curly: "warn", + camelcase: "warn", + "comma-spacing": "warn", + + "computed-property-spacing": ["warn", "never", { + enforceForClassMembers: true, + }], + + "dot-location": ["warn", "property"], + "dot-notation": "warn", + eqeqeq: ["error", "always"], + "func-call-spacing": "warn", + + "func-style": ["error", "expression", { + allowArrowFunctions: true, + }], + + indent: ["warn", 4], + "key-spacing": "warn", + "keyword-spacing": "warn", + "linebreak-style": ["warn", "unix"], + "newline-per-chained-call": "warn", + "no-constructor-return": "warn", + "no-extra-bind": "warn", + "no-sequences": "warn", + "no-useless-call": "warn", + "no-useless-return": "warn", + "no-trailing-spaces": "warn", + + "no-unneeded-ternary": ["warn", { + defaultAssignment: false, + }], + + "no-unused-vars": ["error", { + argsIgnorePattern: "^_", + }], + + "no-var": "warn", + + "object-curly-newline": ["warn", { + consistent: true, + multiline: true, + }], + + "object-curly-spacing": "warn", + "prefer-const": "warn", + "prefer-regex-literals": "warn", + "prefer-template": "warn", + quotes: ["warn", "double"], + "require-atomic-updates": "error", + semi: "warn", + "semi-spacing": "warn", + "space-before-blocks": ["warn", "always"], + "space-before-function-paren": ["warn", "never"], + "space-in-parens": "warn", + yoda: "warn", + }, +}, ...compat.extends("plugin:@typescript-eslint/recommended").map(config => ({ + ...config, + files: ["res/controllers/*.d.ts"], +})), { + files: ["res/controllers/*.d.ts"], + + rules: { + "no-unused-vars": "off", + }, +}, { + files: ["**/*.mjs"], + + languageOptions: { + ecmaVersion: 5, + sourceType: "module", + }, +}, { + files: ["res/controllers/common-hid-packet-parser.js"], + + languageOptions: { + globals: { + console: "readonly", + }, + }, + + rules: { + camelcase: "off", + }, +}, { + files: ["res/controllers/*.js"], + ignores: ["res/controllers/common-hid-packet-parser.js"], + + languageOptions: { + globals: { + console: "readonly", + svg: "writable", + HIDController: "writable", + HIDDebug: "writable", + HIDPacket: "writable", + controller: "writable", + }, + }, +}];