fix(config): implement Merge for rules' options#7941
Conversation
🦋 Changeset detectedLatest commit: 2d21d2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #7941 will not alter performanceComparing Summary
Footnotes
|
bee6655 to
e152b70
Compare
dyc3
left a comment
There was a problem hiding this comment.
FWIW I think this is the better option from a UX perspective. It's the behavior I would expect as a user.
b104bb4 to
b066cb5
Compare
ematipico
left a comment
There was a problem hiding this comment.
That's a better approach, thank you. I left some suggestions regarding the docs
3977f60 to
7ce2ee9
Compare
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Summary
Fixes #7943
This is an alternative approach to #7938
Instead of wrapping
optionsin anOption, all rule options have to implementMerge.This allows to support fine-grained
optionsmerging.For example, given the following shared config:
{ "linter": { "enabled": true, "rules": { "style": { "useNamingConvention": { "level": "on", "options": { "strictCase": false, "conventions": [{ "selector": { "kind": "variable", "scope": "global" }, "formats": ["CONSTANT_CASE"] }] } } } } } }And the following user config that extends the shared one:
{ "extends": ["shared.json"], "linter": { "enabled": true, "rules": { "style": { "useNamingConvention": { "level": "on", "options": { "strictCase": true, "requireAsci": false } } } } } }We obtain the following merged config:
{ "extends": ["shared.json"], "linter": { "enabled": true, "rules": { "style": { "useNamingConvention": { "level": "on", "options": { "strictCase": true, "requireAsci": false, "conventions": [{ "selector": { "kind": "variable", "scope": "global" }, "formats": ["CONSTANT_CASE"] }] } } } } } }In contrast to
files.includes, we don't merge collections in rules'options.This means that if
conventionsis set in the user config, then it overrides theconventionsset in the shared config.Test Plan
I added two tests:
optionsDocs