Skip to content

fix(cli): exit 0 when all fmt input files are excluded by ignorePatterns#1225

Open
nickytonline wants to merge 2 commits intovoidzero-dev:mainfrom
nickytonline:fix/fmt-exit-zero-when-all-files-ignored
Open

fix(cli): exit 0 when all fmt input files are excluded by ignorePatterns#1225
nickytonline wants to merge 2 commits intovoidzero-dev:mainfrom
nickytonline:fix/fmt-exit-zero-when-all-files-ignored

Conversation

@nickytonline
Copy link
Copy Markdown

@nickytonline nickytonline commented Mar 30, 2026

Summary

When vp staged passes files to vp fmt that are all excluded by ignorePatterns in vite.config.ts (e.g., package-lock.json), oxfmt would error with "Expected at least one target file". Now vp fmt automatically adds --no-error-on-unmatched-pattern when the fmt config has ignorePatterns, so it exits 0 gracefully instead.

Closes #1210

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

  • ran vp check --fix before committing
  • ran pnpm bootstrap-cli && pnpm test && git status
  • commit is signed
  • snap test added & reviewed via git diff

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for viteplus-preview ready!

Name Link
🔨 Latest commit 68ccdf8
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69cc23cb1276f000080bac1a
😎 Deploy Preview https://deploy-preview-1225--viteplus-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nickytonline nickytonline force-pushed the fix/fmt-exit-zero-when-all-files-ignored branch from e724b4d to 976155c Compare March 30, 2026 17:30
.get("ignorePatterns")
.and_then(|v| v.as_array())
.is_some_and(|arr| !arr.is_empty())
&& !has_flag_before_terminator(&args, "--no-error-on-unmatched-pattern")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Adding --no-error-on-unmatched-pattern, seemed to make the most sense to handle this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@leaysgur Can this fix be implemented by oxfmt itself?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This flag exists for a reason, so it should be explicitly specified by the
caller who knows that zero matches are expected.

https://oxc.rs/docs/guide/usage/formatter/ci.html#pre-commit-hook

@fengmk2 fengmk2 requested a review from leaysgur March 31, 2026 01:43
@nickytonline
Copy link
Copy Markdown
Author

Just need to dig into why these 3 are failing.

image

nickytonline and others added 2 commits March 31, 2026 15:43
When `vp staged` passes files to `vp fmt` that are all excluded by
ignorePatterns in vite.config.ts (e.g., package-lock.json), oxfmt
would error with "Expected at least one target file". Now vp fmt
automatically adds `--no-error-on-unmatched-pattern` when the fmt
config has ignorePatterns, so it exits 0 gracefully instead.

Closes voidzero-dev#1210

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nickytonline nickytonline force-pushed the fix/fmt-exit-zero-when-all-files-ignored branch from a51dac6 to 68ccdf8 Compare March 31, 2026 19:43
@nickytonline
Copy link
Copy Markdown
Author

had to update the snap test for Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vp fmt errors when all input files are excluded by ignorePatterns

3 participants