Prettier
The Prettier module keeps formatting consistent and enforced before code review. It checks formatting locally, in CI, and in Dagger Cloud, and can rewrite source to match, always using the project's own Prettier config. Each Prettier config roots a project. Keep it alongside a linter so formatting policy stays separate from lint rules.
Add it to your workspace
dagger module install dagger.io/js/prettier
Run the check
dagger check --prettier # check every project
dagger check --prettier-project=packages/ui # check one project
The check is prettier/projects/format-check. It installs dependencies and
runs the project's own Prettier with --check from the project directory,
failing if any file isn't formatted. A check over several projects reports
every project that fails.
Projects
| Flag | Collection | Key |
|---|---|---|
--prettier-project | projects | Directory holding the Prettier config, relative to the workspace root. The root is . |
List the keys with dagger list prettier-projects -a. Select collection items describes how to select items.
A project is a directory holding .prettierrc, .prettierrc.json, .json5,
.yaml, .yml, .toml, .js, .mjs, .cjs, .ts, .mts, or .cts, or
prettier.config.js, .mjs, .cjs, .ts, .mts, or .cts. A config in the
prettier field of package.json does not root a project. A project covers
everything below it except nested projects.
Projects are found at or below the directory dagger runs from, plus the
nearest project that encloses it.
The source is mounted without files ignored by .gitignore, in addition to the
project's own Prettier ignore files. Dependencies install at the nearest
workspace root (a pnpm-workspace.yaml or a package.json with workspaces),
else the nearest lockfile, else the nearest package.json.
Fix formatting
format runs Prettier with --write and returns the reformatted source as a
changeset. It is a regular function, not a check, so it doesn't run during
dagger check. Call it on the project that contains a path:
dagger api call -y prettier project --path=. format
-y applies the changeset without prompting.
Configure it
List the current settings with dagger module settings prettier, then change one with
dagger module settings prettier <key> <value>. They live in dagger.toml
under [modules.prettier.settings] and apply to every project:
packageManager(default empty) is the package manager that installs dependencies:npm,yarn,pnpm, orbun. Empty detects it from thepackageManagerfield ofpackage.json, then from the lockfile, then uses npm.baseImageAddress(defaultnode:25-alpine) is the Node base image Prettier runs in. Pin it to your project's Node version, e.g.node:22-alpine.installFlags(default empty) are extra arguments for the install command, such as["--ignore-scripts"].environment(default empty) sets environment variables for Prettier, asKEY=VALUE.
[modules.prettier.settings]
baseImageAddress = "node:22-alpine"
installFlags = ["--ignore-scripts"]
Working with other modules
Prettier pairs well with ESLint. ESLint checks code quality, Prettier owns formatting. If your project uses Biome for both, use the Biome module instead.