deno fmt: Format and Check in CI
deno fmt formats TypeScript, JavaScript, JSON, and Markdown using an opinionated built-in formatter.
deno fmt needs no config and no plugin. In CI you run it with --check so an unformatted file fails the build without rewriting anything.
What it does
deno fmt rewrites files to a canonical style in place. With --check it does not write; it exits non-zero and prints the files that would change, which is exactly what you want as a CI gate.
Common usage
deno fmt
deno fmt --check
deno fmt src/ docs/
# format only changed files via git
deno fmt $(git diff --name-only --diff-filter=ACMR)Options
| Flag | What it does |
|---|---|
| --check | Verify formatting without writing; exit non-zero if any file differs |
| --ignore=<paths> | Exclude paths from formatting |
| --ext <ext> | Format input read from stdin as the given extension |
| --line-width <n> | Override the maximum line width |
| --single-quote | Prefer single quotes |
| --no-semicolons | Omit semicolons where allowed |
In CI
Run deno fmt --check as its own fast job; it needs no permissions and no cache. Configure exclusions and overrides in deno.json under "fmt" so local and CI runs agree, rather than passing flags only in CI.
Common errors in CI
deno fmt --check exits 1 and prints "from <file>" with a diff when a file is not formatted; run deno fmt locally and commit. "Found N not formatted files" is the summary line that fails the job. If it reformats files you do not own, add them to the "fmt"."exclude" list in deno.json.