-
-
Notifications
You must be signed in to change notification settings - Fork 727
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "extends": [ | ||
| "./allow_all.json", | ||
| "./warn_all.json", | ||
| "./deny_all.json" | ||
| ] | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -215,11 +215,22 @@ impl Oxlintrc { | |||||||||||||||||
| serde_json::to_string_pretty(&schema).unwrap() | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /// Merges two [Oxlintrc] files together | ||||||||||||||||||
| /// [Self] takes priority over `other` | ||||||||||||||||||
| /// Merges two [Oxlintrc] files together. | ||||||||||||||||||
| /// | ||||||||||||||||||
| /// `self` takes priority over `other` - when both configs have the same property, | ||||||||||||||||||
| /// `self`'s value will be used in the merged result. | ||||||||||||||||||
| /// | ||||||||||||||||||
| /// # Example | ||||||||||||||||||
| /// | ||||||||||||||||||
| /// ```text | ||||||||||||||||||
| /// // 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" | ||||||||||||||||||
|
Comment on lines
+226
to
+229
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would clarify which is which:
Suggested change
|
||||||||||||||||||
| /// ``` | ||||||||||||||||||
| #[must_use] | ||||||||||||||||||
| pub fn merge(&self, other: &Oxlintrc) -> Oxlintrc { | ||||||||||||||||||
| let mut categories = other.categories.clone(); | ||||||||||||||||||
| pub fn merge(&self, other: Oxlintrc) -> Oxlintrc { | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we rename this method to |
||||||||||||||||||
| let mut categories = other.categories; | ||||||||||||||||||
| categories.extend(self.categories.iter()); | ||||||||||||||||||
|
|
||||||||||||||||||
| let rules = self | ||||||||||||||||||
|
|
@@ -242,7 +253,7 @@ impl Oxlintrc { | |||||||||||||||||
| let env = self.env.clone(); | ||||||||||||||||||
| let globals = self.globals.clone(); | ||||||||||||||||||
|
|
||||||||||||||||||
| let mut overrides = other.overrides.clone(); | ||||||||||||||||||
| let mut overrides = other.overrides; | ||||||||||||||||||
| overrides.extend(self.overrides.clone()); | ||||||||||||||||||
|
|
||||||||||||||||||
| let plugins = match (self.plugins, other.plugins) { | ||||||||||||||||||
|
|
||||||||||||||||||
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:
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.