8000 feat(eslint-plugin): add *-type-checked-only configs (#8367) · yeonjuan/typescript-eslint@13429cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 13429cc

Browse files
feat(eslint-plugin): add *-type-checked-only configs (typescript-eslint#8367)
1 parent 813ad93 commit 13429cc

File tree

8 files changed

+302
-2
lines changed

8 files changed

+302
-2
lines changed

docs/users/Shared_Configurations.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,45 @@ This config is automatically included if you use any of the recommended configur
390390

391391
See [`configs/eslint-recommended.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts) for the exact contents of this config.
392392

393+
### `recommended-type-checked-only`
394+
395+
A version of `recommended` that _only_ contains type-checked rules and disables of any corresponding core ESLint rules.
396+
This config plus `recommended` is equivalent to `recommended-type-checked`.
397+
398+
```js title=".eslintrc.js"
399+
module.exports = {
400+
extends: ['plugin:@typescript-eslint/recommended-type-checked-only'],
401+
};
402+
```
403+
404+
See [`configs/recommended-type-checked-only.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked-only.ts) for the exact contents of this config.
405+
406+
### `strict-type-checked-only`
407+
408+
A version of `strict` that _only_ contains type-checked rules and disables of any corresponding core ESLint rules.
409+
This config plus `strict` is equivalent to `strict-type-checked`.
410+
411+
```js title=".eslintrc.js"
412+
module.exports = {
413+
extends: ['plugin:@typescript-eslint/strict-type-checked-only'],
414+
};
415+
```
416+
417+
See [`configs/strict-type-checked-only.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict-type-checked-only.ts) for the exact contents of this config.
418+
419+
### `stylistic-type-checked-only`
420+
421+
A version of `stylistic` that _only_ contains type-checked rules and disables of any corresponding core ESLint rules.
422+
This config plus `stylistic` is equivalent to `stylistic-type-checked`.
423+
424+
```js title=".eslintrc.js"
425+
module.exports = {
426+
extends: ['plugin:@typescript-eslint/stylistic-type-checked-only'],
427+
};
428+
```
429+
430+
See [`configs/stylistic-type-checked-only.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic-type-checked-only.ts) for the exact contents of this config.
431+
393432
## Suggesting Configuration Changes
394433

395434
If you feel strongly that a specific rule should (or should not) be one of these configurations, please [file an issue](https://github.com/typescript-eslint/typescript-eslint/issues/new?assignees=&labels=package%3A+eslint-plugin%2Cpreset+config+change%2Ctriage&template=09-config-change.yaml&title=Configs%3A+%3Ca+short+description+of+my+proposal%3E) along with a **detailed** argument explaining your reasoning.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// SEE https://typescript-eslint.io/users/configs
4+
//
5+
// For developers working in the typescript-eslint monorepo:
6+
// You can regenerate it using `yarn generate:configs`
7+
8+
import type { ClassicConfig } from '@typescript-eslint/utils/ts-eslint';
9+
10+
export = {
11+
extends: ['./configs/base', './configs/eslint-recommended'],
12+
rules: {
13+
'@typescript-eslint/await-thenable': 'error',
14+
'@typescript-eslint/no-base-to-string': 'error',
15+
'@typescript-eslint/no-duplicate-type-constituents': 'error',
16+
'@typescript-eslint/no-floating-promises': 'error',
17+
'@typescript-eslint/no-for-in-array': 'error',
18+
'no-implied-eval': 'off',
19+
'@typescript-eslint/no-implied-eval': 'error',
20+
'@typescript-eslint/no-misused-promises': 'error',
21+
'@typescript-eslint/no-redundant-type-constituents': 'error',
22+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
23+
'@typescript-eslint/no-unsafe-argument': 'error',
24+
'@typescript-eslint/no-unsafe-assignment': 'error',
25+
'@typescript-eslint/no-unsafe-call': 'error',
26+
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
27+
'@typescript-eslint/no-unsafe-member-access': 'error',
28+
'@typescript-eslint/no-unsafe-return': 'error',
29+
'require-await': 'off',
30+
'@typescript-eslint/require-await': 'error',
31+
'@typescript-eslint/restrict-plus-operands': 'error',
32+
'@typescript-eslint/restrict-template-expressions': 'error',
33+
'@typescript-eslint/unbound-method': 'error',
34+
},
35+
} satisfies ClassicConfig.Config;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// SEE https://typescript-eslint.io/users/configs
4+
//
5+
// For developers working in the typescript-eslint monorepo:
6+
// You can regenerate it using `yarn generate:configs`
7+
8+
import type { ClassicConfig } from '@typescript-eslint/utils/ts-eslint';
9+
10+
export = {
11+
extends: ['./configs/base', './configs/eslint-recommended'],
12+
rules: {
13+
'@typescript-eslint/await-thenable': 'error',
14+
'@typescript-eslint/no-array-delete': 'error',
15+
'@typescript-eslint/no-base-to-string': 'error',
16+
'@typescript-eslint/no-confusing-void-expression': 'error',
17+
'@typescript-eslint/no-duplicate-type-constituents': 'error',
18+
'@typescript-eslint/no-floating-promises': 'error',
19+
'@typescript-eslint/no-for-in-array': 'error',
20+
'no-implied-eval': 'off',
21+
'@typescript-eslint/no-implied-eval': 'error',
22+
'@typescript-eslint/no-meaningless-void-operator': 'error',
23+
'@typescript-eslint/no-misused-promises': 'error',
24+
'@typescript-eslint/no-mixed-enums': 'error',
25+
'@typescript-eslint/no-redundant-type-constituents': 'error',
26+
'no-throw-literal': 'off',
27+
'@typescript-eslint/no-throw-literal': 'error',
28+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
29+
'@typescript-eslint/no-unnecessary-condition': 'error',
30+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
31+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
32+
'@typescript-eslint/no-unsafe-argument': 'error',
33+
'@typescript-eslint/no-unsafe-assignment': 'error',
34+
'@typescript-eslint/no-unsafe-call': 'error',
35+
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
36+
'@typescript-eslint/no-unsafe-member-access': 'error',
37+
'@typescript-eslint/no-unsafe-return': 'error',
38+
'@typescript-eslint/no-useless-template-literals': 'error',
39+
'@typescript-eslint/prefer-includes': 'error',
40+
'prefer-promise-reject-errors': 'off',
41+
'@typescript-eslint/prefer-promise-reject-errors': 'error',
42+
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
43+
'@typescript-eslint/prefer-return-this-type': 'error',
44+
'require-await': 'off',
45+
'@typescript-eslint/require-await': 'error',
46+
'@typescript-eslint/restrict-plus-operands': 'error',
47+
'@typescript-eslint/restrict-template-expressions': 'error',
48+
'@typescript-eslint/unbound-method': 'error',
49+
},
50+
} satisfies ClassicConfig.Config;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// SEE https://typescript-eslint.io/users/configs
4+
//
5+
// For developers working in the typescript-eslint monorepo:
6+
// You can regenerate it using `yarn generate:configs`
7+
8+
import type { ClassicConfig } from '@typescript-eslint/utils/ts-eslint';
9+
10+
export = {
11+
extends: ['./configs/base', './configs/eslint-recommended'],
12+
rules: {
13+
'dot-notation': 'off',
14+
'@typescript-eslint/dot-notation': 'error',
15+
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
16+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
17+
'@typescript-eslint/prefer-optional-chain': 'error',
18+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
19+
},
20+
} satisfies ClassicConfig.Config;

packages/repo-tools/src/generate-configs.mts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ async function main(): Promise<void> {
251251
}
252252

253253
async function writeExtendedConfig({
254-
filters: ruleFilter,
254+
filters,
255255
name,
256256
ruleEntries,
257257
}: ExtendedConfigSettings): Promise<void> {
258258
await writeConfig(
259259
() => ({
260260
extends: [...CLASSIC_EXTENDS],
261261
rules: ruleEntries.reduce(
262-
(config, entry) => reducer(config, entry, ruleFilter),
262+
(config, entry) => reducer(config, entry, filters),
263263
{},
264264
),
265265
}),
@@ -296,6 +296,14 @@ async function main(): Promise<void> {
296296
ruleEntries: filterRuleEntriesTo('recommended'),
297297
});
298298

299+
await writeExtendedConfig({
300+
filters: {
301+
typeChecked: 'include-only',
302+
},
303+
name: 'recommended-type-checked-only',
304+
ruleEntries: filterRuleEntriesTo('recommended'),
305+
});
306+
299307
await writeExtendedConfig({
300308
filters: {
301309
typeChecked: 'exclude',
@@ -309,6 +317,14 @@ async function main(): Promise<void> {
309317
ruleEntries: filterRuleEntriesTo('recommended', 'strict'),
310318
});
311319

320+
await writeExtendedConfig({
321+
filters: {
322+
typeChecked: 'include-only',
323+
},
324+
name: 'strict-type-checked-only',
325+
ruleEntries: filterRuleEntriesTo('recommended', 'strict'),
326+
});
327+
312328
await writeExtendedConfig({
313329
filters: {
314330
typeChecked: 'exclude',
@@ -322,6 +338,14 @@ async function main(): Promise<void> {
322338
ruleEntries: filterRuleEntriesTo('stylistic'),
323339
});
324340

341+
await writeExtendedConfig({
342+
filters: {
343+
typeChecked: 'include-only',
344+
},
345+
name: 'stylistic-type-checked-only',
346+
ruleEntries: filterRuleEntriesTo('stylistic'),
347+
});
348+
325349
await writeConfig(
326350
() => ({
327351
parserOptions: {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// SEE https://typescript-eslint.io/users/configs
4+
//
5+
// For developers working in the typescript-eslint monorepo:
6+
// You can regenerate it using `yarn generate:configs`
7+
8+
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
9+
10+
import baseConfig from './base';
11+
import eslintRecommendedConfig from './eslint-recommended';
12+
13+
export default (
14+
plugin: FlatConfig.Plugin,
15+
parser: FlatConfig.Parser,
16+
): FlatConfig.ConfigArray => [
17+
baseConfig(plugin, parser),
18+
eslintRecommendedConfig(plugin, parser),
19+
{
20+
rules: {
21+
'@typescript-eslint/await-thenable': 'error',
22+
'@typescript-eslint/no-base-to-string': 'error',
23+
'@typescript-eslint/no-duplicate-type-constituents': 'error',
24+
'@typescript-eslint/no-floating-promises': 'error',
25+
'@typescript-eslint/no-for-in-array': 'error',
26+
'no-implied-eval': 'off',
27+
'@typescript-eslint/no-implied-eval': 'error',
28+
'@typescript-eslint/no-misused-promises': 'error',
29+
'@typescript-eslint/no-redundant-type-constituents': 'error',
30+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
31+
'@typescript-eslint/no-unsafe-argument': 'error',
32+
'@typescript-eslint/no-unsafe-assignment': 'error',
33+
'@typescript-eslint/no-unsafe-call': 'error',
34+
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
35+
'@typescript-eslint/no-unsafe-member-access': 'error',
36+
'@typescript-eslint/no-unsafe-return': 'error',
37+
'require-await': 'off',
38+
'@typescript-eslint/require-await': 'error',
39+
'@typescript-eslint/restrict-plus-operands': 'error',
40+
'@typescript-eslint/restrict-template-expressions': 'error',
41+
'@typescript-eslint/unbound-method': 'error',
42+
},
43+
},
44+
];
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// SEE https://typescript-eslint.io/users/configs
4+
//
5+
// For developers working in the typescript-eslint monorepo:
6+
// You can regenerate it using `yarn generate:configs`
7+
8+
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
9+
10+
import baseConfig from './base';
11+
import eslintRecommendedConfig from './eslint-recommended';
12+
13+
export default (
14+
plugin: FlatConfig.Plugin,
15+
parser: FlatConfig.Parser,
16+
): FlatConfig.ConfigArray => [
17+
baseConfig(plugin, parser),
18+
eslintRecommendedConfig(plugin, parser),
19+
{
20+
rules: {
21+
'@typescript-eslint/await-thenable': 'error',
22+
'@typescript-eslint/no-array-delete': 'error',
23+
'@typescript-eslint/no-base-to-string': 'error',
24+
'@typescript-eslint/no-confusing-void-expression': 'error',
25+
'@typescript-eslint/no-duplicate-type-constituents': 'error',
26+
'@typescript-eslint/no-floating-promises': 'error',
27+
'@typescript-eslint/no-for-in-array': 'error',
28+
'no-implied-eval': 'off',
29+
'@typescript-eslint/no-implied-eval': 'error',
30+
'@typescript-eslint/no-meaningless-void-operator': 'error',
31+
'@typescript-eslint/no-misused-promises': 'error',
32+
'@typescript-eslint/no-mixed-enums': 'error',
33+
'@typescript-eslint/no-redundant-type-constituents': 'error',
34+
'no-throw-literal': 'off',
35+
'@typescript-eslint/no-throw-literal': 'error',
36+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
37+
'@typescript-eslint/no-unnecessary-condition': 'error',
38+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
39+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
40+
'@typescript-eslint/no-unsafe-argument': 'error',
41+
'@typescript-eslint/no-unsafe-assignment': 'error',
42+
'@typescript-eslint/no-unsafe-call': 'error',
43+
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
44+
'@typescript-eslint/no-unsafe-member-access': 'error',
45+
'@typescript-eslint/no-unsafe-return': 'error',
46+
'@typescript-eslint/no-useless-template-literals': 'error',
47+
'@typescript-eslint/prefer-includes': 'error',
48+
'prefer-promise-reject-errors': 'off',
49+
'@typescript-eslint/prefer-promise-reject-errors': 'error',
50+
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
51+
'@typescript-eslint/prefer-return-this-type': 'error',
52+
'require-await': 'off',
53+
'@typescript-eslint/require-await': 'error',
54+
'@typescript-eslint/restrict-plus-operands': 'error',
55+
'@typescript-eslint/restrict-template-expressions': 'error',
56+
'@typescript-eslint/unbound-method': 'error',
57+
},
58+
},
59+
];
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// SEE https://typescript-eslint.io/users/configs
4+
//
5+
// For developers working in the typescript-eslint monorepo:
6+
// You can regenerate it using `yarn generate:configs`
7+
8+
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
9+
10+
import baseConfig from './base';
11+
import eslintRecommendedConfig from './eslint-recommended';
12+
13+
export default (
14+
plugin: FlatConfig.Plugin,
15+
parser: FlatConfig.Parser,
16+
): FlatConfig.ConfigArray => [
17+
baseConfig(plugin, parser),
18+
eslintRecommendedConfig(plugin, parser),
19+
{
20+
rules: {
21+
'dot-notation': 'off',
22+
'@typescript-eslint/dot-notation': 'error',
23+
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
24+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
25+
'@typescript-eslint/prefer-optional-chain': 'error',
26+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
27+
},
28+
},
29+
];

0 commit comments

Comments
 (0)
0