-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
https://github.com/hasakilol/react-vite/blob/master/src/Test.tsx
Repro Code
- This is update to: Bug: [no-duplicate-type-constituent] fixer removes undefined from type #9230
- I can't give you a reproduction on https://typescript-eslint.io/play/ because I'm using latest eslint and typescript-eslint packages.
ESLint Config
import tseslint from 'typescript-eslint';
import globals from 'globals';
import parser from '@typescript-eslint/parser';
export default tseslint.config(
{
name: 'plugins',
plugins: {
['@typescript-eslint']: tseslint.plugin,
},
},
{
languageOptions: {
globals: {
...globals.node,
...globals.es2015,
},
parserOptions: {
allowAutomaticSingleRunInference: true,
project: ['tsconfig.json'],
tsconfigRootDir: '.',
}
},
},
{
name: 'src',
files: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.mts', 'src/**/*.cts'],
extends: tseslint.configs.recommendedTypeChecked,
languageOptions: {
parser,
parserOptions: {
ecmaFeatures: {
jsx: true
},
sourceType: 'module',
},
globals: {
...globals.browser,
...globals.mocha,
...globals.jest,
...globals.jasmine,
},
},
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error'
}
},
);
tsconfig
Expected Result
https://github.com/hasakilol/react-vite/blob/master/src/Test.tsx#L8
No matter how you configure @typescript-eslint/consistent-type-imports
('off' or 'error') and @typescript-eslint/no-duplicate-type-constituents
('off' or 'error'),
item: { a: string; } | typeof Null | typeof Undefined,
should not change after running npx eslint --fix src/Test.tsx
.
Actual Result
When both @typescript-eslint/consistent-type-imports
and @typescript-eslint/no-duplicate-type-constituents
are configured error
, item: { a: string; } | typeof Null | typeof Undefined,
is changed to item: { a: string; } | typeof Null ,
after running npx eslint --fix src/Test.tsx
.
When either @typescript-eslint/consistent-type-imports
or @typescript-eslint/no-duplicate-type-constituents
are configured off
, item: { a: string; } | typeof Null | typeof Undefined,
will not change (what I expect) after running npx eslint --fix src/Test.tsx
.
Additional Info
"@typescript-eslint/eslint-plugin": "^8.0.0-alpha.14",
"@typescript-eslint/parser": "^8.0.0-alpha.14",
"@typescript-eslint/scope-manager": "^8.0.0-alpha.14",
"@typescript-eslint/type-utils": "^8.0.0-alpha.14",
"@typescript-eslint/types": "^8.0.0-alpha.14",
"@typescript-eslint/typescript-estree": "^8.0.0-alpha.14",
"@typescript-eslint/utils": "^8.0.0-alpha.14",
"@typescript-eslint/visitor-keys": "^8.0.0-alpha.14",
"typescript-eslint": "^8.0.0-alpha.14",
"eslint": "^9.3.0",