Skip to content

Conversation

Sysix
Copy link
Member

@Sysix Sysix commented Oct 9, 2025

This PR implements autodetection of the root .oxfmtrc.json configuration file for the language server's formatter functionality. The language server can now automatically discover and use formatter configuration files located at the workspace root.

It does not support a custom config path, the next PR in this stack will implement it.
When a user does change the content of .oxfmtrc.json, he needs to restart the server at the moment.
Need to improve the file watcher implementation, created another stack with tests for current implementation.

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-enhancement Category - New feature or request labels Oct 9, 2025
Copy link
Member Author

Sysix commented Oct 9, 2025


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.

@Sysix Sysix changed the base branch from 10-09-refactor_oxc_formatter_oxfmtrc_into_format_options_use_self_reference to graphite-base/14466 October 9, 2025 21:11
@Sysix Sysix force-pushed the graphite-base/14466 branch from 7bcf896 to 0f19be0 Compare October 9, 2025 21:12
@Sysix Sysix force-pushed the 10-09-feat_language_server_support_root_.oxfmtrc.json_ branch from 28eed71 to 0d60bb7 Compare October 9, 2025 21:12
@Sysix Sysix changed the base branch from graphite-base/14466 to main October 9, 2025 21:12
@Sysix Sysix force-pushed the 10-09-feat_language_server_support_root_.oxfmtrc.json_ branch from 0d60bb7 to d292fd3 Compare October 11, 2025 13:10
@Sysix Sysix changed the title feat(language_server): support root .oxfmtrc.json feat(language_server): autodetect root .oxfmtrc.json Oct 11, 2025
@Sysix Sysix requested a review from Copilot October 11, 2025 22:29
Copy link
Contributor

@Copilot 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

This PR implements autodetection of the root .oxfmtrc.json configuration file for the language server's formatter functionality. The language server can now automatically discover and use formatter configuration files located at the workspace root.

  • Separated linter and formatter configuration file constants for clarity
  • Modified ServerFormatter to accept a root URI and load configuration from .oxfmtrc.json
  • Added test coverage for root configuration detection functionality

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/oxc_language_server/src/main.rs Split config constants into separate linter and formatter file names
crates/oxc_language_server/src/linter/server_linter.rs Updated to use new LINT_CONFIG_FILE constant
crates/oxc_language_server/src/linter/config_walker.rs Updated to use new LINT_CONFIG_FILE constant
crates/oxc_language_server/src/worker.rs Modified ServerFormatter::new() calls to pass root URI parameter
crates/oxc_language_server/src/formatter/server_formatter.rs Added config loading logic and changed constructor to accept root URI
crates/oxc_language_server/fixtures/formatter/root_config/.oxfmtrc.json Test fixture configuration file
crates/oxc_language_server/fixtures/formatter/root_config/semicolons-as-needed.ts Test fixture TypeScript file
crates/oxc_language_server/src/snapshots/[email protected] Test snapshot for configuration detection

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Sysix Sysix marked this pull request as ready for review October 11, 2025 22:34
@Sysix Sysix requested a review from camc314 as a code owner October 11, 2025 22:34
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Oct 12, 2025
Copy link
Contributor

camc314 commented Oct 12, 2025

Merge activity

> This PR implements autodetection of the root .oxfmtrc.json configuration file for the language server's formatter functionality. The language server can now automatically discover and use formatter configuration files located at the workspace root.

It does not support a custom config path, the next PR in this stack will implement it.
When a user does change the content of `.oxfmtrc.json`, he needs to restart the server at the moment.
Need to improve the file watcher implementation, created another stack with tests for current implementation.
@graphite-app graphite-app bot force-pushed the 10-09-feat_language_server_support_root_.oxfmtrc.json_ branch from d292fd3 to 4d3ce2e Compare October 12, 2025 10:17
@graphite-app graphite-app bot merged commit 4d3ce2e into main Oct 12, 2025
20 of 21 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 12, 2025
@graphite-app graphite-app bot deleted the 10-09-feat_language_server_support_root_.oxfmtrc.json_ branch October 12, 2025 10:20
camc314 added a commit that referenced this pull request Oct 13, 2025
## [1.23.0] - 2025-10-13

### 🚀 Features

