Skip to content

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.

Which rules run depends on your workspace settings — see Rules.

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

Option Description
--fix Apply 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
Rule ID Description Auto-fixable
missing-heading Notes without a top-level heading Yes
stale-definitions Link reference definitions that are outdated or unused Yes

stale-definitions only runs when Link Reference Definitions are enabled for the workspace, the same as the “Foam: Lint Workspace” command in VS Code. The foam.edit.linkReferenceDefinitions setting is off by default, so turn it on in your workspace’s .vscode/settings.json to have the rule report and fix definitions:

{
"foam.edit.linkReferenceDefinitions": "withExtensions"
}

Asking for the rule with --rule stale-definitions while the setting is off is a command error (exit 1).

Code Meaning
0 No issues found
1 Command error
2 Issues found

Check the workspace for issues:

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

Fix all auto-fixable issues:

Terminal window
foam lint --fix

Run only one rule:

Terminal window
foam lint --rule missing-heading

Use in CI:

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

Get results as JSON:

Terminal window
foam lint --format json

See also Lint for running lint from VS Code.

Published with Foam