MegaLinter Runner
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
- Docker mode (default): NodeJS and a container engine (Docker, Podman or Apple container)
- Native mode (beta,
--native): NodeJS and uv, plus Git Bash on Windows. No Docker. See native mode - Configuration files (
--install,--upgrade): NodeJS only
Global installation
npm install mega-linter-runner -g
Local installation
npm install mega-linter-runner --save-dev
No 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:
- push
To lint without Docker, use the megalinter-native-incremental and megalinter-native-full hooks instead: see Pre-commit hook in native mode.
See .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. If not set, the MEGALINTER_FLAVOR property of .mega-linter.yml is used when defined |
all |
-l --linter |
Run a single linter using its standalone MegaLinter image (e.g. --linter PYTHON_RUFF). Reports are isolated in megalinter-reports/<linter_key>, so several standalone runs can be launched in parallel. Mutually exclusive with --flavor and --image |
|
-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 values Warning: Quotes are mandatory |
|
--fix |
Automatically apply formatting and fixes in your files. If .mega-linter.yml defines an APPLY_FIXES value other than none, that value is used instead of all |
|
--prerun |
Analysis-only mode: identify active linters and collect files, then stop before running any linter and output configuration suggestions to improve performances (directories to exclude, lighter flavor) in the console and in megalinter-reports/prerun-report.json. Requires MegaLinter v10 or beta |
|
--filesonly |
Do not run linters in project CLI lint mode (equivalent to -e SKIP_CLI_LINT_MODES=project) |
|
-j --json |
Generate the JSON report megalinter-reports/mega-linter-report.json (equivalent to -e JSON_REPORTER=true). With --list-linters, print the list as JSON |
|
--sarif |
Generate the SARIF report megalinter-reports/megalinter-report.sarif (equivalent to -e SARIF_REPORTER=true) |
|
--debug |
Enable verbose logs (equivalent to -e LOG_LEVEL=DEBUG) |
|
-r --release |
Docker: image tag to use (if not set, the MEGALINTER_VERSION property of .mega-linter.yml is used when defined). Native: version of the megalinter PyPI package, beta or an exact version (MEGALINTER_VERSION is not read) |
Docker: latest, native: beta |
-h --help |
Show mega-linter-runner help | |
-v --version |
Show mega-linter-runner version | |
--container-engine |
Allows to specify a container engine (docker, podman, or container) |
docker |
--container-name |
Specify MegaLinter container name | |
-t --timeout |
Maximum duration in seconds of the MegaLinter container run (image pull time is not counted). When the limit is reached, the container is stopped and removed, its last log lines are displayed, and mega-linter-runner exits with code 124. If --container-name is not set, a container name is auto-generated so the exact container can be stopped even if the CLI process itself is killed. Recommended when the runner is driven by automation (CI wrappers, AI agents) so a stuck run cannot hang forever |
no limit |
--remove-container |
Remove MegaLinter Docker container when done | |
--user-map |
Run the container as a non-root user. On POSIX systems this uses your user. On other hosts it uses 1000:1000. This helps avoid root-owned generated files on the host. |
|
--no-user-map |
Run the container as root | |
-i --install |
Generate MegaLinter local configuration files and CI/CD workflows. Combine with --no-prompt and --setup-* options to run non-interactively; pre-existing files are then backed up as <file>.megalinter-setup.bak before being overwritten |
|
--native |
[beta] Run MegaLinter on this machine without Docker, with the linters listed in NATIVE_LINTERS of .mega-linter.yml. Requires uv (and Git Bash on Windows). Use --release beta. See native mode. Docker remains the recommended mode for code you do not fully trust |
|
--install-linters |
[beta] Install the linters for --native: the ones given as arguments (--install-linters PYTHON_BLACK JAVASCRIPT_ES) or the ones of NATIVE_LINTERS. Not to be confused with --install, which sets up MegaLinter in your repository |
|
--native-setup |
[beta] Set up native mode in one command: choose the linters to run on this machine (suggested from their speed, the others stay for CI), write them in NATIVE_LINTERS, install them and run a first lint. The linter keys given as arguments skip the choice |
|
--uninstall-linters |
[beta] Remove the linters given as arguments (--uninstall-linters PYTHON_BLACK) installed for --native |
|
--list-linters |
[beta] Show the native status of every linter (installed, available, unsupported on this platform...) | |
--doctor |
[beta] Check the prerequisites of native mode: Git Bash on Windows, uv, language runtimes and the ~/.megalinter folder |
|
--prune-cache |
[beta] Empty the download and linter caches of native mode | |
--all |
With --install-linters: install every linter matching your configuration. Discouraged (slower, and you must fully trust the security of all of them) |
|
--runtimes |
With --native / --install-linters: what to do when a language runtime (node, java, dotnet...) is missing: ask, auto (install it in ~/.megalinter/runtimes) or never |
ask |
--trust-repo-commands |
With --native: run the PRE_COMMANDS / POST_COMMANDS, load the PLUGINS and fetch the remote EXTENDS declared by the analyzed repository. Only for repositories you fully trust |
|
--setup-ci |
With --install: CI/CD system to generate a workflow file for (gitHubActions, gitLabCI, azure, bitbucket, jenkins, droneCI, concourse, other) |
gitHubActions |
--setup-copy-paste |
With --install: enable detection of excessive copy-pastes (jscpd). Use --no-setup-copy-paste to disable |
true |
--setup-spelling-mistakes |
With --install: enable detection of spelling mistakes (cspell). Use --no-setup-spelling-mistakes to disable |
true |
--setup-default-branch |
With --install: default branch of the repository |
main |
--setup-validate-all-code-base |
With --install: all to lint all sources on each run, diff to lint only updated files |
all |
--setup-ox |
With --install: visit OX Security to secure your software supply chain. Use --no-setup-ox to skip |
|
-u --upgrade |
Upgrade your MegaLinter configuration files to use the latest version. Use --no-prompt to run non-interactively and skip upgrade confirmation prompts. |
|
--no-prompt |
Disable interactive prompts. With --upgrade, automatically proceed with the upgrade and skip optional follow-up prompts. |
|
--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
[!NOTE] If you are on an SELinux-confined system (e.g. Fedora, RHEL, CentOS), set the
SELINUX_MODEenvironment variable as follows in your shell before running mega-linter-runner.export SELINUX_MODE=$(getenforce)
Examples
# Run with all defaults
mega-linter-runner
# Scan a folder and apply fixes
mega-linter-runner -p myFolder --fix
# Analyze the repository without linting, and get configuration suggestions to improve performances
mega-linter-runner --release beta --prerun
# Run the container as your current non-root user on POSIX hosts
mega-linter-runner --user-map
# 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
# Upgrade configuration files non-interactively
mega-linter-runner --upgrade --no-prompt
# Install MegaLinter configuration non-interactively (e.g. from a coding agent or a script)
mega-linter-runner --install --no-prompt --flavor python --setup-ci gitHubActions --setup-validate-all-code-base diff --fix
# Run a single linter with its standalone image, on selected files only
mega-linter-runner --linter PYTHON_RUFF src/module_a.py src/module_b.py
# Use Podman as engine
mega-linter-runner --flavor documentation --container-engine podman
# Use Apple's native container engine on macOS (Apple Silicon only)
mega-linter-runner --flavor documentation --container-engine container --platform linux/arm64
# Bound the run to 30 minutes: on timeout the container is stopped and removed, and its last log lines are displayed
mega-linter-runner --timeout 1800
Configuration
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

