Browse Source

fix: eslint

main
xingyu 2 years ago
parent
commit
c4425a8286
  1. 9
      src/components/Form/src/hooks/useFormValues.ts
  2. 4
      src/components/FormDesign/src/components/VFormDesign/components/ComponentProps.vue
  3. 1
      src/components/FormDesign/src/components/index.ts
  4. 28
      src/components/FormDesign/src/hooks/useVFormMethods.ts
  5. 1
      src/components/FormDesign/src/utils/index.ts
  6. 42
      src/components/Table/src/components/editable/EditableCell.vue
  7. 2
      src/components/Table/src/types/column.ts
  8. 1
      src/enums/appEnum.ts
  9. 1
      src/hooks/web/useDesign.ts
  10. 1
      src/hooks/web/usePage.ts
  11. 2
      src/layouts/default/header/components/user-dropdown/DropMenuItem.vue
  12. 1
      src/locales/setupI18n.ts
  13. 2
      src/router/helper/routeHelper.ts
  14. 1
      src/utils/auth/index.ts
  15. 1
      src/utils/bem.ts
  16. 1
      src/utils/tree.ts
  17. 1
      src/views/base/login/RegisterForm.vue
  18. 2
      src/views/member/point/record/index.vue
  19. 2
      src/views/pay/notify/index.vue
  20. 2
      src/views/pay/order/index.vue
  21. 2
      src/views/pay/refund/index.vue

9
src/components/Form/src/hooks/useFormValues.ts

@ -13,7 +13,7 @@ interface UseFormValuesContext {
}
/**
* @desription deconstruct array-link key. This method will mutate the target.
* @description deconstruct array-link key. This method will mutate the target.
*/
function tryDeconstructArray(key: string, value: any, target: Recordable) {
const pattern = /^\[(.+)\]$/
@ -31,7 +31,7 @@ function tryDeconstructArray(key: string, value: any, target: Recordable) {
}
/**
* @desription deconstruct object-link key. This method will mutate the target.
* @description deconstruct object-link key. This method will mutate the target.
*/
function tryDeconstructObject(key: string, value: any, target: Recordable) {
const pattern = /^\{(.+)\}$/
@ -122,10 +122,11 @@ export function useFormValues({ defaultValueRef, getSchema, formModel, getProps
const { defaultValue, defaultValueObj } = item
const fieldKeys = Object.keys(defaultValueObj || {})
if (fieldKeys.length) {
// eslint-disable-next-line array-callback-return
fieldKeys.map((field) => {
obj[field] = defaultValueObj[field]
obj[field] = defaultValueObj![field]
if (formModel[field] === undefined)
formModel[field] = defaultValueObj[field]
formModel[field] = defaultValueObj![field]
})
}
if (!isNullOrUnDef(defaultValue)) {

4
src/components/FormDesign/src/components/VFormDesign/components/ComponentProps.vue

@ -128,14 +128,14 @@ export default defineComponent({
//
const controlOptions = computed(() => {
return allOptions.value.filter((item) => {
return item.category == 'control'
return item.category === 'control'
})
})
//
const inputOptions = computed(() => {
return allOptions.value.filter((item) => {
return item.category == 'input'
return item.category === 'input'
})
})

1
src/components/FormDesign/src/components/index.ts

@ -1,6 +1,7 @@
import type { Component } from 'vue'
import {
Input,
// eslint-disable-next-line sort-imports
Button,
Select,
Radio,

28
src/components/FormDesign/src/hooks/useVFormMethods.ts

@ -78,20 +78,6 @@ export function useVFormMethods(
formItem[key] = value
}
/**
* props
* @param {string} field field
* @param {string} key key
* @param value
*/
const setProps: ISetProps = (field, key, value) => {
const formItem = get(field)
if (formItem?.componentProps) {
['options', 'treeData'].includes(key) && setValue(field, undefined)
formItem.componentProps[key] = value
}
}
/**
*
* @param {string} field
@ -111,6 +97,20 @@ export function useVFormMethods(
})
}
}
/**
* props
* @param {string} field field
* @param {string} key key
* @param value
*/
const setProps: ISetProps = (field, key, value) => {
const formItem = get(field)
if (formItem?.componentProps) {
['options', 'treeData'].includes(key) && setValue(field, undefined)
formItem.componentProps[key] = value
}
}
/**
*
* @param {string} key

1
src/components/FormDesign/src/utils/index.ts

@ -199,6 +199,7 @@ export function strToReg(rules: IValidationRule[]) {
*/
export function runCode<T>(code: any): T {
try {
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
return new Function(`return ${code}`)()
}
catch {

42
src/components/Table/src/components/editable/EditableCell.vue

@ -1,3 +1,4 @@
<!-- eslint-disable vue/no-mutating-props -->
<script lang="tsx">
import type { CSSProperties } from 'vue'
import { computed, defineComponent, nextTick, ref, toRaw, unref, watchEffect } from 'vue'
@ -138,6 +139,11 @@ export default defineComponent({
return option?.label ?? value
})
const getRowEditable = computed(() => {
const { editable } = props.record || {}
return !!editable
})
const getWrapperStyle = computed((): CSSProperties => {
if (unref(getIsCheckComp) || unref(getRowEditable))
return {}
@ -152,11 +158,6 @@ export default defineComponent({
return `edit-cell-align-${align}`
})
const getRowEditable = computed(() => {
const { editable } = props.record || {}
return !!editable
})
watchEffect(() => {
// defaultValueRef.value = props.value;
currentValueRef.value = props.value
@ -339,10 +340,8 @@ export default defineComponent({
}
function initCbs(cbs: 'submitCbs' | 'validCbs' | 'cancelCbs', handle: Fn) {
if (props.record) {
/* eslint-disable */
if (props.record)
isArray(props.record[cbs]) ? props.record[cbs]?.push(handle) : (props.record[cbs] = [handle])
}
}
if (props.record) {
@ -351,19 +350,19 @@ export default defineComponent({
initCbs('cancelCbs', handleCancel)
if (props.column.dataIndex) {
if (!props.record.editValueRefs) props.record.editValueRefs = {}
if (!props.record.editValueRefs)
props.record.editValueRefs = {}
props.record.editValueRefs[props.column.dataIndex as any] = currentValueRef
}
/* eslint-disable */
props.record.onCancelEdit = () => {
isArray(props.record?.cancelCbs) && props.record?.cancelCbs.forEach((fn) => fn())
isArray(props.record?.cancelCbs) && props.record?.cancelCbs.forEach(fn => fn())
}
/* eslint-disable */
props.record.onSubmitEdit = async () => {
if (isArray(props.record?.submitCbs)) {
if (!props.record?.onValid?.()) return
if (!props.record?.onValid?.())
return
const submitFns = props.record?.submitCbs || []
submitFns.forEach((fn) => fn(false, false))
submitFns.forEach(fn => fn(false, false))
table.emit?.('edit-row-end')
return true
}
@ -392,7 +391,7 @@ export default defineComponent({
getValues,
handleEnter,
handleSubmitClick,
spinning
spinning,
}
},
render() {
@ -406,11 +405,11 @@ export default defineComponent({
<div class="cell-content" title={this.column.ellipsis ? this.getValues ?? '' : ''}>
{this.column.editRender
? this.column.editRender({
text: this.value,
record: this.record as Recordable,
column: this.column,
index: this.index
})
text: this.value,
record: this.record as Recordable,
column: this.column,
index: this.index,
})
: this.getValues ?? '\u00A0'}
</div>
{!this.column.editRow && <FormOutlined class={`${this.prefixCls}__normal-icon`} />}
@ -442,9 +441,10 @@ export default defineComponent({
)}
</div>
)
}
},
})
</script>
<style lang="less">
@prefix-cls: ~'@{namespace}-editable-cell';

2
src/components/Table/src/types/column.ts

@ -135,7 +135,7 @@ export interface ColumnProps<T> {
* Sort function for local sort, see Array.sort's compareFunction. If you need sort buttons only, set to true
* @type boolean | Function
*/
sorter?: boolean | Function
sorter?: boolean | Fn
/**
* Order of sorted values: 'ascend' 'descend' false

1
src/enums/appEnum.ts

@ -59,7 +59,6 @@ export enum IconEnum {
TEST = 'ant-design:deployment-unit-outlined',
EDIT = 'clarity:note-edit-line',
AUTH = 'ant-design:safety-certificate-outlined',
DATA = 'clarity:note-edit-line',
DELETE = 'ant-design:delete-outlined',
SEARCH = 'ant-design:search-outlined',
RESET = 'ant-design:sync-outlined',

1
src/hooks/web/useDesign.ts

@ -16,6 +16,7 @@ export function useDesign(scope: string) {
// }
return {
// prefixCls: computed(() => `${values.prefixCls}-${scope}`),
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
prefixCls: `${values.prefixCls}-${scope}`,
prefixVar: values.prefixCls,
// style,

1
src/hooks/web/usePage.ts

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import type { RouteLocationRaw, Router } from 'vue-router'
import { unref } from 'vue'

2
src/layouts/default/header/components/user-dropdown/DropMenuItem.vue

@ -8,7 +8,7 @@ import { propTypes } from '@/utils/propTypes'
defineOptions({ name: 'DropdownMenuItem' })
const props = defineProps({
// eslint-disable-next-line
// eslint-disable-next-line vue/no-reserved-props
key: propTypes.string,
text: propTypes.string,
icon: propTypes.string,

1
src/locales/setupI18n.ts

@ -8,6 +8,7 @@ import { useLocaleStoreWithOut } from '@/store/modules/locale'
const { fallback, availableLocales } = localeSetting
// eslint-disable-next-line import/no-mutable-exports
export let i18n: ReturnType<typeof createI18n>
async function createI18nOptions(): Promise<I18nOptions> {

2
src/router/helper/routeHelper.ts

@ -80,7 +80,7 @@ export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModul
routeList.forEach((route) => {
if (isUrl(route.path))
route.component = 'IFrame'
else if (route.children && route.parentId == 0)
else if (route.children && route.parentId === 0)
route.component = 'LAYOUT'
else if (!route.children)
route.component = route.component as string

1
src/utils/auth/index.ts

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import type { BasicKeys } from '@/utils/cache/persistent'
import { Persistent } from '@/utils/cache/persistent'
import { ACCESS_TOKEN_KEY, CacheTypeEnum, REFRESH_TOKEN_KEY, TENANT_ID_KEY } from '@/enums/cacheEnum'

1
src/utils/bem.ts

@ -13,6 +13,7 @@ function genBem(name: string, mods?: Mods): string {
return ` ${name}--${mods}`
if (Array.isArray(mods))
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return mods.reduce((ret, item) => ret + genBem(name, item), '')
return Object.keys(mods).reduce((ret, key) => ret + (mods[key] ? genBem(name, key) : ''), '')

1
src/utils/tree.ts

@ -268,6 +268,7 @@ export function handleTree2(data, id, parentId, children, rootId) {
// 返回每一项的子级数组
return father[id] === child[parentId]
})
// eslint-disable-next-line no-unused-expressions
branchArr.length > 0 ? (father.children = branchArr) : ''
// 返回第一层
return father[parentId] === rootId

1
src/views/base/login/RegisterForm.vue

@ -32,6 +32,7 @@ const getShow = computed(() => unref(getLoginState) === LoginStateEnum.REGISTER)
async function handleRegister() {
const data = await validForm()
if (!data)
// eslint-disable-next-line no-useless-return
return
}
</script>

2
src/views/member/point/record/index.vue

@ -5,7 +5,7 @@ import { getRecordPage } from '@/api/member/point/record'
defineOptions({ name: 'PointRecord' })
const [registerTable, { reload }] = useTable({
const [registerTable] = useTable({
title: '积分记录列表',
api: getRecordPage,
columns,

2
src/views/pay/notify/index.vue

@ -39,7 +39,7 @@ async function handleQueryDetails(record: Recordable) {
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.DATA, label: t('action.detail'), auth: 'pay:order:query', onClick: handleQueryDetails.bind(null, record) },
{ icon: IconEnum.VIEW, label: t('action.detail'), auth: 'pay:order:query', onClick: handleQueryDetails.bind(null, record) },
]"
/>
</template>

2
src/views/pay/order/index.vue

@ -59,7 +59,7 @@ async function handleExport() {
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.DATA, label: t('action.detail'), auth: 'pay:order:query', onClick: handleQueryDetails.bind(null, record) },
{ icon: IconEnum.VIEW, label: t('action.detail'), auth: 'pay:order:query', onClick: handleQueryDetails.bind(null, record) },
]"
/>
</template>

2
src/views/pay/refund/index.vue

@ -59,7 +59,7 @@ async function handleExport() {
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.DATA, label: t('action.detail'), auth: 'pay:order:query', onClick: handleQueryDetails.bind(null, record) },
{ icon: IconEnum.VIEW, label: t('action.detail'), auth: 'pay:order:query', onClick: handleQueryDetails.bind(null, record) },
]"
/>
</template>