开始学习 React ,自己想用 Vite 作为开发环境,但是被配置 eslint 和 prettier 卡主了,看网上文章每个教的都不太一样,搞不懂 eslint plugin 到底要装哪些,于是想找个脚手架直接上,但是看网上基本上都是 ts 版的脚手架,想问问有没有 V 友能分享一下在维护的 js 版本的 vite 脚手架
![]() | 1 jawilx 2022-04-14 11:17:47 +08:00 ![]() 放弃 eslint 就简单了,https://github.com/vitejs/awesome-vite 这个里面有各种各样的模板 |
![]() | 3 stille 2022-04-14 11:28:28 +08:00 最近学习 vue 也是 eslint 搞懵逼了,脚手架里一套,vscode 插件又一套.实在不知道该怎么配了. |
4 TWorldIsNButThis 2022-04-14 11:37:06 +08:00 ![]() 这个之前搞了我好几天,也是各种冲突和不适用的老规则 最后定下来是用 eslint 驱动 prettier ,装 eslint-config-prettier eslint-plugin-prettier 然后在 eslintrc 里写 eslint 和 prettier 的配置 { "env": {"browser": true, "es2021": true}, "extends": [ "eslint:recommended", "plugin:react/recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended", "plugin:prettier/recommended" ], "parser": "@typescript-eslint/parser", "parserOptions": {"ecmaFeatures": {"jsx": true}, "ecmaVersion": "latest", "sourceType": "module"}, "settings": { "react": { "version": "detect" } }, "plugins": ["react", "@typescript-eslint"], "rules": { "quotes": ["error", "single"], "semi": ["error", "never"], "react/react-in-jsx-scope": "off", "prettier/prettier": [ "error", { "trailingComma": "es5", "singleQuote": true, "printWidth": 120, "semi": false, "plugins": ["prettier-plugin-tailwindcss"], "tailwindConfig": "./tailwind.config.js", "endOfLine": "auto" } ] }, "ignorePatterns": ["**/*.config.*", "dist/**/*"] } |
![]() | 5 guzzhao 2022-04-14 12:04:10 +08:00 via Android ![]() https://github.com/guzzhao/my-react-app 可以看看我这个,完成度不咋高,eslint 用的腾讯的 |
7 me221 2022-04-14 13:06:51 +08:00 刚开始学就别用什么 lint 了吧 |
![]() | 8 zhaol 2022-04-14 14:39:25 +08:00 如果只是学了自己玩玩可以不学 ts ,如果是为了工作的话,建议还是一起学了,很多公司都有这个要求。其实上手也很快,不用很深入。 |
![]() | 11 dengqing 2022-04-14 20:57:33 +08:00 via iPhone 如果是后台可以用这个 vite-ant-design-pro 完成度还可以 https://github.com/1247748612/vite-ant-design-pro 创建项目 pnpm create ant-design-pro |
![]() | 12 molvqingtai 2022-04-15 00:19:50 +08:00 via Android ![]() 有写过 eslint 配置的文章,其实挺简单的 https://juejin.cn/post/6971812117993226248#heading-5 |
13 me221 2022-04-15 08:27:54 +08:00 ![]() |
14 Kei001 OP @TWorldIsNButThis #4 感谢,可否分享一下你的 package.json 呢 |
![]() | 16 Dragonphy 2022-07-01 15:09:20 +08:00 |