npm init
npm install eslint jest nodemon --save-dev
Create .eslintrc.js for commonjs (useful for generic backend modules) and standard code style
$ eslint --init
You can also run this command directly using 'npm init @eslint/config'.
npx: installed 40 in 1.055s
✔ How would you like to use ESLint? · style
✔ What type of modules does your project use? · commonjs
✔ Which framework does your project use? · none
✔ Does your project use TypeScript? · No / Yes
✔ Where does your code run? · node
✔ How would you like to define a style for your project? · guide
✔ Which style guide do you want to follow? · standard
✔ What format do you want your config file to be in? · JavaScript
Checking peerDependencies of eslint-config-standard@latest
The config that you've selected requires the following dependencies:
eslint-config-standard@latest eslint@^8.0.1 eslint-plugin-import@^2.25.2 eslint-plugin-n@^15.0.0 eslint-plugin-promise@^6.0.0
✔ Would you like to install them now? · No / Yes
✔ Which package manager do you want to use? · yarn
Installing eslint-config-standard@latest, eslint@^8.0.1, eslint-plugin-import@^2.25.2, eslint-plugin-n@^15.0.0, eslint-plugin-promise@^6.0.0
...
Successfully created .eslintrc.js file in /media/nomikos/home/nomikos2/dev/pruebas-trabajo/amazon-sde/plusMinus
ref: https://dev.to/devdammak/setting-up-eslint-in-your-javascript-project-with-vs-code-2amf
In settings.json paste the following code:
.vscode/settings.json
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript"]
}
ref: https://www.digitalocean.com/community/tutorials/workflow-auto-eslinting
In many occasions you just want edit some single js files without all the paraphernalia
- Install standard globally
npm install standard eslint --global
-
Install vscode standardjs extension https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard
-
Customize vscode-standard in your VSCode settings.json.
standard.enable: true
standard.enableGlobally: true
standard.autoFixOnSave: true