June 2019
Intermediate to advanced
192 pages
4h
English
A linter is a program that uses a set of rules to detect code that, though syntactically valid, is likely to contain mistakes. A classic example is using = (assignment) instead of == or === (equality) in an if statement:
| | if (savings = 0) { |
| | // This "condition" would empty your account! |
| | } |
Linting JavaScript is especially valuable because of its relatively freewheeling nature. If you mistype window as wimdow, your program won’t refuse to run; it just won’t run the way you’d hoped. Of course, one way to avoid such fat-finger bugs is to have extensive test coverage. But a linter can often identify such problems sooner, and give you more helpful information for fixing them. Enter ESLint.[24]
Although other ...
Read now
Unlock full access