From 07325a4236ff408075de45cdc6feeb0510062af1 Mon Sep 17 00:00:00 2001 From: Soybean Date: Sun, 28 Aug 2022 14:48:00 +0800 Subject: [PATCH] =?UTF-8?q?build(projects):=20=E6=9B=B4=E6=8D=A2eslint?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E4=B8=BAeslint-config-soybeanjs-vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 6 +++-- .husky/pre-commit | 2 +- .vscode/settings.json | 1 - package.json | 5 ++-- src/components/custom/CountTo.vue | 2 +- src/service/request/request.ts | 28 +++++++++++++---------- src/views/plugin/charts/antv/index.vue | 2 +- src/views/plugin/charts/echarts/index.vue | 2 +- 8 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2b9ac9bb..701b0de9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,9 @@ module.exports = { - extends: ['@soybeanjs'], + extends: ['soybeanjs-vue'], + settings: { + 'import/core-modules': ['uno.css', '~icons/*', 'virtual:svg-icons-register'] + }, rules: { - 'import/no-unresolved': ['error', { ignore: ['uno.css', '~icons/*', 'virtual:svg-icons-register'] }], 'import/order': [ 'error', { diff --git a/.husky/pre-commit b/.husky/pre-commit index fea73319..253914e4 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npm run lint && npm run typecheck +npm run lint:fix && npm run typecheck diff --git a/.vscode/settings.json b/.vscode/settings.json index 942f06ae..bc949a8a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,7 +16,6 @@ "typescript", "typescriptreact", "vue", - "html", "json", "jsonc", "json5", diff --git a/package.json b/package.json index c9cd93ce..61acc30d 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "build:vercel": "cross-env VITE_HASH_ROUTE=Y VITE_VERCEL=Y vite build", "preview": "vite preview", "typecheck": "vue-tsc --noEmit --skipLibCheck", - "lint": "eslint . --fix", + "lint": "eslint .", + "lint:fix": "eslint . --fix", "prepare": "husky install", "postinstall": "patch-package", "release": "standard-version", @@ -84,7 +85,6 @@ "@iconify/json": "^2.1.97", "@iconify/vue": "^3.2.1", "@milahu/patch-package": "^6.4.14", - "@soybeanjs/eslint-config": "0.2.10", "@types/bmapgl": "^0.0.5", "@types/crypto-js": "^4.1.1", "@types/node": "^18.7.13", @@ -97,6 +97,7 @@ "cz-conventional-changelog": "^3.3.0", "cz-customizable": "^6.9.1", "eslint": "^8.22.0", + "eslint-config-soybeanjs-vue": "^0.0.6", "husky": "^8.0.1", "lint-staged": "^13.0.3", "mockjs": "^1.1.0", diff --git a/src/components/custom/CountTo.vue b/src/components/custom/CountTo.vue index f06e3a78..03c08abf 100644 --- a/src/components/custom/CountTo.vue +++ b/src/components/custom/CountTo.vue @@ -82,7 +82,7 @@ function formatNumber(num: number | string) { } const { decimals, decimal, separator, suffix, prefix } = props; let number = Number(num).toFixed(decimals); - number += ''; + number = String(number); const x = number.split('.'); let x1 = x[0]; diff --git a/src/service/request/request.ts b/src/service/request/request.ts index 1393fea2..b747534e 100644 --- a/src/service/request/request.ts +++ b/src/service/request/request.ts @@ -33,13 +33,13 @@ export function createRequest(axiosConfig: AxiosRequestConfig, backendConfig?: S const { url } = param; const method = param.method || 'get'; const { instance } = customInstance; - const res = (await getRequestResponse( + const res = (await getRequestResponse({ instance, method, url, - param.data, - param.axiosConfig - )) as Service.RequestResult; + data: param.data, + config: param.axiosConfig + })) as Service.RequestResult; return res; } @@ -132,7 +132,9 @@ export function createHookRequest(axiosConfig: AxiosRequestConfig, backendConfig const method = param.method || 'get'; const { instance } = customInstance; - getRequestResponse(instance, method, url, param.data, param.axiosConfig).then(handleRequestResult); + getRequestResponse({ instance, method, url, data: param.data, config: param.axiosConfig }).then( + handleRequestResult + ); return { data, @@ -187,13 +189,15 @@ export function createHookRequest(axiosConfig: AxiosRequestConfig, backendConfig }; } -async function getRequestResponse( - instance: AxiosInstance, - method: RequestMethod, - url: string, - data?: any, - config?: AxiosRequestConfig -) { +async function getRequestResponse(params: { + instance: AxiosInstance; + method: RequestMethod; + url: string; + data?: any; + config?: AxiosRequestConfig; +}) { + const { instance, method, url, data, config } = params; + let res: any; if (method === 'get' || method === 'delete') { res = await instance[method](url, config); diff --git a/src/views/plugin/charts/antv/index.vue b/src/views/plugin/charts/antv/index.vue index 0898602e..34b30866 100644 --- a/src/views/plugin/charts/antv/index.vue +++ b/src/views/plugin/charts/antv/index.vue @@ -287,7 +287,7 @@ function renderScatterChart() { chart.axis('GDP', { label: { formatter(value) { - return `${(+value / 1000).toFixed(0)}k`; + return `${(Number(value) / 1000).toFixed(0)}k`; } // 格式化坐标轴的显示 } }); diff --git a/src/views/plugin/charts/echarts/index.vue b/src/views/plugin/charts/echarts/index.vue index e32446e1..fff7984b 100644 --- a/src/views/plugin/charts/echarts/index.vue +++ b/src/views/plugin/charts/echarts/index.vue @@ -294,7 +294,7 @@ const pictorialBarOption = ref(getPictorialBarOption()); const { domRef: pictorialBarRef } = useEcharts(pictorialBarOption); function getPictorialBarOption(): ECOption { const category: string[] = []; - let dottedBase = +new Date(); + let dottedBase = Number(new Date()); const lineData: number[] = []; const barData: number[] = [];