Skip to content

fix(prettier): add .prettierignore to exclude generated Prisma client - #2240

Open
gonzoblasco wants to merge 1 commit into
t3-oss:mainfrom
gonzoblasco:fix/2217-prettier-ignore-generated
Open

fix(prettier): add .prettierignore to exclude generated Prisma client#2240
gonzoblasco wants to merge 1 commit into
t3-oss:mainfrom
gonzoblasco:fix/2217-prettier-ignore-generated

Conversation

@gonzoblasco

Copy link
Copy Markdown

Description

When scaffolding a T3 app with Prisma + ESLint/Prettier, the format scripts (format:write, format:check) use a broad **/*.{ts,tsx,js,jsx,mdx} glob that sweeps through generated/prisma/**. Prettier does not read .gitignore by default, so the existing /generated/ entry in .gitignore offers no protection.

This causes a persistent churn cycle:

  1. prettier --write reformats generated Prisma client files
  2. prisma generate (runs on postinstall) rewrites them back to original format
  3. Git shows noisy diffs in generated/prisma/** on every install/format

Root Cause

The template has no .prettierignore. The .gitignore entry for /generated/ is irrelevant to Prettier — it only reads .prettierignore or the file specified by --ignore-path (neither exists in the scaffold).

This is the Prettier counterpart to #2226 (Biome linting generated files), with the same underlying cause: generated artifacts are not excluded from the formatter/linter.

Fix

1. Add .prettierignore template (cli/template/extras/config/_prettierignore)

# Prisma generated client
generated/

The _ prefix follows the existing convention for dotfiles in the template (e.g. _gitignore, _npmrc) to ensure npm includes them in the package.

2. Copy .prettierignore to the project from the ESLint installer

The file is only relevant when ESLint/Prettier is selected (Biome users are unaffected — Biome has its own files.includes ignore mechanism, fixed in #2239). The copy is added to dynamicEslintInstaller alongside the existing Prettier config copy.

Fixes #2217

Testing

  • pnpm --filter create-t3-app typecheck passes
  • pnpm --filter create-t3-app build passes
  • Changeset included (patch)
  • Manual: scaffold with pnpm create t3-app, select Prisma + ESLint/Prettier, run pnpm format:write, verify generated/ is not touched

When scaffolding with Prisma + ESLint/Prettier, the format scripts use a
broad **/*.{ts,tsx,js,jsx,mdx} glob that sweeps generated/prisma/**.
Prettier does not read .gitignore by default, so the /generated/ entry
there offered no protection. This caused persistent git diff churn:
prettier --write reformats generated files, prisma generate rewrites
them back, repeat on every install.

Add a .prettierignore template (config/_prettierignore) that excludes
generated/ and copy it to the project root from the ESLint installer.

Fixes t3-oss#2217
@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b1dc5e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-t3-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
create-t3-app Ready Ready Preview, Comment Jul 15, 2026 4:33pm

Request Review

@vichudo vichudo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supporting this, Highly necessary 🙌🏻

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.

bug: Prisma generated files under generated/prisma are reformatted by Prettier, causing persistent git diff churn in fresh T3 scaffold

2 participants