CodeVetter · Repo Unpack · Contributor handoff
prettier/prettier
Read src/index.js, src/main/core.js, and the language module you are touching before editing. Do not add formatting options. Do not hand-edit generated builtin-plugin files; run generate-builtin-plugins. Format tests are snapshots — yarn test -u then git diff. Prefer small, reviewable diffs. Dev Node is >=22; production behavior is what dist/ does after yarn build. Run the matching tests/format/<lang> directory plus yarn test tests/unit if you change Doc/parser resolve.
- Must-read first files for any change: package.json (scripts/exports), src/index.js (API), src/main/core.js (pipeline), src/main/parser-and-printer.js (plugin resolve), and CONTRIBUTING.md (test DSL + no-new-options).
- Language work: edit src/language-<lang>/ (parse, print, embed, comments) and add a tests/format/<lang>/<topic>/ directory with format.test.js calling runFormatTest(import.meta, [parser]). Never add files next to format.test.js that you do not want snapshotted.
- After changing languages.evaluate.js, options.js, or plugin parser/printer exports, run yarn generate-builtin-plugins (or yarn fix:builtin-plugins) so development-plugins.js and production-plugins.js stay in sync.
- Safe edit boundaries: src/language-* printers and tests/format snapshots are the normal contributor surface. Avoid src/index.cjs dual ESM/CJS shim, bin/prettier.cjs version gate, and scripts/build/hacks/* unless the change is specifically about bundling. (inferred)
- Tests to run locally: yarn test <path> for a focused directory; yarn test -u to update snapshots; FULL_TEST=1 yarn test for AST/second-format/EOL/BOM. Production: yarn build then yarn test:production. Do not use yarn test:production without a dist/.
- yarn debug <file> runs bin/prettier.js with --ignore-path=.prettierignore against the source tree (no dist needed). yarn perf / perf:inspect / perf:benchmark require a production build.
- Trap: plugins listed last win. Tests that list ['babel','flow','typescript'] also run oxc/yuku/hermes/acorn/espree/meriyah implicitly — a JS print change can fail snapshots in those extra parsers even if babel looks fine.
- Trap: standalone and website need explicit plugins (estree must be loaded to print JS). Node API autoloads builtins; copying Node samples into src/standalone.js consumers will fail with ConfigError 'Plugins must be explicitly added to the standalone bundle.'
- Trap: prettier.util/doc are unavailable from the development CJS build. package.json main points at src/index.cjs, so require('prettier') in this checkout without NODE_ENV=production cannot use those namespaces.
- PRs must follow .github/PULL_REQUEST_TEMPLATE.md and add changelog_unreleased/<area>/<id>.md. AI-generated low-quality PRs are closed. ESLint + Prettier are required (yarn fix).
- This repo’s own prettier.config.js forces parser meriyah for **/*.{js,mjs,cjs}, trailingComma none for bin/prettier.cjs, and jsonc for .vscode/*.json and tsconfig.json — dogfooding, not defaults for users.
- Coverage tooling (c8 in package.json, codecov in Dev workflow) excludes src/standalone.js, src/index.cjs, src/plugins/**, and src/universal/*.browser.js — those paths can regress without coverage signal.