Skip to content

About

A HTML/Django template linter written in Rust

Resources

Contributing

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

Bracketlint ⚡

CodSpeed

HTML template linter for Jinja, Nunjucks, Django templates, Twig, Liquid.

Installation

Prebuilt binaries for macOS (Apple Silicon, Intel), Linux (x86_64, arm64; statically linked) and Windows ship with every release. No Rust toolchain needed.

macOS / Linux:

$ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/feds01/bracketlint/releases/latest/download/bracketlint-installer.sh | sh

Windows:

> powershell -ExecutionPolicy Bypass -c "irm https://github.com/feds01/bracketlint/releases/latest/download/bracketlint-installer.ps1 | iex"

The installer puts bracketlint in ~/.local/bin (or $XDG_BIN_HOME). To fetch an archive directly instead, e.g. in CI:

$ gh release download --repo feds01/bracketlint --pattern 'bracketlint-aarch64-apple-darwin.tar.xz'

From source (with Rust & Cargo installed):

$ cargo install --git https://github.com/feds01/bracketlint bracketlint

Usage

$ bracketlint check templates/   # report problems in the templates
$ bracketlint fmt templates/     # print the formatted templates

Each file is read in the dialect that its extension names: .jinja is Jinja, .liquid is Liquid and .twig is Twig. Any other file, such as .html, is read as Django. To read every file in one dialect instead, pass --dialect:

$ bracketlint check --dialect liquid theme/

Development

Common tasks are recipes in the justfile (install just with brew install just or cargo install just). Run just to list them all:

$ just setup             # install the pinned nightly toolchain and pre-commit hooks
$ just install           # install `bracketlint` from this checkout into ~/.cargo/bin
$ just run check foo/    # run the CLI from source
$ just test              # run all tests
$ just update-snapshots  # re-generate the UI test snapshots in tests/cases, and how the real-world templates in tests/corpus do
$ just corpus            # print how the real-world templates in tests/corpus do
$ just corpus-compare    # compare them with the baselines on main, as the comment on each PR does
$ just ci                # run tests, clippy and the formatting check, like CI does
$ just bench             # run benchmarks

Releasing

Releases are built by dist (.github/workflows/release.yml, config in dist-workspace.toml). Bump version in crates/bl/Cargo.toml, merge, then from an up-to-date main push a matching tag:

$ just release   # tags v<version> from crates/bl/Cargo.toml and pushes it

About

A HTML/Django template linter written in Rust

Resources

Contributing

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages