From 810f4d8e6ddde6e10a0bb92372641e8ce6c44414 Mon Sep 17 00:00:00 2001 From: tnt group Date: Fri, 16 Sep 2022 12:26:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0lint=E8=A7=84=E5=88=99?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E8=84=9A=E6=9C=AC,=E4=BF=AE=E5=A4=8Dlint?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 6 ++- package.json | 4 +- src/api/http.ts | 10 +++-- src/components/I18n/index.vue | 1 + .../Plugins/DialogContent/index.vue | 5 ++- .../Plugins/LoadingContent/index.vue | 1 + .../Plugins/MessageContent/index.vue | 5 ++- src/hooks/useChartDataFetch.hook.ts | 3 +- src/router/types.ts | 44 ++++++++++--------- .../chartEditStore/chartEditStore.d.ts | 1 + .../modules/chartEditStore/chartEditStore.ts | 2 +- src/utils/storage.ts | 13 +++--- src/utils/utils.ts | 9 ++-- .../components/ChartsOptionContent/index.vue | 8 ++-- .../ChartDataMonacoEditor/index.vue | 2 + .../chart/ContentConfigurations/index.vue | 1 + .../chart/ContentHeader/headerTitle/index.vue | 10 ++--- .../components/LayersListItem/index.vue | 10 ++--- src/views/chart/hooks/useSync.hook.ts | 2 +- tsconfig.json | 35 +++------------ 20 files changed, 84 insertions(+), 88 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d27e761e..d01f44ae 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -20,6 +20,10 @@ module.exports = { extends: ['plugin:vue/vue3-essential', 'eslint:recommended'], rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-unused-vars': 'off', + 'vue/multi-word-component-names': 'off', + 'vue/valid-template-root': 'off', + 'vue/no-mutating-props': 'off' } } diff --git a/package.json b/package.json index c839d980..a830dd7f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", "new": "plop --plopfile ./plop/plopfile.js", - "postinstall": "husky install" + "postinstall": "husky install", + "lint": "eslint --ext .js,.jsx,.ts,.tsx,.vue src", + "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx,.vue src --fix" }, "dependencies": { "@types/color": "^3.0.3", diff --git a/src/api/http.ts b/src/api/http.ts index f6657c65..4462c332 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -87,7 +87,7 @@ export const http = (type?: RequestHttpEnum) => { * @param globalParams 全局参数 */ export const customizeHttp = (targetParams: RequestConfigType, globalParams: RequestGlobalConfigType) => { - if(!targetParams || !globalParams) { + if (!targetParams || !globalParams) { return } @@ -127,7 +127,7 @@ export const customizeHttp = (targetParams: RequestConfigType, globalParams: Req // 处理头部 const headers: RequestParamsObjType = { ...globalRequestParams.Header, - ...targetRequestParams.Header, + ...targetRequestParams.Header } // data 参数 @@ -155,15 +155,16 @@ export const customizeHttp = (targetParams: RequestConfigType, globalParams: Req data = targetRequestParams.Body['xml'] break - case RequestBodyEnum.X_WWW_FORM_URLENCODED: + case RequestBodyEnum.X_WWW_FORM_URLENCODED: { headers['Content-Type'] = ContentTypeEnum.FORM_URLENCODED const bodyFormData = targetRequestParams.Body['x-www-form-urlencoded'] for (const i in bodyFormData) formData.set(i, bodyFormData[i]) // FormData 赋值给 data data = formData break + } - case RequestBodyEnum.FORM_DATA: + case RequestBodyEnum.FORM_DATA: { headers['Content-Type'] = ContentTypeEnum.FORM_DATA const bodyFormUrlencoded = targetRequestParams.Body['form-data'] for (const i in bodyFormUrlencoded) { @@ -172,6 +173,7 @@ export const customizeHttp = (targetParams: RequestConfigType, globalParams: Req // FormData 赋值给 data data = formData break + } } // sql 处理 diff --git a/src/components/I18n/index.vue b/src/components/I18n/index.vue index 65b11cb0..4f5cced7 100644 --- a/src/components/I18n/index.vue +++ b/src/components/I18n/index.vue @@ -1,3 +1,4 @@ + diff --git a/src/components/Plugins/LoadingContent/index.vue b/src/components/Plugins/LoadingContent/index.vue index 42d8d06c..31e33db6 100644 --- a/src/components/Plugins/LoadingContent/index.vue +++ b/src/components/Plugins/LoadingContent/index.vue @@ -1,3 +1,4 @@ + diff --git a/src/hooks/useChartDataFetch.hook.ts b/src/hooks/useChartDataFetch.hook.ts index 0462e181..8978df15 100644 --- a/src/hooks/useChartDataFetch.hook.ts +++ b/src/hooks/useChartDataFetch.hook.ts @@ -25,7 +25,7 @@ export const useChartDataFetch = ( const requestIntervalFn = () => { const chartEditStore = useChartEditStore() - + // 全局数据 const { requestOriginUrl, @@ -88,6 +88,7 @@ export const useChartDataFetch = ( // 开启轮询 if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit)) } + // eslint-disable-next-line no-empty } catch (error) {} } diff --git a/src/router/types.ts b/src/router/types.ts index 00febefb..59c3b14a 100644 --- a/src/router/types.ts +++ b/src/router/types.ts @@ -1,38 +1,40 @@ -import type { RouteRecordRaw, RouteMeta } from 'vue-router'; -import { defineComponent } from 'vue'; +import type { RouteRecordRaw, RouteMeta } from 'vue-router' +import { defineComponent } from 'vue' + +declare type Recordable = Record export type Component = | ReturnType | (() => Promise) - | (() => Promise); - + | (() => Promise) + // @ts-ignore export interface AppRouteRecordRaw extends Omit { - name: string; - meta: RouteMeta; - component?: Component | string; - components?: Component; - children?: AppRouteRecordRaw[]; - props?: Recordable; - fullPath?: string; + name: string + meta: RouteMeta + component?: Component | string + components?: Component + children?: AppRouteRecordRaw[] + props?: Recordable + fullPath?: string } export interface Meta { // 名称 - title: string; + title: string // 是否忽略权限 - ignoreAuth?: boolean; - permissions?: string[]; + ignoreAuth?: boolean + permissions?: string[] // 是否不缓存 - noKeepAlive?: boolean; + noKeepAlive?: boolean // 是否固定在tab上 - affix?: boolean; + affix?: boolean // tab上的图标 - icon?: string; + icon?: string // 跳转地址 - frameSrc?: string; + frameSrc?: string // 外链跳转地址 - externalLink?: string; + externalLink?: string //隐藏 - hidden?: boolean; -} \ No newline at end of file + hidden?: boolean +} diff --git a/src/store/modules/chartEditStore/chartEditStore.d.ts b/src/store/modules/chartEditStore/chartEditStore.d.ts index 1defbb77..32c71479 100644 --- a/src/store/modules/chartEditStore/chartEditStore.d.ts +++ b/src/store/modules/chartEditStore/chartEditStore.d.ts @@ -93,6 +93,7 @@ export interface EditCanvasConfigType { } // 坐标轴信息 +// eslint-disable-next-line no-redeclare export enum EditCanvasTypeEnum { START_X = 'startX', START_Y = 'startY', diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index bd2f70ba..a2be5775 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -600,7 +600,7 @@ export const useChartEditStore = defineStore({ ids.push(item.id) }) } else { - ;(historyData[0] as CreateComponentGroupType).groupList.forEach(item => { + (historyData[0] as CreateComponentGroupType).groupList.forEach(item => { ids.push(item.id) }) } diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 60e7c7e8..d55d33bd 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -1,11 +1,10 @@ - /** * * 存储本地会话数据 * @param k 键名 * @param v 键值(无需stringiiy) * @returns RemovableRef */ - export const setLocalStorage = (k: string, v: T) => { +export const setLocalStorage = (k: string, v: T) => { try { window.localStorage.setItem(k, JSON.stringify(v)) } catch (error) { @@ -18,7 +17,7 @@ * @param k 键名 * @returns any */ - export const getLocalStorage = (k: string) => { +export const getLocalStorage = (k: string) => { const item = window.localStorage.getItem(k) try { return item ? JSON.parse(item) : item @@ -29,9 +28,9 @@ /** * * 清除本地会话数据 - * @param name + * @param name */ - export const clearLocalStorage = (name: string) => { +export const clearLocalStorage = (name: string) => { window.localStorage.removeItem(name) } @@ -64,8 +63,8 @@ export const getSessionStorage: (k: string) => any = (k: string) => { /** * * 清除本地会话数据 - * @param name + * @param name */ export const clearSessioStorage = (name: string) => { window.sessionStorage.removeItem(name) -} \ No newline at end of file +} diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 9d7ae3ae..8b686eb0 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -135,11 +135,13 @@ export const fileTobase64 = (file: File, callback: Function) => { /** * * 挂载监听 */ +// eslint-disable-next-line no-undef export const addEventListener = ( target: HTMLElement | Document, type: K, listener: any, delay?: number, + // eslint-disable-next-line no-undef options?: boolean | AddEventListenerOptions | undefined ) => { if (!target) return @@ -156,6 +158,7 @@ export const addEventListener = ( /** * * 卸载监听 */ +// eslint-disable-next-line no-undef export const removeEventListener = ( target: HTMLElement | Document, type: K, @@ -245,12 +248,12 @@ export const intervalUnitHandle = (num: number, unit: RequestHttpIntervalEnum) = /** * * 对象转换 cookie 格式 - * @param obj + * @param obj * @returns string */ export const objToCookie = (obj: RequestParamsObjType) => { - if(!obj) return '' - + if (!obj) return '' + let str = '' for (const key in obj) { str += key + '=' + obj[key] + ';' diff --git a/src/views/chart/ContentCharts/components/ChartsOptionContent/index.vue b/src/views/chart/ContentCharts/components/ChartsOptionContent/index.vue index 5be48f5e..f9ae88cd 100644 --- a/src/views/chart/ContentCharts/components/ChartsOptionContent/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsOptionContent/index.vue @@ -9,7 +9,7 @@ :icon-size="16" :indent="18" @update:value="clickItemHandle" - > + >
@@ -24,14 +24,12 @@ import { ConfigType } from '@/packages/index.d' import { useSettingStore } from '@/store/modules/settingStore/settingStore' import { loadAsyncComponent } from '@/utils' -const ChartsItemBox = loadAsyncComponent(() => - import('../ChartsItemBox/index.vue') -) +const ChartsItemBox = loadAsyncComponent(() => import('../ChartsItemBox/index.vue')) const props = defineProps({ selectOptions: { type: Object, - default: () => [] + default: () => {} } }) diff --git a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataMonacoEditor/index.vue b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataMonacoEditor/index.vue index 56737842..f890f2f7 100644 --- a/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataMonacoEditor/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartData/components/ChartDataMonacoEditor/index.vue @@ -138,9 +138,11 @@ const filterRes = computed(() => { try { const fn = new Function('data', filter.value) const res = fn(cloneDeep(sourceData.value)) + // eslint-disable-next-line vue/no-side-effects-in-computed-properties errorFlag.value = false return toString(res) } catch (error) { + // eslint-disable-next-line vue/no-side-effects-in-computed-properties errorFlag.value = true return '过滤函数错误' } diff --git a/src/views/chart/ContentConfigurations/index.vue b/src/views/chart/ContentConfigurations/index.vue index 6d408f48..c1b11b20 100644 --- a/src/views/chart/ContentConfigurations/index.vue +++ b/src/views/chart/ContentConfigurations/index.vue @@ -102,6 +102,7 @@ const selectTarget = computed(() => { if (selectId.length !== 1) return undefined const target = chartEditStore.componentList[chartEditStore.fetchTargetIndex()] if (target?.isGroup) { + // eslint-disable-next-line vue/no-side-effects-in-computed-properties tabsSelect.value = TabsEnum.CHART_SETTING } return target diff --git a/src/views/chart/ContentHeader/headerTitle/index.vue b/src/views/chart/ContentHeader/headerTitle/index.vue index adf6fbde..5ac70dc8 100644 --- a/src/views/chart/ContentHeader/headerTitle/index.vue +++ b/src/views/chart/ContentHeader/headerTitle/index.vue @@ -24,7 +24,7 @@ v-model:value.trim="title" @keyup.enter="handleBlur" @blur="handleBlur" - > + > @@ -50,16 +50,16 @@ const fetchProhectInfoById = () => { const title = ref(fetchProhectInfoById() || '') - const comTitle = computed(() => { - title.value = title.value.replace(/\s/g, ""); + // eslint-disable-next-line vue/no-side-effects-in-computed-properties + title.value = title.value.replace(/\s/g, '') return title.value.length ? title.value : '新项目' }) const handleFocus = () => { focus.value = true nextTick(() => { - ; (inputInstRef).value.focus() + inputInstRef.value && (inputInstRef.value as any).focus() }) } @@ -71,4 +71,4 @@ const handleBlur = () => { .title { font-size: 15px; } - \ No newline at end of file + diff --git a/src/views/chart/ContentLayers/components/LayersListItem/index.vue b/src/views/chart/ContentLayers/components/LayersListItem/index.vue index 437a7a73..5ef4cdb2 100644 --- a/src/views/chart/ContentLayers/components/LayersListItem/index.vue +++ b/src/views/chart/ContentLayers/components/LayersListItem/index.vue @@ -1,8 +1,5 @@