mirror of
https://github.com/MagicMirrorOrg/MagicMirror.git
synced 2026-03-12 17:51:41 +08:00
Since the project's inception, I've missed a clear separation between default and third-party modules. This increases complexity within the project (exclude `modules`, but not `modules/default`), but the mixed use is particularly problematic in Docker setups. Therefore, with this pull request, I'm moving the default modules to a different directory. ~~I've chosen `default/modules`, but I'm not bothered about it; `defaultmodules` or something similar would work just as well.~~ Changed to `defaultmodules`. Let me know if there's a majority in favor of this change.
163 lines
4.9 KiB
JavaScript
163 lines
4.9 KiB
JavaScript
import { defineConfig, globalIgnores } from "eslint/config";
|
|
import globals from "globals";
|
|
import { flatConfigs as importX } from "eslint-plugin-import-x";
|
|
import js from "@eslint/js";
|
|
import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
import packageJson from "eslint-plugin-package-json";
|
|
import playwright from "eslint-plugin-playwright";
|
|
import stylistic from "@stylistic/eslint-plugin";
|
|
import vitest from "@vitest/eslint-plugin";
|
|
|
|
export default defineConfig([
|
|
globalIgnores(["config/**", "modules/**/*", "js/positions.js"]),
|
|
{
|
|
files: ["**/*.js"],
|
|
languageOptions: {
|
|
ecmaVersion: "latest",
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
Log: "readonly",
|
|
MM: "readonly",
|
|
Module: "readonly",
|
|
config: "readonly",
|
|
moment: "readonly"
|
|
}
|
|
},
|
|
plugins: { js, stylistic },
|
|
extends: [importX.recommended, "js/recommended", jsdocPlugin.configs["flat/recommended"], stylistic.configs.customize({ indent: "tab", quotes: "double", semi: true, commaDangle: "never" })],
|
|
rules: {
|
|
"@stylistic/array-element-newline": ["error", "consistent"],
|
|
"@stylistic/arrow-parens": ["error", "always"],
|
|
"@stylistic/brace-style": "off",
|
|
"@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",
|
|
"dot-notation": "error",
|
|
eqeqeq: "error",
|
|
"id-length": "off",
|
|
"import-x/extensions": "error",
|
|
"import-x/newline-after-import": "error",
|
|
"import-x/order": "error",
|
|
"init-declarations": "off",
|
|
"max-lines-per-function": ["warn", 400],
|
|
"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-unneeded-ternary": "error",
|
|
"no-unused-vars": "off",
|
|
"no-useless-return": "error",
|
|
"no-warning-comments": "off",
|
|
"object-shorthand": ["error", "methods"],
|
|
"one-var": "off",
|
|
"prefer-template": "error",
|
|
"sort-keys": "off"
|
|
}
|
|
},
|
|
{
|
|
files: ["**/*.js"],
|
|
ignores: [
|
|
"clientonly/index.js",
|
|
"js/logger.js",
|
|
"tests/**/*.js"
|
|
],
|
|
rules: { "no-console": "error" }
|
|
},
|
|
{
|
|
files: ["**/package.json"],
|
|
plugins: { packageJson },
|
|
extends: ["packageJson/recommended"]
|
|
},
|
|
{
|
|
files: ["**/*.mjs"],
|
|
languageOptions: {
|
|
ecmaVersion: "latest",
|
|
globals: {
|
|
...globals.node
|
|
},
|
|
sourceType: "module"
|
|
},
|
|
plugins: { js, stylistic },
|
|
extends: [importX.recommended, "js/all", stylistic.configs.customize({ indent: "tab", quotes: "double", semi: true, commaDangle: "never" })],
|
|
rules: {
|
|
"@stylistic/array-element-newline": "off",
|
|
"@stylistic/indent": ["error", "tab"],
|
|
"@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
"@stylistic/padded-blocks": ["error", "never"],
|
|
"@stylistic/quote-props": ["error", "as-needed"],
|
|
"import-x/no-unresolved": ["error", { ignore: ["eslint/config"] }],
|
|
"max-lines-per-function": ["error", 100],
|
|
"no-magic-numbers": "off",
|
|
"one-var": ["error", "never"],
|
|
"sort-keys": "off"
|
|
}
|
|
},
|
|
{
|
|
files: ["tests/**/*.js"],
|
|
languageOptions: {
|
|
globals: {
|
|
...vitest.environments.env.globals
|
|
}
|
|
},
|
|
plugins: { vitest },
|
|
extends: [vitest.configs.recommended],
|
|
rules: {
|
|
"vitest/consistent-test-it": "error",
|
|
"vitest/expect-expect": [
|
|
"error",
|
|
{
|
|
assertFunctionNames: [
|
|
"expect",
|
|
"testElementLength",
|
|
"testTextContain",
|
|
"doTest",
|
|
"runAnimationTest",
|
|
"waitForAnimationClass",
|
|
"assertNoAnimationWithin"
|
|
]
|
|
}
|
|
],
|
|
"vitest/max-nested-describe": ["error", { max: 3 }],
|
|
"vitest/prefer-to-be": "error",
|
|
"vitest/prefer-to-have-length": "error"
|
|
}
|
|
},
|
|
{
|
|
files: ["tests/configs/modules/weather/*.js"],
|
|
rules: {
|
|
"@stylistic/quotes": "off"
|
|
}
|
|
},
|
|
{
|
|
files: ["tests/e2e/**/*.js"],
|
|
extends: [playwright.configs["flat/recommended"]],
|
|
rules: {
|
|
"playwright/no-standalone-expect": "off"
|
|
}
|
|
}
|
|
]);
|