Skip to content

Commit

Permalink
fix(rules): relax a bit some rules that we cannot apply easily
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin SÉGAULT authored and Benjamin SÉGAULT committed Mar 28, 2024
1 parent ecd38af commit 32a1f94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ module.exports = {
"@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",
Expand All @@ -237,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
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
"@typescript-eslint/no-unsafe-member-access": [
"off"
],
"@typescript-eslint/restrict-template-expressions": [
"off"
],
"@typescript-eslint/consistent-indexed-object-style": [
"off"
],
Expand Down Expand Up @@ -1024,9 +1027,6 @@
"@typescript-eslint/restrict-plus-operands": [
"error"
],
"@typescript-eslint/restrict-template-expressions": [
"error"
],
"@typescript-eslint/triple-slash-reference": [
"error"
],
Expand Down
1 change: 0 additions & 1 deletion sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ console.log(fs.readSync);

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const getDummy = (param: unknown) => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
console.log(`${dummy} and ${param} a, ${first}, ${pkg.version}`);
};

0 comments on commit 32a1f94

Please sign in to comment.