Skip to content

Instantly share code, notes, and snippets.

@keidrun
Created October 2, 2018 08:28
Show Gist options
  • Select an option

  • Save keidrun/59c6cbd883fd2334c372d2f2591c86ca to your computer and use it in GitHub Desktop.

Select an option

Save keidrun/59c6cbd883fd2334c372d2f2591c86ca to your computer and use it in GitHub Desktop.
Eslint Airbnb Settings for simple NodeJS project
{
"extends": [
"airbnb-base",
"plugin:prettier/recommended"
],
"plugins": [
"node",
"prettier"
],
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 8
},
"rules": {
"prettier/prettier": [
"error",
{
"trailingComma": "all",
"singleQuote": true,
"semi": true,
"printWidth": 80
}
],
"node/exports-style": [
"error",
"module.exports"
],
"node/no-deprecated-api": "error",
"node/no-missing-import": "error",
"node/no-missing-require": "error",
"node/no-unpublished-bin": "error",
"node/no-unpublished-import": "error",
"node/no-unpublished-require": "error",
"node/no-unsupported-features": "error",
"node/process-exit-as-throw": "error",
"node/shebang": "error",
"no-unused-vars": [
"warn",
{
"vars": "all"
}
],
"arrow-body-style": [
"error",
"as-needed"
],
"no-console": "off",
"radix": "warn",
"no-shadow": [
"error",
{
"builtinGlobals": false,
"hoist": "all",
"allow": [
"resolve",
"reject",
"done",
"next",
"err",
"error",
"cb",
"callback"
]
}
],
"quotes": [
"error",
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"no-underscore-dangle": "off"
}
}

Add devDependencies

$ yarn add --dev eslint eslint-config-airbnb-base eslint-plugin-import eslint-plugin-node
$ yarn add --dev prettier eslint-plugin-prettier eslint-config-prettier 
$ yarn add --dev husky lint-staged

Settings

  • Add and Edit .eslintrc
  • Edit package.json
{
...
"lint-staged": {
"**/**.js": [
"eslint --fix",
"git add"
]
},
"scripts": {
"start": "node app.js",
"lint": "eslint --fix '**/*.js'",
"precommit": "lint-staged"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment