Skip to content

fix(jsts): stop reporting prettier as eslint, and distil prettier's real output#130

Merged
fajarhide merged 1 commit into
mainfrom
fix/114-prettier-eslint-misdetect
Jul 21, 2026
Merged

fix(jsts): stop reporting prettier as eslint, and distil prettier's real output#130
fajarhide merged 1 commit into
mainfrom
fix/114-prettier-eslint-misdetect

Conversation

@fajarhide

@fajarhide fajarhide commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Closes #114

Problem — three compounding prettier defects

npm run format (prettier --write ., which rewrote files across 109 paths) came out as:

$ omni exec npm run format
eslint: no problems found   ⏺ 99.5% reduction (4.6 KB → 25 B)

A destructive command reported as a clean run of a different tool that never ran.

  1. Wrong tool (the false claim). is_eslint_output matched the bare word eslint — which appears as a filename, eslint.config.js, in prettier's file list — and eslint is checked before prettier, so prettier output went to distill_eslinteslint: no problems found. Same substring-in-data trap as CloudDistiller misidentifies any 'kubectl get <resource> -A' table as a pod table, reporting healthy objects as errors #105/Composite npm scripts are distilled as a single tool: npm run verify collapses 19.5 KB to tsc: no errors, discarding four of five gates #106.
  2. Dead detector. is_prettier_output only matched lowercase checking /reformatted , but prettier prints Checking formatting… and [warn]. It never fired on real prettier output.
  3. Wrong parser. distill_prettier parsed black's reformatted N files summary, which prettier never prints — so both counters stayed 0 and a failing --check and a successful --write both rendered prettier: 0 files reformatted, 0 unchanged ("nothing to do" in the one case the gate is red).

Fix

  • eslint detection anchors on shape, not a filename-collidable substring: ✖ N problems (, a rule id (@typescript-eslint/…), or a <line>:<col> error|warning finding line.
  • prettier detection matches what prettier actually prints: Checking formatting, [warn], Code style issues, a <path> <n>ms write line, or a prettier echo (any case).
  • distill_prettier rewritten per mode: --check surfaces the offending filenames (prettier --check: N file(s) need formatting); --write reports N reformatted, M unchanged and names the changed files (capped); declines (returns input) rather than fabricate a count when neither mode is recognisable.

Verified (real binary + snapshots)

$ omni exec npm run format      # after
prettier --write: 3 reformatted, 6 unchanged
  src/lib/i18n.tsx
  src/routes/index.tsx
  src/components/Header.tsx

prettier --checkprettier --check: 2 file(s) need formatting + the filenames (was prettier: 0 files reformatted, 0 unchanged).

Snapshot tests added for both modes (prettier_write.txt, prettier_check.txt). Teeth: restoring the eslint filename match reverts --write to the exact reported eslint: no problems found; restoring the fix keeps the prettier summary. The existing eslint / vitest / tsc snapshots are unchanged.

Gates: cargo fmt / clippy -D warnings / cargo test (1048 passed, 0 failed) on local Homebrew 1.94.0, not CI's pinned 1.97.0 — CI is the source of truth for clippy.

Not fixed here

Report's defect 4prettier --check output reordered with the [warn] filename dropped — is an untraced stdout/stderr-ordering observation (omni exec inherits stderr, so the [warn] lines never reach the distiller there; the merged hook payload is fine). The reporter flagged it as observation, not diagnosis; left for its own issue. This distiller fix is order-independent (it scans all lines for [warn]).

PR Auto Describe

Summary

Fixed three compounding defects in distillers::jsts that misidentified prettier output as eslint: is_eslint_output matched filenames containing "eslint", is_prettier_output only matched lowercase strings that never fired on real prettier output, and distill_prettier parsed black's summary format that prettier never prints. Added snapshot tests for both --check and --write modes.

Key Changes

  • is_eslint_output: Anchored detection on real eslint output shapes ( problems (, rule ids, finding lines) — no longer matches bare word "eslint" in filenames
  • is_prettier_output: Matches capitalized "Checking formatting…", [warn], "Code style issues", and prettier's <path> <n>ms file lines
  • distill_prettier: Rewritten to parse prettier's real output per mode; declines (returns input) rather than fabricate zeros when output is unrecognized

Detailed Breakdown

  • New is_eslint_finding_line: Parses eslint's <line>:<col> error|warning … shape — requires all-digit line/col and an error/warning keyword token
  • New is_prettier_write_line: Detects <path> <n>ms pattern by verifying a token ending in ms with numeric prefix
  • New capped_lines: Helper renders file lists with 20-item cap and … and N more tail
  • distill_prettier --check: Extracts [warn] <path> lines, reports count and capped filenames, or "all files formatted" if clean
  • distill_prettier --write: Separates changed vs (unchanged) files from <path> <n>ms lines, reports counts and changed filenames capped
  • Test fixtures added: tests/fixtures/prettier_check.txt, tests/fixtures/prettier_write.txt
  • Snapshot tests added: test_jsts_prettier_check, test_jsts_prettier_write

Notes

The --check stdout/stderr ordering issue noted in #114 is out of scope — filed separately.

Last updated: 2026-07-21 08:57:28

…eal output (#114)

Three compounding defects made `npm run format` (prettier --write, which rewrote
files across 109 paths) come out as `eslint: no problems found` — a destructive
command reported as a clean run of a different tool that never ran.

1. `is_eslint_output` matched the bare word "eslint", which appears as a FILENAME
   (`eslint.config.js`) in prettier's file list. eslint is checked before prettier
   in the dispatch chain, so prettier output was handed to `distill_eslint`, which
   found no findings and returned "eslint: no problems found". Same substring-in-
   data trap as #105/#106.
2. `is_prettier_output` only matched lowercase `checking `/`reformatted `, but
   prettier prints `Checking formatting…` and `[warn]`. The detector was dead.
3. `distill_prettier` parsed black's `reformatted N files` summary — prettier
   prints no such line — so both counters stayed 0 and a failing `--check` and a
   successful `--write` both rendered `prettier: 0 files reformatted, 0 unchanged`.

Fixes: eslint detection anchors on eslint's real line shape (`✖ N problems (`, a
rule id, or a `<line>:<col> error|warning` finding) instead of a substring that
also occurs in filenames; prettier detection matches what prettier really prints;
`distill_prettier` is rewritten per mode — `--check` surfaces the offending
filenames, `--write` reports "N reformatted, M unchanged" and names the changed
files (capped) — and declines (returns input) rather than fabricate a count when
neither mode is recognisable.

Verified through the real binary: `npm run format` now →
`prettier --write: 3 reformatted, 6 unchanged` + the three changed files, no
eslint. Snapshot tests added for both modes; teeth proven by restoring the
filename match and watching --write revert to `eslint: no problems found`. The
existing eslint/vitest/tsc snapshots are unchanged.

Not fixed: report's defect 4 (`--check` reorder + `[warn]` filename drop) — an
untraced stdout/stderr-ordering observation, left for its own issue.
@fajarhide
fajarhide merged commit 9b79a1a into main Jul 21, 2026
9 checks passed
@fajarhide
fajarhide deleted the fix/114-prettier-eslint-misdetect branch July 21, 2026 09:09
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.

prettier: npm run format is reported as eslint: no problems found — wrong tool, false success, on a command that rewrites files

1 participant