- 452d128 linter: Node/no_process_env (#14536) (Kenneth Skovhus)
- a9e1261 linter: Implement react-refresh/only-export-components
(#14122) (Rintaro Itokawa)
- a8d542b linter/no-duplicate-imports: Support
`allowSeparateTypeImports` option (#14527) (camc314)
- 75a529c linter: Add run info about what functions rules implement
(#13839) (camchenry)
- 4fbdef2 language_server: Support `fmt.configPath` configuration
(#14502) (Sysix)
- 4d3ce2e language_server: Autodetect root `.oxfmtrc.json` (#14466)
(Sysix)

### 🐛 Bug Fixes

- fb4a20d language_server: Add whitespace for `//
oxlint-disable-next-line` fix (#14356) (Sysix)
- 6fce7f4 oxlint/changelog: Remove duplicate changelog entries (#14528)
(camc314)
- 74e52f3 linter/plugins: Resolve JS plugins with ESM condition names
(#14541) (magic-akari)
- 9965676 linter/exhaustive-deps: Ignore empty strings passed to
`additionalHooks` option (#14464) (Redas)
- d0a8e3e linter: `vue/no_required_prop_with_default` called
`Option::unwrap()` on a `None` value (#14491) (Sysix)
- 1192ea2 linter: Correct `nextjs/no-typos` path handling (#14480)
(shulaoda)
- 2796b16 tsgolint: Pipe tsgolints stderr (#14477) (camc314)

### 🚜 Refactor

- 6440cde linter: Remove lifetime of `Message` (#14481) (Sysix)
- f599bef language_server: Move `Message` to `DiagnosticReport`
transformation to one place (#14447) (Sysix)
- 4f301de napi/parser, linter/plugins: Improve formatting of generated
code (#14554) (overlookmotel)
- 68c0252 napi/parser, linter/plugins: Shorten generated raw transfer
deserializer code (#14553) (overlookmotel)
- 20e884e linter: Store `LintService` in `LintRunner` (#14471) (Sysix)
- 9e9c5ba linter: Simplify built-in lint plugin checks (#14518)
(camchenry)
- 1986e0f linter/no-ex-assign: Use let-else chain (#14526) (camc314)
- ce9bcf0 linter/no-func-assign: Use let-else chain (#14525) (camc314)
- a9cea7c language_server: Use `FxHashSet` for
`ServerLinter::extended_paths` (#14517) (Sysix)
- ea5838e linter/no-import-assign: Use let-else chain (#14524) (camc314)
- f977700 language_server: Pass `LintOptions` to
`Worker::refresh_server_linter` (#14510) (Sysix)
- 54b001f linter/no-new-require: Improve diagnostic message clarity
(#14511) (shulaoda)
- 650ea68 linter: Improve nextjs/no-typos rule (#14476) (shulaoda)

### 📚 Documentation

- 198f2e9 linter: Fix code example for `branches-sharing-code` (#14514)
(camc314)
- d776a17 linter: Improve `nextjs/no-typos` rule documentation (#14470)
(shulaoda)

### ⚡ Performance

- b44a30e language_server: Transform `Message` to `DiagnosticReport`
with one call (#14448) (Sysix)
- 31766fd linter/plugins: Provide `loc` via prototype (#14552)
(overlookmotel)
- aec0c08 linter: Allow analyzing node types in match blocks with guards
(#14459) (camchenry)
- 9044187 linter: Skip running node-specific rule if file contains no
relevant nodes (#14457) (camchenry)
- 422f54e linter: Only run rule run functions if implemented (#14454)
(camchenry)
- 2c228ae liner: Use top-level match for `no_obj_calls` (#14523)
(camchenry)
- c49d891 linter: Use match for `no_negated_condition` (#14522)
(camchenry)
- e222fc2 linter: Use match for `no_multi_assign` (#14521) (camchenry)
- 4440516 linter: Refactor rules to take advantage of node type skipping
(#14519) (camchenry)
- 78261d6 linter: Refactor `no-invalid-fetch-options` to be more easily
analyzed (#14458) (camchenry)

### 🧪 Testing

- 8d8881d linter/plugins: Expand tests for module resolution of plugins
(#14559) (overlookmotel)
- 33b6cde language_server: Add basic tests for
`WorkspaceWorker::did_change_configuration` (#14531) (Sysix)
- bfe1ecd language_server: Add tests for
`WorkspaceWorker::init_watchers` (#14516) (Sysix)

Co-authored-by: camc314 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants