Skip to content

Commit 510f1b5

Browse files
committed
Add rules from @typescript-eslint/stylistic-type-checked
closes #4
1 parent 47cfc78 commit 510f1b5

File tree

10 files changed

+82
-33
lines changed

10 files changed

+82
-33
lines changed

docs/angular-ngrx.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ Config for **Angular** projects using **NgRx** library.
4747
}
4848
```
4949

50-
## 📏 Rules (372)
50+
## 📏 Rules (382)
5151

52-
**342** rules are included from [`@code-pushup/eslint-config/angular`](./angular.md#📏-rules-342). For brevity, only the **30** additional rules are listed in this document.
52+
**352** rules are included from [`@code-pushup/eslint-config/angular`](./angular.md#📏-rules-352). For brevity, only the **30** additional rules are listed in this document.
5353

5454
> 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>🧪🚫 Disabled for [test files](../README.md#🧪-test-overrides).<br>🧪⚠️ Severity lessened to warning for [test files](../README.md#🧪-test-overrides).
5555

docs/angular.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ Config for **Angular** projects.
4747
}
4848
```
4949

50-
## 📏 Rules (372)
50+
## 📏 Rules (382)
5151

52-
**297** rules are included from [`@code-pushup/eslint-config/typescript`](./typescript.md#📏-rules-297). For brevity, only the **75** additional rules are listed in this document.
52+
**307** rules are included from [`@code-pushup/eslint-config/typescript`](./typescript.md#📏-rules-307). For brevity, only the **75** additional rules are listed in this document.
5353

5454
> 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>🧪🚫 Disabled for [test files](../README.md#🧪-test-overrides).<br>🧪⚠️ Severity lessened to warning for [test files](../README.md#🧪-test-overrides).
5555

docs/graphql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Config for **GraphQL servers** implemented in Node.js.
3333
}
3434
```
3535

36-
## 📏 Rules (294)
36+
## 📏 Rules (301)
3737

38-
**267** rules are included from [`@code-pushup/eslint-config/node`](./node.md#📏-rules-267). For brevity, only the **27** additional rules are listed in this document.
38+
**274** rules are included from [`@code-pushup/eslint-config/node`](./node.md#📏-rules-274). For brevity, only the **27** additional rules are listed in this document.
3939

4040
> 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>🧪🚫 Disabled for [test files](../README.md#🧪-test-overrides).<br>🧪⚠️ Severity lessened to warning for [test files](../README.md#🧪-test-overrides).
4141

docs/index.md

Lines changed: 9 additions & 2 deletions
Large diffs are not rendered by default.

docs/node.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Config for **Node.js** projects.
1919
}
2020
```
2121

22-
## 📏 Rules (255)
22+
## 📏 Rules (262)
2323

24-
**251** rules are included from [the default config](./index.md#📏-rules-251). For brevity, only the **4** additional rules are listed in this document.
24+
**258** rules are included from [the default config](./index.md#📏-rules-258). For brevity, only the **4** additional rules are listed in this document.
2525

2626
> 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>🧪🚫 Disabled for [test files](../README.md#🧪-test-overrides).<br>🧪⚠️ Severity lessened to warning for [test files](../README.md#🧪-test-overrides).
2727

docs/typescript.md

Lines changed: 24 additions & 20 deletions
Large diffs are not rendered by default.

index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,32 @@ module.exports = {
109109
yoda: 'warn',
110110

111111
// https://typescript-eslint.io/rules/
112-
'@typescript-eslint/default-param-last': 'warn',
112+
'@typescript-eslint/array-type': 'warn',
113+
'@typescript-eslint/adjacent-overload-signatures': 'warn',
114+
'@typescript-eslint/ban-tslint-comment': 'warn',
113115
// TODO - remove condition after updating to "@typescript-eslint/eslint-plugin": "^7.0.0" in peerDependencies
114116
// add new "class-methods-use-this" rule (added in @typescript-eslint/[email protected])
115117
...(typescriptEslint.rules['class-methods-use-this']
116118
? {
117119
'@typescript-eslint/class-methods-use-this': 'warn',
118120
}
119121
: {}),
122+
'@typescript-eslint/consistent-generic-constructors': 'warn',
123+
'@typescript-eslint/default-param-last': 'warn',
120124
'@typescript-eslint/max-params': ['warn', { max: 4 }],
121125
'@typescript-eslint/method-signature-style': 'warn',
126+
'@typescript-eslint/no-confusing-non-null-assertion': 'warn',
127+
'@typescript-eslint/no-empty-function': [
128+
'warn',
129+
{
130+
allow: [
131+
'private-constructors',
132+
'protected-constructors',
133+
'decoratedFunctions',
134+
'overrideMethods',
135+
],
136+
},
137+
],
122138
'@typescript-eslint/no-import-type-side-effects': 'warn',
123139
'@typescript-eslint/no-magic-numbers': [
124140
'warn',
@@ -134,6 +150,7 @@ module.exports = {
134150
detectObjects: true,
135151
},
136152
],
153+
'@typescript-eslint/prefer-function-type': 'warn',
137154
'@typescript-eslint/no-require-imports': 'error',
138155
'@typescript-eslint/no-shadow': 'warn',
139156
'@typescript-eslint/no-unused-expressions': 'warn',
@@ -169,6 +186,7 @@ module.exports = {
169186
curly: 'off',
170187
'@typescript-eslint/no-non-null-assertion': 'off',
171188
'@typescript-eslint/no-explicit-any': 'off',
189+
'@typescript-eslint/no-empty-function': 'off',
172190
'sonarjs/no-duplicate-string': 'off',
173191
'unicorn/consistent-function-scoping': 'off',
174192
'functional/no-let': 'off',
@@ -197,6 +215,7 @@ module.exports = {
197215
rules: {
198216
// DISABLED RULES FOR GENERATED FILES
199217

218+
'@typescript-eslint/ban-tslint-comment': 'off',
200219
'unicorn/no-abusive-eslint-disable': 'off',
201220
},
202221
},

tests/configs/typescript.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ describe('typescript config', () => {
4646
.sort();
4747
expect(rulesWithoutTypes).toEqual([
4848
'@typescript-eslint/consistent-type-assertions',
49-
'@typescript-eslint/no-explicit-any',
5049
]);
5150
});
5251

tests/helpers/lint-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function setupLintUtils(config, defaultFilePath = '*.ts') {
3838
* @returns {string[]}
3939
*/
4040
const getExplicitRuleIds = config => [
41-
...Object.keys(config.rules ?? {}),
41+
...Object.keys(config.rules ?? {}).filter(id => config.rules[id] !== 'off'),
4242
...(config.overrides?.flatMap(getExplicitRuleIds) ?? []),
4343
];
4444

typescript.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module.exports = {
6161

6262
'@typescript-eslint/unbound-method': 'off',
6363
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
64+
'unicorn/prefer-string-starts-ends-with': 'off', // superseded by @typescript-eslint/prefer-string-starts-ends-with
6465

6566
// ADDITIONAL RULES
6667

@@ -72,6 +73,10 @@ module.exports = {
7273
objectLiteralTypeAssertions: 'never',
7374
},
7475
],
76+
'@typescript-eslint/dot-notation': [
77+
'warn',
78+
{ allowIndexSignaturePropertyAccess: true },
79+
],
7580
'@typescript-eslint/naming-convention': [
7681
'warn',
7782
...NAMING_CONVENTION_OPTIONS,
@@ -83,6 +88,13 @@ module.exports = {
8388
'@typescript-eslint/no-unsafe-unary-minus': 'error',
8489
}
8590
: {}),
91+
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
92+
'@typescript-eslint/prefer-nullish-coalescing': [
93+
'warn',
94+
{ ignorePrimitives: { string: true, boolean: true } },
95+
],
96+
'@typescript-eslint/prefer-optional-chain': 'warn',
97+
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
8698

8799
// https://github.com/eslint-functional/eslint-plugin-functional#rules
88100
'functional/immutable-data': [
@@ -116,6 +128,14 @@ module.exports = {
116128
objectLiteralTypeAssertions: 'allow',
117129
},
118130
],
131+
'@typescript-eslint/dot-notation': [
132+
'warn',
133+
{
134+
allowPrivateClassPropertyAccess: true,
135+
allowProtectedClassPropertyAccess: true,
136+
allowIndexSignaturePropertyAccess: true,
137+
},
138+
],
119139
'@typescript-eslint/require-await': 'warn',
120140
'functional/immutable-data': [
121141
'warn',

0 commit comments

Comments
 (0)