生活随笔
收集整理的這篇文章主要介紹了
搭建react + typescript + airbnb eslint 项目
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
步驟:
使用 create-react-app 創(chuàng)建項(xiàng)目 + typescript安裝eslint – airbnb修改 .eslintrc.json配置
npx create
-react
-app my
-app
--template typescript
yarn global add eslint
yarn add eslint
--dev
eslint
--init
{"env": {"browser": true,"es2021": true,"node": true},"extends": ["plugin:react/recommended","airbnb"],"settings": {"import/parsers": {"@typescript-eslint/parser": [".ts",".tsx"]},"import/resolver": {"node": {"extensions": [".js",".jsx",".ts",".tsx"],"moduleDirectory": ["node_modules","src/"]}},"import/extensions": 0},"parser": "@typescript-eslint/parser","parserOptions": {"ecmaFeatures": {"jsx": true},"ecmaVersion": 12,"sourceType": "module"},"plugins": ["react","@typescript-eslint"],"rules": {"linebreak-style":0,"react/jsx-filename-extension": [2,{"extensions": [".js",".jsx",".ts",".tsx"]}],"semi": ["error","never"],"react/jsx-uses-react": 2,"no-use-before-define": "off","@typescript-eslint/no-use-before-define": ["error"],"import/extensions": "off"}
}
可能出現(xiàn)報(bào)錯(cuò):
解決方法:可以刪除依賴包node_modules重新安裝依賴 ~ yarn
總結(jié)
以上是生活随笔為你收集整理的搭建react + typescript + airbnb eslint 项目的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。