Skip to content

Configuration

MegaLinter works out of the box. To adapt it to your repository, set its variables in a .mega-linter.yml file at the root of the repository, or as environment variables, which take priority.

# .mega-linter.yml
APPLY_FIXES: all                        # Apply the fixes of formatters and linters
DISABLE_LINTERS:                        # Linters you do not want
  - SPELL_CSPELL
FILTER_REGEX_EXCLUDE: (test/fixtures/)  # Files that must not be linted

Your IDE completes and checks the variables of .mega-linter.yml thanks to its JSON schema.

  • .mega-linter.yml file

    Where to put the configuration, how to extend a shared one, and the autocompletion in your IDE.

    Configuration file

  • Common variables

    All the variables that apply to the whole run: workspace, reports, excluded directories, errors...

    Common variables

  • Activation and deactivation

    Enable or disable languages and linters, make a linter not blocking, or allow a number of errors.

    Activation and deactivation

  • Filter linted files

    Include or exclude files with regular expressions, for all the linters or for one of them.

    Filtering files

  • Apply fixes

    Let formatters and linters fix your files, then commit the fixes or open a pull request with them.

    Apply fixes

  • Linter specific variables

    Arguments, configuration file, rules folder, file extensions and more, for each linter.

    Linter scopes variables

  • Pre-commands

    Run commands before the linters, to install linter extensions with npm, pip or any other tool.

    Pre-commands

  • Post-commands

    Run commands after the linters, for example to publish the reports.

    Post-commands

  • Environment variables security

    Hide from the linters the environment variables that can contain secrets.

    ENV variables security

  • CLI lint mode

    Lint file by file, a list of files at once, or the whole project: how each linter is called.

    CLI lint mode

Going further

  • Flavors: smaller Docker images with only the linters of your languages
  • Reporters: pull request comments, SARIF, console and file reports
  • Plugins: add your own linters
  • LLM Advisor: AI suggestions to fix the errors
  • Observability: send the results of each run to your dashboards

Comments