Browse Source

fix: eslint

main
xingyu 2 years ago
parent
commit
1e3cb0c885
  1. 2
      src/components/Form/src/hooks/useAutoFocus.ts
  2. 2
      src/components/Form/src/hooks/useForm.ts
  3. 2
      src/components/Form/src/hooks/useFormEvents.ts
  4. 2
      src/components/SimpleMenu/src/components/Menu.vue
  5. 1
      src/components/Table/src/BasicTable.vue
  6. 1
      src/components/Table/src/hooks/useTable.ts
  7. 22
      src/layouts/default/sider/MixSider.vue
  8. 1
      src/router/types.ts
  9. 1
      src/store/modules/multipleTab.ts
  10. 3
      src/utils/domUtils.ts
  11. 3
      src/utils/index.ts
  12. 3
      src/utils/props.ts

2
src/components/Form/src/hooks/useAutoFocus.ts

@ -8,7 +8,7 @@ interface UseAutoFocusContext {
isInitedDefault: Ref<boolean> isInitedDefault: Ref<boolean>
formElRef: Ref<FormActionType> formElRef: Ref<FormActionType>
} }
export async function useAutoFocus({ getSchema, getProps, formElRef, isInitedDefault }: UseAutoFocusContext) { export function useAutoFocus({ getSchema, getProps, formElRef, isInitedDefault }: UseAutoFocusContext) {
watchEffect(async () => { watchEffect(async () => {
if (unref(isInitedDefault) || !unref(getProps).autoFocusFirstItem) if (unref(isInitedDefault) || !unref(getProps).autoFocusFirstItem)
return return

2
src/components/Form/src/hooks/useForm.ts

@ -78,7 +78,7 @@ export function useForm(props?: Props): UseFormReturnType {
}, },
removeSchemaByField: async (field: string | string[]) => { removeSchemaByField: async (field: string | string[]) => {
unref(formRef)?.removeSchemaByField(field) await unref(formRef)?.removeSchemaByField(field)
}, },
// TODO promisify // TODO promisify

2
src/components/Form/src/hooks/useFormEvents.ts

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/require-await */
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import type { NamePath } from 'ant-design-vue/lib/form/interface' import type { NamePath } from 'ant-design-vue/lib/form/interface'
import { nextTick, toRaw, unref } from 'vue' import { nextTick, toRaw, unref } from 'vue'
@ -89,6 +90,7 @@ export function useFormEvents({
const defaultValueObj = schema?.defaultValueObj const defaultValueObj = schema?.defaultValueObj
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) => {
formModel[field] = defaultValueObj![field] formModel[field] = defaultValueObj![field]
}) })

2
src/components/SimpleMenu/src/components/Menu.vue

@ -6,8 +6,6 @@ import { useDesign } from '@/hooks/web/useDesign'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import mitt from '@/utils/mitt' import mitt from '@/utils/mitt'
defineOptions({ name: 'Menu' })
const props = defineProps({ const props = defineProps({
theme: propTypes.oneOf(['light', 'dark']).def('light'), theme: propTypes.oneOf(['light', 'dark']).def('light'),
activeName: propTypes.oneOfType([propTypes.string, propTypes.number]), activeName: propTypes.oneOfType([propTypes.string, propTypes.number]),

1
src/components/Table/src/BasicTable.vue

@ -1,3 +1,4 @@
<!-- eslint-disable no-useless-call -->
<script lang="ts" setup> <script lang="ts" setup>
import { computed, inject, ref, toRaw, unref, useAttrs, useSlots, watchEffect } from 'vue' import { computed, inject, ref, toRaw, unref, useAttrs, useSlots, watchEffect } from 'vue'
import { Table } from 'ant-design-vue' import { Table } from 'ant-design-vue'

1
src/components/Table/src/hooks/useTable.ts

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/await-thenable */
import type { WatchStopHandle } from 'vue' import type { WatchStopHandle } from 'vue'
import { onUnmounted, ref, toRaw, unref, watch } from 'vue' import { onUnmounted, ref, toRaw, unref, watch } from 'vue'
import type { BasicColumn, BasicTableProps, FetchParams, TableActionType } from '../types/table' import type { BasicColumn, BasicTableProps, FetchParams, TableActionType } from '../types/table'

22
src/layouts/default/sider/MixSider.vue

@ -1,3 +1,4 @@
<!-- eslint-disable vue/no-side-effects-in-computed-properties -->
<script lang="ts" setup> <script lang="ts" setup>
import type { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { computed, onMounted, ref, unref, watch } from 'vue' import { computed, onMounted, ref, unref, watch } from 'vue'
@ -51,28 +52,27 @@ const permissionStore = usePermissionStore()
useDragLine(sideRef, dragBarRef, true) useDragLine(sideRef, dragBarRef, true)
const getMixSideWidth = computed(() => {
return unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH
})
const getMenuStyle = computed((): CSSProperties => { const getMenuStyle = computed((): CSSProperties => {
return { return {
width: unref(openMenu) ? `${unref(getMenuWidth)}px` : 0, width: unref(openMenu) ? `${unref(getMenuWidth)}px` : 0,
// eslint-disable-next-line @typescript-eslint/no-use-before-define
left: `${unref(getMixSideWidth)}px`, left: `${unref(getMixSideWidth)}px`,
} }
}) })
const getIsFixed = computed(() => { const getIsFixed = computed(() => {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
mixSideHasChildren.value = unref(childrenMenus).length > 0 mixSideHasChildren.value = unref(childrenMenus).length > 0
const isFixed = unref(getMixSideFixed) && unref(mixSideHasChildren) const isFixed = unref(getMixSideFixed) && unref(mixSideHasChildren)
if (isFixed) if (isFixed)
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
openMenu.value = true openMenu.value = true
return isFixed return isFixed
}) })
const getMixSideWidth = computed(() => {
return unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH
})
const getDomStyle = computed((): CSSProperties => { const getDomStyle = computed((): CSSProperties => {
const fixedWidth = unref(getIsFixed) ? unref(getRealWidth) : 0 const fixedWidth = unref(getIsFixed) ? unref(getRealWidth) : 0
@ -292,6 +292,7 @@ onClickOutside(wrap, () => {
<style lang="less"> <style lang="less">
@prefix-cls: ~'@{namespace}-layout-mix-sider'; @prefix-cls: ~'@{namespace}-layout-mix-sider';
@width: 80px; @width: 80px;
.@{prefix-cls} { .@{prefix-cls} {
position: fixed; position: fixed;
top: 0; top: 0;
@ -326,7 +327,7 @@ onClickOutside(wrap, () => {
} }
&.open { &.open {
> .scrollbar { >.scrollbar {
border-right: 1px solid rgb(238 238 238); border-right: 1px solid rgb(238 238 238);
} }
} }
@ -341,6 +342,7 @@ onClickOutside(wrap, () => {
} }
} }
} }
.@{prefix-cls}-menu-list { .@{prefix-cls}-menu-list {
&__content { &__content {
box-shadow: 0 0 4px 0 rgb(0 0 0 / 10%); box-shadow: 0 0 4px 0 rgb(0 0 0 / 10%);
@ -364,10 +366,11 @@ onClickOutside(wrap, () => {
border-bottom: 1px solid var(--sider-dark-lighten-bg-color); border-bottom: 1px solid var(--sider-dark-lighten-bg-color);
} }
> .scrollbar { >.scrollbar {
border-right: 1px solid var(--sider-dark-lighten-bg-color); border-right: 1px solid var(--sider-dark-lighten-bg-color);
} }
} }
.@{prefix-cls}-menu-list { .@{prefix-cls}-menu-list {
background-color: var(--sider-dark-bg-color); background-color: var(--sider-dark-bg-color);
@ -379,7 +382,7 @@ onClickOutside(wrap, () => {
} }
} }
> .scrollbar { >.scrollbar {
height: calc(100% - @header-height - 38px); height: calc(100% - @header-height - 38px);
} }
@ -408,6 +411,7 @@ onClickOutside(wrap, () => {
&:hover { &:hover {
color: @white; color: @white;
} }
// &:hover, // &:hover,
&--active { &--active {
font-weight: 700; font-weight: 700;

1
src/router/types.ts

@ -4,6 +4,7 @@ import type { RoleEnum } from '@/enums/roleEnum'
export type Component<T = any> = ReturnType<typeof defineComponent> | (() => Promise<typeof import('*.vue')>) | (() => Promise<T>) export type Component<T = any> = ReturnType<typeof defineComponent> | (() => Promise<typeof import('*.vue')>) | (() => Promise<T>)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error // @ts-expect-error
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> { export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
keepAlive?: boolean keepAlive?: boolean

1
src/store/modules/multipleTab.ts

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

3
src/utils/domUtils.ts

@ -158,13 +158,16 @@ export function once(el: HTMLElement, event: string, fn: EventListener): void {
export function useRafThrottle<T extends FunctionArgs>(fn: T): T { export function useRafThrottle<T extends FunctionArgs>(fn: T): T {
let locked = false let locked = false
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error // @ts-expect-error
return function (...args: any[]) { return function (...args: any[]) {
if (locked) if (locked)
return return
locked = true locked = true
window.requestAnimationFrame(() => { window.requestAnimationFrame(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error // @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-invalid-this
fn.apply(this, args) fn.apply(this, args)
locked = false locked = false
}) })

3
src/utils/index.ts

@ -164,6 +164,9 @@ export function simpleDebounce(fn, delay = 100) {
clearTimeout(timer) clearTimeout(timer)
timer = setTimeout(() => { timer = setTimeout(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-invalid-this
fn.apply(this, args) fn.apply(this, args)
}, delay) }, delay)
} }

3
src/utils/props.ts

@ -34,8 +34,7 @@ type _BuildPropType<T, V, C> =
export type BuildPropType<T, V, C> = _BuildPropType<IfUnknown<T, never>, IfUnknown<V, never>, IfUnknown<C, never>> export type BuildPropType<T, V, C> = _BuildPropType<IfUnknown<T, never>, IfUnknown<V, never>, IfUnknown<C, never>>
type _BuildPropDefault<T, D> = [T] extends [ type _BuildPropDefault<T, D> = [T] extends [
// eslint-disable-next-line @typescript-eslint/ban-types Record<string, unknown> | Array<any> | Fn,
Record<string, unknown> | Array<any> | Function,
] ]
? D ? D
: D extends () => T : D extends () => T