Installing and configuring ESLint

The first step to automating the quality of your React source code is installing and configuring the tool used to automate it—ESLint. When ESLint is installed, it installs an eslint command on your system. Like other packages that install commands, it's better to have them installed locally as part of the project, so that you don't have to rely on the command being available globally on the system.

To install ESLint in your project, run the following npm command:

npm install eslint --save-dev

Now that you have ESLint installed, you can create a new npm script that will run ESLint for you. Add the following to the scripts section of your package.json file:

"scripts": { 
  ... 
  "lint": "eslint" 
}, 

You now have ...

Get React 16 Tooling 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.