fix(oxfmt): Use correct root dir with ignore and overrides for nested cwd#17244
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where ignore patterns from .oxfmtrc.json and glob patterns from .editorconfig were incorrectly resolved relative to the current working directory instead of their respective config file locations. This caused issues when running oxfmt from nested subdirectories.
Key changes:
- EditorConfig patterns now resolve relative to the
.editorconfigfile location - Ignore patterns from
.oxfmtrc.jsonnow resolve relative to the config file location - Multiple gitignore matchers are used to handle different pattern types with their appropriate root directories
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/oxfmt/src/core/config.rs | Updated to use the .editorconfig file's directory as the base for pattern resolution instead of cwd |
| apps/oxfmt/src/cli/walk.rs | Refactored to use multiple gitignore matchers with correct root directories for each pattern type (ignore files, config patterns, exclude paths) |
| apps/oxfmt/src/cli/format.rs | Passed oxfmtrc_path parameter to Walk::build to enable proper pattern resolution |
| apps/oxfmt/test/editorconfig.test.ts | Added test case for nested cwd with editorconfig pattern matching |
| apps/oxfmt/test/config_ignore_patterns.test.ts | Added test case for nested cwd with ignore patterns |
| apps/oxfmt/test/snapshots/editorconfig.test.ts.snap | Added snapshot verifying correct editorconfig pattern resolution from nested directory |
| apps/oxfmt/test/snapshots/config_ignore_patterns.test.ts.snap | Added snapshot verifying correct ignore pattern resolution from nested directory |
| apps/oxfmt/test/fixtures/editorconfig/nested_cwd/.editorconfig | Test fixture defining per-directory indentation rules |
| apps/oxfmt/test/fixtures/editorconfig/nested_cwd/sub/test.ts | Test fixture file with 8-space indentation |
| apps/oxfmt/test/fixtures/config_ignore_patterns_nested_cwd/.oxfmtrc.json | Test fixture defining ignore patterns for subdirectory |
| apps/oxfmt/test/fixtures/config_ignore_patterns_nested_cwd/sub/src/test.js | Test fixture file that should be formatted |
| apps/oxfmt/test/fixtures/config_ignore_patterns_nested_cwd/sub/generated/ignored.js | Test fixture file that should be ignored |
| apps/oxfmt/test/fixtures/config_ignore_patterns_nested_cwd/src/test.js | Test fixture file at root level |
| apps/oxfmt/test/fixtures/config_ignore_patterns_nested_cwd/generated/ignored.js | Test fixture file at root level that should be ignored |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apps/oxfmt/test/fixtures/config_ignore_patterns_nested_cwd/sub/src/test.js
Show resolved
Hide resolved
a491971 to
fd8879c
Compare
fd8879c to
e00d403
Compare
e00d403 to
fde61bb
Compare
Merge activity
|
… cwd (#17244) In the `oxfmt`-related settings, paths are specified in the following: - `.editorconfig` `[src/*.json]` part - `.(prettier|git)ignore`, `--ignore-path`ed file - `.oxfmtrc` `.ignorePatterns` - CLI positional paths These paths are often written as relative paths, but path resolution is currently based on the `cwd`. This is generally not a problem in most common use cases, as follows. ``` - project/ # root == cwd - .editorconfig - .prettierignore - .oxfmtrc.json ``` However, `oxfmt` can also find `.oxfmtrc` files by traversing upward from nested subdirectories toward the parent directory. ``` - project/ # root - .editorconfig - .prettierignore - .oxfmtrc.json - nested/ # cwd ``` At this case, relative path resolution should be based on each individual setting file.
fde61bb to
7b810f4
Compare

In the
oxfmt-related settings, paths are specified in the following:.editorconfig[src/*.json]part.(prettier|git)ignore,--ignore-pathed file.oxfmtrc.ignorePatternsThese paths are often written as relative paths, but path resolution is currently based on the
cwd.This is generally not a problem in most common use cases, as follows.
However,
oxfmtcan also find.oxfmtrcfiles by traversing upward from nested subdirectories toward the parent directory.At this case, relative path resolution should be based on each individual setting file.