Skip to content
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

Removing duplicates breaks in TypeScript when "type" is being used #3016

Closed
bennycode opened this issue Jun 17, 2024 · 3 comments · Fixed by #3033
Closed

Removing duplicates breaks in TypeScript when "type" is being used #3016

bennycode opened this issue Jun 17, 2024 · 3 comments · Fixed by #3033

Comments

@bennycode
Copy link

In my current ESLint config I have set up eslint-plugin-import v2.29.1 in the following way:

{
  "$schema": "https://json.schemastore.org/eslintrc.json",
  "env": {
    "browser": true,
    "node": true
  },
  "extends": ["prettier", "plugin:import/typescript"],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 8,
    "project": "./tsconfig.json",
    "sourceType": "module"
  },
  "plugins": ["@typescript-eslint", "prettier", "sort-keys-fix", "import"],
  "rules": {
    "import/no-commonjs": ["error"],
    "import/no-duplicates": [
      "error",
      {
        "prefer-inline": true
      }
    ],  
  },
  "settings": {
    "import/resolver": {
      "node": true,
      "typescript": true
    }
  }
}  

Unfortunately, the import/no-duplicates rule breaks my TS code.

Initial code:

import type {
  AxiosDefaults,
  AxiosInterceptorManager,
  AxiosRequestConfig,
  AxiosResponse,
  AxiosInstance,
  AxiosError,
} from 'axios';
import axios, {isAxiosError} from 'axios';

Broken code after formatting:

import axios, type {
  AxiosDefaults,
  AxiosInterceptorManager,
  AxiosRequestConfig,
  AxiosResponse,
  AxiosInstance,
  AxiosError,
isAxiosError} from 'axios';
@yesl-kim
Copy link
Contributor

yesl-kim commented Aug 8, 2024

I’d like to work on this issue. Is it okay if I take it?

@ljharb
Copy link
Member

ljharb commented Aug 8, 2024

@yesl-kim yes, in open source anyone can just put up a PR, no need to ask.

yesl-kim added a commit to yesl-kim/eslint-plugin-import that referenced this issue Aug 11, 2024
yesl-kim added a commit to yesl-kim/eslint-plugin-import that referenced this issue Aug 11, 2024
@injae-kim
Copy link

Fix PR: #3033 PTAL! 🙇

@ljharb ljharb closed this as completed in 4bdf61a Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants