|
| 1 | +import eslint from "@eslint/js"; |
| 2 | +import reactPlugin from "eslint-plugin-react"; |
| 3 | +import globals from "globals"; |
| 4 | +import tseslint from "typescript-eslint"; |
| 5 | + |
| 6 | +export default tseslint.config( |
| 7 | + eslint.configs.recommended, |
| 8 | + tseslint.configs.strictTypeChecked, |
| 9 | + tseslint.configs.stylisticTypeChecked, |
| 10 | + reactPlugin.configs.flat.recommended, |
| 11 | + reactPlugin.configs.flat["jsx-runtime"], |
| 12 | + { |
| 13 | + name: "base", |
| 14 | + settings: { |
| 15 | + react: { |
| 16 | + version: "18.3", |
| 17 | + }, |
| 18 | + }, |
| 19 | + languageOptions: { |
| 20 | + ecmaVersion: 2022, |
| 21 | + globals: { |
| 22 | + ...globals.browser, |
| 23 | + ...globals.node, |
| 24 | + }, |
| 25 | + parserOptions: { |
| 26 | + projectService: true, |
| 27 | + tsconfigRootDir: import.meta.dirname, |
| 28 | + }, |
| 29 | + }, |
| 30 | + rules: { |
| 31 | + // - eslint rules |
| 32 | + // Possible Problems |
| 33 | + "array-callback-return": "error", |
| 34 | + "no-duplicate-imports": "warn", |
| 35 | + "no-self-compare": "error", |
| 36 | + "no-unmodified-loop-condition": "error", |
| 37 | + "no-unneeded-ternary": ["warn", { defaultAssignment: false }], |
| 38 | + "valid-typeof": ["error", { requireStringLiterals: true }], |
| 39 | + |
| 40 | + // Suggestions |
| 41 | + "accessor-pairs": "warn", |
| 42 | + "block-scoped-var": "error", |
| 43 | + eqeqeq: ["error", "always", { null: "ignore" }], |
| 44 | + "no-empty": ["error", { allowEmptyCatch: true }], |
| 45 | + "no-eval": "error", |
| 46 | + "no-extend-native": "error", |
| 47 | + "no-extra-bind": "warn", |
| 48 | + "no-implicit-coercion": "error", |
| 49 | + "no-label-var": "error", |
| 50 | + "no-lone-blocks": "warn", |
| 51 | + "no-lonely-if": "warn", |
| 52 | + "no-multi-assign": "error", |
| 53 | + "no-new": "warn", |
| 54 | + "no-new-func": "error", |
| 55 | + "no-new-wrappers": "error", |
| 56 | + "no-throw-literal": "error", |
| 57 | + "no-undef-init": "error", |
| 58 | + "no-useless-call": "warn", |
| 59 | + "no-useless-computed-key": "warn", |
| 60 | + "no-useless-concat": "warn", |
| 61 | + "no-useless-rename": "warn", |
| 62 | + "no-useless-return": "warn", |
| 63 | + radix: "error", |
| 64 | + "object-shorthand": "warn", |
| 65 | + "operator-assignment": "warn", |
| 66 | + "prefer-regex-literals": "warn", |
| 67 | + "prefer-rest-params": "error", |
| 68 | + "prefer-spread": "error", |
| 69 | + "prefer-template": "warn", |
| 70 | + "sort-imports": ["warn", { ignoreDeclarationSort: true }], |
| 71 | + "symbol-description": "error", |
| 72 | + yoda: ["warn", "never", { exceptRange: true }], |
| 73 | + |
| 74 | + // - typescript-eslint rules |
| 75 | + "no-unused-vars": "off", |
| 76 | + "@typescript-eslint/array-type": ["warn", { default: "array-simple" }], |
| 77 | + "@typescript-eslint/default-param-last": "error", |
| 78 | + "@typescript-eslint/dot-notation": ["warn", { allowKeywords: true }], |
| 79 | + "@typescript-eslint/explicit-function-return-type": [ |
| 80 | + "error", |
| 81 | + { |
| 82 | + allowExpressions: true, |
| 83 | + allowConciseArrowFunctionExpressionsStartingWithVoid: true, |
| 84 | + }, |
| 85 | + ], |
| 86 | + "@typescript-eslint/explicit-member-accessibility": ["warn", { accessibility: "explicit" }], |
| 87 | + "@typescript-eslint/naming-convention": [ |
| 88 | + "warn", |
| 89 | + { |
| 90 | + selector: "default", |
| 91 | + format: ["camelCase", "PascalCase", "UPPER_CASE"], |
| 92 | + leadingUnderscore: "allow", |
| 93 | + trailingUnderscore: "allow", |
| 94 | + filter: { |
| 95 | + regex: "^[a-zA-Z_$][a-zA-Z0-9_$]*$", |
| 96 | + match: true, |
| 97 | + }, |
| 98 | + }, |
| 99 | + ], |
| 100 | + "@typescript-eslint/no-array-constructor": "error", |
| 101 | + "@typescript-eslint/no-confusing-void-expression": ["warn", { ignoreArrowShorthand: true }], |
| 102 | + "@typescript-eslint/no-floating-promises": ["error", { ignoreIIFE: true }], |
| 103 | + "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }], |
| 104 | + "@typescript-eslint/no-unnecessary-condition": [ |
| 105 | + "warn", |
| 106 | + { allowConstantLoopConditions: false }, |
| 107 | + ], |
| 108 | + "@typescript-eslint/no-unused-vars": [ |
| 109 | + "error", |
| 110 | + { |
| 111 | + vars: "all", |
| 112 | + varsIgnorePattern: "^_", |
| 113 | + args: "all", |
| 114 | + argsIgnorePattern: "^_", |
| 115 | + ignoreRestSiblings: true, |
| 116 | + caughtErrors: "all", |
| 117 | + caughtErrorsIgnorePattern: "^_", |
| 118 | + }, |
| 119 | + ], |
| 120 | + "@typescript-eslint/no-use-before-define": [ |
| 121 | + "error", |
| 122 | + { |
| 123 | + functions: false, |
| 124 | + classes: false, |
| 125 | + variables: true, |
| 126 | + allowNamedExports: true, |
| 127 | + }, |
| 128 | + ], |
| 129 | + "@typescript-eslint/no-useless-constructor": "warn", |
| 130 | + "@typescript-eslint/prefer-destructuring": [ |
| 131 | + "warn", |
| 132 | + { |
| 133 | + VariableDeclarator: { array: false, object: true }, |
| 134 | + AssignmentExpression: { array: false, object: false }, |
| 135 | + }, |
| 136 | + { enforceForRenamedProperties: false }, |
| 137 | + ], |
| 138 | + |
| 139 | + "@typescript-eslint/no-invalid-void-type": "off", |
| 140 | + "@typescript-eslint/no-namespace": "off", |
| 141 | + "@typescript-eslint/no-non-null-assertion": "off", |
| 142 | + "@typescript-eslint/no-redundant-type-constituents": "off", |
| 143 | + "@typescript-eslint/no-require-imports": "off", |
| 144 | + "@typescript-eslint/no-unnecessary-type-parameters": "off", |
| 145 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 146 | + "@typescript-eslint/no-unsafe-call": "off", |
| 147 | + "@typescript-eslint/no-unsafe-member-access": "off", |
| 148 | + "@typescript-eslint/no-unsafe-return": "off", |
| 149 | + "@typescript-eslint/prefer-nullish-coalescing": "off", |
| 150 | + "@typescript-eslint/restrict-template-expressions": "off", |
| 151 | + |
| 152 | + // - eslint-plugin-react rules |
| 153 | + "react/display-name": "off", |
| 154 | + "react/prop-types": "off", |
| 155 | + }, |
| 156 | + }, |
| 157 | +); |
0 commit comments