-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
feat(linter): Support plugins
array in config
#5046
Labels
Milestone
Comments
DonIsaac
added
C-enhancement
Category - New feature or request
A-linter
Area - Linter
labels
Aug 21, 2024
This was referenced Aug 22, 2024
Boshen
pushed a commit
that referenced
this issue
Aug 23, 2024
DonIsaac
added a commit
that referenced
this issue
Aug 23, 2024
DonIsaac
added a commit
that referenced
this issue
Oct 10, 2024
> Closes #5046 This PR migrates the linter crate and oxlint app to use the new `LinterBuilder` API. This PR has the following effects: 1. `plugins` in oxlint config files are now supported 2. irons out weirdness when using CLI args and config files together. CLI args are now always applied on top of config file settings, overriding them. # Breaking Changes Before, config files would override rules set in CLI arguments. For example, running this command: ```sh oxlint -A correctness -c oxlintrc.json ``` With this config file ```jsonc // oxlintrc.json { "rules": { "no-const-assign": "error" } } ``` Would result in a single rule, `no-const-assign` being turned on at an error level with all other rules disabled (i.e. set to "allow"). Now, **CLI arguments will override config files**. That same command with the same config file will result with **all rules being disabled**. ## Details For a more in-depth explanation, assume we are running the below command using the `oxlintrc.json` file above: ```sh oxlint -A all -W correctness -A all -W suspicious -c oxlintrc.json ``` ### Before > Note: GitHub doesn't seem to like deeply nested lists. Apologies for the formatting. Here was the config resolution process _before_ this PR: <details><summary>Before Steps</summary> 1. Start with a default set of filters (["correctness", "warn"]) if no filters were passed to the CLI. Since some were, the filter list starts out empty. 2. Apply each filter taken from the CLI from left to right. When a filter allows a rule or category, it clears the configured set of rules. So applying those filters looks like this a. start with an empty list `[]` b. `("all", "allow")` -> `[]` c. `("correctness", "warn")` -> `[ <correctness rules> ]` d. `("all", "allow")` -> `[]` e. `("suspicious", "warn")` -> `[ <suspicious rules> ]`. This is the final rule set for this step 3. Apply overrides from `oxlintrc.json`. This is where things get a little funky, as mentioned in point 2 of what this PR does. At this point, all rules in the rules list are only from the CLI. a. If a rule is only set in the CLI and is not present in the config file, there's no effect b. If a rule is in the config file but not the CLI, it gets inserted into the list. c. If a rule is already in the list and in the config file i. If the rule is only present once (e.g. `"no-loss-of-precision": "error"`), unconditionally override whatever was in the CLI with what was set in the config file ii. If the rule is present twice (e.g. `"no-loss-of-precision": "off", "@typescript-eslint/no-loss-of-precision": "error"`), a. if all rules in the config file are set to `allow`, then turn the rule off b. If one of them is `warn` or `deny`, then update the currently-set rule's config object, but _leave its severity alone_. So, for our example, the final rule set would be `[<all suspicious rules: "warn">, no-const-assign: "error"]` </details> ### After Rule filters were completely re-worked in a previous PR. Now, lint filters aren't kept on hand-only the rule list is. <details><summary>After Steps</summary> 1. Start with the default rule set, which is all correctness rules for all enabled plugins (`[<all correctness rules: "warn">]`) 2. Apply configuration from `oxlintrc.json` _first_. a. If the rule is warn/deny exists in the list already, update its severity and config object. If it's not in the list, add it. b. If the rule is set to allow, remove it from the list. The list is now `[<all correctness rules except no-const-assign: "warn">, no-const-assign: "error"]`. 3. Apply each filter taken from the CLI from left to right. This works the same way as before. So, after they're applied, the list is now `[<suspicous rules: "warn">]` </details>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Support
config.plugins
in.oxlintrc.json
.Acceptance Criteria
typescript-eslint
should be handled flexibly. Both@typescript-eslint
andtypescript-eslint
should be acceptable values.The text was updated successfully, but these errors were encountered: