-
Install React
npx create-react-app Demo
-
Install prettier and eslint extensions in VS Code
-
Install prettier and eslint as dev dependencies
npm install -D eslint prettier
-
Install Airbnb config
npx install-peerdeps --dev eslint-config-airbnb
-
Disable eslint formatting
npm install -D eslint-config-prettier eslint-plugin-prettier
-
Create .eslintrc.json
{ "extends": ["airbnb", "prettier"], "plugins": ["prettier"], "rules": { "prettier/prettier": ["error"] } }
-
Create .prettierrc
{ "printWidth": 100, "singleQuote": true }
-
Set up format on save in VS Code
"editor.formatOnSave": true
-
Add simple rules
{ "env": { "browser": true, "es6": true, "jest": true }, "extends": ["airbnb", "prettier"], "plugins": ["prettier"], "rules": { "prettier/prettier": [ "error", { "endOfLine": "auto" } ], "react/jsx-one-expression-per-line": "off", "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }] } }
-
Add lint command
"lint": "eslint ./src --ext .js,.jsx"
-
Add .eslintignore
src/serviceWorker.js
-
Install husky
npm i -D husky lint-staged
-
Set linting pre-commit
"husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "./src/*.{js,jsx}": "eslint --fix" }
-
Notifications
You must be signed in to change notification settings - Fork 0
jakubgrzywaczewski/eslint-prettier-tutorial
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Simple eslint and prettier tutorial
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published