日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

搭建react + typescript + airbnb eslint 项目

發布時間:2024/3/13 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 搭建react + typescript + airbnb eslint 项目 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

步驟:

  • 使用 create-react-app 創建項目 + typescript
  • 安裝eslint – airbnb
  • 修改 .eslintrc.json配置
  • // 1.使用 create-react-app 創建項目 + typescript // (npx create-react-app my-app --typescript 已廢棄 -- 中文文檔更新不及時) // 參照英文文檔 https://create-react-app.dev/docs/adding-typescript npx create-react-app my-app --template typescript// 2.安裝eslint -- airbnb // 全局安裝eslint yarn global add eslint // 本地安裝 eslint yarn add eslint --dev // 初始化 eslint --init

    // 3.修改 .eslintrc.json配置 //.eslintrc.json {"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"} }


    可能出現報錯:

    解決方法:可以刪除依賴包node_modules重新安裝依賴 ~ yarn

    總結

    以上是生活随笔為你收集整理的搭建react + typescript + airbnb eslint 项目的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。