import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bennycode opened this issue · comments

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';