npx create-next-app@latest
cd folder
npx eslint --init
yarn add --dev eslint-plugin-react-hooks
Edit eslintrc.json
Add to plugins
"plugins": ["react", "@typescript-eslint", "react-hooks"],
Add to rules
"rules": {"react-hooks/rules-of-hooks": "error","react-hooks/exhaustive-deps": "warn","react/react-in-jsx-scope": "off"}
Add to settings
"settings":{"react":{"version": "detect"}}
yarn add --dev --exact prettier
Create .prettierrc
{"trailingComma": "none","semi": true,"singleQuote": true}
yarn add --dev eslint-config-prettier eslint-plugin-prettier
Open .eslintrc.json Add to extends
"extends": ["plugin:prettier/recommended","prettier"],
Add to rules
"rules": {"prettier/prettier": "error"}
Create folder .vscode and inside settings.json
{"editor.formatOnSave": false,"editor.codeActionsOnSave": {"source.fixAll.eslint": true}}
yarn add --dev eslint-plugin-import-helpers
Open .eslintrc.json Add to plugins
"plugins": ["eslint-plugin-import-helpers"]
Add to rules
"rules": {
"import-helpers/order-imports": [
"warn",
{
"newlinesBetween": "always",
"groups": [
["/^react/","/@react/","/^next/","/@next/"],
"/module/",
"/^@shared/",
"/absolute/",
["parent", "sibling", "index"]
],
"alphabetize": { "order": "asc", "ignoreCase": true }
}
]
}
Lets remove @ from import edit tsconfig.json Add to compilerOptions
"baseUrl": "src",