Skip to content

Commit 69e2f6c

Browse files
feat: support stringly-typed extends (#10973)
* work in progress * wip * fix stuff * lintfixy stuff * why not work * yay, passing tests! * undo extraneous change * point to the new config locations * ignore dep from website build * website mocking take 2 * unused var * typo Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com> * up eslint * knip ignore * alfa * Revert "up eslint" This reverts commit 7d36b57. * fix up resolution stuff * is it this * Revert "is it this" This reverts commit 97d1346. * uhhh * fixup * fixup --------- Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
1 parent d1f57a7 commit 69e2f6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+250
-137
lines changed

docs/users/Shared_Configurations.mdx

+13-13
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ module.exports = {
144144
</TabItem>
145145
</Tabs>
146146

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

149149
### `recommended-type-checked`
150150

@@ -173,7 +173,7 @@ module.exports = {
173173
</TabItem>
174174
</Tabs>
175175

176-
See [`configs/recommended-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked.ts) for the exact contents of this config.
176+
See [`configs/recommended-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/recommended-type-checked.ts) for the exact contents of this config.
177177

178178
### `strict`
179179

@@ -203,7 +203,7 @@ module.exports = {
203203
</Tabs>
204204

205205
Some rules also enabled in `recommended` default to more strict settings in this configuration.
206-
See [`configs/strict.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts) for the exact contents of this config.
206+
See [`configs/strict.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/strict.ts) for the exact contents of this config.
207207

208208
:::tip
209209
We recommend a TypeScript project extend from `plugin:@typescript-eslint/strict` only if a nontrivial percentage of its developers are highly proficient in TypeScript.
@@ -242,7 +242,7 @@ module.exports = {
242242
</Tabs>
243243

244244
Some rules also enabled in `recommended-type-checked` default to more strict settings in this configuration.
245-
See [`configs/strict-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict-type-checked.ts) for the exact contents of this config.
245+
See [`configs/strict-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/strict-type-checked.ts) for the exact contents of this config.
246246

247247
:::tip
248248
We recommend a TypeScript project extend from `plugin:@typescript-eslint/strict-type-checked` only if a nontrivial percentage of its developers are highly proficient in TypeScript.
@@ -283,7 +283,7 @@ module.exports = {
283283
Note that `stylistic` does not replace `recommended` or `strict`.
284284
`stylistic` adds additional rules.
285285

286-
See [`configs/stylistic.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic.ts) for the exact contents of this config.
286+
See [`configs/stylistic.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/stylistic.ts) for the exact contents of this config.
287287

288288
### `stylistic-type-checked`
289289

@@ -315,7 +315,7 @@ module.exports = {
315315
Note that `stylistic-type-checked` does not replace `recommended-type-checked` or `strict-type-checked`.
316316
`stylistic-type-checked` adds additional rules.
317317

318-
See [`configs/stylistic-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic-type-checked.ts) for the exact contents of this config.
318+
See [`configs/stylistic-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/stylistic-type-checked.ts) for the exact contents of this config.
319319

320320
## Other Configurations
321321

@@ -326,7 +326,7 @@ typescript-eslint includes a few utility configurations.
326326
Enables each the rules provided as a part of typescript-eslint.
327327
Note that many rules are not applicable in all codebases, or are meant to be configured.
328328

329-
See [`configs/all.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/all.ts) for the exact contents of this config.
329+
See [`configs/all.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/all.ts) for the exact contents of this config.
330330

331331
:::warning
332332
We do not recommend TypeScript projects extend from `plugin:@typescript-eslint/all`.
@@ -345,14 +345,14 @@ We don't recommend using this directly; instead, extend from an earlier recommen
345345

346346
This config is automatically included if you use any of the recommended configurations.
347347

348-
See [`configs/base.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/base.ts) for the exact contents of this config.
348+
See [`configs/base.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/base.ts) for the exact contents of this config.
349349

350350
### `disable-type-checked`
351351

352352
A utility ruleset that will disable type-aware linting and all type-aware rules available in our project.
353353
This config is useful if you'd like to have your base config concerned with type-aware linting, and then conditionally use [overrides](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-based-on-glob-patterns) to disable type-aware linting on specific subsets of your codebase.
354354

355-
See [`configs/disable-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/disable-type-checked.ts) for the exact contents of this config.
355+
See [`configs/disable-type-checked.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/disable-type-checked.ts) for the exact contents of this config.
356356

357357
:::info
358358
If you use type-aware rules from other plugins, you will need to manually disable these rules or use a premade config they provide to disable them.
@@ -449,7 +449,7 @@ module.exports = {
449449

450450
This config is automatically included if you use any of the recommended configurations.
451451

452-
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.
452+
See [`configs/eslint-recommended.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/eslint-recommended.ts) for the exact contents of this config.
453453

454454
### `recommended-type-checked-only`
455455

@@ -462,7 +462,7 @@ module.exports = {
462462
};
463463
```
464464

465-
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.
465+
See [`configs/recommended-type-checked-only.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/recommended-type-checked-only.ts) for the exact contents of this config.
466466

467467
### `strict-type-checked-only`
468468

@@ -475,7 +475,7 @@ module.exports = {
475475
};
476476
```
477477

478-
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.
478+
See [`configs/strict-type-checked-only.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/strict-type-checked-only.ts) for the exact contents of this config.
479479

480480
:::warning
481481
This configuration is not considered "stable" under Semantic Versioning (semver).
@@ -493,7 +493,7 @@ module.exports = {
493493
};
494494
```
495495

496-
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.
496+
See [`configs/stylistic-type-checked-only.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/stylistic-type-checked-only.ts) for the exact contents of this config.
497497

498498
## Suggesting Configuration Changes
499499

eslint.config.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,9 @@ export default tseslint.config(
646646
{
647647
files: ['**/*'],
648648
ignores: [
649-
'packages/eslint-plugin/src/configs/*',
649+
'packages/eslint-plugin/src/configs/eslintrc/*',
650+
'packages/eslint-plugin/src/configs/flat/*',
650651
'packages/scope-manager/src/configs/*',
651-
'packages/typescript-eslint/src/configs/*',
652652
],
653653
rules: {
654654
'@typescript-eslint/sort-type-constituents': 'off',

knip.ts

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default {
139139
'src/mock/eslint-rules.js',
140140
'src/mock/eslint.js',
141141
'src/mock/lru-cache.js',
142+
'src/mock/parser.js',
142143
'src/mock/path.js',
143144
'src/mock/typescript.js',
144145
'src/mock/util.js',

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@
148148
"react-split-pane@^0.1.92": "patch:react-split-pane@npm%3A0.1.92#./.yarn/patches/react-split-pane-npm-0.1.92-93dbf51dff.patch",
149149
"tmp": "0.2.1",
150150
"tsx": "^4.7.2",
151-
"typescript": "5.8.2"
151+
"typescript": "5.8.2",
152+
"@eslint/config-helpers": "^0.2.0"
152153
},
153154
"packageManager": "yarn@3.8.2",
154155
"nx": {

packages/eslint-plugin/eslint-recommended-raw.d.ts

-5
This file was deleted.

packages/eslint-plugin/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"dist",
77
"!*.tsbuildinfo",
88
"docs",
9-
"eslint-recommended-raw.d.ts",
109
"index.d.ts",
10+
"raw-plugin.d.ts",
1111
"rules.d.ts",
1212
"package.json",
1313
"README.md",
@@ -24,9 +24,9 @@
2424
"types": "./rules.d.ts",
2525
"default": "./dist/rules/index.js"
2626
},
27-
"./use-at-your-own-risk/eslint-recommended-raw": {
28-
"types": "./eslint-recommended-raw.d.ts",
29-
"default": "./dist/configs/eslint-recommended-raw.js"
27+
"./use-at-your-own-risk/raw-plugin": {
28+
"types": "./raw-plugin.d.ts",
29+
"default": "./dist/raw-plugin.js"
3030
}
3131
},
3232
"engines": {
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
2+
3+
import type plugin from './index';
4+
5+
declare const cjsExport: {
6+
flatConfigs: {
7+
'flat/all': FlatConfig.ConfigArray;
8+
'flat/base': FlatConfig.Config;
9+
'flat/disable-type-checked': FlatConfig.Config;
10+
'flat/eslint-recommended': FlatConfig.Config;
11+
'flat/recommended': FlatConfig.ConfigArray;
12+
'flat/recommended-type-checked': FlatConfig.ConfigArray;
13+
'flat/recommended-type-checked-only': FlatConfig.ConfigArray;
14+
'flat/strict': FlatConfig.ConfigArray;
15+
'flat/strict-type-checked': FlatConfig.ConfigArray;
16+
'flat/strict-type-checked-only': FlatConfig.ConfigArray;
17+
'flat/stylistic': FlatConfig.ConfigArray;
18+
'flat/stylistic-type-checked': FlatConfig.ConfigArray;
19+
'flat/stylistic-type-checked-only': FlatConfig.ConfigArray;
20+
};
21+
parser: FlatConfig.Parser;
22+
plugin: typeof plugin;
23+
};
24+
25+
export = cjsExport;

packages/eslint-plugin/src/configs/eslint-recommended-raw.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// NOTE: this file is isolated to be shared across legacy and flat configs
2-
// it is exported via `./use-at-your-own-risk/eslint-recommended-raw`
3-
// and it has types manually defined in `./eslint-recommended-raw.d.ts`
1+
// NOTE: this file is isolated to be shared across legacy and flat configs.
42

53
/**
64
* This is a compatibility ruleset that:
@@ -11,7 +9,7 @@ const config = (
119
style: 'glob' | 'minimatch',
1210
): {
1311
files: string[];
14-
rules: Record<string, 'off' | 'warn' | 'error'>;
12+
rules: Record<string, 'error' | 'off' | 'warn'>;
1513
} => ({
1614
files:
1715
style === 'glob'
@@ -30,8 +28,8 @@ const config = (
3028
'no-func-assign': 'off', // ts(2630)
3129
'no-import-assign': 'off', // ts(2632) & ts(2540)
3230
// TODO - remove this once we no longer support ESLint v8
33-
'no-new-symbol': 'off', // ts(7009)
3431
'no-new-native-nonconstructor': 'off', // ts(7009)
32+
'no-new-symbol': 'off', // ts(7009)
3533
'no-obj-calls': 'off', // ts(2349)
3634
'no-redeclare': 'off', // ts(2451)
3735
'no-setter-return': 'off', // ts(2408)
@@ -40,10 +38,10 @@ const config = (
4038
'no-unreachable': 'off', // ts(7027)
4139
'no-unsafe-negation': 'off', // ts(2365) & ts(2322) & ts(2358)
4240
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
41+
'no-with': 'off', // ts(1101) & ts(2410)
4342
'prefer-const': 'error', // ts provides better types with const
4443
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
4544
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
46-
'no-with': 'off', // ts(1101) & ts(2410)
4745
},
4846
});
4947

packages/eslint-plugin/src/configs/eslint-recommended.ts renamed to packages/eslint-plugin/src/configs/eslintrc/eslint-recommended.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import type { ClassicConfig } from '@typescript-eslint/utils/ts-eslint';
88

9-
import eslintRecommended_raw from './eslint-recommended-raw';
9+
import eslintRecommended_raw from '../eslint-recommended-raw';
1010

1111
export = {
1212
overrides: [eslintRecommended_raw('glob')],

packages/typescript-eslint/src/configs/eslint-recommended.ts renamed to packages/eslint-plugin/src/configs/flat/eslint-recommended.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
22

3-
import config from '@typescript-eslint/eslint-plugin/use-at-your-own-risk/eslint-recommended-raw';
3+
import config from '../eslint-recommended-raw';
44

55
/**
66
* This is a compatibility ruleset that:

packages/eslint-plugin/src/index.ts

+2-50
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,3 @@
1-
import type { Linter } from '@typescript-eslint/utils/ts-eslint';
1+
import rawPlugin from './raw-plugin';
22

3-
import all from './configs/all';
4-
import base from './configs/base';
5-
import disableTypeChecked from './configs/disable-type-checked';
6-
import eslintRecommended from './configs/eslint-recommended';
7-
import recommended from './configs/recommended';
8-
import recommendedTypeChecked from './configs/recommended-type-checked';
9-
import recommendedTypeCheckedOnly from './configs/recommended-type-checked-only';
10-
import strict from './configs/strict';
11-
import strictTypeChecked from './configs/strict-type-checked';
12-
import strictTypeCheckedOnly from './configs/strict-type-checked-only';
13-
import stylistic from './configs/stylistic';
14-
import stylisticTypeChecked from './configs/stylistic-type-checked';
15-
import stylisticTypeCheckedOnly from './configs/stylistic-type-checked-only';
16-
import rules from './rules';
17-
18-
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
19-
const { name, version } = require('../package.json') as {
20-
name: string;
21-
version: string;
22-
};
23-
24-
const configs = {
25-
all,
26-
base,
27-
'disable-type-checked': disableTypeChecked,
28-
'eslint-recommended': eslintRecommended,
29-
recommended,
30-
/** @deprecated - please use "recommended-type-checked" instead. */
31-
'recommended-requiring-type-checking': recommendedTypeChecked,
32-
'recommended-type-checked': recommendedTypeChecked,
33-
'recommended-type-checked-only': recommendedTypeCheckedOnly,
34-
strict,
35-
'strict-type-checked': strictTypeChecked,
36-
'strict-type-checked-only': strictTypeCheckedOnly,
37-
stylistic,
38-
'stylistic-type-checked': stylisticTypeChecked,
39-
'stylistic-type-checked-only': stylisticTypeCheckedOnly,
40-
};
41-
42-
const meta = {
43-
name,
44-
version,
45-
};
46-
47-
export = {
48-
configs,
49-
meta,
50-
rules,
51-
} satisfies Linter.Plugin;
3+
export = rawPlugin.plugin;

0 commit comments

Comments
 (0)