mega-linter-runner
v9.4.0
Published
Local runner for MegaLinter
Keywords
Readme
MegaLinter Runner
MegaLinter analyzes 37 languages, 15 formats, 16 tooling formats , copy-pastes and spell in your repository sources, generate reports in several formats, and can even apply formatting and auto-fixes with auto-generated commit or PR, to ensure all your projects are clean, whatever IDE/toolbox are used by their developers !
See MegaLinter Online Documentation Web Site
This package allows to run MegaLinter locally before running it in your CD/CI workflow, or simply to locally apply reformatting and fixes without having to install up to date linters for your files

Installation
Pre-requisites
You need to have NodeJS and Docker installed on your computer to run MegaLinter locally with MegaLinter Runner
Global installation
npm install mega-linter-runner -gLocal installation
npm install mega-linter-runner --save-devNo installation
You can run mega-linter-runner without installation by using npx
Example:
npx mega-linter-runner -r beta -e "'ENABLE=MARKDOWN,YAML'" -e 'SHOW_ELAPSED_TIME=true'Pre-commit hook
You can run mega-linter-runner as a pre-commit hook
Sample .pre-commit-config.yaml:
repos:
- repo: https://github.com/oxsecurity/megalinter
rev: v6.8.0 # Git tag specifying the hook, not mega-linter-runner, version
hooks:
- id: megalinter-incremental # Faster, less thorough
stages:
- commit
- id: megalinter-full # Slower, more thorough
stages:
- pushSee .pre-commit-hooks.yaml for more details.
Usage
mega-linter-runner [OPTIONS] [FILES]The options are only related to mega-linter-runner. For MegaLinter options, please use a .mega-linter.yml configuration file
| Option | Description | Default |
|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
| -p --path | Directory containing the files to lint | current directory |
| -f --flavor | Set this parameter to use a MegaLinter flavor | all |
| -d --image | You can override the used docker image, including if it's on another docker registry | |
| -e --env | Environment variables for MegaLinter, following format 'ENV_VAR_NAME=VALUE' for a single value or "'ENV_VAR_NAME=VALUE1,VALUE2'" for a list of valuesWarning: Quotes are mandatory | |
| --fix | Automatically apply formatting and fixes in your files | |
| -r --release | Allows to override MegaLinter version used | v5 |
| -h --help | Show mega-linter-runner help | |
| -v --version | Show mega-linter-runner version | |
| --container-engine | Allows to specify a docker engine (docker or podman) | docker |
| --container-name | Specify MegaLinter container name | |
| --remove-container | Remove MegaLinter Docker container when done | |
| -i --install | Generate MegaLinter local configuration files and CI/CD workflows | |
| -i --upgrade | Upgrade your MegaLinter configuration files to use the latest version | |
| --custom-flavor-setup | Initialize a new repository to generate a custom flavor | |
| --custom-flavor-linters | Comma-separated list of linter keys if using --custom-flavor-setup | |
You can also use npx mega-linter-runner if you do not want to install the package
Examples
# Run with all defaults
mega-linter-runner# Scan a folder and apply fixes
mega-linter-runner -p myFolder --fix# Send environment variables
mega-linter-runner -r beta -e "'ENABLE=MARKDOWN,YAML'" -e 'SHOW_ELAPSED_TIME=true'# Use python flavor beta version, only on some files
mega-linter-runner --flavor python --release beta --filesonly path/to/my/file1.py another/path/to/a/file.js and/another/file.py# Use Podman as engine
mega-linter-runner --flavor documentation --container-engine podmanConfiguration
You can generate a ready-to-use .mega-linter.yml configuration file by running npx mega-linter-runner --install at the root of your repository

