Skip to content

Commit

Permalink
fix: upgraded @typescript-eslint* to v7
Browse files Browse the repository at this point in the history
relax a bit some new rules that we cannot apply easily
  • Loading branch information
Benjamin SÉGAULT authored and bsegault committed Jan 6, 2025
1 parent b4716b0 commit 79275bc
Show file tree
Hide file tree
Showing 4 changed files with 482 additions and 7,644 deletions.
39 changes: 36 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ module.exports = {
extends: [
// Base recommended set of rules
"eslint:recommended",
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs
// recommended extends @typescript-eslint/eslint-recommended which disables some of eslint:recommended
"plugin:@typescript-eslint/recommended",

// https://typescript-eslint.io/linting/configs/#recommended-configurations
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic",

// Additional recommended react rules
"plugin:react/recommended",
// Additional recommended react-hooks rules
Expand Down Expand Up @@ -203,6 +205,25 @@ module.exports = {
],
},
],

// Relax some @typescript-eslint/recommended-type-checked rules
// Sometimes we use any type implictely, because we don't have the type at all
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unsafe-member-access": "off",

// Allow to serialize caught variables like `${err}` (because err would have unknown type by default)
"@typescript-eslint/restrict-template-expressions": "off",

// Relax some @typescript-eslint/stylistic rules
// Allow to use indexed objects
"@typescript-eslint/consistent-indexed-object-style": "off",
// Allow to use interfaces and types
"@typescript-eslint/consistent-type-definitions": "off",
// Allow to use T[] and Array<T>
"@typescript-eslint/array-type": "off",
},
overrides: [
// Typescript overrides
Expand All @@ -219,6 +240,18 @@ module.exports = {
// Allow assertion operator in unit tests because TS does not recognize
// jest expects such as toBeDefined() or not.toBeNull() as type-validating
"@typescript-eslint/no-non-null-assertion": "off",
// Lots of tests can have async test callback, for consistency and easy update
// Allow to have them without await in the callback body, because side effect in tests are minimal
"@typescript-eslint/require-await": "off",
},
},
// TSOA/Nest Overrides
{
files: ["**/controllers/**"],
rules: {
// Some annotations helpers must be used but explicitly return any
// Disable them for those cases
"@typescript-eslint/no-unsafe-return": "off",
},
},
// Storybook overrides
Expand Down
106 changes: 101 additions & 5 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@
"@typescript-eslint/adjacent-overload-signatures": [
"error"
],
"@typescript-eslint/array-type": [
"off"
],
"@typescript-eslint/await-thenable": [
"error"
],
"@typescript-eslint/ban-ts-comment": [
"error"
],
"@typescript-eslint/ban-tslint-comment": [
"error"
],
"@typescript-eslint/ban-types": [
"warn"
],
Expand All @@ -58,12 +67,27 @@
"@typescript-eslint/brace-style": [
"off"
],
"@typescript-eslint/class-literal-property-style": [
"error"
],
"@typescript-eslint/comma-dangle": [
"off"
],
"@typescript-eslint/comma-spacing": [
"off"
],
"@typescript-eslint/consistent-generic-constructors": [
"error"
],
"@typescript-eslint/consistent-indexed-object-style": [
"off"
],
"@typescript-eslint/consistent-type-assertions": [
"error"
],
"@typescript-eslint/consistent-type-definitions": [
"off"
],
"@typescript-eslint/explicit-module-boundary-types": [
"warn"
],
Expand All @@ -88,6 +112,18 @@
"@typescript-eslint/no-array-constructor": [
"error"
],
"@typescript-eslint/no-base-to-string": [
"error"
],
"@typescript-eslint/no-confusing-non-null-assertion": [
"error"
],
"@typescript-eslint/no-duplicate-enum-values": [
"error"
],
"@typescript-eslint/no-duplicate-type-constituents": [
"error"
],
"@typescript-eslint/no-empty-function": [
"error"
],
Expand All @@ -106,6 +142,15 @@
"@typescript-eslint/no-extra-semi": [
"off"
],
"@typescript-eslint/no-floating-promises": [
"error"
],
"@typescript-eslint/no-for-in-array": [
"error"
],
"@typescript-eslint/no-implied-eval": [
"error"
],
"@typescript-eslint/no-inferrable-types": [
"error"
],
Expand All @@ -115,21 +160,48 @@
"@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": [
"warn"
"@typescript-eslint/no-redundant-type-constituents": [
"error"
],
"@typescript-eslint/no-this-alias": [
"error"
],
"@typescript-eslint/no-unnecessary-type-assertion": [
"error"
],
"@typescript-eslint/no-unnecessary-type-constraint": [
"error"
],
"@typescript-eslint/no-unsafe-argument": [
"off"
],
"@typescript-eslint/no-unsafe-assignment": [
"off"
],
"@typescript-eslint/no-unsafe-call": [
"off"
],
"@typescript-eslint/no-unsafe-declaration-merging": [
"error"
],
"@typescript-eslint/no-unsafe-enum-comparison": [
"off"
],
"@typescript-eslint/no-unsafe-member-access": [
"off"
],
"@typescript-eslint/no-unsafe-return": [
"error"
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
Expand All @@ -146,12 +218,27 @@
"@typescript-eslint/prefer-as-const": [
"error"
],
"@typescript-eslint/prefer-for-of": [
"error"
],
"@typescript-eslint/prefer-function-type": [
"error"
],
"@typescript-eslint/prefer-namespace-keyword": [
"error"
],
"@typescript-eslint/quotes": [
0
],
"@typescript-eslint/require-await": [
"error"
],
"@typescript-eslint/restrict-plus-operands": [
"error"
],
"@typescript-eslint/restrict-template-expressions": [
"off"
],
"@typescript-eslint/semi": [
"off"
],
Expand All @@ -170,6 +257,9 @@
"@typescript-eslint/type-annotation-spacing": [
"off"
],
"@typescript-eslint/unbound-method": [
"error"
],
"array-bracket-newline": [
"off"
],
Expand Down Expand Up @@ -436,6 +526,9 @@
"no-global-assign": [
"error"
],
"no-implied-eval": [
"off"
],
"no-import-assign": [
"error"
],
Expand Down Expand Up @@ -791,6 +884,9 @@
"react/require-render-return": [
2
],
"require-await": [
"off"
],
"require-yield": [
"error"
],
Expand Down Expand Up @@ -971,9 +1067,6 @@
"template-tag-spacing": [
"off"
],
"unicode-bom": [
"off"
],
"unicorn/empty-brace-spaces": [
"off"
],
Expand All @@ -983,6 +1076,9 @@
"unicorn/number-literal-case": [
"off"
],
"unicorn/template-indent": [
0
],
"use-isnan": [
"error"
],
Expand Down
Loading

0 comments on commit 79275bc

Please sign in to comment.