开发环境: node >=18,npm >=8.10.2,vue <= 3.2.31
安装项目
npx degit dcloudio/uni-preset-vue#vite-ts vue3-uniapp
1、引入样式规范
npm add -D eslint eslint-config-airbnb-base eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint-plugin-vue @typescript-eslint/eslint-plugin @typescript-eslint/parser vue-global-api
-
.editorconfig
# editorconfig.org root = true [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false
- .prettierrc.cjs
{ "singleQuote": true, "semi": false, "printWidth": 180, "trailingComma": "all", "endOfLine": "auto" }
- .eslintrc.cjs
/* eslint-env node */ require('@rushstack/eslint-patch/modern-module-resolution') module.exports = { root: true, extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/eslint-config-typescript', '@vue/eslint-config-prettier'], // 小程序全局变量 globals: { uni: true, wx: true, WechatMiniprogram: true, getCurrentPages: true, getApp: true, UniApp: true, UniHelper: true, App: true, Page: true, Component: true, AnyObject: true, }, parserOptions: { ecmaVersion: 'latest', }, rules: { 'prettier/prettier': [ 'warn', { singleQuote: true, semi: false, printWidth: 180, trailingComma: 'all', endOfLine: 'auto', }, ], 'vue/multi-word-component-names': ['off'],