Skip to content

Bug: single run mode breaks with fixers #9344

@hasakilol

Description

@hasakilol

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

  1. This is update to: Bug: [no-duplicate-type-constituent] fixer removes undefined from type #9230
  2. 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

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

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",

Metadata

Metadata

Labels

bugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: typescript-estreeIssues related to @typescript-eslint/typescript-estreeteam assignedA member of the typescript-eslint team should work on this.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy