Skip to content

feat(oxfmt): .js/.ts config file support#20135

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-09-feat_oxfmt_.js_.ts_config_file_support
Mar 11, 2026
Merged

feat(oxfmt): .js/.ts config file support#20135
graphite-app[bot] merged 1 commit intomainfrom
03-09-feat_oxfmt_.js_.ts_config_file_support

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Mar 9, 2026

Fixes #19711, also resolves some of the demands for nested configs.

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 changes, fast-track this PR to the front of the merge queue

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 A-cli Area - CLI A-formatter Area - Formatter C-enhancement Category - New feature or request labels Mar 9, 2026
@leaysgur leaysgur force-pushed the 03-09-feat_oxfmt_.js_.ts_config_file_support branch 4 times, most recently from 37d2b76 to f7f8894 Compare March 9, 2026 05:04
@leaysgur leaysgur force-pushed the 03-09-feat_oxfmt_.js_.ts_config_file_support branch from f7f8894 to dcf7c16 Compare March 9, 2026 05:45
@leaysgur leaysgur marked this pull request as ready for review March 9, 2026 05:47
Copilot AI review requested due to automatic review settings March 9, 2026 05:47
@leaysgur leaysgur force-pushed the 03-09-feat_oxfmt_.js_.ts_config_file_support branch from dcf7c16 to ebafbbf Compare March 9, 2026 05:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds dynamic JS/TS configuration file support to oxfmt (similar to oxlint), enabling oxfmt.config.{ts,mts,cts,js,mjs,cjs} to be discovered/loaded (via Node/NAPI) across CLI, stdin, and LSP flows.

Changes:

  • Add config discovery support for oxfmt.config.* and pass a JS config loader callback through NAPI into Rust config resolution.
  • Add defineConfig() to the JS API for typed config authoring, plus CLI/LSP/API tests and fixtures.
  • Update LSP watch patterns and CLI config tests/snapshots to account for new config file types.

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
apps/oxfmt/test/lsp/init/init.test.ts Updates LSP config watch patterns to include JS/TS config filenames.
apps/oxfmt/test/lsp/format/format.test.ts Adds fixtures/tests for applying JS/TS configs and explicit fmt.configPath with TS config.
apps/oxfmt/test/lsp/format/fixtures/custom_config_path_js/semicolons-as-needed.ts Fixture for explicit TS config path formatting behavior.
apps/oxfmt/test/lsp/format/fixtures/custom_config_path_js/format.config.ts Fixture TS config used via fmt.configPath.
apps/oxfmt/test/lsp/format/fixtures/config-js-semi/test.ts Fixture verifying oxfmt.config.ts is picked up.
apps/oxfmt/test/lsp/format/fixtures/config-js-semi/oxfmt.config.ts Fixture TS config for LSP formatting tests.
apps/oxfmt/test/lsp/format/snapshots/format.test.ts.snap Snapshot updates for new LSP config behaviors.
apps/oxfmt/test/cli/js_config/js_config.test.ts New CLI integration tests for JS/TS config loading and error cases.
apps/oxfmt/test/cli/js_config/fixtures/priority/test.ts Fixture for precedence behavior (JSON vs JS/TS config).
apps/oxfmt/test/cli/js_config/fixtures/priority/oxfmt.config.ts Fixture TS config (lower priority than JSON).
apps/oxfmt/test/cli/js_config/fixtures/priority/.oxfmtrc.json Fixture JSON config (higher priority).
apps/oxfmt/test/cli/js_config/fixtures/error_not_object/test.ts Fixture for “default export not object” error.
apps/oxfmt/test/cli/js_config/fixtures/error_not_object/oxfmt.config.ts Fixture TS config exporting non-object.
apps/oxfmt/test/cli/js_config/fixtures/error_no_default/test.ts Fixture for “no default export” error.
apps/oxfmt/test/cli/js_config/fixtures/error_no_default/oxfmt.config.ts Fixture TS config without default export.
apps/oxfmt/test/cli/js_config/fixtures/basic/test.ts Basic fixture for loading TS config.
apps/oxfmt/test/cli/js_config/fixtures/basic/oxfmt.config.ts Basic TS config fixture.
apps/oxfmt/test/cli/js_config/snapshots/js_config.test.ts.snap Snapshots for CLI JS/TS config cases.
apps/oxfmt/test/cli/config_file/fixtures/fmt.config.ts Adds TS config fixture for --config path.
apps/oxfmt/test/cli/config_file/config_file.test.ts Updates config-file tests to include TS config and to exclude .ts from check globs.
apps/oxfmt/test/cli/config_file/snapshots/config_file.test.ts.snap Snapshot updates for config-file tests.
apps/oxfmt/test/api/basic.test.ts Adds defineConfig() API coverage in the JS API tests.
apps/oxfmt/src/stdin/mod.rs Plumbs JS config loader into stdin formatting config resolution.
apps/oxfmt/src/main_napi.rs Extends NAPI run_cli to accept a JS config loader callback and propagate it to all modes.
apps/oxfmt/src/lsp/server_formatter.rs Adds JS/TS config files to LSP watch patterns; uses unified config resolver that supports JS/TS configs.
apps/oxfmt/src/lsp/mod.rs Updates LSP entrypoint to accept/pass JS config loader.
apps/oxfmt/src/core/mod.rs Exposes JS config loader types and config filename lists under the napi feature.
apps/oxfmt/src/core/js_config.rs Adds NAPI-based JS/TS config loader wrapper for Rust codepaths.
apps/oxfmt/src/core/config.rs Adds discovery of oxfmt.config.* and unified ConfigResolver::from_config supporting JS/TS configs (NAPI) and JSON/JSONC.
apps/oxfmt/src/cli/format.rs Plumbs optional JS config loader into CLI config resolution (NAPI build).
apps/oxfmt/src/cli/command.rs Updates CLI help text to document supported config extensions.
apps/oxfmt/src-js/index.ts Adds defineConfig() helper with type inference for configs.
apps/oxfmt/src-js/cli/js_config.ts Implements Node-side loader using dynamic import() with cache-busting.
apps/oxfmt/src-js/cli.ts Passes JS config loader callback into NAPI runCli.
apps/oxfmt/src-js/bindings.js Updates generated bindings exports/destructuring to match native exports.
apps/oxfmt/src-js/bindings.d.ts Updates generated typings for changed runCli signature.

You can also share your feedback on Copilot code review. Take the survey.

@leaysgur leaysgur force-pushed the 03-09-feat_oxfmt_.js_.ts_config_file_support branch 2 times, most recently from ee283ec to b0ff1a0 Compare March 9, 2026 06:26
@leaysgur leaysgur requested a review from Dunqing March 9, 2026 08:10
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leaysgur should we share this logic between oxlint/oxfmt rather than duplicating it?

@leaysgur
Copy link
Member Author

leaysgur commented Mar 9, 2026

If it's just about the part that calls js to resolve config, I feel that standardizing it would probably increase maintenance costs?

We might need to look at it from a broader scope, but our CLI differ the supported features (such as .editorconfig, how walk through dirs, etc) and the behavior isn't strictly consistent, I'm not sure how exactly we should compromise. 😓

@camc314
Copy link
Contributor

camc314 commented Mar 9, 2026

Fixes #19711, also resolves some of the demands for nested configs.

I didn't really look at the code, but it sounds like you've also added nested config support?

I think we should share this + implement a trait for oxfmt/oxlint for the parts that need specialisation

@leaysgur
Copy link
Member Author

leaysgur commented Mar 9, 2026

Ah, no, that's not yet. (Personally, I'm not sure if it should be supported or not. And if it becomes necessary, as you said, I will definitely start by standardizing the implementation…)

It meant that user can now refer to common/shared settings without nesting. 👌🏻

@leaysgur leaysgur force-pushed the 03-09-feat_oxfmt_.js_.ts_config_file_support branch 2 times, most recently from 7f1696f to 6a74e82 Compare March 10, 2026 13:39
@leaysgur leaysgur force-pushed the 03-09-feat_oxfmt_.js_.ts_config_file_support branch from 6a74e82 to 49e7843 Compare March 11, 2026 02:22
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 11, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 11, 2026

Merge activity

