ESLint: enforce prefer-const where possible

https://eslint.org/docs/latest/rules/prefer-const

In our tests we use this pattern a lot:
```
let something;

beforeEach(() => {
  something = ...;
});
```

This is not valid ~ prefer-const, but can be "let through" with some configuration.
However, this would make the rule too loose for the non-test codebase.

Therefore, we enable it overall but turn it off for tests only -- the `*.spec.ts` overrides apply to test files only and take precedence over `*.ts`
This commit is contained in:
Yury Bondarenko
2023-05-08 15:53:05 +02:00
parent 884aa07430
commit 702246be38

View File

@@ -104,7 +104,7 @@
"allowTernary": true
}
],
"prefer-const": "off", // todo: re-enable & fix errors (more strict than it used to be in TSLint)
"prefer-const": "error",
"prefer-spread": "off",
"no-underscore-dangle": "off",
@@ -213,6 +213,21 @@
]
}
},
{
"files": [
"*.spec.ts"
],
"parserOptions": {
"project": [
"./tsconfig.json",
"./cypress/tsconfig.json"
],
"createDefaultProgram": true
},
"rules": {
"prefer-const": "off"
}
},
{
"files": [
"*.html"