Repository navigation
Description
Summary
rtk prettier --check on a project with real formatting failures (prettier exits 1) reports either a false All files formatted correctly or an uninformative bare Checking formatting... — never the actual list of files that need formatting. Confirmed on rtk 0.43.0 (Homebrew, macOS arm64), reproduced both from a clean source clone and against the installed binary.
Not a duplicate of #2395 (that one is the binary-not-installed case). Also appears not to be fixed by whatever closed #221 — see "Relationship to #221 and #2395" below.
Root cause (verified against the v0.43.0 tag, commit 5a7880d)
Two independent defects compound:
-
src/cmds/js/prettier_cmd.rs:24 —
run()callsrunner::run_filtered(..., RunOptions::stdout_only()). Prettier 3.x writesChecking formatting...to stdout but writes the per-file[warn] <file>lines and the finalCode style issues found in N files...summary to stderr. Withstdout_only(),filter_prettier_outputnever even sees those lines — they're discarded before filtering runs. -
src/cmds/js/prettier_cmd.rs:52 — even if stderr were captured,
filter_prettier_outputexplicitly excludes any line.contains("[warn]"). Prettier 3 emits failing files as exactly[warn] <file>(Prettier 2 used bare filenames — the format the function's parsing logic and its test fixtures, lines 128-184, still assume). This is the original defect described in bug: rtk prettier --check incorrectly reports "All files formatted correctly" when files need formatting #221's issue body.
A third factor decides which wrong message you see: src/core/guard.rs:6-12, guard::never_worse(). It's a pure token-count comparator with no correctness awareness — it keeps whichever of {filtered, raw} has fewer estimated tokens. Because filter_stdout_only also makes raw_for_tracking stdout-only, and filter_prettier_output("Checking formatting...\n") (no file lines ever reach it) produces the longer string "Prettier: All files formatted correctly", the guard discards it for being longer and falls back to raw stdout — which is just "Checking formatting...". That's why the exact wrong message differs by build even though the underlying defect (silently dropping the failing-file list) is the same one.
Repro (verified live against the installed rtk 0.43.0 binary)
$ cat package.json
{"devDependencies": {"prettier": "^3.3.0"}}
$ printf 'const x = {\n a:1,\n b:2\n}\n' > messy.js
$ pnpm exec prettier --check . 2>/dev/null # stdout only
Checking formatting...
$ pnpm exec prettier --check . 1>/dev/null # stderr only
[warn] messy.js
[warn] pnpm-lock.yaml
[warn] Code style issues found in 2 files. Run Prettier with --write to fix.
$ pnpm exec prettier --check .; echo "exit=$?"
exit=1
$ rtk prettier --check .; echo "exit=$?"
Checking formatting...
exit=1rtk prettier's exit code correctly propagates (1), but the printed message gives no indication anything failed or which files are affected. An agent piping through head/tail, or reading only stdout, sees a clean-looking Checking formatting... with no files-need-formatting message anywhere.
Relationship to #221 and #2395
- bug: rtk prettier --check incorrectly reports "All files formatted correctly" when files need formatting #221 (closed,
stateReason: COMPLETED, opened and closed same day, no comments) reported this exact[warn]-filter defect. The commit that closed it,85b0b3e/ PR #359 ("fix: prettier false positive when not installed (bug: rtk prettier --check incorrectly reports "All files formatted correctly" when files need formatting #221)"), only added the empty-output early-return (now lines 30-33 ofprettier_cmd.rs, tagged// #221in the source) — i.e. it fixed the binary-not-installed case, not the[warn]-line exclusion bug: rtk prettier --check incorrectly reports "All files formatted correctly" when files need formatting #221's body actually described. That exclusion (current line 52) is unchanged by the fix. It looks like bug: rtk prettier --check incorrectly reports "All files formatted correctly" when files need formatting #221 got closed via the commit message's(#221)auto-link on a PR that fixed an adjacent-but-different bug, not the one described in bug: rtk prettier --check incorrectly reports "All files formatted correctly" when files need formatting #221's body. - bug:
rtk prettierprints "All files formatted correctly" when the prettier binary is not installed (and for--version) #2395 (open) is the binary not installed /--versioncase — what PR fix: prettier false positive when not installed (#221) #359 actually fixed for the empty-output branch, minus the case where prettier does produce (stderr) output but rtk still discards it. Distinct from this issue.
Environment
- rtk 0.43.0, Homebrew install, macOS arm64 (0.40.0 also reported affected; only 0.43.0 was independently re-verified for this report)
- Node v22.23.1, pnpm 10.22.0, prettier 3.9.4
Suggested fix
- Capture stderr too (drop
stdout_only(), or add a stderr-aware variant) sofilter_prettier_outputactually sees prettier 3's real output. - Replace the
[warn]/[error]line exclusion at line 52 with logic that recognizes[warn] <file>as a failing-file line rather than noise — Prettier 2's bare-filename format can likely be kept alongside it. - Add
.svelteto the tracked extension list (lines 54-61) while in the area — currently absent. - The test module (lines 128-184) encodes Prettier 2's output shape; add Prettier-3-shaped fixtures (
[warn] <file>arriving via stderr) so a regression here fails CI.
Local workaround
We route around this with a hook-level exclusion in config.toml (mirrors the rewrite rule in src/discover/rules.rs, not a general fix — just stops rtk intercepting prettier at all so real output reaches the caller unfiltered):
[hooks]
exclude_commands = [
'^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx)\s+)?prettier(\s|$)',
]
Activity
linustalacko commentedon Jul 8, 2026
Companion issue: #2879 (same class of bug — rtk output-filtering silently hides real failures — found and verified together; unrelated code path so filed separately).
pszymkowiak commentedon Jul 8, 2026
🔍 Automated Triage
bughighSummary
rtk prettier discards prettier 3's stderr-only failure output (stdout_only capture) and also filters out [warn]-prefixed failing-file lines, silently hiding real formatting failures despite correct exit code; fix in prettier_cmd.rs (capture stderr, fix [warn] filter) with a guard.rs interaction to be aware of.
📁 Relevant files
src/cmds/js/prettier_cmd.rssrc/core/guard.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
fix(prettier): surface Prettier 3 failures instead of dropping them (#1)
fix: deny bare prettier runs, require rtk proxy
test(core): keep the stderr integration tests off the real tracking DB
KuSh commentedon Sep 12, 2026
Heads-up: once #3772 merges, this issue's manifestation changes. Today
rtk prettier --checksilently swallows the[warn]lines (you get a false "all good" or a bare "Checking formatting..."). After #3772, stderr is forwarded raw and unfiltered instead, so on a large repo with many unformatted files you'll get the full unfiltered prettier report — observed ~26k tokens on a large repo, versus near-zero today. Worth bumping priority on the second half of this issue (extendingfilter_prettier_output, or a stderr-aware equivalent, to summarize the[warn]lines) now that the failure mode is "noisy" rather than "silent."