Fixes #19711, also resolves some of the demands for nested configs.
@graphite-app graphite-app bot force-pushed the 03-09-feat_oxfmt_.js_.ts_config_file_support branch from 49e7843 to 172fc07 Compare March 11, 2026 04:34
@graphite-app graphite-app bot merged commit 172fc07 into main Mar 11, 2026
19 checks passed
@graphite-app graphite-app bot deleted the 03-09-feat_oxfmt_.js_.ts_config_file_support branch March 11, 2026 04:45
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 11, 2026
leaysgur added a commit that referenced this pull request Mar 11, 2026
# Oxlint
### 🚀 Features

- 04a5ce0 oxlint: Support `vite.config.ts` `.lint` field (#20214)
(leaysgur)
- 1735215 linter: Implement `react/no-clone-element` rule. (#20129)
(connorshea)
- 68e6f6f linter: Implement `react/no-react-children` rule. (#20104)
(connorshea)
- fe3b32e linter/plugins: Add `oxlint-plugin-eslint` package (#20009)
(overlookmotel)

### 🐛 Bug Fixes

- 05f6a09 linter/no-inline-comments: Deserialize rule options with serde
(#20207) (camc314)
- c7eb09d linter/default-case: Deserialize rule options with serde
(#20206) (camc314)
- f85e16c linter/plugins: Fix types for visitor compilation (#20203)
(overlookmotel)
- 44e24e0 linter/exhaustive-deps: Ignore type-only typeof deps (#20201)
(camc314)
- 0b04998 linter/no-fallthrough: Deserialize rule options with serde
(#20192) (camc314)
- a1031cb linter/new-cap: Deserialize rule options with serde (#20161)
(camc314)
- ad27fd6 linter: Add help messages to import plugin diagnostics
(#20158) (John Costa)
- 1340307 linter/plugins: Ensure `after` hooks always run (#20167)
(overlookmotel)
- c4812ec linter/plugins: Reset visitor compilation state if error
during compilation (#20166) (overlookmotel)
- 887eecc linter/plugins: Add license notice to `oxlint-plugin-eslint`
package (#20164) (overlookmotel)
- e1713a4 linter/plugins: Include common chunks in
`oxlint-plugin-eslint` package (#20163) (overlookmotel)
- a9acb2b linter: Check `globals` entry for `no-undef`, only check
es2026 globals for `no-extend-native` and
`no-constant-binary-expression` (#20089) (Sysix)
- 5559f0d linter/no-unused-vars: `reportUsedIgnorePattern` should not
report used rest siblings (#20108) (Don Isaac)
- de7c0e2 linter/plugins: Correct error message for `markVariableAsUsed`
(#20152) (overlookmotel)

### ⚡ Performance

- 3a86427 linter/plugins: Pre-populate cache of `EnterExit` objects at
startup (#20194) (overlookmotel)
- d243391 linter/plugins: Replace arrays with `Uint8Array`s (#20190)
(overlookmotel)
- 8742f8b linter/plugins: Pre-populate cache of `VisitProp` objects
(#20189) (overlookmotel)
- 3061acb linter/plugins: Pre-populate cache of `EnterExit` objects
(#20187) (overlookmotel)
- c73912b linter/plugins: Free visit functions earlier (#20186)
(overlookmotel)
- d9f8ff4 linter/plugins: Faster reset of visitor state (#20185)
(overlookmotel)
- 42aff15 oxlint/lsp: Avoid computing diagnostics for non invoked code
actions requests (#20080) (Sysix)

### 📚 Documentation

- a080650 linter/plugins: Fix documentation of visitor compilation
(#20202) (overlookmotel)
- 542a04a linter: Add a link to the cyclomatic complexity Wikipedia
article in `eslint/complexity` (#20174) (connorshea)
# Oxfmt
### 🚀 Features

- 95943aa oxfmt: Support `vite.config.*` `.fmt` field (#20197)
(leaysgur)
- 172fc07 oxfmt: .js/.ts config file support (#20135) (leaysgur)

### 🐛 Bug Fixes

- e483569 oxfmt: Avoid double-escaping in css-in-js (#20211) (leaysgur)

Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oxfmt: dynamic config file support (oxfmt.config.ts)

4 participants