Skip to content

Commit

Permalink
Migrate deprecated eslint config to to new format
Browse files Browse the repository at this point in the history
The .eslintrc and .eslintignore formats are deprecated. The new format
uses a single eslint.config.js (or .mjs) file at the top.
  • Loading branch information
samhed committed Apr 30, 2024
1 parent c998c72 commit 8d1b665
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 83 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

54 changes: 0 additions & 54 deletions .eslintrc

This file was deleted.

98 changes: 98 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import globals from "globals";
import js from "@eslint/js";

export default [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2020,
sourceType: "module",
globals: {
...globals.browser,
...globals.es2020,
}
},
ignores: ["**/xtscancodes.js"],
rules: {
// Unsafe or confusing stuff that we forbid

"no-unused-vars": ["error", { "vars": "all",
"args": "none",
"ignoreRestSiblings": true,
"caughtErrors": "none" }],
"no-constant-condition": ["error", { "checkLoops": false }],
"no-var": "error",
"no-useless-constructor": "error",
"object-shorthand": ["error", "methods", { "avoidQuotes": true }],
"prefer-arrow-callback": "error",
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": false } ],
"arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
"arrow-spacing": ["error"],
"no-confusing-arrow": ["error", { "allowParens": true }],

// Enforced coding style

"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"indent": ["error", 4, { "SwitchCase": 1,
"VariableDeclarator": "first",
"FunctionDeclaration": { "parameters": "first" },
"FunctionExpression": { "parameters": "first" },
"CallExpression": { "arguments": "first" },
"ArrayExpression": "first",
"ObjectExpression": "first",
"ImportDeclaration": "first",
"ignoreComments": true }],
"comma-spacing": ["error"],
"comma-style": ["error"],
"curly": ["error", "multi-line"],
"func-call-spacing": ["error"],
"func-names": ["error"],
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
"key-spacing": ["error"],
"keyword-spacing": ["error"],
"no-trailing-spaces": ["error"],
"semi": ["error"],
"space-before-blocks": ["error"],
"space-before-function-paren": ["error", { "anonymous": "always",
"named": "never",
"asyncArrow": "always" }],
"switch-colon-spacing": ["error"],
"camelcase": ["error", { "allow": ["^XK_", "^XF86XK_"] }],
}
},
{
files: ["po/po2js", "po/xgettext-html"],
languageOptions: {
globals: {
...globals.node,
}
},
},
{
files: ["tests/*"],
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
sinon: false,
chai: false,
}
},
rules: {
"prefer-arrow-callback": 0,
// Too many anonymous callbacks
"func-names": "off",
},
},
{
files: ["utils/*"],
languageOptions: {
globals: {
...globals.node,
}
},
rules: {
"no-console": 0,
},
},
];
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"commander": "latest",
"eslint": "latest",
"fs-extra": "latest",
"globals": "latest",
"jsdom": "latest",
"karma": "latest",
"karma-mocha": "latest",
Expand Down
5 changes: 0 additions & 5 deletions po/.eslintrc

This file was deleted.

15 changes: 0 additions & 15 deletions tests/.eslintrc

This file was deleted.

8 changes: 0 additions & 8 deletions utils/.eslintrc

This file was deleted.

0 comments on commit 8d1b665

Please sign in to comment.