Linting and formatting
We employ a variety of linting and formatting tools. They can be run manually or with Ninja.
Ninja script
To run all the linters:
./scripts/lint/lint.py
To run all the formatters:
./scripts/lint/lint.py --format
As a pre-commit hook:
cat <<'EOF' > .git/hooks/pre-commit
#!/usr/bin/env bash
./scripts/lint/lint.py
EOF
chmod +x .git/hooks/pre-commit
Clippy
We lint Rust code with Clippy.
You can install Clippy with rustup like so:
rustup component add clippy
and run it like this:
cargo clippy --all-targets -- --deny warnings
Generic scripts
We have a few Python scripts in scripts/lint/ that perform one-off checks.
They generally take some number of paths as arguments. Use their --help
options to learn more.
mdlynx
We run mdlynx on our Markdown files to check for broken links.
git ls-files -z --exclude-standard '*.md' | xargs -0 mdlynx
Mypy
We lint Python code with mypy in --strict mode.
git ls-files -z --exclude-standard '*.py' | xargs -0 mypy --strict
Ruff
We lint and format Python code with Ruff.
git ls-files -z --exclude-standard '*.py' | xargs -0 ruff format
git ls-files -z --exclude-standard '*.py' | xargs -0 ruff check
rustfmt
We format Rust code with [rustfmt].
You can install rustfmt with rustup like so:
rustup component add rustfmt
and then run it like this:
cargo fmt --all
ShellCheck
We lint shell scripts with ShellCheck.
git ls-files -z --exclude-standard '*.sh' | xargs -0 shellcheck
taplo
We format TOML files with taplo.
git ls-files -z --exclude-standard '*.toml' | xargs -0 taplo format
typos
We run typos on Markdown files.
git ls-files -z --exclude-standard '*.md' | xargs -0 typos
zizmor
We lint our GitHub Actions files with zizmor.
zizmor .github