|
| 1 | +// @ts-check |
| 2 | +import { defineConfig } from "eslint/config" |
| 3 | +import { fixupConfigRules, fixupPluginRules } from "@eslint/compat" |
| 4 | +import typescriptEslint from "@typescript-eslint/eslint-plugin" |
| 5 | +import _import from "eslint-plugin-import" |
| 6 | +import globals from "globals" |
| 7 | +import tsParser from "@typescript-eslint/parser" |
| 8 | +import path from "node:path" |
| 9 | +import js from "@eslint/js" |
| 10 | +import { FlatCompat } from "@eslint/eslintrc" |
| 11 | + |
| 12 | +const __dirname = path.dirname(import.meta.filename) |
| 13 | +const compat = new FlatCompat({ |
| 14 | + baseDirectory: __dirname, |
| 15 | + recommendedConfig: js.configs.recommended, |
| 16 | + allConfig: js.configs.all, |
| 17 | +}) |
| 18 | + |
| 19 | +export default defineConfig([ |
| 20 | + { |
| 21 | + extends: fixupConfigRules( |
| 22 | + compat.extends( |
| 23 | + "eslint:recommended", |
| 24 | + "plugin:@typescript-eslint/recommended", |
| 25 | + "plugin:react/recommended", |
| 26 | + "plugin:import/errors", |
| 27 | + "plugin:import/typescript", |
| 28 | + "plugin:react-hooks/recommended", |
| 29 | + "prettier" |
| 30 | + ) |
| 31 | + ), |
| 32 | + |
| 33 | + plugins: { |
| 34 | + "@typescript-eslint": fixupPluginRules(typescriptEslint), |
| 35 | + import: fixupPluginRules(_import), |
| 36 | + }, |
| 37 | + |
| 38 | + languageOptions: { |
| 39 | + globals: { |
| 40 | + ...globals.node, |
| 41 | + ...globals.browser, |
| 42 | + }, |
| 43 | + |
| 44 | + parser: tsParser, |
| 45 | + }, |
| 46 | + |
| 47 | + settings: { |
| 48 | + react: { |
| 49 | + version: "detect", |
| 50 | + }, |
| 51 | + |
| 52 | + "import/parsers": { |
| 53 | + "@typescript-eslint/parser": [".ts", ".tsx"], |
| 54 | + }, |
| 55 | + |
| 56 | + "import/resolver": { |
| 57 | + typescript: { |
| 58 | + alwaysTryTypes: true, |
| 59 | + }, |
| 60 | + }, |
| 61 | + }, |
| 62 | + |
| 63 | + rules: { |
| 64 | + "@typescript-eslint/ban-ts-comment": "off", |
| 65 | + |
| 66 | + "@typescript-eslint/consistent-type-imports": [ |
| 67 | + "error", |
| 68 | + { |
| 69 | + disallowTypeAnnotations: false, |
| 70 | + }, |
| 71 | + ], |
| 72 | + |
| 73 | + "@typescript-eslint/ban-types": [ |
| 74 | + "error", |
| 75 | + { |
| 76 | + extendDefaults: false, |
| 77 | + |
| 78 | + types: { |
| 79 | + String: { |
| 80 | + message: "Use string instead", |
| 81 | + fixWith: "string", |
| 82 | + }, |
| 83 | + |
| 84 | + Number: { |
| 85 | + message: "Use number instead", |
| 86 | + fixWith: "number", |
| 87 | + }, |
| 88 | + |
| 89 | + Boolean: { |
| 90 | + message: "Use boolean instead", |
| 91 | + fixWith: "boolean", |
| 92 | + }, |
| 93 | + |
| 94 | + Symbol: { |
| 95 | + message: "Use symbol instead", |
| 96 | + fixWith: "symbol", |
| 97 | + }, |
| 98 | + }, |
| 99 | + }, |
| 100 | + ], |
| 101 | + |
| 102 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 103 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 104 | + "@typescript-eslint/no-empty-function": "off", |
| 105 | + "@typescript-eslint/no-explicit-any": "off", |
| 106 | + "@typescript-eslint/no-namespace": "off", |
| 107 | + "@typescript-eslint/no-non-null-assertion": "off", |
| 108 | + "@typescript-eslint/no-use-before-define": "off", |
| 109 | + "@typescript-eslint/no-var-requires": "off", |
| 110 | + "@typescript-eslint/no-unused-vars": "off", |
| 111 | + "@typescript-eslint/triple-slash-reference": "off", |
| 112 | + "@typescript-eslint/no-empty-interface": "off", |
| 113 | + "arrow-body-style": ["error", "as-needed"], |
| 114 | + "class-methods-use-this": "off", |
| 115 | + |
| 116 | + complexity: [ |
| 117 | + "warn", |
| 118 | + { |
| 119 | + max: 100, |
| 120 | + }, |
| 121 | + ], |
| 122 | + |
| 123 | + curly: ["error", "multi-line", "consistent"], |
| 124 | + eqeqeq: ["error", "smart"], |
| 125 | + "no-async-promise-executor": "off", |
| 126 | + "no-case-declarations": "off", |
| 127 | + |
| 128 | + "no-constant-condition": [ |
| 129 | + "error", |
| 130 | + { |
| 131 | + checkLoops: false, |
| 132 | + }, |
| 133 | + ], |
| 134 | + |
| 135 | + "no-debugger": "off", |
| 136 | + |
| 137 | + "no-empty": [ |
| 138 | + "error", |
| 139 | + { |
| 140 | + allowEmptyCatch: true, |
| 141 | + }, |
| 142 | + ], |
| 143 | + |
| 144 | + "no-inner-declarations": "off", |
| 145 | + "no-lonely-if": "error", |
| 146 | + "no-template-curly-in-string": "error", |
| 147 | + "no-var": "error", |
| 148 | + "import/export": "off", |
| 149 | + |
| 150 | + "import/order": [ |
| 151 | + "error", |
| 152 | + { |
| 153 | + groups: ["builtin", "external"], |
| 154 | + }, |
| 155 | + ], |
| 156 | + |
| 157 | + "object-shorthand": [ |
| 158 | + "error", |
| 159 | + "always", |
| 160 | + { |
| 161 | + ignoreConstructors: true, |
| 162 | + }, |
| 163 | + ], |
| 164 | + |
| 165 | + "one-var": [ |
| 166 | + "error", |
| 167 | + { |
| 168 | + var: "never", |
| 169 | + let: "never", |
| 170 | + }, |
| 171 | + ], |
| 172 | + |
| 173 | + "prefer-arrow-callback": "error", |
| 174 | + |
| 175 | + "prefer-const": [ |
| 176 | + "error", |
| 177 | + { |
| 178 | + destructuring: "all", |
| 179 | + }, |
| 180 | + ], |
| 181 | + |
| 182 | + "prefer-destructuring": "warn", |
| 183 | + "prefer-object-spread": "error", |
| 184 | + "prefer-rest-params": "warn", |
| 185 | + "prefer-spread": "warn", |
| 186 | + "quote-props": ["error", "as-needed"], |
| 187 | + "react/display-name": "off", |
| 188 | + "react/no-children-prop": "off", |
| 189 | + "react/prop-types": "off", |
| 190 | + "react/react-in-jsx-scope": "off", |
| 191 | + |
| 192 | + "spaced-comment": [ |
| 193 | + "error", |
| 194 | + "always", |
| 195 | + { |
| 196 | + markers: ["/"], |
| 197 | + }, |
| 198 | + ], |
| 199 | + |
| 200 | + "sort-imports": [ |
| 201 | + "warn", |
| 202 | + { |
| 203 | + ignoreDeclarationSort: true, |
| 204 | + }, |
| 205 | + ], |
| 206 | + |
| 207 | + yoda: [ |
| 208 | + "error", |
| 209 | + "never", |
| 210 | + { |
| 211 | + exceptRange: true, |
| 212 | + }, |
| 213 | + ], |
| 214 | + }, |
| 215 | + }, |
| 216 | +]) |
0 commit comments