docs/versioned_docs/version-1.0-beta/modules/prettier.mdx
Official module: dagger/prettier
Install with dagger mod install github.com/dagger/prettier.
The Prettier module checks and rewrites formatting for files handled by Prettier.
Use it when formatting should be boring, consistent, and enforced before code review.
check: fail when files are not formatted.write: return source with Prettier formatting applied.Install the module, then run its check:
dagger mod install github.com/dagger/prettier
dagger check # run every check in the workspace
dagger check prettier:check # fail when source files are not formatted
check installs dependencies and runs prettier --check . over the whole workspace using the project's own Prettier configuration, failing if any file is not formatted.
List the current settings and their values with dagger settings prettier, then set one with dagger settings prettier <key> <value>. Settings are stored in .dagger/config.toml under [modules.prettier.settings].
packageManager (default npm): the package manager used to install dependencies before checking. Set it to yarn or pnpm to match the project, so the same lockfile and dependency versions are used.baseImageAddress (default node:25-alpine): the Node base image Prettier runs in. Pin it to the project's Node version, for example node:22-alpine.[modules.prettier.settings]
packageManager = "pnpm"
baseImageAddress = "node:22-alpine"
Prettier also exposes a write function that runs prettier --write . and returns the reformatted source as a changeset. The changeset is limited to the file types Prettier owns here (.js, .ts, .jsx, .md). It is a regular function rather than a check, so it does not run during dagger check; call it with dagger function call (run dagger function list to see available functions).
Prettier works well next to ESLint: ESLint checks code quality, Prettier owns formatting. If the project uses Biome for both, use the Biome module instead.
Source repo: github.com/dagger/prettier