Eslint is a linter that helps keep every team member commit the same style of code. During a internship, I come across Eslint. I was already using Prettier at the time.
Something weird happens. Prettier is forcing a style on save. Eslint is forcing another style on commit. So I decide to merge Prettier and Eslint.
Setup Eslint for Node.js
npm i --save-dev eslint prettier eslint-config-prettier eslint-plugin-prettier
.eslintrc.json at the level of
Add below scripts to the file
The default of prettier is double quotation mark. Industry standard prefers single quotation mark. To change double quotation to single quotation, open
Add below key and value in the outermost curly bracket:
How to Run
Add a script to package.json. The files I want to Eslint to work on is under
Open terminal and type in
npm run pretest. Eslint should fix the styling problems.