Configure ES Lint with Airbnb rules for a Node.js Application
Install ES Lint modules⌗
npm install --save-dev eslint-plugin-import eslint
Install Airbnb config⌗
Use the base version for Node.js applications. They also publish a version for React applications as eslint-config-airbnb
.
npm install --save-dev eslint-config-airbnb-base
Config File⌗
Create a .eslintrc
file with following contents to Airbnb rules for the Node.js Application.
{
"extends": "eslint-config-airbnb-base"
}
NPM Scripts⌗
Create few npm scripts to integrate linting into development flow.
{
"scripts":{
"start": "node .",
"lint": "eslint --fix .",
"dev": "nodemon --exec 'npm run lint && npm run start'"
}
}
VS Code⌗
There is an extension on VS Code for ES Lint, available at https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
Read other posts
Discuss Post