The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive

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.

Intro

To me, GitHub Super Linter is the ultimate linter, because it al…


This content originally appeared on DEV Community and was authored by Davide Benvegnù

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.

Intro

To me, GitHub Super Linter is the ultimate linter, because it allows you to lint almost any kind of code, with a minimal setup.

If you don't know what a linter is and why you should use one, I'd highly recommend you to check out the previous post or the video I've published on the subject.

What is GitHub Super Linter?

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.

And it doesn't end here. In fact GitHub Super Linter is unique, it supports many languages. Usually a linter is developed specifically for a Language, but the Super Linter supports almost every programming and scripting language you can think of. Whether you are using C#, Groovy, Kotlin, Python, GO, JavaScript or even IaC languages like Ansible, Terraform, or ARM, or yet XML, JSON and YAML... this linter has you covered.

GitHub Super Linter

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

How does GitHub Super Linter work?

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.

How to set up the Super Linter

To show how to set up and use the Super Linter, I created a video in which I have a full demo:

Link to the video: https://youtu.be/BCrtoZ04L1Y

Click here to jump directly to the demo part

Customizations for the GitHub Super Linter

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.

Environment Variables

Click here to jump directly to the demo part for the Environment Variables

Template Rules and Custom Rules

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.

Other Customizations

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.

Conclusions

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:

? YouTube
Buy me a coffee
? Patreon
? Merch
?? Facebook page
?‍? GitHub
?? Twitter
?? LinkedIn
? Podcast


This content originally appeared on DEV Community and was authored by Davide Benvegnù


Print Share Comment Cite Upload Translate Updates
APA

Davide Benvegnù | Sciencx (2021-04-12T23:42:47+00:00) The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive. Retrieved from https://www.scien.cx/2021/04/12/the-easiest-way-to-lint-any-code-github-super-linter-deep-dive/

MLA
" » The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive." Davide Benvegnù | Sciencx - Monday April 12, 2021, https://www.scien.cx/2021/04/12/the-easiest-way-to-lint-any-code-github-super-linter-deep-dive/
HARVARD
Davide Benvegnù | Sciencx Monday April 12, 2021 » The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive., viewed ,<https://www.scien.cx/2021/04/12/the-easiest-way-to-lint-any-code-github-super-linter-deep-dive/>
VANCOUVER
Davide Benvegnù | Sciencx - » The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/12/the-easiest-way-to-lint-any-code-github-super-linter-deep-dive/
CHICAGO
" » The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive." Davide Benvegnù | Sciencx - Accessed . https://www.scien.cx/2021/04/12/the-easiest-way-to-lint-any-code-github-super-linter-deep-dive/
IEEE
" » The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive." Davide Benvegnù | Sciencx [Online]. Available: https://www.scien.cx/2021/04/12/the-easiest-way-to-lint-any-code-github-super-linter-deep-dive/. [Accessed: ]
rf:citation
» The EASIEST Way to Lint Any Code – GitHub Super Linter Deep Dive | Davide Benvegnù | Sciencx | https://www.scien.cx/2021/04/12/the-easiest-way-to-lint-any-code-github-super-linter-deep-dive/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.