-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to ESLint v9 and flat config (#3558)
Since PR #3551 was not yet complete, I made my own attempt. 1. Update to ESLint v9. 2. Replace deprecated `.eslintrc.json` and `.eslintignore` by flat config `eslint.config.mjs`. 3. Adapt `check_config.js` to use flat config. 4. Since `eslint-plugin-import` still doesn't support ESLint v9 I removed it. We can add it back when it does support v9. 5. Run tests `npm run check:js` and `npm run config:check`. 6. In order not to overload this PR, I have not yet activated more additional rules - there are some useful ones in the new plugin `@eslint/js`. @bugsounet, please don't take it as an offence that I have created a competing PR. The migration to ESLint v9 has been burning under my nails for some time.
- Loading branch information
1 parent
5ffdf9a
commit d318768
Showing
10 changed files
with
367 additions
and
1,149 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
*.js | ||
.eslintignore | ||
*.mjs | ||
.husky/pre-commit | ||
.prettierignore | ||
/config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import eslintPluginJest from "eslint-plugin-jest"; | ||
import eslintPluginJs from "@eslint/js"; | ||
import eslintPluginStylistic from "@stylistic/eslint-plugin"; | ||
import globals from "globals"; | ||
|
||
const config = [ | ||
eslintPluginJs.configs.recommended, | ||
{ | ||
files: ["**/*.js"], | ||
languageOptions: { | ||
ecmaVersion: "latest", | ||
globals: { | ||
...globals.browser, | ||
...globals.node, | ||
...globals.jest, | ||
Log: "readonly", | ||
MM: "readonly", | ||
Module: "readonly", | ||
config: "readonly", | ||
moment: "readonly" | ||
} | ||
}, | ||
plugins: { | ||
...eslintPluginStylistic.configs["all-flat"].plugins, | ||
...eslintPluginJest.configs["flat/recommended"].plugins | ||
}, | ||
rules: { | ||
...eslintPluginStylistic.configs["all-flat"].rules, | ||
...eslintPluginJest.configs["flat/recommended"].rules, | ||
"@stylistic/array-element-newline": ["error", "consistent"], | ||
"@stylistic/arrow-parens": ["error", "always"], | ||
"@stylistic/brace-style": "off", | ||
"@stylistic/comma-dangle": ["error", "never"], | ||
"@stylistic/dot-location": ["error", "property"], | ||
"@stylistic/function-call-argument-newline": ["error", "consistent"], | ||
"@stylistic/function-paren-newline": ["error", "consistent"], | ||
"@stylistic/implicit-arrow-linebreak": ["error", "beside"], | ||
"@stylistic/indent": ["error", "tab"], | ||
"@stylistic/max-statements-per-line": ["error", {max: 2}], | ||
"@stylistic/multiline-comment-style": "off", | ||
"@stylistic/multiline-ternary": ["error", "always-multiline"], | ||
"@stylistic/newline-per-chained-call": ["error", {ignoreChainWithDepth: 4}], | ||
"@stylistic/no-extra-parens": "off", | ||
"@stylistic/no-tabs": "off", | ||
"@stylistic/object-curly-spacing": ["error", "always"], | ||
"@stylistic/object-property-newline": ["error", {allowAllPropertiesOnSameLine: true}], | ||
"@stylistic/operator-linebreak": ["error", "before"], | ||
"@stylistic/padded-blocks": "off", | ||
"@stylistic/quote-props": ["error", "as-needed"], | ||
"@stylistic/quotes": ["error", "double"], | ||
"@stylistic/semi": ["error", "always"], | ||
"@stylistic/space-before-function-paren": ["error", "always"], | ||
"@stylistic/spaced-comment": "off", | ||
eqeqeq: "error", | ||
"id-length": "off", | ||
"init-declarations": "off", | ||
"jest/consistent-test-it": "warn", | ||
"jest/no-done-callback": "warn", | ||
"jest/prefer-expect-resolves": "warn", | ||
"jest/prefer-mock-promise-shorthand": "warn", | ||
"jest/prefer-to-be": "warn", | ||
"jest/prefer-to-have-length": "warn", | ||
"max-lines-per-function": ["warn", 350], | ||
"max-statements": "off", | ||
"no-global-assign": "off", | ||
"no-inline-comments": "off", | ||
"no-magic-numbers": "off", | ||
"no-param-reassign": "error", | ||
"no-plusplus": "off", | ||
"no-prototype-builtins": "off", | ||
"no-ternary": "off", | ||
"no-throw-literal": "error", | ||
"no-undefined": "off", | ||
"no-unused-vars": "off", | ||
"no-useless-return": "error", | ||
"no-warning-comments": "off", | ||
"object-shorthand": ["error", "methods"], | ||
"one-var": "off", | ||
"prefer-destructuring": "off", | ||
"prefer-template": "error", | ||
"sort-keys": "off" | ||
} | ||
}, | ||
{ | ||
files: ["**/*.mjs"], | ||
languageOptions: { | ||
ecmaVersion: "latest", | ||
globals: { | ||
...globals.node | ||
}, | ||
sourceType: "module" | ||
}, | ||
plugins: { | ||
...eslintPluginStylistic.configs["all-flat"].plugins | ||
}, | ||
rules: { | ||
...eslintPluginStylistic.configs["all-flat"].rules, | ||
"@stylistic/array-element-newline": "off", | ||
"@stylistic/indent": ["error", "tab"], | ||
"@stylistic/padded-blocks": ["error", "never"], | ||
"@stylistic/quote-props": ["error", "as-needed"], | ||
"func-style": "off", | ||
"import/namespace": "off", | ||
"max-lines-per-function": ["error", 100], | ||
"no-magic-numbers": "off", | ||
"one-var": "off", | ||
"prefer-destructuring": "off" | ||
} | ||
}, | ||
{ | ||
files: ["tests/configs/modules/weather/*.js"], | ||
rules: { | ||
"@stylistic/quotes": "off" | ||
} | ||
}, | ||
{ | ||
ignores: ["config/**", "modules/**", "!modules/default/**", "js/positions.js"] | ||
} | ||
]; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.