Code Formatter (`spc fmt`)

SP features an opinionated, built-in code formatter that enforces uniform style across codebases.

bash
1# Check formatting without modifying files (returns non-zero if diff exists)
2spc fmt src/ --check
3
4# Format files in-place
5spc fmt src/ --write
6
7# Custom 4-space indent
8spc fmt src/ --write --indent 4

Formatting Guarantees

  • Strict Idempotency: Applying the formatter repeatedly produces the identical AST and text layout: fmt(fmt(x)) == fmt(x).
  • Preserves Comments: All single-line // comments, multi-line blocks, and /// docstrings are preserved.
  • CI Ready: The --check flag is suited for GitHub Actions and pre-commit hooks.