Add --parent-config command-line option#6768
Open
tsushanth wants to merge 2 commits into
Open
Conversation
Closes realm#5421. Adds a `--parent-config` option to the `lint` and `analyze` commands that injects parent configuration paths at the command line, equivalent to declaring `parent_config:` inside the resolved config. This lets the parent path be supplied dynamically (e.g. when it lives in a temporary directory whose location isn't known when the child config is authored) without forcing the child config to be rewritten. The new option threads through: - `LintOrAnalyzeArguments.parentConfig` ([URL]) - `LintOrAnalyzeOptions.parentConfigurationFiles` - `Configuration.init(configurationFiles:parentConfigurationFiles:...)` - `Configuration.FileGraph.init(commandLineChildConfigs:commandLineParentConfigs:...)` In the file graph, each `--parent-config` vertex becomes a parent of the first `--config` vertex (or of the default `.swiftlint.yml` when no `--config` is provided). Existing `parent_config:` resolution inside YAML configs is unchanged.
Generated by 🚫 Danger |
Covers the new `parentConfigurationFiles` argument plumbed through `Configuration.init` and `FileGraph.init`. Asserts that supplying the parent config via the command line produces the same merged configuration as declaring `parent_config:` inside the child config itself, and that both equal the pre-merged expected output. Fixture lives under `Tests/FileSystemAccessTests/Resources/ProjectMock/ParentConfig/CommandLine/` with `child.yml`, `parent.yml`, `main_with_inline_parent.yml`, and `expected.yml`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Closes #5421.
The `parent_config:` entry inside a SwiftLint configuration file lets a project chain a parent ruleset, but the path has to be baked into the child config file at authoring time. The issue describes the case where the parent config lives in a temporary directory whose path is only known at lint time — pulled from a remote, generated by a script, etc. — and the child config can't reasonably hard-code it.
What
Adds `--parent-config ` to both `lint` and `analyze`. Equivalent to declaring `parent_config:` inside the resolved config, but supplied at the command line so the parent path can be passed in dynamically. Can be repeated to layer multiple parent configurations.
```bash
swiftlint --parent-config /tmp/pulled/shared.yml --config .swiftlint.yml
```
In the file graph, each `--parent-config` vertex becomes a parent of the first `--config` vertex (or of the default `.swiftlint.yml` when no `--config` is provided). Existing `parent_config:` resolution inside YAML configs is unchanged.
The option threads through:
8 files, ~57 LOC. Cache identifier now includes the parent-config list so configurations with different parent paths don't collide.
Compat
Tests
`swift build` is clean. Happy to add a fixture-based test exercising the parent-config injection (likely in `Tests/SwiftLintFrameworkTests/ConfigurationTests/`) if you'd like — pointing me at the right existing test as the template would help.