Back to Foam

foam lint

docs/user/tools/cli/lint.md

0.40.22.1 KB
Original Source

foam lint

Check notes for issues.

foam lint [options]

Scans all notes in the workspace and reports problems such as missing headings or stale link reference definitions. With --fix, auto-fixable issues are corrected in place.

Exits with code 2 when issues are found (and no --fix), making it easy to use in CI pipelines.

Options

OptionDescription
--fixApply all auto-fixable issues
--rule <id>Run only the given rule (can be repeated)
--workspace <dir>Workspace root (default: FOAM_WORKSPACE env var, then current directory)
--format <fmt>Output format: text (default) or json

Rules

Rule IDDescriptionAuto-fixable
missing-headingNotes without a top-level headingYes
stale-definitionsLink reference definitions that are outdated or unusedYes

Exit codes

CodeMeaning
0No issues found
1Command error
2Issues found

Examples

Check the workspace for issues:

bash
foam lint
# notes/my-note.md
#   5:1  warning  Missing heading  missing-heading
#
# 1 problem (0 errors, 1 warning, 1 fixable with --fix)

Fix all auto-fixable issues:

bash
foam lint --fix

Run only one rule:

bash
foam lint --rule missing-heading

Use in CI:

bash
foam lint || echo "Lint issues found — please fix before merging"

Get results as JSON:

bash
foam lint --format json

See also [workspace-janitor] for running the janitor from VS Code.