$ 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- Add and Edit
.eslintrc - Edit
package.json
| { | |
| "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" | |
| } | |
| } |
| { | |
| ... | |
| "lint-staged": { | |
| "**/**.js": [ | |
| "eslint --fix", | |
| "git add" | |
| ] | |
| }, | |
| "scripts": { | |
| "start": "node app.js", | |
| "lint": "eslint --fix '**/*.js'", | |
| "precommit": "lint-staged" | |
| } | |
| } |