Skip to content

chore: next build reformats tsconfig.json into a shape prettier rejects, failing the pre-commit check-format hook #4885

Description

@frano-m

Problem

next build / next dev rewrites tsconfig.json — expanding the lib / paths / exclude arrays to multiline and appending a .next/dev/types/**/*.ts include entry. That regenerated shape fails prettier --check (prettier wants the short arrays collapsed onto one line).

Because the pre-commit hook runs check-format (prettier --check .) across the whole repo, committing after a build fails the hook on tsconfig.json, forcing a --no-verify bypass. The file also shows as perpetually "modified" in git status after any build.

Correction: the committed tsconfig.json is already prettier-clean — an earlier note here had it backwards. The failing version is the one Next produces at build time, not the one in git.

Repro

# committed version is clean:
npx prettier --check tsconfig.json    # passes

# after `next build` (arrays expanded to multiline):
npx prettier --check tsconfig.json    # [warn] tsconfig.json  -> check-format / pre-commit fails

Origin

Surfaced during #4877. Introduced by the Next.js 16 upgrade (#4876) — Next rewrites tsconfig.json on build.

Fix (PR #4886)

Add tsconfig.json to .prettierignore. It's a Next-managed file, so prettier shouldn't enforce its format. The committed file is left unchanged (already clean).

Acceptance

  • npm run check-format passes even when tsconfig.json is in its build-modified state
  • Pre-commit hook no longer requires --no-verify for unrelated commits
  • Committed tsconfig.json unchanged

Activity

  1. self-assigned this
    on Jul 1, 2026
  2. changed the title [-]chore: committed tsconfig.json is not prettier-clean, failing the pre-commit check-format hook on clean checkouts[/-] [+]chore: next build reformats tsconfig.json into a shape prettier rejects, failing the pre-commit check-format hook[/+] on Jul 1, 2026
  3. NoopDog commented on Aug 11, 2026

    @NoopDog
    Collaborator

    Completed by PR #4886.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions