Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: support stringly-typed extends #10973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions docs/users/Shared_Configurations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ module.exports = {
</TabItem>
</Tabs>

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.
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.

### `recommended-type-checked`

Expand Down Expand Up @@ -173,7 +173,7 @@ module.exports = {
</TabItem>
</Tabs>

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.
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.

### `strict`

Expand Down Expand Up @@ -203,7 +203,7 @@ module.exports = {
</Tabs>

Some rules also enabled in `recommended` default to more strict settings in this configuration.
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.
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.

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

Some rules also enabled in `recommended-type-checked` default to more strict settings in this configuration.
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.
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.

:::tip
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.
Expand Down Expand Up @@ -283,7 +283,7 @@ module.exports = {
Note that `stylistic` does not replace `recommended` or `strict`.
`stylistic` adds additional rules.

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.
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.

### `stylistic-type-checked`

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

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.
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.

## Other Configurations

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

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.
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.

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

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

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.
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.

### `disable-type-checked`

A utility ruleset that will disable type-aware linting and all type-aware rules available in our project.
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.

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.
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.

:::info
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.
Expand Down Expand Up @@ -449,7 +449,7 @@ module.exports = {

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

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.
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.

### `recommended-type-checked-only`

Expand All @@ -462,7 +462,7 @@ module.exports = {
};
```

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.
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.

### `strict-type-checked-only`

Expand All @@ -475,7 +475,7 @@ module.exports = {
};
```

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.
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.

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

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.
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.

## Suggesting Configuration Changes

Expand Down
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,9 @@ export default tseslint.config(
{
files: ['**/*'],
ignores: [
'packages/eslint-plugin/src/configs/*',
'packages/eslint-plugin/src/configs/eslintrc/*',
'packages/eslint-plugin/src/configs/flat/*',
'packages/scope-manager/src/configs/*',
'packages/typescript-eslint/src/configs/*',
],
rules: {
'@typescript-eslint/sort-type-constituents': 'off',
Expand Down
1 change: 1 addition & 0 deletions knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default {
'src/mock/eslint-rules.js',
'src/mock/eslint.js',
'src/mock/lru-cache.js',
'src/mock/parser.js',
'src/mock/path.js',
'src/mock/typescript.js',
'src/mock/util.js',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@
"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",
"tmp": "0.2.1",
"tsx": "^4.7.2",
"typescript": "5.8.2"
"typescript": "5.8.2",
"@eslint/config-helpers": "^0.2.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This manual resolution is required pending release of the next version of eslint (eslint/eslint#19533 has been merged but not yet released)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're clear to remove this now, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, on main we still have

├─ eslint@npm:9.22.0
│  └─ @eslint/config-helpers@npm:0.1.0 (via npm:^0.1.0)
│
└─ eslint@npm:9.22.0 [43684]
   └─ @eslint/config-helpers@npm:0.1.0 (via npm:^0.1.0)

so we need either this or to upgrade eslint past 9.23

Copy link
Member Author

@kirkwaiblinger kirkwaiblinger Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I've implemented the latter, updating our eslint dependency) I've kept the resolutions since I had some CI failures that I had a hard time debugging when I tried upgrading the eslint version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but yeah once main has eslint >= 9.23 we can remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun. I just clicked the checkmark in #6687 to start the Renovate PR.

},
"packageManager": "[email protected]",
"nx": {
Expand Down
5 changes: 0 additions & 5 deletions packages/eslint-plugin/eslint-recommended-raw.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dist",
"!*.tsbuildinfo",
"docs",
"eslint-recommended-raw.d.ts",
"index.d.ts",
"raw-plugin.d.ts",
"rules.d.ts",
"package.json",
"README.md",
Expand All @@ -24,9 +24,9 @@
"types": "./rules.d.ts",
"default": "./dist/rules/index.js"
},
"./use-at-your-own-risk/eslint-recommended-raw": {
"types": "./eslint-recommended-raw.d.ts",
"default": "./dist/configs/eslint-recommended-raw.js"
"./use-at-your-own-risk/raw-plugin": {
"types": "./raw-plugin.d.ts",
"default": "./dist/raw-plugin.js"
}
},
"engines": {
Expand Down
25 changes: 25 additions & 0 deletions packages/eslint-plugin/raw-plugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';

import type plugin from './index';

declare const cjsExport: {
flatConfigs: {
'flat/all': FlatConfig.ConfigArray;
'flat/base': FlatConfig.Config;
'flat/disable-type-checked': FlatConfig.Config;
'flat/eslint-recommended': FlatConfig.Config;
'flat/recommended': FlatConfig.ConfigArray;
'flat/recommended-type-checked': FlatConfig.ConfigArray;
'flat/recommended-type-checked-only': FlatConfig.ConfigArray;
'flat/strict': FlatConfig.ConfigArray;
'flat/strict-type-checked': FlatConfig.ConfigArray;
'flat/strict-type-checked-only': FlatConfig.ConfigArray;
'flat/stylistic': FlatConfig.ConfigArray;
'flat/stylistic-type-checked': FlatConfig.ConfigArray;
'flat/stylistic-type-checked-only': FlatConfig.ConfigArray;
};
parser: FlatConfig.Parser;
plugin: typeof plugin;
};

export = cjsExport;
10 changes: 4 additions & 6 deletions packages/eslint-plugin/src/configs/eslint-recommended-raw.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// NOTE: this file is isolated to be shared across legacy and flat configs
// it is exported via `./use-at-your-own-risk/eslint-recommended-raw`
// and it has types manually defined in `./eslint-recommended-raw.d.ts`
// NOTE: this file is isolated to be shared across legacy and flat configs.

/**
* This is a compatibility ruleset that:
Expand All @@ -11,7 +9,7 @@ const config = (
style: 'glob' | 'minimatch',
): {
files: string[];
rules: Record<string, 'off' | 'warn' | 'error'>;
rules: Record<string, 'error' | 'off' | 'warn'>;
} => ({
files:
style === 'glob'
Expand All @@ -30,8 +28,8 @@ const config = (
'no-func-assign': 'off', // ts(2630)
'no-import-assign': 'off', // ts(2632) & ts(2540)
// TODO - remove this once we no longer support ESLint v8
'no-new-symbol': 'off', // ts(7009)
'no-new-native-nonconstructor': 'off', // ts(7009)
'no-new-symbol': 'off', // ts(7009)
'no-obj-calls': 'off', // ts(2349)
'no-redeclare': 'off', // ts(2451)
'no-setter-return': 'off', // ts(2408)
Expand All @@ -40,10 +38,10 @@ const config = (
'no-unreachable': 'off', // ts(7027)
'no-unsafe-negation': 'off', // ts(2365) & ts(2322) & ts(2358)
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
'no-with': 'off', // ts(1101) & ts(2410)
'prefer-const': 'error', // ts provides better types with const
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
'no-with': 'off', // ts(1101) & ts(2410)
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

import eslintRecommended_raw from './eslint-recommended-raw';
import eslintRecommended_raw from '../eslint-recommended-raw';

export = {
overrides: [eslintRecommended_raw('glob')],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';

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

/**
* This is a compatibility ruleset that:
Expand Down
52 changes: 2 additions & 50 deletions packages/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,3 @@
import type { Linter } from '@typescript-eslint/utils/ts-eslint';
import rawPlugin from './raw-plugin';

import all from './configs/all';
import base from './configs/base';
import disableTypeChecked from './configs/disable-type-checked';
import eslintRecommended from './configs/eslint-recommended';
import recommended from './configs/recommended';
import recommendedTypeChecked from './configs/recommended-type-checked';
import recommendedTypeCheckedOnly from './configs/recommended-type-checked-only';
import strict from './configs/strict';
import strictTypeChecked from './configs/strict-type-checked';
import strictTypeCheckedOnly from './configs/strict-type-checked-only';
import stylistic from './configs/stylistic';
import stylisticTypeChecked from './configs/stylistic-type-checked';
import stylisticTypeCheckedOnly from './configs/stylistic-type-checked-only';
import rules from './rules';

// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
const { name, version } = require('../package.json') as {
name: string;
version: string;
};

const configs = {
all,
base,
'disable-type-checked': disableTypeChecked,
'eslint-recommended': eslintRecommended,
recommended,
/** @deprecated - please use "recommended-type-checked" instead. */
'recommended-requiring-type-checking': recommendedTypeChecked,
'recommended-type-checked': recommendedTypeChecked,
'recommended-type-checked-only': recommendedTypeCheckedOnly,
strict,
'strict-type-checked': strictTypeChecked,
'strict-type-checked-only': strictTypeCheckedOnly,
stylistic,
'stylistic-type-checked': stylisticTypeChecked,
'stylistic-type-checked-only': stylisticTypeCheckedOnly,
};

const meta = {
name,
version,
};

export = {
configs,
meta,
rules,
} satisfies Linter.Plugin;
export = rawPlugin.plugin;
Loading
Loading