Skip to content

linter: .oxlintrc.json in parent directory overrides config in current directory #20904

@bwbuchanan

Description

@bwbuchanan

What version of Oxlint are you using?

1.58.0

What command did you run?

../node_modules/.bin/oxlint bug-test.ts

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

Root:

{
  "$schema": "node_modules/oxlint/configuration_schema.json",
  "plugins": ["typescript"],
  "rules": {
    "typescript/no-explicit-any": "error"
  }
}

tests directory:

{
  "$schema": "node_modules/oxlint/configuration_schema.json",
  "plugins": ["typescript"],
  "rules": {
    "eslint/no-unused-vars": "off",
    "typescript/no-explicit-any": "off"
  }
}

What happened?

In the tests directory under the project root, linted the file bug-test.ts:

const ab: any = 2;

I expected that, based on the nested .oxlintrc.json, no lints would be output. Instead:

> ../node_modules/.bin/oxlint bug-test.ts

  ⚠ eslint(no-unused-vars): Variable 'ab' is declared but never used. Unused variables should start with a '_'.
   ╭─[bug-test.ts:1:7]
 1 │ const ab: any = 2;
   ·       ─┬
   ·        ╰── 'ab' is declared here
   ╰────
  help: Consider removing this declaration.

  × typescript-eslint(no-explicit-any): Unexpected `any`. Specify a different type.
   ╭─[bug-test.ts:1:11]
 1 │ const ab: any = 2;
   ·           ───
   ╰────
  help: Use `unknown` instead, this will force you to explicitly, and safely, assert the type is correct.

Found 1 warning and 1 error.
Finished in 26ms on 1 file using 10 threads.

Removing the .oxlintrc.json in the parent directory results in the expected behaviour, as does reverting to 1.57.0.

> ../node_modules/.bin/oxlint bug-test.ts
Found 0 warnings and 0 errors.
Finished in 4ms on 1 file with 66 rules using 10 threads.

Curiously, the bug also does not manifest if you run oxlint from the parent directory, but it also does not print the number of rules evaluated:

> node_modules/.bin/oxlint tests/bug-test.ts 
Found 0 warnings and 0 errors.
Finished in 4ms on 1 file using 10 threads.

Metadata

Metadata

Assignees

No one assigned

    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