Skip to content

feat(oxlint): Add --config-field CLI option#20139

Closed
leaysgur wants to merge 2 commits intomainfrom
03-09-feat_oxlint_add_--config-field_cli_option
Closed

feat(oxlint): Add --config-field CLI option#20139
leaysgur wants to merge 2 commits intomainfrom
03-09-feat_oxlint_add_--config-field_cli_option

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Mar 9, 2026

The same as #20138

However, I believe what can be done with my agent can also be done with yours, so feel free to close this PR. 🙏🏻 (There are no tests either and also failing...)

Prompts
## Task

Add `--config-field` CLI option to oxlint, mirroring the implementation in oxfmt (PR #20138).

This option lets users specify a top-level key to extract from the config object before deserializing into `Oxlintrc`. For example: `oxlint --config shared.json --config-field linter`.

## Requirements

- `--config-field` requires `--config` to be specified (use `bpaf` guard validation)
- Field extraction must happen at the `serde_json::Value` stage, before `Oxlintrc` deserialization (because `Oxlintrc` uses `#[serde(deny_unknown_fields)]`)
- Must work for both JSON/JSONC and JS/TS config files
- JSON and JS/TS paths must extract the field at the same layer (`config_loader.rs`), not at different stages

## Key design

Split `Oxlintrc::from_file` into `read_to_json_value` + `from_value` so callers can insert field extraction between reading and deserializing.

Change `JsConfigLoaderCb` to return raw `serde_json::Value` (`JsRawConfigResult`) instead of deserialized `Oxlintrc`, so `config_loader.rs` can uniformly apply field extraction for both config types.

Add a shared `extract_config_field(value, field, path)` helper in `config_loader.rs`.

## Files to modify

- `crates/oxc_linter/src/config/oxlintrc.rs` -- split `from_file` into `read_to_json_value` + `from_value`
- `apps/oxlint/src/command/lint.rs` -- add `--config-field` option with guard
- `apps/oxlint/src/js_config.rs` -- change callback to return raw values, extract `deserialize_js_config`
- `apps/oxlint/src/config_loader.rs` -- add `extract_config_field`, `load_with_field`, thread `config_field` through loading methods
- `apps/oxlint/src/lint.rs` -- pass `config_field` to loader
- `apps/oxlint/src/lsp/options.rs` -- add `configField` option
- `apps/oxlint/src/lsp/server_linter.rs` -- pass `config_field`, add to `needs_restart`
- `crates/oxc_language_server/README.md` -- document `configField` in table and JSON examples

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-editor Area - Editor and Language Server labels Mar 9, 2026
Copy link
Member Author

leaysgur commented Mar 9, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Mar 9, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 9, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 52 skipped benchmarks1


Comparing 03-09-feat_oxlint_add_--config-field_cli_option (98dfa42) with main (36b2e56)

Open in CodSpeed

Footnotes

  1. 52 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@leaysgur leaysgur changed the title feat(oxlint): Add --config-field CLI option feat(oxlint): Add --config-field CLI option Mar 9, 2026
@leaysgur
Copy link
Member Author

We've decided to take a different approach, so closing.

@leaysgur leaysgur closed this Mar 10, 2026
@leaysgur leaysgur deleted the 03-09-feat_oxlint_add_--config-field_cli_option branch March 10, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-editor Area - Editor and Language Server A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant