Videos
» npm install eslint-config-recommended
There are plenty for React, but I couldn't find one specifically made for the backend.
» npm install eslint-config-node
1) Add the following modules to your devDependencies using:
npm install --save-dev eslint
npm install --save-dev eslint-config-airbnb-base
npm install --save-dev eslint-plugin-import
2) Add an eslintConfig section to your package.json:
"eslintConfig": {
"extends": "airbnb-base",
"env": {
"es6": true,
"browser": true
},
"rules": {
"brace-style": [
"error",
"stroustrup"
],
"comma-dangle": [
"error",
"never"
],
"no-unused-vars": [
"warn"
],
"no-var": [
"off"
],
"one-var": [
"off"
]
}
}
3) Visit eslint.org/docs/rules, search for the warnings you want to tweak and add them to the eslintConfig above.
4) Delete the .eslintrc file in the root of your project.
5) Restart your IDE
Install eslint package locally to your project.
$yarn add eslint --dev
Ideally one can generate configuration file .eslintrc through below command, unfortunately it installs wrong versions of peerDependencies resulting in weired linting errors.
$./node_modules/.bin/eslint --init
Easier way to fix the version of peerDependencies issue, use below command and install(I suggest you to install packages related to jsx and react though you may not doing any stuff related to React) corresponding version of the peerDependencies along with eslint-config-airbnb
$npm info "eslint-config-airbnb@latest" peerDependencies
Edit .eslintrc file with below content
{
"extends": "airbnb",
"plugins": [
"react",
"jsx-a11y",
"import"
],
"rules": {
},
"env": {
}
}
*Note: Please edit eslintrc file depending on your coding rules, environment you follow. Refer developer-guide
» npm install @asd14/eslint-config