Part V — The Modern Experience Layer · Chapter 30 · Lesson 2 of 2
Formatter, linter, codemods and scaffolding
Style drift is a tax on every review. PeaLang pays it for you — if you let it.
The formatter
pea fmt . # format in place
pea fmt --check . # CI gate, non-zero exit on diff
PeaFormatter and format_source_ast format from the syntax tree, not regexes — it never mangles string contents or comments, and it is idempotent. One canonical style: no configuration files, no bike-shedding, no .editorconfig negotiations.
The linter and codemods
PeaLinter / lint_source_ast # rules over the AST
codemod_remove_unused_imports
codemod_rename_variable # safe rename across a module
codemod_fix_naming # snake_case enforcement
The linter flags dead imports, inconsistent naming, shadowed bindings and a small set of bug-shaped patterns. Codemods apply the mechanical fixes in bulk — the difference between "we should rename these" and "it is renamed" is a codemod away.
Project scaffolding
pea init myproj --template webapp
pea templates # default, webapp, api, analysis, etl,
# automation, library, interop
Eight templates, all opinionated: correct layout, a passing test, CI config and a README stub. Pick the closest template and delete what you don't need — never start from an empty directory.
Metrics and dependency checks
import ux
metrics = ux.code_metrics(source) # size, complexity, nesting, arity
report = ux.dependency_check(path) # pin hygiene, license flags
hint = ux.suggest_fix(source, diagnostics)
Complexity and nesting counts are crude but honest; the value is in watching them trend downward across PRs, not in the absolute numbers.
Where the tools live
- Repo:
editors/(LSP, formatter, linter, codemods),tools/(scaffolding, metrics),pea_tests/(tooling tests). - Full treatment: Chapter 25 — Language Internals and Contribution.
Guided practice
- Run
pea fmt --check .on an old project; read the diff before accepting it. - Scaffold a new project with
pea init --template analysis; delete one thing you understand and re-run the tests. - Run the linter, apply one codemod, and verify tests still pass — that is the whole loop.