Skip to content

Commit

Permalink
feat: remove eslintrc compat logic from eslint.config
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Nov 22, 2024
1 parent 8384c76 commit 53b37de
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 144 deletions.
4 changes: 1 addition & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ repos:
additional_dependencies:
- eslint@^9.14.0
- "@eslint/js"
- "@eslint/eslintrc"
- typescript-eslint
- eslint-plugin-jsdoc@^v50.4.3
- "@typescript-eslint/eslint-plugin"
- "@typescript-eslint/parser"
- eslint-plugin-diff@^2.0.3
- repo: local
hooks:
Expand Down
288 changes: 147 additions & 141 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -1,154 +1,160 @@
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
});
const eslint = require("@eslint/js");
const tseslint = require("typescript-eslint");
const jsdoc = require("eslint-plugin-jsdoc");
const diff = require("eslint-plugin-diff");

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"), {
// https://github.com/paleite/eslint-plugin-diff/issues/47#issuecomment-2480733106
const diffConfig = {
plugins: {
jsdoc,
"@typescript-eslint": typescriptEslint,
diff,
},

languageOptions: {
globals: {
console: "readonly",
},

parser: tsParser,
ecmaVersion: 7,
sourceType: "script",
processor: diff.processors.diff,
}

module.exports = tseslint.config(
{
// these are autogenerated and thus should not be linted at all.
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",
],
},

settings: {
jsdoc: {
preferredTypes: {
object: "Object",
},
{
languageOptions: {
ecmaVersion: 7,
sourceType: "script",
},
},

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",
{
plugins: {
jsdoc,
}
},
}, {
files: ["**/*.mjs"],

languageOptions: {
ecmaVersion: 5,
sourceType: "module",
eslint.configs.recommended,
tseslint.configs.recommended,
jsdoc.configs['flat/recommended'],
diffConfig,
{
files: ["res/controllers/**/*"],
languageOptions: {
globals: {
// QJSEngine::ConsoleExtension, https://doc.qt.io/qt-6/qtquick-debugging.html#console-api
"console": "readonly",
// lodash, deprecated
"_": "readonly",
// Mixxx custom
"ColorMapper": "readonly",
"components": "readonly",
"engine": "readonly",
"midi": "readonly",
// common-controller-scripts globals
"print": "readonly",
"printObject": "readonly",
"stringifyObject": "readonly",
"arrayContains": "readonly",
"secondstominutes": "readonly",
"msecondstominutes": "readonly",
"colorCodeToObject": "readonly",
"colorCodeFromObject": "readonly",
"script": "readonly",
"bpm": "readonly",
"ButtonState": "readonly",
"LedState": "readonly",
"Controller": "readonly",
"Button": "readonly",
"Control": "readonly",
"Deck": "readonly"
}
}
},
}, {
files: ["res/controllers/common-hid-packet-parser.js"],

languageOptions: {
globals: {
console: "readonly",
{
// vanilla rule config from previous `.eslintrc`
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-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",
},
},

rules: {
camelcase: "off",
{
// special rules required for the typescript plugin
rules: {
// Note: you must disable the base rule as it can report incorrect errors
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", {
argsIgnorePattern: "^_",
}],
// no need for jsdoc type annotation, the typescript syntax already requires it.
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
// this is commonly needed in ComponentsJS
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-explicit-any": "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",
},
{
// JSDoc specific stuff
rules: {
// the style here is too mixed currently, disable for now
"jsdoc/tag-lines": "off"
}
},
}];
);

0 comments on commit 53b37de

Please sign in to comment.