Skip to content

[extensions] false positive on external dependencies #394

@Zamiell

Description

@Zamiell

Problem

The import-x/extensions rule has a false positive on external dependencies. (Furthermore, the autofixer incorrectly "fixes" the issues, which causes run-time errors.)

Details

First, turn on the import-x/extensions rule like this:

      "import-x/extensions": [
        "error",
        "always",
        {
          fix: true,
          pattern: {},
        },
      ],

(The reason for these strange options is because the autofixer is currently bugged, so ignore that for now.)

Once the rule is turned on, the rule will error on the following code:

import { foo } from "./foo";
import { GitVersionType } from "azure-devops-node-api/interfaces/GitInterfaces";
  • Erroring on the first line is correct, because "foo.ts" exists in my code and import { foo } from "./foo.ts"; is a valid import.
  • However, erroring on the second line is a bug, because "GitInterfaces.ts" does NOT exist. The autofixer will change it to import { GitVersionType } from "azure-devops-node-api/interfaces/GitInterfaces.ts";, which will cause a run-time error.

Thus, I propose that the rule should only error on non-external dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions