{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
}
-
- install prettier -> npm install prettier --save-dev --save-exact
-
- add .prettierrc.json and .prettierignore files for ignoring /node_modules
{
"bracketSameLine": true,
"bracketSpacing": true,
"printWidth": 200,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "none",
"useTabs": false
}
-
- check & install eslint -> npm ls eslint / npm install eslint --save-dev
- configure eslint -> npm init @eslint/config
-
- check & install eslint-plugin-react -> npm ls eslint-plugin-react-hooks / npm i eslint-plugin-react-hooks --save-dev
-
- check & install eslint-react-hooks -> npm ls eslint-react-hooks / npm install eslint-react-hooks --save-dev -> - for react hooks follow thins link - https://reactjs.org/docs/hooks-rules.html
-
- npm install eslint-config-prettier --save-dev -> so that no conflict happen between eslint and prettier
-
- create .eslintrc.json setup - configure the .eslintrc.json file accroding to your needs -> https://eslint.org/docs/latest/rules/
// .eslintrc.json
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": ["react-app", "react-app/jest", "prettier"],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"no-var": "error",
"camelcase": "error",
"no-empty": "error",
"default-case": "error",
"eqeqeq": "error",
"max-lines": ["error", 50],
"max-depth": ["error", 3]
}
}
-
- apply prettier now -> npx prettier --write .