adapted from https://github.com/pappijx/Vite-react-eslint-prettier-husky-setup
- init
npm create vite@latest
- write name of project
- choose
React
- choose
Typescript + SWC
- cd to folder and
npm install
- install
npm install --save-dev eslint
- init config
npm init @eslint/config
- choose
To check syntax and find problems
- choose
JavaScript modules (import/export)
- choose
React
- choose
yes
(for typescript) - choose
browser
- choose
Javascript
(for config format) - choose
yes
to install dependencies now - choose
npm
as package manager
npx install-peerdeps --dev eslint-config-airbnb
extends: [
+ 'airbnb',
+ 'airbnb/hooks'
]
npm install --save-dev eslint-config-airbnb-typescript
extends: [
'airbnb/hooks',
+ 'airbnb-typescript'
]
+ parserOptions: {
+ project: './tsconfig.json'
+ }
include: ".eslintrc.cjs"
rules: {
'react/react-in-jsx-scope': 0,
// disable because prettier decides this
'implicit-arrow-linebreak': 'off',
// disable because prettier decides this
'operator-linebreak': 'off',
// disable indent https://github.com/typescript-eslint/typescript-eslint/issues/1824
'@typescript-eslint/indent': 'off',
},
edit tsconfig.json
change:
"moduleResolution": "bundler",
to:
"moduleResolution": "node",
- install
npm install --save-dev prettier eslint-config-prettier eslint-plugin-prettier
- create
.prettierrc.cjs
file with:
module.exports = {
trailingComma: "all", // all instead of es5 because of typescript
tabWidth: 2,
semi: true,
singleQuote: true,
};