Prettier
The Prettier plugin gives every package a format task that writes its formatting and a format:check task that checks it, so each package is checked on its own and stays cached until something it reads changes.
Add it
Section titled “Add it”axle add prettierThis writes it into the root axle.toml:
[plugins.prettier]source = "npm:@axle-rs/plugin-prettier@0.1.0"hash = "sha256-…"A package gets the tasks when it, or the root of the repository, has a Prettier config: .prettierrc with or without an extension, prettier.config.* or a "prettier" key in package.json. The root package itself gets none, since its check would cover every package again.
| Task | Command | Settings |
|---|---|---|
format |
prettier --write . |
cache = false, since it rewrites the package’s files |
format:check |
prettier --check . |
inputs the package’s files and the root’s config, outputs nothing |
Each command runs through the repository’s package manager, such as pnpm exec prettier --check ., so it uses the version the package installs.
Prettier reads .prettierignore from the folder it runs in, so a package checks only its own files.
Scripts the repository already has
Section titled “Scripts the repository already has”A package’s own script wins. When its package.json has a script with a task’s name that runs something else, such as "format": "prettier --write src", the plugin leaves that task alone and Axle runs the script. A script that runs the same command is replaced by the plugin’s task, which runs it and adds its settings. The repository’s axle.toml changes a task as it would any other, and wins over the plugin.
Settings
Section titled “Settings”| Setting | Default | Meaning |
|---|---|---|
format |
"format" |
the name of the task that writes, or false to leave it out |
check |
"format:check" |
the name of the check task, or false |
The plugin’s answers are kept until a Prettier config, a package.json, pnpm-workspace.yaml or a lockfile changes.