Lint everything From A to Z
Project links:
- GitHub: https://github.com/matejkosiarcik/azlint
- DockerHub: https://hub.docker.com/r/matejkosiarcik/azlint
Platform | Latest version |
---|---|
GitHub | |
DockerHub |
Table of contents
The main purpose of AZLint is to bundle as many linters as possible into a single docker image and provide convenient CLI interface for calling them in bulk.
I see it as a complement to SuperLinter and MegaLinter. These meta-linters are awesome, but are missing some features of AZLint.
All that said, AZLint is mostly for my personal usage. However feel free to use it and report any found issues 😉.
- 📦 Includes 48 linters
- 🛠️ Supports autofix mode (only for 9 linters though)
- 🐳 Distributed as a docker image (both
x64
/arm64
available) - 💯 Reports all found problems
- 🏎️ Runs linters in parallel
- 🌈 Clear, colored output
NOTE: In this chapter, we will use :latest
tag.
It is recommended to replace :latest
with a specific version
when you use it.
Go to dockerhub's tags to see all available tags or go to github's releases for all project versions.
To lint files in current directory:
docker run -itv "$PWD:/project:ro" matejkosiarcik/azlint:latest lint
To format files in current directory:
docker run -itv "$PWD:/project" matejkosiarcik/azlint:latest fmt
When in doubt, print help:
$ docker run matejkosiarcik/azlint:latest --help
Usage: azlint <command> [options…] [dir]
Commands:
azlint lint Lint project (default)
azlint fmt Format project (autofix)
Positionals:
dir Path to project directory [string] [default: "."]
Options:
-h, --help Show usage [boolean]
-V, --version Show version [boolean]
-v, --verbose Verbose logging (stackable, max: -vvv) [count]
-q, --quiet Less logging [boolean]
--only-changed Analyze only changed files (requires project to be a git directory) [boolean]
-n, --dry-run Dry run [boolean]
--color Colored output [string] [choices: "auto", "never", "always"] [default: "auto"]
Refer to Linux & macOS examples above, just swap $PWD
to %cd%
, for example:
docker run -itv "%cd%:/project:ro" matejkosiarcik/azlint:latest lint
azlint:
image: matejkosiarcik/azlint:latest
script:
- lint
version: 2.1
workflows:
version: 2
workflow:
jobs:
- azlint
jobs:
azlint:
docker:
- image: matejkosiarcik/azlint:latest
steps:
- checkout
- run: lint
name: AZLint
permissions: read-all
on:
push:
branches:
- main
pull_request:
jobs:
azlint:
name: AZLint
runs-on: ubuntu-latest
container:
image: matejkosiarcik/azlint:latest
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Full git history is needed to get a proper list of changed files
- name: Run AZLint
run: lint
AZLint is configured by environment variables with AZLINT_
prefix.
AZLint looks for config files in following places by default: [git-root]/
and [git-root]/.config/
.
You can specify a custom config directory with: AZLINT_CONFIG_DIR=some/config/directory
(note: path value is relative to [git-root]
).
AZLint will find config files and pass them to linters automatically.
If you want to specify a custom config file for a specific linter, set AZLINT_FOO_CONFIG_FILE=some/path/file.json
(note 1: replace FOO
with specific linter's name;
note 2: file path is relative to specified config directory).
You can turn of linters/formatters by specifying environment variable AZLINT_FOO=false
(note: replace FOO
with specific linter's name).
A note about linter names, if a linter is named foo-bar
,
then you need to specify environment variable named FOO_BAR
(so capitalized and underscores instead of dashes).
tool | links | disable | files | fmt support |
---|---|---|---|---|
editorconfig-checker | GitHub docs |
VALIDATE_EDITORCONFIG_CHECKER |
* |
❌ |
eclint | GitHub | VALIDATE_ECLINT |
* |
❌ |
Git check-ignore [custom] | - | VALIDATE_GITIGNORE |
* |
✅ |
jscpd | GitHub | VALIDATE_JSCPD |
* |
❌ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
dotenv-linter | GitHub docs |
VALIDATE_DOTENV |
*.env |
❌ |
jsonlint | GitHub try-online |
VALIDATE_JSONLINT |
*.json |
❌* |
prettier | GitHub docs |
VALIDATE_PRETTIER |
*.{json,yml,css,html} |
✅ |
stoml | GitHub | VALIDATE_STOML |
*.{cfg,ini,toml} |
❌ |
tomljson (go-toml) | GitHub | VALIDATE_TOMLJSON |
*.toml |
❌ |
yamllint | GitHub docs |
VALIDATE_YAMLLINT |
*.{yml,yaml} |
❌ |
Jsonlint* - Formatting conflicts with prettier, so it is turned off.
These tools are not real "linters".
These tools are vanilla package managers, which we invoke with a dry-run
flag to only attempt to install dependencies without actually installing them.
This verifies the given config files are actually working in that respective package manager.
tool | links | disable | files | fmt support |
---|---|---|---|---|
brew-bundle | GitHub manpage |
VALIDATE_BREW_BUNDLE |
Brewfile |
❌ |
composer-install | docs | VALIDATE_COMPOSER_INSTALL |
composer.json |
❌ |
pip-install | docs | VALIDATE_PIP_INSTALL |
requirements.txt |
❌ |
npm-install | docs | VALIDATE_NPM_INSTALL |
package.json |
❌ |
npm-ci | docs | VALIDATE_NPM_CI |
package.json & package-lock.json |
❌ |
Extra validators for package-manager files. These check additional rules, which are recommended, but not required for the config files to be valid.
tool | links | disable | files | fmt support |
---|---|---|---|---|
composer-normalize | GitHub blogpost |
VALIDATE_COMPOSER_NORMALIZE |
composer.json |
✅ |
composer-validate | docs | VALIDATE_COMPOSER_VALIDATE |
composer.json |
❌ |
package-json-validator | GitHub | VALIDATE_PACKAGE_JSON |
package.json |
❌ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
CircleCI CLI lint | docs GitHub |
VALIDATE_CIRCLECI_VALIDATE |
.circleci/config.yml |
❌ |
gitlab-ci-lint | GitHub | VALIDATE_GITLABCI_LINT |
.gitlab-ci.yml |
❌ |
gitlab-ci-validate | GitHub | VALIDATE_GITLABCI_VALIDATE |
.gitlab-ci.yml |
❌ |
Travis CI CLI lint | GitHub | VALIDATE_TRAVIS_LINT |
.travis.yml |
❌ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
checkmake | GitHub | VALIDATE_CHECKMAKE |
Makefile etc. |
❌ |
BSD Make | manpage | VALIDATE_BMAKE |
Makefile etc. |
❌ |
GNU Make | docs manpage |
VALIDATE_GMAKE |
Makefile etc. |
❌ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
dockerfilelint | GitHub try-online |
VALIDATE_DOCKERFILELINT |
Dockerfile etc. |
❌ |
hadolint | GitHub | VALIDATE_HADOLINT |
Dockerfile etc. |
❌ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
HTMLHint | GitHub | VALIDATE_HTMLHINT |
*.{html,htm} |
❌ |
htmllint | GitHub | VALIDATE_HTMLLINT |
*.{html,htm} |
❌ |
SVGLint | GitHub | VALIDATE_SVGLINT |
*.svg |
❌ |
xmllint | gitlab docs manpage |
VALIDATE_XMLLINT |
*.xml |
✅ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
markdown-link-check | GitHub | VALIDATE_MARKDOWN_LINK_CHECK |
*.md |
❌ |
markdownlint | GitHub | VALIDATE_MARKDOWNLINT |
*.md |
✅ |
markdownlint (mdl) | GitHub | VALIDATE_MDL |
*.md |
❌ |
proselint | GitHub | VALIDATE_PROSELINT |
*.{md,txt} |
❌ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
bashate | GitHub opendev docs |
VALIDATE_BASHATE |
*.sh etc. |
❌ |
bats-core | GitHub docs |
VALIDATE_BATS |
*.bats |
❌ |
shellcheck | GitHub wiki try-online |
VALIDATE_SHELLCHECK |
*.sh etc. |
❌ |
shellharden | GitHub | VALIDATE_SHELLHARDEN |
*.sh etc. |
✅ |
shfmt | GitHub go pkg |
VALIDATE_SHFMT |
*.sh etc. |
✅ |
hush | GitHub docs |
VALIDATE_HUSH |
*.hush |
❌ |
Custom dry runner | - | VALIDATE_SHELL_DRY_RUN |
*.sh etc. |
❌ |
The following shells are checked in custom dry runner:
tool | links | linter ID | files | fmt support |
---|---|---|---|---|
Linux port of OpenBSD's ksh (loksh) | GitHub | LOKSH - loksh |
*.{sh,ksh} |
❌ |
Portable OpenBSD ksh (oksh) | GitHub | OKSH - oksh |
*.{sh,ksh} |
❌ |
tool | links | disable | files | fmt support |
---|---|---|---|---|
autopep8 | GitHub pypi |
VALIDATE_AUTOPEP8 |
*.py |
❌* |
black | GitHub docs pypi |
VALIDATE_BLACK |
*.py |
✅ |
flake8 | GitHub docs pypi |
VALIDATE_FLAKE8 |
*.py |
❌ |
isort | GitHub docs pypi |
VALIDATE_ISORT |
*.py |
✅ |
pycodestyle | GitHub docs pypi |
VALIDATE_PYCODESTYLE |
*.py |
❌ |
pylint | GitHub docs pypi |
VALIDATE_PYLINT |
*.py |
❌ |
mypy | GitHub docs pypi |
VALIDATE_MYPY |
*.py |
❌ |
Autopep8* - Formatting conflicts with black, so it is turned off.
In order to develop on this project, first install required system packages.
- If you are on macOS and have Homebrew available,
just run
brew bundle install
in project's root directory. This will install all packages fromBrewfile
(learn more about Homebrew Bundle). - If you are on Debian/Ubuntu Linux, check out
.circleci/config.yml
-> job native-build forapt-get
instructions. - If you are on Windows, you need to find and install packages yourself - check out Chocolatey.
Note: Also make sure you have Docker installed.
Now run make bootstrap
to install local project dependencies.
To run project locally:
npm run azlint:fmt && npm run azlint:lint
To build and run project in docker:
make build run
This project is licensed under the MIT License, see LICENSE.txt for full license details.
- super-linter
- mega-linter
- git-lint (deprecated)