Skip to content

linter: eslint/no-restricted-imports false negatives for side-effect imports with regex config #19956

@oleasteo

Description

@oleasteo

What version of Oxlint are you using?

1.51.0

What command did you run?

No response

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "plugins": ["eslint"],
  "categories": {
    "correctness": "off"
  },
  "rules": {
    "eslint/no-restricted-imports": ["error", { "patterns": [
      {"regex": "foo", "message": "no foo allowed (regex match)"},
      {"group": ["bar"], "message": "no bar allowed (group match)"}
    ]}],
  },
}

What happened?

import type { Foo } from "./foo"; // lint error
import { foo } from "./foo"; // lint error
import "./foo"; // <----- no lint error

import type { Bar } from "./bar"; // lint error
import { bar } from "./bar"; // lint error
import "./bar"; // lint error

In this example, all "bar" related imports are properly flagged by the group: ["bar"] pattern, but for the "foo" related imports, only the first two are matched by regex: "foo" pattern. The foo side-effect import is not matched.

Reproduction: https://github.com/oleasteo/repro-oxlint-no-restricted-imports

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions