Skip to content

Latest commit

 

History

History
126 lines (99 loc) · 2.03 KB

how-project-was-created.md

File metadata and controls

126 lines (99 loc) · 2.03 KB

How project was created

adapted from https://github.com/pappijx/Vite-react-eslint-prettier-husky-setup

vite

  1. init
npm create vite@latest
  1. write name of project
  2. choose React
  3. choose Typescript + SWC
  4. cd to folder and
npm install

eslint

install eslint

  1. install
npm install --save-dev eslint
  1. init config
npm init @eslint/config
  1. choose To check syntax and find problems
  2. choose JavaScript modules (import/export)
  3. choose React
  4. choose yes (for typescript)
  5. choose browser
  6. choose Javascript (for config format)
  7. choose yes to install dependencies now
  8. choose npm as package manager

install airbnb config

npx install-peerdeps --dev eslint-config-airbnb

edit .eslintrc.cjs

extends: [
+  'airbnb',
+ 'airbnb/hooks'
]

install typescript support for airbnb

npm install --save-dev eslint-config-airbnb-typescript

edit .eslintrc.cjs

extends: [
  'airbnb/hooks',
+ 'airbnb-typescript'
]
+ parserOptions: {
+   project: './tsconfig.json'
+ }

edit tsconfig.json

include: ".eslintrc.cjs"

add rules to .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 to fix jsx intrinsic element error in tsx files

vitejs/vite#14011 (comment)

edit tsconfig.json

change:

"moduleResolution": "bundler",

to:

"moduleResolution": "node",

prettier

  1. install
npm install --save-dev prettier eslint-config-prettier eslint-plugin-prettier
  1. create .prettierrc.cjs file with:
module.exports = {
  trailingComma: "all", // all instead of es5 because of typescript
  tabWidth: 2,
  semi: true,
  singleQuote: true,
};