-
-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linter: nested file configuration #7408
Comments
I did a bit of testing and thinking on this today. As it stands, these are my current thoughts on what we need to implement.
|
This is a brief informal description of the nested file configuration specification for oxlint. It is primarily based on ESLint, but with some inspiration taken from the https://docs.astral.sh/ruff/configuration/#config-file-discovery as well. This should be documented officially on the website later DecisionsThese are the main decisions / important points:
ContextIn large monorepositories (repositories containing multiple packages/projects), it is convenient for each project to have its own configuration files, rather than having a single shared file. This makes it easy to clone or work out of just a subdirectory and treat it as its own independent project. This means that each project directory should have its own
However, it is not possible to lint the entire Resolving configuration filesIn ESLint, configuration files are resolved by using the file in the current directory or nearest parent directory as the base configuration file, and then subsequently merging that with each file in each parent directory, up to the root directory. The base configuration file takes precedence over any parent configurations. However, this can create situations where you have more rules enabled than you want, such as rules that shouldn't apply for test files, or rules for packages you aren't using in a subdirectory. ESLint solves this by supporting adding a In oxlint, we will not automatically search upwards in the file hierarchy for configuration files. We will only use the closest configuration file to the file currently being linted. Every configuration file will essentially be treated as if it already contained In priority order, the "nearest" configuration should be defined as:
However, not automatically merging configuration files means that it becomes harder to share configuration across directories. So, we need to define a way to share lint configurations. Extending configuration filesIn ESLint, the Oxlint will also support the
The configuration file paths are resolved relative to the base configuration file. When extending other files, some general rules apply:
Other details and contextHow are CLI arguments resolved?In general, CLI arguments take precedence over the final resolved configuration. For example, if the What is the precedence of configuration resolution?This is a list of the general precedence of configuration, in order from highest precedence to lowest:
How does
|
It would be nice if Oxlint could provide a migration program to convert YAML configuration(or other) files to JSON |
Hi, First off, I want to express how much I appreciate the thought and effort that went into making this decision. It's great to see the structured approach taken here! I do, however, have a few pieces of feedback that I think could help refine the priority order for configuration resolution: 1. Priority Order AdjustmentYou’ve mentioned the priority order as follows:
Based on my experience with mono-repos across many organizations, I’d suggest adjusting this order. Specifically, I recommend prioritizing the current working directory (CWD) configuration after The reason is that in large mono-repos, it's common to run scripts from the root of the repository that are meant to target specific sub-projects. If the root config takes precedence, it can unintentionally override the configuration intended for a specific project. For instance, when using tools like Bit, the CWD is often the root, but the script is executed for a sub-project. In such cases, prioritizing the CWD would lead to the scenario you’ve mentioned: “more rules enabled than desired.” 2. Explicit Configuration (
|
@GiladShoham Thanks for the feedback, I've updated the post with some extra details, but I'll try to add more in the future as well with more clarifications. I'm going to try and get started on implementing this.
This was a mistake on my part, I wrote down the list incorrectly. I agree that the root directory should be a lower priority than a config file in a subdirectory. I've updated the precedence list.
Agreed, I added a clarification on this, as well as a more general list of precedence in configuration. |
This is the tracking issue for nested file configuration in oxlint.
The text was updated successfully, but these errors were encountered: