analyze.format

Synopsis

analyze.format <path>... [name: value]...

Description

Finds the files that the configured formatters would change, then runs the formatters on exactly those files. The formatters are Prettier, Biome, Ruff, gofmt and rustfmt. The set of files is determined before any formatter starts: each formatter is first run in its check mode on the requested files.

The result lists the files and shows up to sample_lines changed lines per file as -old and +new lines.

Files changed outside the determined set are detected as for run.

Parameters

Parameter Type Default Description
path list<path> none Files or directories to format.
changed_only bool false Only files changed in the repository.
sample_lines int 12 Maximum number of changed lines shown per file, from 1 to 200.

Input and output

Form Input Output
default none effect

No input. Output: an effect report with one change per formatted file.

Effect

Property Value
Category change
Effect process
Reversibility reversible
Implementation user_program
Reversibility conditions The previous content of every file passed to the formatter is kept in the journal.

Examples

Format files changed in the repository.

analyze.format changed_only: true

Format one directory and show more changed lines.

analyze.format "src" sample_lines: 40

Format two directories.

analyze.format "src" "tests"

Errors

Code Meaning Typical fix
E_SPAWN A formatter ended with a failure. Run analyze.check checks: ["format"] and fix the reported syntax errors.
E_PROGRAM_NOT_FOUND A formatter program could not be started. Install the formatter or fix its path.

analyze.check, analyze.tools.

Source file on GitHub: docs/commands/analyze.format.md