Skip to content

process: format:check can never be green — committed style diverges from unconfigured prettier #360

Closed

Description

@ranxianglei

来源: #357 分析 #353 (image pre-compression PR) 的 rebase/CI 验证时发现

Repro

git checkout origin/master && npm ci && npm run format:check

→ Code style issues found in 101 files (with src/**/*.ts tests/**/*.ts; the npm script's broader globs report ~120).

Impact

  • AGENTS.md §7.2 requires re-running format:check after rebase and §7.4 lists it in the auto-merge gate — but the check can never be green without a ~120-file mass reformat, which §7.4 simultaneously forbids ("no mass whitespace/reformat"). The gate is unsatisfiable for every PR.
  • Sampled divergence: interface members committed at 4-space indent where prettier 3.9.6 (locked version) emits 2-space (e.g. src/truncate-tools.ts:6-13). Repo has NO .prettierrc, no prettier key in package.json, no .editorconfig — so bare defaults apply to a codebase clearly not formatted by bare defaults.
  • ci.yml runs typecheck/test/build only, so this never surfaced in CI.

Suggested fix (pick one)

  • (a) Add a prettier config matching the committed style so the check passes without churn (preferred: smallest blast radius);
  • (b) One dedicated whitespace-only cleanup PR running prettier --write (large, noise-heavy review);
  • (c) Drop format:check from the AGENTS.md gates until the style converges.

Found while verifying PR #357: the rebased tree fails format:check identically to pristine master, i.e. pre-existing and unrelated to that PR.

Activity

  1. ranxianglei commented on Sep 22, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷 Triage + fix ready (push/PR pending — network to GitHub currently unreachable)

    Verification (on origin/master @ b30723f):

    • Repro confirmed: npm run format:check fails with 115 files (prettier 3.9.6, no config anywhere in the repo).
    • Root cause runs deeper than "missing config": the committed style is not a single style. Grid-searched tabWidth{2,4} × printWidth{80,100,120} × trailingComma{all,es5,none} (+ markdown settings) over all 160 checkable files: the best config passes only 45/160, and 78 of 146 TS files match no config at all (e.g. src/truncate-tools.ts mixes 4-space indents with lines longer than every tested width). So option (a) is impossible as stated — no single config makes the check pass without churn.
    • Chose (b) + explicit config: pin the exact rule set the check already applied (convergence = zero semantic drift vs. today's check behavior), then one-time prettier --write.

    Done (branch 2026-09-23_prettier-converge, commit 08aaaf4, base master b30723f):

    • .prettierrc.json: {tabWidth:2, printWidth:80, semi:true, singleQuote:false, trailingComma:"all", arrowParens:"always", bracketSpacing:true, endOfLine:"lf"} — explicit pin of the current defaults, immune to future prettier default changes.
    • .prettierignore: package-lock.json (npm rewrites it in its own format; it can never stay prettier-clean).
    • One-time convergence: 115 files, whitespace/wrap/punctuation only. package.json diff is indentation-only — no version change, no semantic edits.
    • .gitignore: added .tmp/ (workspace scratch dir must not be able to break the mandated check).
    • Gates on the head: format:check ✅ · typecheck ✅ · npm test ✅ 869/869 · build ✅

    Behavior changes (old → new):

    1. No prettier config → explicit .prettierrc.json pinning the identical rules as bare defaults (protects against future default drift).
    2. Mixed 2sp/4sp/inconsistent-wrap style → converged to the pinned defaults (~115-file churn; semantics unchanged, proven by the full suite).
    3. format:check: permanently red on master (115 files) → green and satisfiable going forward — unblocks the AGENTS.md §7.2/§7.4 gates.
    4. Markdown docs: table columns padded, some emphasis markers normalized, embedded code in fences reformatted.
    5. package-lock.json excluded from the format check.

    Out of scope (your call): ci.yml still runs no format step — adding one would keep this regression-free automatically. Say the word and I'll file a separate issue/PR.

    Currently blocked: git ls-remote / git push to origin time out (≥25s probes, exit 124) — the network path to GitHub is down from this environment right now. Everything is committed locally and all gates are green; I'll push 2026-09-23_prettier-converge and open the PR referencing this issue as soon as connectivity recovers, then report back here with the link.

    一句话中文摘要:已确认 master 上 format:check 必然红(115 个文件),且已提交代码并非单一风格(网格搜索证明任何单一配置都无法零改动通过),故采用「显式固定当前默认配置 + 一次性 prettier --write 收敛」方案;format/typecheck/869 项测试/build 全部通过;因当前到 GitHub 的网络不通,分支与提交已在本地就绪,网络恢复后即推送并开 PR。

  2. ranxianglei commented on Sep 22, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷 网络已恢复,推送和 PR 完成:

    PR: #361 (2026-09-23_prettier-converge → master, commit 08aaaf4)

    • 内容与上一条回复一致:.prettierrc.json(显式固定当前默认规则)+ .prettierignore(排除 npm 管理的 lockfile)+ 一次性 prettier --write 收敛(115 文件,纯空白/换行/标点)+ .gitignore 增加 .tmp/。
    • 门禁全绿:format:check ✅ · typecheck ✅ · npm test ✅ 869/869 · build ✅。
    • 行为变更已在 PR 描述中逐条披露(旧值→新值+原因),其中核心一条:format:check 从 master 上永久红(115 文件)变为可持续保持绿,§7.2/§7.4 门禁恢复可满足。
    • 未动 version;ci.yml 未加 format 步骤——如需,说一声我另开 issue/PR。

    一句话中文摘要:修复了 format:check 永不绿的问题(显式 prettier 配置+一次性风格收敛),分支已推送、PR #361 已开,等待你 review/合并;合并前我不会自行 merge。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions