Login

Log in with one your accounts

Contribution

We are happy you want to contribute to DXKB. Please choose your preferred way

All Articles
Nov 11, 20193 min read

Linting

Avoid stress with Linter! Let it analyze your code and find bugs and stylistic errors. Linter should be your best friend.

What Is a Linting

Lint, or a Linter, is a very useful tool for automated analyzing of your source code to look for bugs and stylistic errors. Linter helps to ensure that your code does not include any structural issues which can make your code harder to maintain. Linting became a verb and it is the process of flagging the functional and structural problems. The Lint tool is a basic static code analyzer. The term Linting comes from a Unix utility for C.

LintingSource: Linting

Linters are available for most programming languages. Here are the most common ones:

You should restrain from using TSLint as your linter for JavaScript. Palantir (the creator of TSlint) deprecated their linter in favor of Eslint's improvements (Source).

Ready to put this knowledge into action?

Visit our website and learn how DX Heroes can help your business succeed.

Why You Might Want the Linting

  • Linting helps you reduce errors and improve the quality of your code.
  • It is an automated check and it saves the developers’ time.
  • It improves the code readability. It unifies the style within the team and therefore safes the time during the Code Review.
  • It can automatically correct some mistakes (auto fix).

Problems the Linting Solves

How to Implement the Linting

  • Linting should happen early in the development phase, before the Code Review and testing. It has to be integrated into the developer environment.
  • Implement the Linting to the Continuous Integration.
  • Ensure that your code follows standard rules. Otherwise, the Linter flags more than you need. You can override the default settings or disable rules for specific files but it can bring more trouble.
  • Turn on the auto fixer for as many errors as possible. After the implementation, fix all the issues from the auto fix.
  • Make a separate pull request so the other developers understand that you started using a Linter.

Common Pitfalls of the Linting

  • A high number of searched errors can lead to high false positive and false negative rates. Also, automatically corrected errors have to be rewritten by hand.
  • Too many rules and therefore too many notifications can get annoying. Turn on the auto fixer and get rid of as many marked errors as possible.
  • Implementing the Linting without informing your colleagues can lead to misunderstandings.
  • Do not Lint on demand. If you have it, use it.

Resources for the Linting

Was the article helpful?

Want to write for DXKB?

Feel free to contribute. People from DXKB community will be more than happy.

Avatar

Prokop Simek

CEO

CEO at DX Heroes
CEO at DX Heroes

Contribution

We are happy you want to contribute to DXKB. Please choose your preferred way