Skip to content

Apply fixes

MegaLinter can apply fixes provided by linters. To use this capability, you need three environment variables defined at the top level.

  • APPLY_FIXES: all to apply fixes of all linters, or a list of linter keys (ex: JAVASCRIPT_ES,MARKDOWN_MARKDOWNLINT)

Only for the GitHub Actions workflow file, if you use it:

  • APPLY_FIXES_EVENT: all, push, pull_request, none (use none in case of use of Updated sources reporter)
  • APPLY_FIXES_MODE: commit to create a new commit and push it on the same branch, or pull_request to create a new PR targeting the branch.

Apply fixes issues

You may see GitHub permission errors, or workflows not running on the new commit.

To solve these issues, apply one of the following solutions.

-- Method 2: Easier, but any contributor with write access can see your Personal Access Token, so use it only on private repositories. - Create a Classic Personal Access Token, then copy the PAT value - Define secret variable named PAT on your repository, and paste the PAT value

Notes

  • You can use the Updated sources reporter if you don't want fixes to be automatically applied on the Git branch. Instead, download them in a ZIP file and manually extract them into your project.
  • If used, APPLY_FIXES_EVENT and APPLY_FIXES_MODE cannot be defined in the .mega-linter.yml config file; they must be set as environment variables.
  • If you use APPLY_FIXES, add the following line to your .gitignore file:
megalinter-reports/