AZLint

January 3, 2025 Β· View on GitHub

Lint everything From A to Z

Project links:

PlatformLatest version
GitHubgithub release
git tag
DockerHubdockerhub tag
Table of contents

About

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 πŸ˜‰.

Features

  • πŸ“¦ 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

Usage

azlint demo

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.

Local - Linux & macOS

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"]

Local - Windows

Refer to Linux & macOS examples above, just swap $PWD to %cd%, for example:

docker run -itv "%cd%:/project:ro" matejkosiarcik/azlint:latest lint

GitLabCI

azlint:
  image: matejkosiarcik/azlint:latest
  script:
    - lint

CircleCI

version: 2.1

workflows:
  version: 2
  workflow:
    jobs:
      - azlint

jobs:
  azlint:
    docker:
      - image: matejkosiarcik/azlint:latest
    steps:
      - checkout
      - run: lint

GitHub Actions

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

Configuration

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).

Included linters

All files

toollinksdisablefilesfmt support
editorconfig-checkerGitHub
docs
VALIDATE_EDITORCONFIG_CHECKER*❌
eclintGitHubVALIDATE_ECLINT*❌
Git check-ignore [custom]-VALIDATE_GITIGNORE*βœ…
jscpdGitHubVALIDATE_JSCPD*❌

General configs

toollinksdisablefilesfmt support
dotenv-linterGitHub
docs
VALIDATE_DOTENV*.env❌
jsonlintGitHub
try-online
VALIDATE_JSONLINT*.json❌*
prettierGitHub
docs
VALIDATE_PRETTIER*.{json,yml,css,html}βœ…
stomlGitHubVALIDATE_STOML*.{cfg,ini,toml}❌
tomljson (go-toml)GitHubVALIDATE_TOMLJSON*.toml❌
yamllintGitHub
docs
VALIDATE_YAMLLINT*.{yml,yaml}❌

Jsonlint* - Formatting conflicts with prettier, so it is turned off.

Package manager files

Dry runners

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.

toollinksdisablefilesfmt support
brew-bundleGitHub
manpage
VALIDATE_BREW_BUNDLEBrewfile❌
composer-installdocsVALIDATE_COMPOSER_INSTALLcomposer.json❌
pip-installdocsVALIDATE_PIP_INSTALLrequirements.txt❌
npm-installdocsVALIDATE_NPM_INSTALLpackage.json❌
npm-cidocsVALIDATE_NPM_CIpackage.json & package-lock.json❌

Validators

Extra validators for package-manager files. These check additional rules, which are recommended, but not required for the config files to be valid.

toollinksdisablefilesfmt support
composer-normalizeGitHub
blogpost
VALIDATE_COMPOSER_NORMALIZEcomposer.jsonβœ…
composer-validatedocsVALIDATE_COMPOSER_VALIDATEcomposer.json❌
package-json-validatorGitHubVALIDATE_PACKAGE_JSONpackage.json❌

CI/CD services

toollinksdisablefilesfmt support
CircleCI CLI lintdocs
GitHub
VALIDATE_CIRCLECI_VALIDATE.circleci/config.yml❌
gitlab-ci-lintGitHubVALIDATE_GITLABCI_LINT.gitlab-ci.yml❌
gitlab-ci-validateGitHubVALIDATE_GITLABCI_VALIDATE.gitlab-ci.yml❌

Makefiles

toollinksdisablefilesfmt support
checkmakeGitHubVALIDATE_CHECKMAKEMakefile etc.❌
BSD MakemanpageVALIDATE_BMAKEMakefile etc.❌
GNU Makedocs
manpage
VALIDATE_GMAKEMakefile etc.❌

Dockerfiles

toollinksdisablefilesfmt support
dockerfilelintGitHub
try-online
VALIDATE_DOCKERFILELINTDockerfile etc.❌
hadolintGitHubVALIDATE_HADOLINTDockerfile etc.❌

XML, HTML, SVG

toollinksdisablefilesfmt support
HTMLHintGitHubVALIDATE_HTMLHINT*.{html,htm}❌
htmllintGitHubVALIDATE_HTMLLINT*.{html,htm}❌
SVGLintGitHubVALIDATE_SVGLINT*.svg❌
xmllintgitlab
docs
manpage
VALIDATE_XMLLINT*.xmlβœ…

Documentation (Markdown, Plain Text)

toollinksdisablefilesfmt support
markdown-link-checkGitHubVALIDATE_MARKDOWN_LINK_CHECK*.md❌
markdownlintGitHubVALIDATE_MARKDOWNLINT*.mdβœ…
markdownlint (mdl)GitHubVALIDATE_MDL*.md❌
proselintGitHubVALIDATE_PROSELINT*.{md,txt}❌

Shell script files

toollinksdisablefilesfmt support
bashateGitHub
opendev
docs
VALIDATE_BASHATE*.sh etc.❌
bats-coreGitHub
docs
VALIDATE_BATS*.bats❌
shellcheckGitHub
wiki
try-online
VALIDATE_SHELLCHECK*.sh etc.❌
shellhardenGitHubVALIDATE_SHELLHARDEN*.sh etc.βœ…
shfmtGitHub
go pkg
VALIDATE_SHFMT*.sh etc.βœ…
hushGitHub
docs
VALIDATE_HUSH*.hush❌
Custom dry runner-VALIDATE_SHELL_DRY_RUN*.sh etc.❌

The following shells are checked in custom dry runner:

toollinkslinter IDfilesfmt support
Linux port of OpenBSD's ksh (loksh)GitHubLOKSH - loksh*.{sh,ksh}❌
Portable OpenBSD ksh (oksh)GitHubOKSH - oksh*.{sh,ksh}❌

Python

toollinksdisablefilesfmt support
autopep8GitHub
pypi
VALIDATE_AUTOPEP8*.py❌*
blackGitHub
docs
pypi
VALIDATE_BLACK*.pyβœ…
flake8GitHub
docs
pypi
VALIDATE_FLAKE8*.py❌
isortGitHub
docs
pypi
VALIDATE_ISORT*.pyβœ…
pycodestyleGitHub
docs
pypi
VALIDATE_PYCODESTYLE*.py❌
pylintGitHub
docs
pypi
VALIDATE_PYLINT*.py❌
mypyGitHub
docs
pypi
VALIDATE_MYPY*.py❌

Autopep8* - Formatting conflicts with black, so it is turned off.

Development

Prepare you system

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 from Brewfile (learn more about Homebrew Bundle).
  • If you are on Debian/Ubuntu Linux, check out .circleci/config.yml -> job native-build for apt-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.

Build & Run

To run project locally:

npm run azlint:fmt && npm run azlint:lint

To build and run project in docker:

make build run

License

This project is licensed under the MIT License, see LICENSE.txt for full license details.

Alternatives