fix(linter): preserve rule options from extends in --print-config#22276
Open
kimjune01 wants to merge 1 commit into
Open
fix(linter): preserve rule options from extends in --print-config#22276kimjune01 wants to merge 1 commit into
kimjune01 wants to merge 1 commit into
Conversation
Fixes oxc-project#22230 ## Problem When `--print-config` is used with a config that inherits rules via `extends` (object-form or path-form), rule severities are correctly merged into the printed output, but per-rule options are silently dropped. This occurs because `resolve_final_config_file` builds the printed `rules` map by zipping severities from `self.rules` (the merged builder state) with option arrays looked up from the `oxlintrc` parameter — which is the un-merged root config passed from `apps/oxlint/src/lint.rs:303`. Rules inherited through `extends` only exist in the merged config (produced internally by `from_oxlintrc`), so the lookup fails and `unwrap_or_default()` substitutes empty options. Runtime linting is unaffected because `from_configuration` bakes the merged options into `RuleEnum` instances. The bug is specific to `--print-config`. ## Solution Store the merged `Oxlintrc` (from `resolve_oxlintrc_config`) in `ConfigStoreBuilder` and use it in `resolve_final_config_file` instead of the un-merged root config. This preserves rule options from all extends (both object-form and path-form). ## Test plan Added test fixture `print_config_extends_with_options` demonstrating object-form extends with rule options. The fixture will pass once CI generates the correct snapshot showing options preserved. Manual verification: ```bash # Create test config with path-based extends echo '{"rules": {"getter-return": ["error", {"allowImplicit": true}]}}' > rules.json echo '{"extends": ["./rules.json"]}' > .oxlintrc.json oxlint --print-config | jq '.rules."getter-return"' # Before: "deny" # After: ["deny", [{"allowImplicit": true}]] ```
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.
Closes #22230.
When using object-form
extendsinoxlint.config.ts, rule options from extended configs were silently dropped by--print-config. The resolved rules were correct, butresolve_final_config_fileonly serialized the rootOxlintrc, which doesn't contain options inherited throughextends.This stores the merged
Oxlintrcproduced byfrom_oxlintrcand uses it instead of the un-merged root config when printing. A regression fixture covers the case wherebase.tsdefinesgetter-returnandno-consolewith options, and the root config extends it.