mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-04 04:37:37 -04:00
[linter] Refactor ESLint config to use defineConfig
and globalIgnores
This commit is contained in:
parent
24a6bebedd
commit
a3d2064bb7
1 changed files with 21 additions and 22 deletions
|
@ -1,16 +1,13 @@
|
||||||
import eslintPluginJest from "eslint-plugin-jest";
|
import {defineConfig, globalIgnores} from "eslint/config";
|
||||||
import eslintPluginJs from "@eslint/js";
|
|
||||||
import eslintPluginPackageJson from "eslint-plugin-package-json";
|
|
||||||
import eslintPluginStylistic from "@stylistic/eslint-plugin";
|
|
||||||
import globals from "globals";
|
import globals from "globals";
|
||||||
import {flatConfigs as importX} from "eslint-plugin-import-x";
|
import {flatConfigs as importX} from "eslint-plugin-import-x";
|
||||||
|
import jest from "eslint-plugin-jest";
|
||||||
|
import js from "@eslint/js";
|
||||||
|
import packageJson from "eslint-plugin-package-json";
|
||||||
|
import stylistic from "@stylistic/eslint-plugin";
|
||||||
|
|
||||||
const config = [
|
export default defineConfig([
|
||||||
eslintPluginJest.configs["flat/recommended"],
|
globalIgnores(["config/**", "modules/**/*", "!modules/default/**", "js/positions.js"]),
|
||||||
eslintPluginJs.configs.recommended,
|
|
||||||
eslintPluginPackageJson.configs.recommended,
|
|
||||||
eslintPluginStylistic.configs.all,
|
|
||||||
importX.recommended,
|
|
||||||
{
|
{
|
||||||
files: ["**/*.js"],
|
files: ["**/*.js"],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
|
@ -18,7 +15,6 @@ const config = [
|
||||||
globals: {
|
globals: {
|
||||||
...globals.browser,
|
...globals.browser,
|
||||||
...globals.node,
|
...globals.node,
|
||||||
...globals.jest,
|
|
||||||
Log: "readonly",
|
Log: "readonly",
|
||||||
MM: "readonly",
|
MM: "readonly",
|
||||||
Module: "readonly",
|
Module: "readonly",
|
||||||
|
@ -26,6 +22,8 @@ const config = [
|
||||||
moment: "readonly"
|
moment: "readonly"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
plugins: {js, stylistic},
|
||||||
|
extends: [importX.recommended, jest.configs["flat/recommended"], "js/recommended", "stylistic/all"],
|
||||||
rules: {
|
rules: {
|
||||||
"@stylistic/array-element-newline": ["error", "consistent"],
|
"@stylistic/array-element-newline": ["error", "consistent"],
|
||||||
"@stylistic/arrow-parens": ["error", "always"],
|
"@stylistic/arrow-parens": ["error", "always"],
|
||||||
|
@ -81,11 +79,15 @@ const config = [
|
||||||
"no-warning-comments": "off",
|
"no-warning-comments": "off",
|
||||||
"object-shorthand": ["error", "methods"],
|
"object-shorthand": ["error", "methods"],
|
||||||
"one-var": "off",
|
"one-var": "off",
|
||||||
"prefer-destructuring": "off",
|
|
||||||
"prefer-template": "error",
|
"prefer-template": "error",
|
||||||
"sort-keys": "off"
|
"sort-keys": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
files: ["**/package.json"],
|
||||||
|
plugins: {packageJson},
|
||||||
|
extends: ["packageJson/recommended"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
files: ["**/*.mjs"],
|
files: ["**/*.mjs"],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
|
@ -95,17 +97,19 @@ const config = [
|
||||||
},
|
},
|
||||||
sourceType: "module"
|
sourceType: "module"
|
||||||
},
|
},
|
||||||
|
plugins: {js, stylistic},
|
||||||
|
extends: [importX.recommended, "js/all", "stylistic/all"],
|
||||||
rules: {
|
rules: {
|
||||||
"@stylistic/array-element-newline": "off",
|
"@stylistic/array-element-newline": "off",
|
||||||
"@stylistic/indent": ["error", "tab"],
|
"@stylistic/indent": ["error", "tab"],
|
||||||
|
"@stylistic/object-property-newline": ["error", {allowAllPropertiesOnSameLine: true}],
|
||||||
"@stylistic/padded-blocks": ["error", "never"],
|
"@stylistic/padded-blocks": ["error", "never"],
|
||||||
"@stylistic/quote-props": ["error", "as-needed"],
|
"@stylistic/quote-props": ["error", "as-needed"],
|
||||||
"func-style": "off",
|
"import-x/no-unresolved": ["error", {ignore: ["eslint/config"]}],
|
||||||
"max-lines-per-function": ["error", 100],
|
"max-lines-per-function": ["error", 100],
|
||||||
"no-magic-numbers": "off",
|
"no-magic-numbers": "off",
|
||||||
"one-var": "off",
|
"one-var": ["error", "never"],
|
||||||
"prefer-destructuring": "off",
|
"sort-keys": "off"
|
||||||
"sort-keys": "error"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -113,10 +117,5 @@ const config = [
|
||||||
rules: {
|
rules: {
|
||||||
"@stylistic/quotes": "off"
|
"@stylistic/quotes": "off"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
ignores: ["config/**", "modules/**/*", "!modules/default/**", "js/positions.js"]
|
|
||||||
}
|
}
|
||||||
];
|
]);
|
||||||
|
|
||||||
export default config;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue