|
| 1 | +module.exports = { |
| 2 | + env: { |
| 3 | + es2022: true, |
| 4 | + jest: true, |
| 5 | + node: true, |
| 6 | + }, |
| 7 | + parser: "@typescript-eslint/parser", |
| 8 | + parserOptions: { |
| 9 | + ecmaVersion: "latest", |
| 10 | + sourceType: "module", |
| 11 | + project: "./tsconfig.json", |
| 12 | + }, |
| 13 | + settings: { |
| 14 | + "import/resolver": { |
| 15 | + node: { extensions: [".js", ".jsx", ".ts", ".tsx"] }, |
| 16 | + typescript: {}, |
| 17 | + }, |
| 18 | + "import/extensions": [".js", ".mjs", ".jsx", ".ts", ".tsx"], |
| 19 | + jest: { |
| 20 | + version: 29, |
| 21 | + }, |
| 22 | + }, |
| 23 | + extends: [ |
| 24 | + "airbnb-base", |
| 25 | + "plugin:import/typescript", |
| 26 | + "plugin:jest/recommended", |
| 27 | + "plugin:jest/style", |
| 28 | + "plugin:jest-formatting/recommended", |
| 29 | + "plugin:@typescript-eslint/recommended", |
| 30 | + "plugin:@typescript-eslint/recommended-requiring-type-checking", |
| 31 | + "plugin:import/typescript", |
| 32 | + "plugin:prettier/recommended", |
| 33 | + "prettier", |
| 34 | + ], |
| 35 | + plugins: [ |
| 36 | + "import-helpers", |
| 37 | + "simple-import-sort", |
| 38 | + "jest", |
| 39 | + "jest-formatting", |
| 40 | + "@typescript-eslint", |
| 41 | + "prettier", |
| 42 | + ], |
| 43 | + rules: { |
| 44 | + "prettier/prettier": [ |
| 45 | + "error", |
| 46 | + { |
| 47 | + printWidth: 80, |
| 48 | + tabWidth: 2, |
| 49 | + singleQuote: true, |
| 50 | + trailingComma: "all", |
| 51 | + arrowParens: "always", |
| 52 | + }, |
| 53 | + { usePrettierrc: false }, |
| 54 | + ], |
| 55 | + |
| 56 | + // base |
| 57 | + "arrow-body-style": ["error", "as-needed"], |
| 58 | + camelcase: "off", |
| 59 | + "class-methods-use-this": "off", |
| 60 | + "implicit-arrow-linebreak": "off", |
| 61 | + "no-await-in-loop": "off", |
| 62 | + "no-console": ["warn", { allow: ["warn", "error"] }], |
| 63 | + "no-plusplus": ["error", { allowForLoopAfterthoughts: true }], |
| 64 | + "no-param-reassign": [ |
| 65 | + "error", |
| 66 | + { |
| 67 | + props: true, |
| 68 | + ignorePropertyModificationsForRegex: [ |
| 69 | + "^draft", |
| 70 | + "(result|map|set|obj|record|sum|group)", |
| 71 | + "^acc", |
| 72 | + ".*(Map|Set)$", |
| 73 | + ], |
| 74 | + }, |
| 75 | + ], |
| 76 | + "no-shadow": "off", |
| 77 | + "no-return-await": "off", |
| 78 | + "no-underscore-dangle": "off", |
| 79 | + "no-unneeded-ternary": "error", |
| 80 | + "no-unused-expressions": "off", |
| 81 | + "no-unused-vars": "off", |
| 82 | + "no-use-before-define": "off", |
| 83 | + "no-useless-concat": "error", |
| 84 | + "no-useless-constructor": "off", |
| 85 | + "no-void": "off", |
| 86 | + "prefer-template": "error", |
| 87 | + "padding-line-between-statements": [ |
| 88 | + "warn", |
| 89 | + // Note: When defining new entries for this rule keep the related lines |
| 90 | + // together and separate them from other lines using blank lines. |
| 91 | + |
| 92 | + // Require a blank line after groups of imports. |
| 93 | + { blankLine: "always", prev: "import", next: "*" }, |
| 94 | + { blankLine: "any", prev: "import", next: ["import"] }, |
| 95 | + |
| 96 | + // Require a blank line after block-like statements. |
| 97 | + { blankLine: "always", prev: "block-like", next: "*" }, |
| 98 | + // Ignore rule for blocks within `switch` statements. |
| 99 | + { blankLine: "any", prev: "block-like", next: ["case", "default"] }, |
| 100 | + ], |
| 101 | + |
| 102 | + //imports |
| 103 | + "simple-import-sort/imports": "error", |
| 104 | + "simple-import-sort/exports": "error", |
| 105 | + "import/prefer-default-export": "off", |
| 106 | + "import/no-duplicates": ["error", { considerQueryString: true }], |
| 107 | + "import/no-named-as-default": "off", |
| 108 | + "import/no-useless-path-segments": ["error", { noUselessIndex: true }], |
| 109 | + "import/no-extraneous-dependencies": [ |
| 110 | + "error", |
| 111 | + { |
| 112 | + devDependencies: [ |
| 113 | + "**/test/**", // tape, common npm pattern |
| 114 | + "**/tests/**", // also common npm pattern |
| 115 | + "**/__tests__/**", // jest pattern |
| 116 | + "**/__mocks__/**", // jest pattern |
| 117 | + "test.{js,jsx,ts,tsx}", // repos with a single test file |
| 118 | + "test-*.{js,jsx,ts,tsx}", // repos with multiple top-level test files |
| 119 | + "**/*{.,_}{test,spec,e2e-spec}.{js,jsx,ts,tsx}", // tests where the extension or filename suffix denotes that it is a test |
| 120 | + "**/*.config.{js,ts}", // config files |
| 121 | + "**/*.setup.{js,ts}", // setup files |
| 122 | + "**/.eslintrc.js", // eslint config |
| 123 | + ], |
| 124 | + optionalDependencies: false, |
| 125 | + }, |
| 126 | + ], |
| 127 | + "import/extensions": [ |
| 128 | + "error", |
| 129 | + "ignorePackages", |
| 130 | + { js: "never", mjs: "never", jsx: "never", ts: "never", tsx: "never" }, |
| 131 | + ], |
| 132 | + "import-helpers/order-imports": [ |
| 133 | + "warn", |
| 134 | + { |
| 135 | + newlinesBetween: "always", |
| 136 | + groups: [ |
| 137 | + [ |
| 138 | + "/^(react|express|fastify)$/", |
| 139 | + "/^react-(native|dom)$/", |
| 140 | + "/^(next|@next|@nestjs|@fastify)/", |
| 141 | + ], |
| 142 | + "module", |
| 143 | + [ |
| 144 | + "/^@(api|app|assets|common|components|constants|contexts|features|hooks|mocks|pages|routes|services|styles|types|utils|shared|store)/", |
| 145 | + ], |
| 146 | + ["parent", "sibling"], |
| 147 | + "index", |
| 148 | + ], |
| 149 | + alphabetize: { order: "ignore", ignoreCase: true }, |
| 150 | + }, |
| 151 | + ], |
| 152 | + "import/no-anonymous-default-export": [ |
| 153 | + "error", |
| 154 | + { |
| 155 | + allowArray: true, |
| 156 | + allowArrowFunction: false, |
| 157 | + allowAnonymousClass: false, |
| 158 | + allowAnonymousFunction: false, |
| 159 | + allowCallExpression: true, |
| 160 | + allowLiteral: true, |
| 161 | + allowObject: true, |
| 162 | + }, |
| 163 | + ], |
| 164 | + "no-restricted-imports": [ |
| 165 | + "error", |
| 166 | + { |
| 167 | + patterns: [ |
| 168 | + { |
| 169 | + group: ["@features/*/*"], |
| 170 | + message: |
| 171 | + "Usage of a feature internal modules is not allowed, please import from the feature public API", |
| 172 | + }, |
| 173 | + ], |
| 174 | + }, |
| 175 | + ], |
| 176 | + |
| 177 | + // jest |
| 178 | + "jest/consistent-test-it": "error", |
| 179 | + "jest/expect-expect": [ |
| 180 | + "error", |
| 181 | + { |
| 182 | + assertFunctionNames: [ |
| 183 | + "expect", |
| 184 | + "expectTypeOf", |
| 185 | + "request.**.expect", |
| 186 | + "supertest.**.expect", |
| 187 | + ], |
| 188 | + }, |
| 189 | + ], |
| 190 | + "jest/no-standalone-expect": [ |
| 191 | + "error", |
| 192 | + { additionalTestBlockFunctions: ["eachCase"] }, |
| 193 | + ], |
| 194 | + "jest/prefer-lowercase-title": [ |
| 195 | + "error", |
| 196 | + { |
| 197 | + allowedPrefixes: ["GET", "POST", "PUT", "PATCH", "DELETE"], |
| 198 | + ignoreTopLevelDescribe: true, |
| 199 | + }, |
| 200 | + ], |
| 201 | + "jest/valid-title": [ |
| 202 | + "error", |
| 203 | + { |
| 204 | + mustNotMatch: { |
| 205 | + it: [/^should/.source, 'Titles should not start with "should"'], |
| 206 | + }, |
| 207 | + }, |
| 208 | + ], |
| 209 | + "jest/no-conditional-expect": "warn", |
| 210 | + "jest-formatting/padding-around-after-all-blocks": "warn", |
| 211 | + "jest-formatting/padding-around-after-each-blocks": "warn", |
| 212 | + "jest-formatting/padding-around-before-all-blocks": "warn", |
| 213 | + "jest-formatting/padding-around-before-each-blocks": "warn", |
| 214 | + "jest-formatting/padding-around-describe-blocks": "warn", |
| 215 | + "jest-formatting/padding-around-test-blocks": "warn", |
| 216 | + |
| 217 | + // typescript |
| 218 | + "no-undef": "off", |
| 219 | + "@typescript-eslint/array-type": [ |
| 220 | + "warn", |
| 221 | + { default: "array-simple", readonly: "array-simple" }, |
| 222 | + ], |
| 223 | + "@typescript-eslint/await-thenable": "error", |
| 224 | + "@typescript-eslint/ban-types": [ |
| 225 | + "error", |
| 226 | + { |
| 227 | + extendDefaults: true, |
| 228 | + types: { "{}": false }, |
| 229 | + }, |
| 230 | + ], |
| 231 | + camelcase: "off", |
| 232 | + "@typescript-eslint/camelcase": "off", |
| 233 | + "@typescript-eslint/consistent-type-imports": [ |
| 234 | + "warn", |
| 235 | + { fixStyle: "inline-type-imports" }, |
| 236 | + ], |
| 237 | + "@typescript-eslint/consistent-generic-constructors": "warn", |
| 238 | + "@typescript-eslint/consistent-indexed-object-style": "warn", |
| 239 | + "@typescript-eslint/consistent-type-assertions": "warn", |
| 240 | + "default-param-last": "off", |
| 241 | + "@typescript-eslint/default-param-last": "warn", |
| 242 | + "dot-notation": "off", |
| 243 | + "@typescript-eslint/dot-notation": "warn", |
| 244 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 245 | + "@typescript-eslint/indent": "off", |
| 246 | + "@typescript-eslint/member-delimiter-style": "warn", |
| 247 | + "@typescript-eslint/method-signature-style": "warn", |
| 248 | + "@typescript-eslint/naming-convention": [ |
| 249 | + "error", |
| 250 | + { |
| 251 | + selector: "variable", |
| 252 | + format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"], |
| 253 | + leadingUnderscore: "allow", |
| 254 | + }, |
| 255 | + ], |
| 256 | + "@typescript-eslint/no-confusing-non-null-assertion": "warn", |
| 257 | + "@typescript-eslint/no-confusing-void-expression": "off", |
| 258 | + "no-dupe-class-members": "off", |
| 259 | + "@typescript-eslint/no-dupe-class-members": "warn", |
| 260 | + "@typescript-eslint/no-duplicate-enum-values": "warn", |
| 261 | + "@typescript-eslint/no-dynamic-delete": "warn", |
| 262 | + "@typescript-eslint/no-empty-interface": [ |
| 263 | + "error", |
| 264 | + { allowSingleExtends: true }, |
| 265 | + ], |
| 266 | + "@typescript-eslint/no-explicit-any": "off", |
| 267 | + "no-extra-parens": "off", |
| 268 | + "@typescript-eslint/no-extra-parens": "off", |
| 269 | + "@typescript-eslint/no-extraneous-class": "off", |
| 270 | + "@typescript-eslint/no-floating-promises": ["error", { ignoreVoid: true }], |
| 271 | + "@typescript-eslint/no-for-in-array": "off", |
| 272 | + "@typescript-eslint/no-inferrable-types": [ |
| 273 | + "error", |
| 274 | + { ignoreParameters: true }, |
| 275 | + ], |
| 276 | + "@typescript-eslint/no-invalid-void-type": "warn", |
| 277 | + |
| 278 | + "@typescript-eslint/no-meaningless-void-operator": "warn", |
| 279 | + "@typescript-eslint/no-misused-promises": [ |
| 280 | + "error", |
| 281 | + { checksVoidReturn: { attributes: false, properties: false } }, |
| 282 | + ], |
| 283 | + "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "warn", |
| 284 | + "@typescript-eslint/no-non-null-asserted-optional-chain": "error", |
| 285 | + "no-return-await": "off", |
| 286 | + "@typescript-eslint/return-await": "error", |
| 287 | + "no-shadow": "off", |
| 288 | + "@typescript-eslint/no-shadow": ["error", { ignoreTypeValueShadow: true }], |
| 289 | + "@typescript-eslint/unbound-method": "off", |
| 290 | + "@typescript-eslint/no-explicit-any": "off", |
| 291 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 292 | + "@typescript-eslint/no-unsafe-return": "off", |
| 293 | + "@typescript-eslint/no-unsafe-call": "off", |
| 294 | + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn", |
| 295 | + "@typescript-eslint/no-unnecessary-condition": "warn", |
| 296 | + "@typescript-eslint/no-unnecessary-type-arguments": "warn", |
| 297 | + "@typescript-eslint/no-unnecessary-type-constraint": "error", |
| 298 | + "@typescript-eslint/no-unsafe-member-access": "error", |
| 299 | + "no-unused-vars": "off", |
| 300 | + "@typescript-eslint/no-unused-vars": [ |
| 301 | + "warn", |
| 302 | + { |
| 303 | + ignoreRestSiblings: true, |
| 304 | + argsIgnorePattern: "^_", |
| 305 | + varsIgnorePattern: "^_$|[iI]gnored", |
| 306 | + }, |
| 307 | + ], |
| 308 | + "no-use-before-define": "off", |
| 309 | + "@typescript-eslint/no-use-before-define": ["error"], |
| 310 | + "no-useless-constructor": "off", |
| 311 | + "@typescript-eslint/no-useless-constructor": "error", |
| 312 | + "@typescript-eslint/non-nullable-type-assertion-style": "warn", |
| 313 | + "@typescript-eslint/prefer-for-of": "error", |
| 314 | + "@typescript-eslint/prefer-function-type": "error", |
| 315 | + "@typescript-eslint/prefer-includes": "error", |
| 316 | + "@typescript-eslint/prefer-nullish-coalescing": "error", |
| 317 | + "@typescript-eslint/prefer-optional-chain": "error", |
| 318 | + "@typescript-eslint/prefer-reduce-type-parameter": "error", |
| 319 | + "@typescript-eslint/prefer-return-this-type": "error", |
| 320 | + "@typescript-eslint/prefer-string-starts-ends-with": "error", |
| 321 | + "@typescript-eslint/prefer-ts-expect-error": "error", |
| 322 | + "@typescript-eslint/require-array-sort-compare": "error", |
| 323 | + "@typescript-eslint/restrict-plus-operands": [ |
| 324 | + "error", |
| 325 | + { checkCompoundAssignments: true }, |
| 326 | + ], |
| 327 | + "@typescript-eslint/switch-exhaustiveness-check": "warn", |
| 328 | + "@typescript-eslint/unified-signatures": "warn", |
| 329 | + }, |
| 330 | + |
| 331 | + overrides: [ |
| 332 | + { |
| 333 | + files: ["*.spec.ts", "*.e2e-spec.ts"], |
| 334 | + rules: { |
| 335 | + "@typescript-eslint/no-unsafe-argument": "off", |
| 336 | + }, |
| 337 | + }, |
| 338 | + ], |
| 339 | +}; |
0 commit comments