Command-line option to disable merging of nested configurations#2245
Command-line option to disable merging of nested configurations#2245aksvenk wants to merge 5 commits intorealm:masterfrom
Conversation
Note: The `mergeNestedFlags` command-line option is registered on the `root` config only. Nested configurations other than root will not have this value set.
Generated by 🚫 Danger |
Codecov Report
@@ Coverage Diff @@
## master #2245 +/- ##
=========================================
- Coverage 92.13% 92.1% -0.04%
=========================================
Files 285 285
Lines 14475 14486 +11
=========================================
+ Hits 13337 13342 +5
- Misses 1138 1144 +6
Continue to review full report at Codecov.
|
|
Thanks for the PR here and sorry for not reviewing sooner. I definitely see the value of disconnecting a nested configuration file from its parents. However, I still think it's useful to make this decision on a per-configuration basis rather than based on the invocation of swiftlint. Besides, I think a useful property of SwiftLint configurations is that you can go to any Swift project that has properly configured SwiftLint and run So instead of a CLI flag, how about we add a Configuration key like What do you think? |
|
@Dschee sorry about the delay. @jpsim I get your point, it is heaps more elegant to stop nesting through configuration than command-line arguments. We do gain the capability of locking in a configuration to "what the author intended" on third party code while keeping the nesting behaviour of the subdirectories untouched. The initial reasoning behind the command-line parameter was to provide this feature instantly to projects that don't have control over code that they nest, but I do agree it is a jackhammer approach. I'm happy to close this and open another PR with the configuration file based flag. Do you think it is worth somehow showing the user where the merging of configurations was terminated in each path so as to avoid confusions about rules not being picked up in configurations "outside the root". Or does this feature already exist? |
This PR adds an option to disable merging configurations in nested folders.
Usage:
swiftlint lint --disable-nested-config-mergeMotivation
Sometimes nested configurations in a project may have vastly different rules from the parent.
The current strategy of always merging nested configs might not cut it in the above case. The nested configs would inherit rules that are not expected from the parent.
Solution
A command-line flag has been added to disable merging of nested configurations. When the said flag is used, nested configurations are 'disconnected' from the parent and the rule-sets are not merged.
Potential use-case
The change in the project structure below:
swiftlintcommand fromProject A's root folder