ESLint Installation and Initial Setup for Express (Node.js) Projects

Tadashi Shigeoka ·  Sat, December 28, 2019

I’ll introduce the steps for installing and initially setting up ESLint in an Express (Node.js) project.

JavaScript

Background for ESLint Introduction

I’m introducing ESLint for purposes like “improving code quality” and “organizing code style.”

I’ll explain the complete flow from ESLint installation to initial setup for an Express (Node.js) project based on the following GitHub Pull Request:

ESLint Installation

npm install eslint --save-dev

npm install eslint —save-dev · Pull Request #9 · codenote-net/expressjs-sandbox

ESLint Initial Setup

$(npm bin)/eslint --init

? How would you like to use ESLint? To check syntax, find problems, and enforce code style
? What type of modules does your project use? CommonJS (require/exports)
? Which framework does your project use? None of these
? Does your project use TypeScript? No
? Where does your code run? Node
? How would you like to define a style for your project? Use a popular style guide
? Which style guide do you want to follow? Standard: https://github.com/standard/standard
? What format do you want your config file to be in? JavaScript

$(npm bin)/eslint —init · Pull Request #9 · codenote-net/expressjs-sandbox

Add eslint --fix to npm-scripts

Add “lint”: “eslint .” to npm scripts · Pull Request #9 · codenote-net/expressjs-sandbox

npm run lint:fix

That’s all from the Gemba.

Reference Information