Sign inSign up

kaictl/j2lint

By kaictl

•Updated over 7 years ago

Jinja 2 linter (docker fork from https://github.com/drm/jinja2-lint )

Image
1

10K+

kaictl/j2lint repository overview

⁠Linter for jinja2

Every now and then, it's pretty useful to just have a cli tool that does the job. This does it.

⁠Usage:

cp j2lint.py /usr/local/bin/
j2lint.py my-template.j2

It accepts multiple arguments so shell expansion and/or combining with find is no issue:

j2lint.py *.j2
find src -type f -name "*.j2" -exec j2lint.py '{}' +

⁠Usage with custom filters, tests, etc

If you want to use this linter with custom filters, tests, etc, you can easily extend the main cli endpoint by passing in a env keyword argument.

The file custom_check_example.py⁠ provides a working example for the filter 'to_nice_json'.

Note that for linting it is not necessary to refer to the actual implementation of the filters, jinja2 only needs to know they exist.

⁠Usage with docker

To run this using docker, run:

docker run --rm -v "$(pwd)":/check kaictl/j2lint

Important options:

  • -e CUSTOMLINT=path/to/custom/lint: the path to a custom lint py file in the directory you're checking. By default we check for /custom.py, so you can mount a file there instead of specifying this.
  • -v "$(pwd)":/check: mount the current directory to /check on the container

Tag summary

Content type

Image

Digest

Size

14.1 MB

Last updated

over 7 years ago

docker pull kaictl/j2lint