-
-
Notifications
You must be signed in to change notification settings - Fork 726
feat(linter): Follow-up to config extends fixes #15818
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
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refines the configuration merging logic for Oxlintrc files, improving clarity around merge priority and eliminating unnecessary clones for better performance. The changes follow up on previous config extends fixes (#14939).
Key Changes:
- Improved documentation for the
mergemethod to clearly explain merge priority - Changed
mergemethod signature to take ownership ofotherparameter instead of borrowing - Added comprehensive test coverage for extends order precedence
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_linter/src/config/oxlintrc.rs | Enhanced documentation and optimized merge method to take ownership of other parameter |
| crates/oxc_linter/src/config/config_builder.rs | Updated merge call site and added test for extends array precedence |
| crates/oxc_linter/fixtures/extends_config/rules_multiple/extends_order_test.json | Added test fixture for validating extends order behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #15818 will not alter performanceComparing Summary
Footnotes
|
ea2de9c to
b785dac
Compare
overlookmotel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff. Sorry to come back with more suggestions.
Since you've done the work of fixing the problem, I think it's ideal to make this new correct implementation as clear as possible, to make sure it's used correctly and that we don't accidentally break it again!
| // This test uses fixtures that set the same rule to different values: | ||
| // - allow_all.json: sets "no-console" to "off" | ||
| // - warn_all.json: sets "no-console" to "warn" | ||
| // - deny_all.json: sets "no-console" to "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text fixture does make sure that the last wins over the first 2. But it'd be ideal to also check all the other combinations (including no clashes). Something like:
// first.json
{
"rules": { "rule_A": "off", "rule_C": "off", "rule_D": "off", "rule_G": "off" }
}// second.json
{
"rules": { "rule_A": "warn", "rule_B": "warn", "rule_D": "warn", "rule_F": "warn" }
}// third.json
{
"rules": { "rule_A": "error", "rule_B": "error", "rule_C": "error", "rule_E": "error" }
}// main.json
{
"extends": [
"./first.json",
"./second.json",
"./third.json"
]
}Merged config should be equivalent to:
{
"rules": {
"rule_A": "error", // `third` wins over both `first` and `second`
"rule_B": "error", // `third` wins over `second`
"rule_C": "error", // `third` wins over `first`
"rule_D": "warn", // `second` wins over `first`
"rule_E": "error", // `third` wins when no clash
"rule_F": "warn", // `second` wins when no clash
"rule_G": "off", // `first` wins when no clash
},
}That's rather convoluted, but since we're trying to fix this for once and for all, I think it's worthwhile covering all cases.
| /// // base.json: { "rules": { "eqeqeq": "error" } } | ||
| /// // current.json: { "rules": { "eqeqeq": "warn", "no-console": "error" } } | ||
| /// // After merge: { "rules": { "eqeqeq": "warn", "no-console": "error" } } | ||
| /// // ^ current.json's "warn" wins over base.json's "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would clarify which is which:
| /// // base.json: { "rules": { "eqeqeq": "error" } } | |
| /// // current.json: { "rules": { "eqeqeq": "warn", "no-console": "error" } } | |
| /// // After merge: { "rules": { "eqeqeq": "warn", "no-console": "error" } } | |
| /// // ^ current.json's "warn" wins over base.json's "error" | |
| /// // self.json: { "rules": { "eqeqeq": "error", "no-debugger": "error" } } | |
| /// // other.json: { "rules": { "eqeqeq": "warn", "no-console": "warn" } } | |
| /// // After merge: { "rules": { "eqeqeq": "error", "no-debugger": "error", "no-console": "warn" } } | |
| /// // ^ self.json's "error" for `eqeqeq` wins over other.json's "warn" |
| #[must_use] | ||
| pub fn merge(&self, other: &Oxlintrc) -> Oxlintrc { | ||
| let mut categories = other.categories.clone(); | ||
| pub fn merge(&self, other: Oxlintrc) -> Oxlintrc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we rename this method to merge_onto? self.merge_onto(other) I think makes it clearer at the call site that self takes priority.
Follow up to #14939.