Skip to content

matejkosiarcik/azlint

Repository files navigation

AZLint

Lint everything From A to Z

Project links:

Platform Latest version
GitHub github release
git tag
DockerHub dockerhub 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

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 *

General configs

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.

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.

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

Validators

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

CI/CD services

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

Makefiles

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.

Dockerfiles

tool links disable files fmt support
dockerfilelint GitHub
try-online
VALIDATE_DOCKERFILELINT Dockerfile etc.
hadolint GitHub VALIDATE_HADOLINT Dockerfile etc.

XML, HTML, SVG

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

Documentation (Markdown, Plain Text)

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}

Shell script files

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}

Python

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.

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