Linters
Languages
| | Language | Linter | Additional |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------:|---------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| | BASH | bash-execBASH_EXEC | |
| | BASH | shellcheckBASH_SHELLCHECK |
|
| | BASH | shfmtBASH_SHFMT |
|
| | C | cppcheckC_CPPCHECK | |
| | C | cpplintC_CPPLINT |
|
| | C | clang-formatC_CLANG_FORMAT |
|
| | CLOJURE | clj-kondoCLOJURE_CLJ_KONDO |
|
| | CLOJURE | cljstyleCLOJURE_CLJSTYLE |
|
| | COFFEE | coffeelintCOFFEE_COFFEELINT |
|
| | C++ (CPP) | cppcheckCPP_CPPCHECK | |
| | C++ (CPP) | cpplintCPP_CPPLINT |
|
| | C++ (CPP) | clang-formatCPP_CLANG_FORMAT |
|
| | C# (CSHARP) | dotnet-formatCSHARP_DOTNET_FORMAT |
|
| | C# (CSHARP) | csharpierCSHARP_CSHARPIER |
|
| | C# (CSHARP) | roslynatorCSHARP_ROSLYNATOR |
|
| | DART | dartanalyzerDART_DARTANALYZER |
|
| | GO | golangci-lintGO_GOLANGCI_LINT |
|
| | GO | reviveGO_REVIVE |
|
| | GROOVY | npm-groovy-lintGROOVY_NPM_GROOVY_LINT |
|
| | JAVA | checkstyleJAVA_CHECKSTYLE |
|
| | JAVA | pmdJAVA_PMD |
|
| | JAVASCRIPT | eslintJAVASCRIPT_ES |
|
| | JAVASCRIPT | standardJAVASCRIPT_STANDARD |
|
| | JAVASCRIPT | prettierJAVASCRIPT_PRETTIER |
|
| | JSX | eslintJSX_ESLINT |
|
| | KOTLIN | ktlintKOTLIN_KTLINT |
|
| | KOTLIN | detektKOTLIN_DETEKT |
|
| | LUA | luacheckLUA_LUACHECK |
|
| | LUA | seleneLUA_SELENE |
|
| | LUA | styluaLUA_STYLUA |
|
| | MAKEFILE | checkmakeMAKEFILE_CHECKMAKE |
|
| | PERL | perlcriticPERL_PERLCRITIC |
|
| | PHP | phpcsPHP_PHPCS |
|
| | PHP | phpstanPHP_PHPSTAN |
|
| | PHP | psalmPHP_PSALM |
|
| | PHP | phplintPHP_PHPLINT |
|
| | PHP | php-cs-fixerPHP_PHPCSFIXER |
|
| | POWERSHELL | powershellPOWERSHELL_POWERSHELL |
|
| | POWERSHELL | powershell_formatterPOWERSHELL_POWERSHELL_FORMATTER |
|
| | PYTHON | pylintPYTHON_PYLINT |
|
| | PYTHON | blackPYTHON_BLACK |
|
| | PYTHON | flake8PYTHON_FLAKE8 |
|
| | PYTHON | isortPYTHON_ISORT |
|
| | PYTHON | banditPYTHON_BANDIT |
|
| | PYTHON | mypyPYTHON_MYPY |
|
| | PYTHON | nbqaPYTHON_NBQA_MYPY |
|
| | PYTHON | pyrightPYTHON_PYRIGHT |
|
| | PYTHON | ruffPYTHON_RUFF |
|
| | PYTHON | ruff-formatPYTHON_RUFF_FORMAT |
|
| | R | lintrR_LINTR |
|
| | RAKU | rakuRAKU_RAKU |
|
| | RUBY | rubocopRUBY_RUBOCOP |
|
| | RUST | clippyRUST_CLIPPY |
|
| | SALESFORCE | code-analyzer-apexSALESFORCE_CODE_ANALYZER_APEX |
|
| | SALESFORCE | code-analyzer-auraSALESFORCE_CODE_ANALYZER_AURA |
|
| | SALESFORCE | code-analyzer-lwcSALESFORCE_CODE_ANALYZER_LWC |
|
| | SALESFORCE | sfdx-scanner-apexSALESFORCE_SFDX_SCANNER_APEX |
|
| | SALESFORCE | sfdx-scanner-auraSALESFORCE_SFDX_SCANNER_AURA |
|
| | SALESFORCE | sfdx-scanner-lwcSALESFORCE_SFDX_SCANNER_LWC |
|
| | SALESFORCE | lightning-flow-scannerSALESFORCE_LIGHTNING_FLOW_SCANNER |
|
| | SCALA | scalafixSCALA_SCALAFIX |
|
| | SQL | sqlfluffSQL_SQLFLUFF |
|
| | SQL | tsqllintSQL_TSQLLINT |
|
| | SWIFT | swiftlintSWIFT_SWIFTLINT |
|
| | TSX | eslint[TSX_ESLINT](https://github.com/oxsecurity/megalinter/tree/main/docs/descriptors/tsx_eslint.md
