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) { function tryDeconstructArray(key: string, value: any, target: Recordable) {
const pattern = /^\[(.+)\]$/ 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) { function tryDeconstructObject(key: string, value: any, target: Recordable) {
const pattern = /^\{(.+)\}$/ const pattern = /^\{(.+)\}$/
@ -122,10 +122,11 @@ export function useFormValues({ defaultValueRef, getSchema, formModel, getProps
const { defaultValue, defaultValueObj } = item const { defaultValue, defaultValueObj } = item
const fieldKeys = Object.keys(defaultValueObj || {}) const fieldKeys = Object.keys(defaultValueObj || {})
if (fieldKeys.length) { if (fieldKeys.length) {
// eslint-disable-next-line array-callback-return
fieldKeys.map((field) => { fieldKeys.map((field) => {
obj[field] = defaultValueObj[field] obj[field] = defaultValueObj![field]
if (formModel[field] === undefined) if (formModel[field] === undefined)
formModel[field] = defaultValueObj[field] formModel[field] = defaultValueObj![field]
}) })
} }
if (!isNullOrUnDef(defaultValue)) { if (!isNullOrUnDef(defaultValue)) {

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

@ -128,14 +128,14 @@ export default defineComponent({
// //
const controlOptions = computed(() => { const controlOptions = computed(() => {
return allOptions.value.filter((item) => { return allOptions.value.filter((item) => {
return item.category == 'control' return item.category === 'control'
}) })
}) })
// //
const inputOptions = computed(() => { const inputOptions = computed(() => {
return allOptions.value.filter((item) => { 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 type { Component } from 'vue'
import { import {
Input, Input,
// eslint-disable-next-line sort-imports
Button, Button,
Select, Select,
Radio, Radio,

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

@ -78,20 +78,6 @@ export function useVFormMethods(
formItem[key] = value 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 * @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 * @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 { export function runCode<T>(code: any): T {
try { try {
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
return new Function(`return ${code}`)() return new Function(`return ${code}`)()
} }
catch { catch {

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

@ -1,3 +1,4 @@
<!-- eslint-disable vue/no-mutating-props -->
<script lang="tsx"> <script lang="tsx">
import type { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { computed, defineComponent, nextTick, ref, toRaw, unref, watchEffect } from 'vue' import { computed, defineComponent, nextTick, ref, toRaw, unref, watchEffect } from 'vue'
@ -138,6 +139,11 @@ export default defineComponent({
return option?.label ?? value return option?.label ?? value
}) })
const getRowEditable = computed(() => {
const { editable } = props.record || {}
return !!editable
})
const getWrapperStyle = computed((): CSSProperties => { const getWrapperStyle = computed((): CSSProperties => {
if (unref(getIsCheckComp) || unref(getRowEditable)) if (unref(getIsCheckComp) || unref(getRowEditable))
return {} return {}
@ -152,11 +158,6 @@ export default defineComponent({
return `edit-cell-align-${align}` return `edit-cell-align-${align}`
}) })
const getRowEditable = computed(() => {
const { editable } = props.record || {}
return !!editable
})
watchEffect(() => { watchEffect(() => {
// defaultValueRef.value = props.value; // defaultValueRef.value = props.value;
currentValueRef.value = props.value currentValueRef.value = props.value
@ -339,10 +340,8 @@ export default defineComponent({
} }
function initCbs(cbs: 'submitCbs' | 'validCbs' | 'cancelCbs', handle: Fn) { function initCbs(cbs: 'submitCbs' | 'validCbs' | 'cancelCbs', handle: Fn) {
if (props.record) { if (props.record)
/* eslint-disable */
isArray(props.record[cbs]) ? props.record[cbs]?.push(handle) : (props.record[cbs] = [handle]) isArray(props.record[cbs]) ? props.record[cbs]?.push(handle) : (props.record[cbs] = [handle])
}
} }
if (props.record) { if (props.record) {
@ -351,19 +350,19 @@ export default defineComponent({
initCbs('cancelCbs', handleCancel) initCbs('cancelCbs', handleCancel)
if (props.column.dataIndex) { 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 props.record.editValueRefs[props.column.dataIndex as any] = currentValueRef
} }
/* eslint-disable */
props.record.onCancelEdit = () => { 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 () => { props.record.onSubmitEdit = async () => {
if (isArray(props.record?.submitCbs)) { if (isArray(props.record?.submitCbs)) {
if (!props.record?.onValid?.()) return if (!props.record?.onValid?.())
return
const submitFns = props.record?.submitCbs || [] const submitFns = props.record?.submitCbs || []
submitFns.forEach((fn) => fn(false, false)) submitFns.forEach(fn => fn(false, false))
table.emit?.('edit-row-end') table.emit?.('edit-row-end')
return true return true
} }
@ -392,7 +391,7 @@ export default defineComponent({
getValues, getValues,
handleEnter, handleEnter,
handleSubmitClick, handleSubmitClick,
spinning spinning,
} }
}, },
render() { render() {
@ -406,11 +405,11 @@ export default defineComponent({
<div class="cell-content" title={this.column.ellipsis ? this.getValues ?? '' : ''}> <div class="cell-content" title={this.column.ellipsis ? this.getValues ?? '' : ''}>
{this.column.editRender {this.column.editRender
? this.column.editRender({ ? this.column.editRender({
text: this.value, text: this.value,
record: this.record as Recordable, record: this.record as Recordable,
column: this.column, column: this.column,
index: this.index index: this.index,
}) })
: this.getValues ?? '\u00A0'} : this.getValues ?? '\u00A0'}
</div> </div>
{!this.column.editRow && <FormOutlined class={`${this.prefixCls}__normal-icon`} />} {!this.column.editRow && <FormOutlined class={`${this.prefixCls}__normal-icon`} />}
@ -442,9 +441,10 @@ export default defineComponent({
)} )}
</div> </div>
) )
} },
}) })
</script> </script>
<style lang="less"> <style lang="less">
@prefix-cls: ~'@{namespace}-editable-cell'; @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 * Sort function for local sort, see Array.sort's compareFunction. If you need sort buttons only, set to true
* @type boolean | Function * @type boolean | Function
*/ */
sorter?: boolean | Function sorter?: boolean | Fn
/** /**
* Order of sorted values: 'ascend' 'descend' false * 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', TEST = 'ant-design:deployment-unit-outlined',
EDIT = 'clarity:note-edit-line', EDIT = 'clarity:note-edit-line',
AUTH = 'ant-design:safety-certificate-outlined', AUTH = 'ant-design:safety-certificate-outlined',
DATA = 'clarity:note-edit-line',
DELETE = 'ant-design:delete-outlined', DELETE = 'ant-design:delete-outlined',
SEARCH = 'ant-design:search-outlined', SEARCH = 'ant-design:search-outlined',
RESET = 'ant-design:sync-outlined', RESET = 'ant-design:sync-outlined',

1
src/hooks/web/useDesign.ts

@ -16,6 +16,7 @@ export function useDesign(scope: string) {
// } // }
return { return {
// prefixCls: computed(() => `${values.prefixCls}-${scope}`), // prefixCls: computed(() => `${values.prefixCls}-${scope}`),
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
prefixCls: `${values.prefixCls}-${scope}`, prefixCls: `${values.prefixCls}-${scope}`,
prefixVar: values.prefixCls, prefixVar: values.prefixCls,
// style, // 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 type { RouteLocationRaw, Router } from 'vue-router'
import { unref } from 'vue' 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' }) defineOptions({ name: 'DropdownMenuItem' })
const props = defineProps({ const props = defineProps({
// eslint-disable-next-line // eslint-disable-next-line vue/no-reserved-props
key: propTypes.string, key: propTypes.string,
text: propTypes.string, text: propTypes.string,
icon: propTypes.string, icon: propTypes.string,

1
src/locales/setupI18n.ts

@ -8,6 +8,7 @@ import { useLocaleStoreWithOut } from '@/store/modules/locale'
const { fallback, availableLocales } = localeSetting const { fallback, availableLocales } = localeSetting
// eslint-disable-next-line import/no-mutable-exports
export let i18n: ReturnType<typeof createI18n> export let i18n: ReturnType<typeof createI18n>
async function createI18nOptions(): Promise<I18nOptions> { 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) => { routeList.forEach((route) => {
if (isUrl(route.path)) if (isUrl(route.path))
route.component = 'IFrame' route.component = 'IFrame'
else if (route.children && route.parentId == 0) else if (route.children && route.parentId === 0)
route.component = 'LAYOUT' route.component = 'LAYOUT'
else if (!route.children) else if (!route.children)
route.component = route.component as string 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 type { BasicKeys } from '@/utils/cache/persistent'
import { Persistent } from '@/utils/cache/persistent' import { Persistent } from '@/utils/cache/persistent'
import { ACCESS_TOKEN_KEY, CacheTypeEnum, REFRESH_TOKEN_KEY, TENANT_ID_KEY } from '@/enums/cacheEnum' 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}` return ` ${name}--${mods}`
if (Array.isArray(mods)) if (Array.isArray(mods))
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return mods.reduce((ret, item) => ret + genBem(name, item), '') return mods.reduce((ret, item) => ret + genBem(name, item), '')
return Object.keys(mods).reduce((ret, key) => ret + (mods[key] ? genBem(name, key) : ''), '') 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] return father[id] === child[parentId]
}) })
// eslint-disable-next-line no-unused-expressions
branchArr.length > 0 ? (father.children = branchArr) : '' branchArr.length > 0 ? (father.children = branchArr) : ''
// 返回第一层 // 返回第一层
return father[parentId] === rootId 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() { async function handleRegister() {
const data = await validForm() const data = await validForm()
if (!data) if (!data)
// eslint-disable-next-line no-useless-return
return return
} }
</script> </script>

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

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

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

@ -39,7 +39,7 @@ async function handleQueryDetails(record: Recordable) {
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :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> </template>

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

@ -59,7 +59,7 @@ async function handleExport() {
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :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> </template>

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

@ -59,7 +59,7 @@ async function handleExport() {
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :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> </template>