Skip to content

linter: Nested configuration rules are not detected in subdirectories #10156

@zubhav

Description

@zubhav

While using nested configurations, there is an issue which is causing Oxlint CLI to bypass rules in nested directories.

├── .oxlintrc.json
├── packageA
│   ├── .oxlintrc.json
│   └── src
│       └── helpers.js
├── packageB
│   ├── .oxlintrc.json
│   └── helpers.js

In the example above, we have two nested configs.

  • packageA has a src directory with a file nested inside it. Lint configuration is at top-level.
  • packageB has a file which is adjacent to the lint configuration.

If the root config contains a rule no-console: warn, and a nested configuration has no-console: off, the rule is still applied in the nested directory when running the Oxlint CLI command. This only happens when files are nested within a subdirectory relative to the configuration file. The functionality works as expected if the subject file is located adjacently to .oxlintrc.json

The expected behaviour is that the rule should be turned off in the nested directory since there is a nested .oxlintrc.json file present.

This only applies to the Oxlint CLI. In the language server, it appears that the nested configuration is behaving correctly as the warning does disappear when the rule is turned off.

I've produced a minimal reproducible example of the issue in this project - https://github.com/zubhav/oxlint-nested-config-issue-example

  1. Clone project and run yarn
  2. Run yarn lint

Output is:

  ⚠ eslint(no-console): eslint(no-console): Unexpected console statement.
   ╭─[packageA/src/helpers.js:1:1]
 1 │ console.log("Hello from packageA");
   · ───────────
   ╰────
  help: Delete this console statement.

Found 1 warning and 0 errors.
  1. Based on the output above, the nested configuration in packageA is not being used to lint files within subdirectories of packageA. The expected behaviour is that running yarn lint will output no warnings at all, since the rule is turned off in all nested configurations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions