Skip to content

oxfmt: --stdin-filepath does not respect ignorePatterns #20545

@duytbp

Description

@duytbp

When using --stdin-filepath, ignorePatterns from .oxfmtrc.json is not applied. The file content is still formatted and output to stdout, even though the filepath matches an ignore pattern.

This is the stdin counterpart of #17729, which was fixed for CLI positional arguments in #17732. The --stdin-filepath code path appears to skip the ignore check.

Repro

// .oxfmtrc.json
{
  "ignorePatterns": ["ignored/**"]
}
// ignored/should-be-ignored.ts
const   x   =   1;
const y={a:1,b:2,c:3,d:4,e:5};
function   foo(   a:string,b:   number,   c:boolean   ){return    a+b+c}
cat ignored/should-be-ignored.ts | oxfmt --stdin-filepath ignored/should-be-ignored.ts -c .oxfmtrc.json

Expected

The original content should be output unchanged (file is ignored).

Prettier has the expected behavior — if the filepath matches .prettierignore, prettier --stdin-filepath outputs the content unchanged.

Actual

The file is fully formatted:

const x = 1;
const y = { a: 1, b: 2, c: 3, d: 4, e: 5 };
function foo(a: string, b: number, c: boolean) {
  return a + b + c;
}

Why this matters

Jujutsu (jj) has a jj fix feature that operates by piping file contents through stdin and reading formatted output from stdout. It relies on --stdin-filepath to give the formatter the file path context. Without ignorePatterns being respected in this code path, jj fix will format files that should be ignored.

Environment

  • oxfmt: 0.41.0
  • macOS (arm64)

Metadata

Metadata

Assignees

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