From 82a6f534489209029a387f6a1caff73d91eea576 Mon Sep 17 00:00:00 2001 From: szq233 <470774720@qq.com> Date: Fri, 1 Jul 2022 17:56:11 +0800 Subject: [PATCH] chore: eslint --- .eslintrc.js | 35 ++ README.md | 10 +- babel.config.js | 14 +- package.json | 8 + public/index.html | 3 +- sfc.d.ts | 13 +- shims-vue.d.ts | 4 +- src/App.vue | 38 +- src/common/http.interceptor.ts | 2 +- src/components/register.ts | 4 +- src/main.ts | 6 +- src/models/uview/index.ts | 1 + src/pages/about/index.vue | 2 +- src/pages/home/index.vue | 5 +- src/pages/noAccess/index.vue | 2 +- src/pages/profile/index.vue | 2 +- src/router/index.ts | 12 +- src/store/$u.mixin.ts | 30 +- src/store/index.ts | 95 +++-- src/utils/manifestJson.js | 9 +- src/utils/pagesJson.js | 3 +- vue.config.js | 38 +- yarn.lock | 683 +++++++++++++++++++++++++++++++-- 23 files changed, 852 insertions(+), 167 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..4e18c09 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,35 @@ +module.exports = { + root: true, + env: { + browser: true, + es2021: true, + node: true + }, + extends: [ + 'plugin:vue/essential', + 'standard' + ], + globals: { + uni: 'readonly', + dd: 'readonly', + plus: 'readonly', + wx: 'readonly' + }, + parserOptions: { + ecmaVersion: 'latest', + parser: '@typescript-eslint/parser', + sourceType: 'module' + }, + plugins: [ + 'vue', + '@typescript-eslint' + ], + rules: { + camelcase: 'off', + semi: 'error', + 'import/first': 'off', + 'no-console': 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'vue/multi-word-component-names': 'off' + } +} diff --git a/README.md b/README.md index 08bbce7..7ec3bb0 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,23 @@ # uni-app-template ## Project setup -``` + +``` shell yarn install ``` ### Compiles and hot-reloads for development -``` + +``` shell yarn serve ``` ### Compiles and minifies for production -``` + +``` shell yarn build ``` ### Customize configuration + See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/babel.config.js b/babel.config.js index 6d0b7ce..c35c8e2 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,10 +1,10 @@ -const plugins = [] +const plugins = [] if (process.env.UNI_OPT_TREESHAKINGNG) { plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js')) -} +} -if ( +if ( ( process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8 @@ -12,7 +12,7 @@ if ( ( process.env.UNI_PLATFORM === 'h5' && process.env.UNI_H5_BROWSER === 'builtin' - ) + ) ) { const path = require('path') @@ -42,8 +42,8 @@ process.UNI_LIBRARIES.forEach(libraryName => { plugins.push([ 'import', { - 'libraryName': libraryName, - 'customName': (name) => { + libraryName, + customName: (name) => { return `${libraryName}/lib/${name}/${name}` } } @@ -60,4 +60,4 @@ module.exports = { ] ], plugins -} +} diff --git a/package.json b/package.json index f43fdf1..5acb25e 100644 --- a/package.json +++ b/package.json @@ -95,11 +95,19 @@ "@dcloudio/webpack-uni-mp-loader": "^2.0.1-34920220609002", "@dcloudio/webpack-uni-pages-loader": "^2.0.1-34920220609002", "@types/node": "^18.0.0", + "@typescript-eslint/eslint-plugin": "^5.30.0", + "@typescript-eslint/parser": "^5.30.0", "@vue/cli-plugin-babel": "~4.5.13", "@vue/cli-plugin-typescript": "~4.5.11", "@vue/cli-service": "~4.5.13", "babel-plugin-import": "^1.11.0", "cross-env": "^7.0.2", + "eslint": "^8.0.1", + "eslint-config-standard": "^17.0.0", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-n": "^15.0.0", + "eslint-plugin-promise": "^6.0.0", + "eslint-plugin-vue": "^9.1.1", "jest": "^25.4.0", "mini-types": "*", "miniprogram-api-typings": "*", diff --git a/public/index.html b/public/index.html index a528055..e182836 100644 --- a/public/index.html +++ b/public/index.html @@ -1,12 +1,12 @@ -