|
| 1 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 2 | +import _import from "eslint-plugin-import"; |
| 3 | +import unicorn from "eslint-plugin-unicorn"; |
| 4 | +import i18Next from "eslint-plugin-i18next"; |
| 5 | +import sortKeysFix from "eslint-plugin-sort-keys-fix"; |
| 6 | +import {fixupPluginRules} from "@eslint/compat"; |
| 7 | +import globals from "globals"; |
| 8 | +import tsParser from "@typescript-eslint/parser"; |
| 9 | +import jsonc from "eslint-plugin-jsonc"; |
| 10 | +import parser from "jsonc-eslint-parser"; |
| 11 | +import path from "node:path"; |
| 12 | +import {fileURLToPath} from "node:url"; |
| 13 | +import js from "@eslint/js"; |
| 14 | +import {FlatCompat} from "@eslint/eslintrc"; |
| 15 | + |
| 16 | +const __filename = fileURLToPath(import.meta.url); |
| 17 | +const __dirname = path.dirname(__filename); |
| 18 | +const compat = new FlatCompat({ |
| 19 | + baseDirectory: __dirname, |
| 20 | + recommendedConfig: js.configs.recommended, |
| 21 | + allConfig: js.configs.all |
| 22 | +}); |
| 23 | + |
| 24 | +export default [...compat.extends( |
| 25 | + "plugin:@typescript-eslint/recommended", |
| 26 | + "plugin:unicorn/recommended", |
| 27 | + "plugin:i18next/recommended", |
| 28 | +), { |
| 29 | + plugins: { |
| 30 | + "@typescript-eslint": typescriptEslint, |
| 31 | + import: fixupPluginRules(_import), |
| 32 | + unicorn, |
| 33 | + i18next: i18Next, |
| 34 | + "sort-keys-fix": sortKeysFix, |
| 35 | + }, |
| 36 | + |
| 37 | + languageOptions: { |
| 38 | + globals: { |
| 39 | + ...globals.browser, |
| 40 | + ...globals.node, |
| 41 | + }, |
| 42 | + |
| 43 | + parser: tsParser, |
| 44 | + ecmaVersion: 5, |
| 45 | + sourceType: "module", |
| 46 | + |
| 47 | + parserOptions: { |
| 48 | + project: "tsconfig.json", |
| 49 | + }, |
| 50 | + }, |
| 51 | +}, ...compat.extends("plugin:@typescript-eslint/recommended").map(config => ({ |
| 52 | + ...config, |
| 53 | + files: ["**/**.ts"], |
| 54 | +})), { |
| 55 | + files: ["**/**.ts"], |
| 56 | + |
| 57 | + rules: { |
| 58 | + "@typescript-eslint/array-type": ["error", { |
| 59 | + default: "array-simple", |
| 60 | + }], |
| 61 | + |
| 62 | + "@typescript-eslint/consistent-indexed-object-style": "error", |
| 63 | + "@typescript-eslint/consistent-type-definitions": ["error", "type"], |
| 64 | + "@typescript-eslint/consistent-type-exports": "error", |
| 65 | + "@typescript-eslint/consistent-type-imports": "error", |
| 66 | + |
| 67 | + "@typescript-eslint/member-ordering": ["error", { |
| 68 | + default: [ |
| 69 | + "signature", |
| 70 | + "field", |
| 71 | + "static-initialization", |
| 72 | + "constructor", |
| 73 | + ["get", "set"], |
| 74 | + "method", |
| 75 | + ], |
| 76 | + }], |
| 77 | + |
| 78 | + "@typescript-eslint/method-signature-style": "error", |
| 79 | + |
| 80 | + "@typescript-eslint/naming-convention": ["warn", { |
| 81 | + format: ["camelCase", "UPPER_CASE", "PascalCase"], |
| 82 | + selector: "variable", |
| 83 | + }], |
| 84 | + |
| 85 | + "@typescript-eslint/no-confusing-non-null-assertion": "error", |
| 86 | + "@typescript-eslint/no-confusing-void-expression": "off", |
| 87 | + "@typescript-eslint/no-dupe-class-members": "error", |
| 88 | + "@typescript-eslint/no-duplicate-enum-values": "error", |
| 89 | + "@typescript-eslint/no-empty-interface": "error", |
| 90 | + "@typescript-eslint/no-explicit-any": "warn", |
| 91 | + "@typescript-eslint/no-extra-non-null-assertion": "error", |
| 92 | + "@typescript-eslint/no-extra-parens": "off", |
| 93 | + "@typescript-eslint/no-extraneous-class": "warn", |
| 94 | + "@typescript-eslint/no-inferrable-types": "error", |
| 95 | + "@typescript-eslint/prefer-namespace-keyword": "error", |
| 96 | + "@typescript-eslint/sort-type-constituents": "error", |
| 97 | + camelcase: "error", |
| 98 | + eqeqeq: ["error", "smart"], |
| 99 | + |
| 100 | + "id-blacklist": [ |
| 101 | + "error", |
| 102 | + "any", |
| 103 | + "Number", |
| 104 | + "number", |
| 105 | + "String", |
| 106 | + "string", |
| 107 | + "Boolean", |
| 108 | + "boolean", |
| 109 | + "Undefined", |
| 110 | + ], |
| 111 | + |
| 112 | + "id-match": "error", |
| 113 | + "import/exports-last": "error", |
| 114 | + "import/first": "error", |
| 115 | + "import/named": "error", |
| 116 | + "import/newline-after-import": "error", |
| 117 | + "import/no-cycle": "error", |
| 118 | + "import/no-default-export": "error", |
| 119 | + "import/no-duplicates": "error", |
| 120 | + "import/no-internal-modules": "off", |
| 121 | + "import/no-namespace": "error", |
| 122 | + "import/order": ["error", { |
| 123 | + groups: [ |
| 124 | + ["builtin", "external"], |
| 125 | + "internal", |
| 126 | + ["parent", "sibling", "index"], |
| 127 | + ["type"], |
| 128 | + ], |
| 129 | + |
| 130 | + "newlines-between": "always", |
| 131 | + }], |
| 132 | + |
| 133 | + "no-eval": "error", |
| 134 | + "no-trailing-spaces": "error", |
| 135 | + "no-underscore-dangle": "off", |
| 136 | + "no-unsafe-finally": "error", |
| 137 | + "no-var": "error", |
| 138 | + "prefer-const": "error", |
| 139 | + "sort-keys": "error", |
| 140 | + "sort-keys-fix/sort-keys-fix": "error", |
| 141 | + "spaced-comment": "error", |
| 142 | + |
| 143 | + "unicorn/filename-case": ["error", { |
| 144 | + cases: { |
| 145 | + camelCase: true, |
| 146 | + pascalCase: true, |
| 147 | + }, |
| 148 | + }], |
| 149 | + |
| 150 | + "unicorn/no-array-reduce": "off", |
| 151 | + "unicorn/no-null": "off", |
| 152 | + "unicorn/prefer-code-point": "off", |
| 153 | + "unicorn/prefer-module": "off", |
| 154 | + "unicorn/prefer-ternary": ["off", "only-single-line"], |
| 155 | + "unicorn/import-style": "off", |
| 156 | + |
| 157 | + "unicorn/prevent-abbreviations": ["error", { |
| 158 | + replacements: { |
| 159 | + env: false, |
| 160 | + i: false, |
| 161 | + j: false, |
| 162 | + }, |
| 163 | + }], |
| 164 | + }, |
| 165 | +}, ...compat.extends("plugin:jsonc/recommended-with-json").map(config => ({ |
| 166 | + ...config, |
| 167 | + files: ["**/*.json"], |
| 168 | +})), { |
| 169 | + files: ["**/*.json"], |
| 170 | + |
| 171 | + plugins: { |
| 172 | + jsonc, |
| 173 | + }, |
| 174 | + |
| 175 | + languageOptions: { |
| 176 | + parser: parser, |
| 177 | + }, |
| 178 | + |
| 179 | + ignores: [ |
| 180 | + "build/**", |
| 181 | + "**/*.d.ts", |
| 182 | + "package.json", |
| 183 | + "launch.json", |
| 184 | + "tsconfig.json" |
| 185 | + ], |
| 186 | + |
| 187 | + rules: { |
| 188 | + "jsonc/key-name-casing": "off", |
| 189 | + "jsonc/no-comments": "off", |
| 190 | + "jsonc/sort-keys": "error", |
| 191 | + }, |
| 192 | +}]; |
0 commit comments