According to google, the definition of “lint” is “short, fine fibres which separate from the surface of cloth or yarn during processing.”
However for us programmers a linter is a software that checks your code for errors, bad practices, bad formatting and logical issues, and gives you a warning when you make a mistake. A linter can be configurable according to rules that you decide.
Well, there are quite a few reasons:
Let me double stress the fact that linters are especially important if you work in a team (meaning not alone), because by following some rules you can make sure that your code looks the same regardless of who’s writing the code.
The error position is also specified within parenthesis, in this case it is 7,12 (line 7, char 12).
While a sass linter looks like this (screenshot courtesy of Stack Overflow)
npm install -g eslint
npm install -g sass-lint
Linters need configuration files in order to give instructions to our linters about how we want the linter to behave. To get started, you can use some default linter configurations, and when you grow more accustomed to their usage you can change these defaults. You have to place these config files in the root of your project for it to be recognised by the code editor.
Go to your project folder using your Terminal, and type:
This will start a little program that will ask you a few questions. The first question you get is the following, just press enter to proceed.
Then you’ll be asked a bunch of additional question, choose whatever you want:
This will create a .eslintrc.json file which will look like this:
That’s it, you got a working ESlint configuration.
You can find a sample configuration file here on the official repository. Download the file and add it to your root.
Linters are available for any coding language, and the installation steps are similar to these ones, although almost certainly slightly different.