Skip to content

linter: default rules are re-enabled in overrides despite correctness set to off #19409

@connorshea

Description

@connorshea

What version of Oxlint are you using?

1.47.0

What command did you run?

oxlint

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

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": ["react", "typescript"],
  "categories": {
    "correctness": "off"
  },
  "rules": {
    "react/no-multi-comp": "error",
    "@typescript-eslint/no-inferrable-types": "error"
  },
  "overrides": [
    {
      "files": [
        "subdir/**/*.ts",
        "subdir/**/*.tsx"
      ],
      "plugins": ["node"],
      "rules": {
        "node/global-require": "error"
      },
    }
  ]
}

What happened?

Reproduction repo: https://github.com/connorshea/test-migrate

Note: See the comments, I found the root source of the problem I think

Reproduction instructions:

  • git clone https://github.com/connorshea/test-migrate
  • cd test-migrate
  • pnpm install
  • pnpm oxlint, see that it returns a warning for no-unused-vars despite that rule not being enabled.

The foo.tsx file is this:

// This file will trigger the no-multi-comp rule, that's fine.
const ComponentOne = () => <div>A</div>;
const ComponentTwo = () => <div>B</div>;

// This next line triggers typescript/no-inferrable-type, that's fine.
// However, it also triggers typescript/no-unused-vars, despite that rule not being enabled in any way?
const a: number = 5;

export { ComponentOne, ComponentTwo };

Output of oxlint:

test-migrate % pnpm oxlint

  × eslint-plugin-react(no-multi-comp): Declare only one React component per file. Found: ComponentTwo
   ╭─[subdir/foo.tsx:3:7]
 2 │ const ComponentOne = () => <div>A</div>;
 3 │ const ComponentTwo = () => <div>B</div>;
   ·       ─────────────────────────────────
 4 │ 
   ╰────
  help: Move this component to a separate file.

  ⚠ eslint(no-unused-vars): Variable 'a' is declared but never used. Unused variables should start with a '_'.
   ╭─[subdir/foo.tsx:7:7]
 6 │ // It also triggers typescript/no-unused-vars, despite that rule not being enabled in any way?
 7 │ const a: number = 5;
   ·       ┬
   ·       ╰── 'a' is declared here
 8 │ 
   ╰────
  help: Consider removing this declaration.

  × typescript-eslint(no-inferrable-types): Type can be trivially inferred from the initializer
   ╭─[subdir/foo.tsx:7:8]
 6 │ // It also triggers typescript/no-unused-vars, despite that rule not being enabled in any way?
 7 │ const a: number = 5;
   ·        ────────
 8 │ 
   ╰────
  help: Remove the type annotation

Found 1 warning and 2 errors.
Finished in 5ms on 1 file with 2 rules using 8 threads.

This is a bizarre behavior and it should not be happening. correctness is set to "off", and the rule is not enabled explicitly in the config. So why does it still get triggered by this code?

I also tested this on 1.43.0 and it happens there too (before that, react/no-multi-comp doesn't exist so we'll maybe want to adjust the config to go back further, if we think this is a recent regression).

A similar problem occurs if I change the foo.tsx file:

// This file will trigger the no-multi-comp rule.
const ComponentOne = () => <div>A</div>;
const ComponentTwo = () => <div>B</div>;

const a: number = 5;

export { ComponentOne, ComponentTwo };

// Now this has a warning that it should not have:
if (a === {}) {
  console.log("foo");
}

Resulting warning from oxlint:

  ⚠ eslint(no-constant-binary-expression): Unexpected comparison to newly constructed object
    ╭─[subdir/foo.tsx:11:5]
 10 │ 
 11 │ if (a === {}) {
    ·     ────────
 12 │   console.log("foo");
    ╰────
  help: These two values can never be equal

Found 1 warning and 2 errors.
Finished in 26ms on 1 file with 2 rules using 8 threads.

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