@addon24/eslint-config
Version: 
ESLint configuration rules for WorldOfTextcraft projects - Centralized configuration for all project types
373 lines (358 loc) • 13.5 kB
JavaScript
import stylistic from "@stylistic/eslint-plugin";
import typescript from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
import deprecatePlugin from "eslint-plugin-deprecate";
import importPlugin from "eslint-plugin-import";
import perfectionist from "eslint-plugin-perfectionist";
import sonarjsPlugin from "eslint-plugin-sonarjs";
import globals from "globals";
export default [
  {
    files: ["**/*.ts"],
    languageOptions: {
      ecmaVersion: "latest",
      sourceType: "module",
      globals: globals.node,
      parser: typescriptParser,
      parserOptions: {
        ecmaVersion: "latest",
        sourceType: "module",
        project: "./tsconfig.json",
        ecmaFeatures: {
          jsx: true,
        },
      },
    },
    plugins: {
      "@typescript-eslint": typescript,
      "@stylistic": stylistic,
      import: importPlugin,
      deprecate: deprecatePlugin,
      perfectionist,
      sonarjs: sonarjsPlugin,
    },
    rules: {
      // Best Practices
      "no-console": "warn",
      "no-debugger": "error",
      "no-alert": "error",
      "no-eval": "error",
      "no-implied-eval": "error",
      "no-new-func": "error",
      "no-script-url": "error",
      "no-self-compare": "error",
      "no-sequences": "error",
      "no-throw-literal": "error",
      "no-unmodified-loop-condition": "error",
      "no-unused-expressions": "error",
      "no-useless-call": "error",
      "no-useless-concat": "error",
      "no-useless-return": "error",
      "prefer-promise-reject-errors": "error",
      "require-await": "error",
      "yoda": "error",
      // Deprecated
      "deprecate/import": [
        "error",
        {
          "name": "lodash",
          "message": "Please use native JavaScript methods instead of lodash."
        }
      ],
      // Errors
      "no-dupe-args": "error",
      "no-dupe-keys": "error",
      "no-dupe-else-if": "error",
      "no-duplicate-case": "error",
      "no-empty": "error",
      "no-extra-boolean-cast": "error",
      "no-extra-semi": "error",
      "no-func-assign": "error",
      "no-import-assign": "error",
      "no-inner-declarations": "error",
      "no-invalid-regexp": "error",
      "no-irregular-whitespace": "error",
      "no-loss-of-precision": "error",
      "no-misleading-character-class": "error",
      "no-mixed-spaces-and-tabs": "error",
      "no-obj-calls": "error",
      "no-octal": "error",
      "no-prototype-builtins": "error",
      "no-redeclare": "error",
      "no-regex-spaces": "error",
      "no-setter-return": "error",
      "no-shadow-restricted-names": "error",
      "no-sparse-arrays": "error",
      "no-this-before-super": "error",
      "no-undef": "error",
      "no-unexpected-multiline": "error",
      "no-unreachable": "error",
      "no-unsafe-finally": "error",
      "no-unsafe-negation": "error",
      "no-unsafe-optional-chaining": "error",
      "no-var": "error",
      "object-shorthand": "error",
      "prefer-arrow-callback": "error",
      "prefer-const": "error",
      "prefer-destructuring": "error",
      "prefer-numeric-literals": "error",
      "prefer-rest-params": "error",
      "prefer-spread": "error",
      "prefer-template": "error",
      "require-yield": "error",
      "use-isnan": "error",
      "valid-typeof": "error",
      // ES6
      "arrow-spacing": "error",
      "constructor-super": "error",
      "generator-star-spacing": "error",
      "no-class-assign": "error",
      "no-confusing-arrow": "error",
      "no-const-assign": "error",
      "no-dupe-class-members": "error",
      "no-duplicate-imports": "error",
      "no-new-symbol": "error",
      "no-useless-computed-key": "error",
      "no-useless-constructor": "error",
      "no-useless-rename": "error",
      "rest-spread-spacing": "error",
      "symbol-description": "error",
      "template-curly-spacing": "error",
      "yield-star-spacing": "error",
      // Imports
      "import/default": "error",
      "import/export": "error",
      "import/named": "error",
      "import/namespace": "error",
      "import/no-duplicates": "error",
      "import/no-mutable-exports": "error",
      "import/no-named-as-default": "error",
      "import/no-named-as-default-member": "error",
      "import/no-self-import": "error",
      "import/no-unresolved": "error",
      "import/no-useless-path-segments": "error",
      "import/order": [
        "error",
        {
          "groups": [
            "builtin",
            "external",
            "internal",
            "parent",
            "sibling",
            "index"
          ],
          "newlines-between": "always",
          "alphabetize": {
            "order": "asc",
            "caseInsensitive": true
          }
        }
      ],
      // Node.js
      "node/no-deprecated-api": "error",
      "node/no-missing-import": "error",
      "node/no-unpublished-import": "error",
      "node/process-exit-as-throw": "error",
      // Strict
      "strict": ["error", "global"],
      // Style
      "array-bracket-newline": "error",
      "array-bracket-spacing": "error",
      "array-element-newline": "error",
      "arrow-parens": "error",
      "block-spacing": "error",
      "brace-style": "error",
      "comma-dangle": "error",
      "comma-spacing": "error",
      "comma-style": "error",
      "computed-property-spacing": "error",
      "dot-location": "error",
      "dot-notation": "error",
      "eol-last": "error",
      "function-call-argument-newline": "error",
      "function-paren-newline": "error",
      "implicit-arrow-linebreak": "error",
      "indent": "error",
      "jsx-quotes": "error",
      "key-spacing": "error",
      "keyword-spacing": "error",
      "line-comment-position": "error",
      "linebreak-style": "error",
      "lines-around-comment": "error",
      "lines-between-class-members": "error",
      "max-len": "error",
      "max-statements-per-line": "error",
      "multiline-ternary": "error",
      "new-cap": "error",
      "new-parens": "error",
      "newline-per-chained-call": "error",
      "no-array-constructor": "error",
      "no-bitwise": "error",
      "no-continue": "error",
      "no-inline-comments": "error",
      "no-lonely-if": "error",
      "no-mixed-operators": "error",
      "no-multi-assign": "error",
      "no-multiple-empty-lines": "error",
      "no-negated-condition": "error",
      "no-nested-ternary": "error",
      "no-new-object": "error",
      "no-plusplus": "error",
      "no-tabs": "error",
      "no-trailing-spaces": "error",
      "no-underscore-dangle": "error",
      "no-unneeded-ternary": "error",
      "no-whitespace-before-property": "error",
      "nonblock-statement-body-position": "error",
      "object-curly-newline": "error",
      "object-curly-spacing": "error",
      "object-property-newline": "error",
      "one-var": "error",
      "one-var-declaration-per-line": "error",
      "operator-assignment": "error",
      "operator-linebreak": "error",
      "padded-blocks": "error",
      "padding-line-between-statements": "error",
      "prefer-exponentiation-operator": "error",
      "prefer-object-spread": "error",
      "quote-props": "error",
      "quotes": "error",
      "semi": "error",
      "semi-spacing": "error",
      "semi-style": "error",
      "space-before-blocks": "error",
      "space-before-function-paren": "error",
      "space-in-parens": "error",
      "space-infix-ops": "error",
      "space-unary-ops": "error",
      "spaced-comment": "error",
      "switch-colon-spacing": "error",
      "template-tag-spacing": "error",
      "unicode-bom": "error",
      "wrap-regex": "error",
      // TypeScript
      "@typescript-eslint/adjacent-overload-signatures": "error",
      "@typescript-eslint/array-type": "error",
      "@typescript-eslint/ban-ts-comment": "error",
      "@typescript-eslint/ban-types": "error",
      "@typescript-eslint/class-literal-property-style": "error",
      "@typescript-eslint/consistent-indexed-object-style": "error",
      "@typescript-eslint/consistent-type-assertions": "error",
      "@typescript-eslint/consistent-type-definitions": "error",
      "@typescript-eslint/explicit-function-return-type": "error",
      "@typescript-eslint/explicit-member-accessibility": "error",
      "@typescript-eslint/explicit-module-boundary-types": "error",
      "@typescript-eslint/member-delimiter-style": "error",
      "@typescript-eslint/member-ordering": "error",
      "@typescript-eslint/method-signature-style": "error",
      "@typescript-eslint/naming-convention": "error",
      "@typescript-eslint/no-base-to-string": "error",
      "@typescript-eslint/no-confusing-non-null-assertion": "error",
      "@typescript-eslint/no-confusing-void-expression": "error",
      "@typescript-eslint/no-dynamic-delete": "error",
      "@typescript-eslint/no-empty-function": "error",
      "@typescript-eslint/no-empty-interface": "error",
      "@typescript-eslint/no-explicit-any": "error",
      "@typescript-eslint/no-extra-non-null-assertion": "error",
      "@typescript-eslint/no-extraneous-class": "error",
      "@typescript-eslint/no-floating-promises": "error",
      "@typescript-eslint/no-for-in-array": "error",
      "@typescript-eslint/no-inferrable-types": "error",
      "@typescript-eslint/no-misused-new": "error",
      "@typescript-eslint/no-misused-promises": "error",
      "@typescript-eslint/no-namespace": "error",
      "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
      "@typescript-eslint/no-non-null-assertion": "error",
      "@typescript-eslint/no-parameter-properties": "error",
      "@typescript-eslint/no-require-imports": "error",
      "@typescript-eslint/no-this-alias": "error",
      "@typescript-eslint/no-throw-literal": "error",
      "@typescript-eslint/no-type-assertion": "error",
      "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
      "@typescript-eslint/no-unnecessary-condition": "error",
      "@typescript-eslint/no-unnecessary-qualifier": "error",
      "@typescript-eslint/no-unnecessary-type-arguments": "error",
      "@typescript-eslint/no-unnecessary-type-assertion": "error",
      "@typescript-eslint/no-unnecessary-type-constraint": "error",
      "@typescript-eslint/no-unsafe-argument": "error",
      "@typescript-eslint/no-unsafe-assignment": "error",
      "@typescript-eslint/no-unsafe-call": "error",
      "@typescript-eslint/no-unsafe-member-access": "error",
      "@typescript-eslint/no-unsafe-return": "error",
      "@typescript-eslint/no-var-requires": "error",
      "@typescript-eslint/prefer-as-const": "error",
      "@typescript-eslint/prefer-function-type": "error",
      "@typescript-eslint/prefer-includes": "error",
      "@typescript-eslint/prefer-literal-enum-member": "error",
      "@typescript-eslint/prefer-namespace-keyword": "error",
      "@typescript-eslint/prefer-nullish-coalescing": "error",
      "@typescript-eslint/prefer-optional-chain": "error",
      "@typescript-eslint/prefer-readonly": "error",
      "@typescript-eslint/prefer-readonly-parameter-types": "error",
      "@typescript-eslint/prefer-reduce-type-parameter": "error",
      "@typescript-eslint/prefer-regexp-exec": "error",
      "@typescript-eslint/prefer-string-starts-ends-with": "error",
      "@typescript-eslint/prefer-ts-expect-error": "error",
      "@typescript-eslint/promise-function-async": "error",
      "@typescript-eslint/require-array-sort-compare": "error",
      "@typescript-eslint/require-await": "error",
      "@typescript-eslint/restrict-plus-operands": "error",
      "@typescript-eslint/restrict-template-expressions": "error",
      "@typescript-eslint/return-await": "error",
      "@typescript-eslint/strict-boolean-expressions": "error",
      "@typescript-eslint/switch-exhaustiveness-check": "error",
      "@typescript-eslint/triple-slash-reference": "error",
      "@typescript-eslint/type-annotation-spacing": "error",
      "@typescript-eslint/unbound-method": "error",
      "@typescript-eslint/unified-signatures": "error",
      // Variables
      "id-length": "error",
      "no-label-var": "error",
      "no-restricted-globals": "error",
      "no-shadow": "error",
      "no-undef-init": "error",
      "no-use-before-define": "error",
      // SonarJS-Regeln für Code-Qualität und Sicherheit
      "sonarjs/no-identical-expressions": "error",
      "sonarjs/no-identical-functions": "error",
      "sonarjs/no-redundant-boolean": "error",
      "sonarjs/no-redundant-jump": "error",
      "sonarjs/no-unused-collection": "error",
      "sonarjs/no-use-of-empty-return-value": "error",
      "sonarjs/prefer-immediate-return": "error",
      "sonarjs/prefer-object-literal": "error",
      "sonarjs/prefer-single-boolean-return": "error",
      "sonarjs/prefer-while": "error",
      // Konfiguriere Export-Sortierung
      "perfectionist/sort-named-exports": [
        "error",
        {
          "type": "alphabetical",
          "order": "asc",
          "newlinesBetween": "never"
        }
      ],
      "perfectionist/sort-exports": [
        "error",
        {
          "type": "alphabetical",
          "order": "asc"
        }
      ],
    },
  },
  {
    ignores: [
      "node_modules/**",
      "dist/**",
      "coverage/**",
      "logs/**",
      "scripts/**",
      "**/__tests__/**",
      "**/*.test.ts",
      "**/*.spec.ts",
      "src/tests/**"
    ],
  },
];