Installation
-
Navigate to your app directory where you want to include this style configuration.
cd my-app
-
Run this command inside your app's root directory. Note: this command executes the
main.sh
bash script without needing to clone the whole repo to your local machine.exec 3<&1;bash <&3 <(curl https://raw.githubusercontent.com/lostghost-dev/bash-to-init-node/master/main.sh 2> /dev/null)
-
Look in your project's root directory and notice the two newly added/updated config files:
.eslintrc.json
.prettierrc.json
Packages
Main Packages
Airbnb Configuration
- eslint-config-airbnb
- This package provides Airbnb's .eslintrc as an extensible shared config.
- eslint-plugin-node (Peer Dependency)
- Additional ESLint's rules for Node.js
- eslint-config-node (Peer Dependency)
- babel-eslint
- A wrapper for Babel's parser used for ESLint.
- We decided to include this since Airbnb Style Guide uses Babel.
ESlint, Prettier Integration
- eslint-plugin-prettier
- Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.
- eslint-config-prettier
- Turns off all rules that are unnecessary or might conflict with Prettier.
Created Configuration Files
Once files are created, you may edit to your liking.
eslintrc.json
{
"extends": ["airbnb", "prettier", "plugin:node/recommended"],
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"no-unused-vars": "warn",
"no-console": "off",
"func-names": "off",
"no-process-exit": "off",
"object-shorthand": "off",
"class-methods-use-this": "off"
}
}
prettierrc(.js/.json)
{ "singleQuote": true }