Apply fixes
Mega-linter is able to apply fixes provided by linters. To use this capability, you need 3 env variables defined at top level
- APPLY_FIXES:
all
to apply fixes of all linters, or a list of linter keys (ex:JAVASCRIPT_ES
,MARKDOWN_MARKDOWNLINT
)
Only for GitHub Action 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, orpull_request
to create a new PR targeting the branch.
Apply fixes issues
You may see github permission errors, or workflows not run on the new commit.
To solve these issues, you can apply one of the following solutions.
- Method 1: The most secured
- Create Fine Grained Personal Access Token, scoped only on your repository and then copy the PAT value
- Define environment secret variable named PAT on your repository, and paste the PAT value
- Update your Github Actions Workflow to add the environment name
- Method 2: Easier, but any contributor with write access can see your Personal Access Token
- Create 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 Updated sources reporter if you don't want fixes to be automatically applied on git branch, but download them in a zipped file and manually extract them in your project
- If used, APPLY_FIXES_EVENT and APPLY_FIXES_MODE can not be defined in
.mega-linter.yml
config file, they must be set as environment variables - If you use APPLY_FIXES, add the following line in your
.gitignore file
megalinter-reports/