Checking Code Quality with ESLint
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 ...
Get Test-Driven React now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.