...

/

ESLint to Check Code Quality

ESLint to Check Code Quality

Learn to use ESLint to identify any mistakes in your code, and find out how to configure and install it.

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 freewheel 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 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.

Although other JavaScript linters have been tried before, ESLint is the first to really take off, thanks to its pluggable ...