j2lint
raw JSON → 1.2.0 verified Fri May 01 auth: no python
j2lint is a command-line utility that validates Jinja2 syntax according to Arista's AVD style guide. It checks for formatting, spelling, and structural issues in Jinja2 templates. Current version: 1.2.0. Release cadence: occasional, maintenance mode.
pip install j2lint Common errors
error pkg_resources.DistributionNotFound: The 'j2lint' distribution was not found and is required by the application ↓
cause j2lint is not installed or the environment is broken.
fix
Run 'pip install --upgrade j2lint' to reinstall in the current environment.
error ERROR: j2lint requires Python >=3.9 but you have Python 3.8 ↓
cause Incompatible Python version.
fix
Upgrade to Python 3.9 or later.
Warnings
breaking Version 1.0.0 changed the CLI output format from plain text to structured JSON. Scripts parsing stdout will break. ↓
fix Update parsing logic to expect JSON output, or use the --format plain flag (if available) to revert to old style.
gotcha By default, j2lint only checks files with .j2 extension. Other extensions are ignored unless explicitly passed. ↓
fix Pass files with .j2 extension or use --ext .<ext> to add custom extensions.
gotcha j2lint's built-in rules are opinionated towards Arista's AVD style guide. Running on non-AVD templates may produce many false positives. ↓
fix Disable specific rules via --ignore RULE or create a custom config file.
Imports
- J2LintRunner wrong
from j2lint.j2lint import J2LintRunnercorrectfrom j2lint import J2LintRunner - Linter wrong
from j2lint import Lintercorrectfrom j2lint.linter import Linter
Quickstart
from j2lint import J2LintRunner
runner = J2LintRunner()
runner.run(['template.j2'])