Skip to content

linter: import/no-duplicates not merging type and non-type imports #10455

@ccmetz

Description

@ccmetz

What version of Oxlint are you using?

0.16.6

What command did you run?

No response

What does your .oxlintrc.json config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": ["typescript", "unicorn", "oxc", "import", "promise", "vitest"],
  "categories": {
     "correctness": "error",
     "suspicious": "warn",
     "pedantic": "off",
     "perf": "warn",
     "style": "warn",
     "restriction": "warn",
     "nursery": "warn"
  },
  "env": {
     "browser": true
  },
  "globals": {},
  "ignorePatterns": [],
  "rules": {
     "eslint/no-duplicate-imports": "off",
     "typescript/consistent-type-imports": [
        "warn",
        {
           "fixStyle": "separate-type-imports"
        }
     ],
     "unicorn/filename-case": "off",
     "import/group-exports": "off",
     "import/exports-last": "off",
     "import/no-duplicates": [
        "warn",
        {
           "prefer-inline": true
        }
     ]
  }
}

What happened?

It's possible this is user error but I cannot get the "import/no-duplicates" rule to either show as a warning or error or auto-fix on save in VSCode when there are duplicate imports involving type and non-type imports.

oxc extension version: 0.16.6
VSCode version: 1.98.2

I've set up an example project with these files:

.vscode/settings.json

{
  // Save actions
  "editor.codeActionsOnSave": {
    //"source.fixAll.eslint": "explicit",
    "source.organizeImports": "always",
    "source.fixAll.oxc": "always"
  },

  "typescript.format.enable": false,
  "files.insertFinalNewline": true,
  "typescript.preferences.preferTypeOnlyAutoImports": true,
  "typescript.preferences.organizeImports": {
    "unicodeCollation": "unicode",
    "caseSensitivity": "caseInsensitive",
    "typeOrder": "inline"
  },
  "oxc.enable": true
}

package.json

{
  "scripts": {
    "lint": "oxlint --config=.oxlintrc.json"
  },
  "dependencies": {
    "oxlint": "^0.16.6"
  }
}

car.ts

export interface Car {
  make: string;
  model: string;
  year: number;
};


export const getCarDescription = (car: Car): string => {
  return car.year + " " + car.make + " " + car.model;
}

index.ts

// No error/warning show on these imports. Saving does not trigger an auto-fix.
import type { Car } from "./car";
import { getCarDescription } from "./car";

const car: Car = {
  make: "Ford",
  model: "Mustang",
  year: 1964,
};

const _carDesc = getCarDescription(car);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions