Skip to content

oxfmt: ambiguous error "Expected at least one target file" when all files are excluded by .prettierignore #21107

@almahdi404

Description

@almahdi404

Description

When oxfmt is run with target paths or glob patterns, but a .prettierignore (or .gitignore) rule excludes all matched files, the error message is:

Expected at least one target file

This message implies that no files were found matching the given paths/globs, when in reality files do exist and match — they are just being excluded by an ignore rule. This makes the root cause extremely difficult to diagnose, especially when .prettierignore was set up for a previous Prettier-based workflow and the user is unaware that oxfmt reads it by default.

Reproduction

  1. Create a project with some .md files
  2. Add a .prettierignore with the following rules:
    /**/*.*
    !*.svg
    
  3. Run:
    npx oxfmt '**/*.md'
  4. Observe:
    Expected at least one target file
    

The same happens with npx oxfmt . or even npx oxfmt README.md — any invocation where files exist but are fully excluded by the ignore file. Note that .md files are excluded by the /**/*.* rule and are not re-included by the !*.svg negation, so all targets end up excluded.

Expected behavior

The error message should indicate why no files were processed. For example:

No files to format. All matched files were excluded by ignore rules.
Ignore sources: .prettierignore, .gitignore
Hint: Use --ignore-path to override the default ignore files, or --no-error-on-unmatched-pattern to suppress this error.

Or at minimum:

Expected at least one target file (all candidates were excluded by .prettierignore)

This would immediately point the user toward the root cause.

Context

This is a common scenario when migrating from Prettier to Biome + oxfmt. Projects that used Biome for JS/TS formatting often have a .prettierignore like:

/**/*.*
!*.svg

This is intended to prevent Prettier from running on most files while still allowing SVGs to be formatted. When oxfmt is later added to format non-JS files (Markdown, YAML, CSS), the leftover .prettierignore silently blocks everything that isn't an SVG, with no hint in the error output.

The --ignore-path flag is the correct workaround, but discovering it requires significant debugging since the error message gives no hint about ignore files being involved.

Environment

  • oxfmt version: 0.41.0
  • OS: Linux (x64)
  • Node.js: v25

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions