fix: 添加lint规则运行脚本,修复lint错误

This commit is contained in:
tnt group 2022-09-16 12:26:12 +08:00
parent 1bd0f516e2
commit 810f4d8e6d
20 changed files with 84 additions and 88 deletions

View File

@ -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'
}
}

View File

@ -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",

View File

@ -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 处理

View File

@ -1,3 +1,4 @@
<!-- eslint-disable vue/valid-template-root -->
<template></template>
<script lang="ts" setup>

View File

@ -1,6 +1,7 @@
<!-- eslint-disable vue/valid-template-root -->
<template></template>
<script lang="ts" setup>
import { useDialog } from 'naive-ui';
import { useDialog } from 'naive-ui'
// window 便js使
window['$dialog'] = useDialog();
window['$dialog'] = useDialog()
</script>

View File

@ -1,3 +1,4 @@
<!-- eslint-disable vue/valid-template-root -->
<template></template>
<script lang="ts" setup>

View File

@ -1,7 +1,8 @@
<!-- eslint-disable vue/valid-template-root -->
<template></template>
<script lang="ts" setup>
import { useMessage } from 'naive-ui';
import { useMessage } from 'naive-ui'
// window 便js使
window['$message'] = useMessage();
window['$message'] = useMessage()
</script>

View File

@ -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) {}
}

View File

@ -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<T = any> = Record<string, T>
export type Component<T extends any = any> =
| ReturnType<typeof defineComponent>
| (() => Promise<typeof import('*.vue')>)
| (() => Promise<T>);
| (() => Promise<T>)
// @ts-ignore
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
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;
}
hidden?: boolean
}

View File

@ -93,6 +93,7 @@ export interface EditCanvasConfigType {
}
// 坐标轴信息
// eslint-disable-next-line no-redeclare
export enum EditCanvasTypeEnum {
START_X = 'startX',
START_Y = 'startY',

View File

@ -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)
})
}

View File

@ -1,11 +1,10 @@
/**
* *
* @param k
* @param v stringiiy
* @returns RemovableRef
*/
export const setLocalStorage = <T>(k: string, v: T) => {
export const setLocalStorage = <T>(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)
}
}

View File

@ -135,11 +135,13 @@ export const fileTobase64 = (file: File, callback: Function) => {
/**
* *
*/
// eslint-disable-next-line no-undef
export const addEventListener = <K extends keyof WindowEventMap>(
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 = <K extends keyof WindowEventMap>(
/**
* *
*/
// eslint-disable-next-line no-undef
export const removeEventListener = <K extends keyof WindowEventMap>(
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] + ';'

View File

@ -9,7 +9,7 @@
:icon-size="16"
:indent="18"
@update:value="clickItemHandle"
></n-menu>
></n-menu>
<div class="chart-content-list">
<n-scrollbar>
<charts-item-box :menuOptions="packages.selectOptions"></charts-item-box>
@ -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: () => {}
}
})

View File

@ -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 '过滤函数错误'
}

View File

@ -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

View File

@ -24,7 +24,7 @@
v-model:value.trim="title"
@keyup.enter="handleBlur"
@blur="handleBlur"
></n-input>
></n-input>
</n-space>
</template>
@ -50,16 +50,16 @@ const fetchProhectInfoById = () => {
const title = ref<string>(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(() => {
; (<any>inputInstRef).value.focus()
inputInstRef.value && (inputInstRef.value as any).focus()
})
}
@ -71,4 +71,4 @@ const handleBlur = () => {
.title {
font-size: 15px;
}
</style>
</style>

View File

@ -1,8 +1,5 @@
<template>
<div
class="go-content-layers-list-item"
:class="{ hover: hover, select: select }"
>
<div class="go-content-layers-list-item" :class="{ hover: hover, select: select }">
<div class="go-flex-center item-content">
<n-image
class="list-img"
@ -10,7 +7,7 @@
preview-disabled
:src="image"
:fallback-src="requireErrorImg()"
></n-image>
></n-image>
<n-ellipsis>
<n-text class="list-text" :depth="2">
{{ props.componentData.chartConfig.title }}
@ -43,6 +40,7 @@ const props = defineProps({
}
})
// eslint-disable-next-line vue/no-setup-props-destructure
const { image } = props.componentData.chartConfig
//
@ -80,7 +78,7 @@ $textSize: 10px;
/* 需要设置最高级,覆盖 hover 的颜色 */
background-color: rgba(0, 0, 0, 0);
.list-img {
border:1px solid v-bind('themeColor')!important;
border: 1px solid v-bind('themeColor') !important;
}
}
.select-modal,

View File

@ -35,7 +35,7 @@ export const useSync = () => {
}
if (e.isGroup) {
;(e as CreateComponentGroupType).groupList.forEach(groupItem => {
(e as CreateComponentGroupType).groupList.forEach(groupItem => {
intComponent(groupItem)
})
} else {

View File

@ -10,37 +10,16 @@
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true,
"lib": [
"es6",
"ESNext",
"dom"
],
"types": [
"vite/client"
],
"lib": ["es6", "ESNext", "dom"],
"types": ["vite/client"],
"paths": {
"@/*": [
"src/*"
],
"/#/*": [
"types/*"
]
"@/*": ["src/*"],
"/#/*": ["types/*"]
},
"noImplicitAny": true, //使any
// "strictNullChecks": true, //使null
"noImplicitThis": true //this
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"types/**/*.d.ts",
"types/**/*.ts",
],
"exclude": [
"node_modules",
"dist",
"**/*.js"
]
}
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "types/**/*"],
"exclude": ["node_modules", "dist", "**/*.js"]
}