What is a linter

In practical exercises on Hexlet, the solution code is not only checked by tests, but also by a linter. Linters are programs that check the code against standards, following a certain set of rules. The rules describe indents, names of entities to be created, parentheses, mathematical operations, string lengths, and many other aspects. Each rule may seem unimportant, but following them all is the basis of good code.

The linter's main purpose is to make the code uniform and intelligible to both the programmer and the people who will be reading it. Different teams can have different linters and sets of rules for them, but the main thing is to be able to work with a linter in principle, and it's not hard to get used to writing according to certain rules.

Linters in exercises

The linter notes in exercises are displayed at the bottom of the screen in the Linter tab. This screenshot shows an example for the JavaScript language and the ESLint linter, but other linters' output contains similar information. In the linter output, you will always find the name of the file where errors are detected. Under it will be a list of errors with the line number in the file, the number of characters, a brief description, and the name of the violated rule.

To deal with an obscure error, enter its name into the search engine - one of the first links in the output will be the linter site. There is usually a more detailed description of the error, and examples of good and bad code that illustrate it. Fix the code so the linter is happy :)

If you don't understand how to fix the bug, save your solution and ask a question in the corresponding lesson discussion. Someone from our team will definitely help you.