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)
When using
--stdin-filepath,ignorePatternsfrom.oxfmtrc.jsonis 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-filepathcode path appears to skip the ignore check.Repro
cat ignored/should-be-ignored.ts | oxfmt --stdin-filepath ignored/should-be-ignored.ts -c .oxfmtrc.jsonExpected
The original content should be output unchanged (file is ignored).
Prettier has the expected behavior — if the filepath matches
.prettierignore,prettier --stdin-filepathoutputs the content unchanged.Actual
The file is fully formatted:
Why this matters
Jujutsu (
jj) has ajj fixfeature that operates by piping file contents through stdin and reading formatted output from stdout. It relies on--stdin-filepathto give the formatter the file path context. WithoutignorePatternsbeing respected in this code path,jj fixwill format files that should be ignored.Environment
0.41.0