GitHub Super Linter allows you to lint almost any code with just a single component. Today I'm going to show you how it works, how to set it up and use it for your code.
To me, GitHub Super Linter is the ultimate linter, because it allows you to lint almost any kind of code, with a minimal setup.
So, first things first... what is the GitHub Super Linter?
GitHub Super Linter is not just a linter, it's a very special one. In fact, the Super Linter is a source code repository that is packaged into a Docker container and called by GitHub Actions. This allows for any repository on GitHub.com to call the Super Linter and start utilizing its benefits.
To add on this, the end goal of this tool is to:
- Prevent broken code from being uploaded to the default branch (Usually master or main)
- Help establish coding best practices across multiple languages
- Build guidelines for code layout and format
- Automate the process to help streamline code reviews
So, how does this work, you ask. Well, it's pretty easy actually.
When you’ve set your repository to start running this action, any time you open a pull request, it will start linting the code and return via the Status API. It will let you know if any of your code changes passed successfully, or, if any errors were detected, where they are, and what they are. This allows you to go back to your branch, fix any issues, and create a new push to the pull request. At that point, the Super Linter will run again and validate the updated code and repeat the process.
You can configure your branch protection rules to make sure all code must pass before being able to merge as an additional measure.
To show how to set up and use the Super Linter, I created a video in which I have a full demo:
Now that we have our Super Linter set up, let's see how we can customize it.
We are going to analyze the use of Environment Variables, template rules files, and using your own rules files.
Let's move to the rules. You can use the GitHub Super-Linter with or without your own personal rules sets. This allows for greater flexibility for each individual code base.
To use template rules files provided by GitHub, you can copy any or all template rules files from the Templates folder of the Super Linter repo into the folder
.github/linters/ of your repository.
If your repository does not have rules files, the Super Linter will anyway fall back to the defaults rules contained in the TEMPLATES folder.
You can of course use those templates as base to develop your own ruleset. And as we have seen before, you can use the Environment variables to tell the Super Linter where your custom rules files are, if you prefer saving them in a different folder.
There’s a ton of other customizations with flags and templates that can help you customize the Super Linter to your individual repository. Just follow the detailed directions at the Super Linter repository and the Super Linter wiki.
It is also possible to use the GitHub Super Linter outside of GitHub, for example in Azure, Azure DevOps, GitLab and even locally on your machine. Let me know in the comment section below if you want me to make another post or video showing how to do this.
Let me also know what you think about the GitHub Super Linter, I truly love it and I'm using it basically in every repo I have.
Like, share and follow me 🚀 for more content: