Skip to content

fix(linter): preserve rule options from extends in --print-config#22276

Open
kimjune01 wants to merge 1 commit into
oxc-project:mainfrom
kimjune01:fix/print-config-extends-options
Open

fix(linter): preserve rule options from extends in --print-config#22276
kimjune01 wants to merge 1 commit into
oxc-project:mainfrom
kimjune01:fix/print-config-extends-options

Conversation

@kimjune01
Copy link
Copy Markdown

Closes #22230.

When using object-form extends in oxlint.config.ts, rule options from extended configs were silently dropped by --print-config. The resolved rules were correct, but resolve_final_config_file only serialized the root Oxlintrc, which doesn't contain options inherited through extends.

This stores the merged Oxlintrc produced by from_oxlintrc and uses it instead of the un-merged root config when printing. A regression fixture covers the case where base.ts defines getter-return and no-console with options, and the root config extends it.

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}]]
```
@camc314 camc314 added the A-linter Area - Linter label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: rule options are dropped from --print-config when using object-form extends in oxlint.config.ts

2 participants