fix: lint erros

This commit is contained in:
07akioni 2024-09-25 01:14:09 +08:00
parent 3045265346
commit d5d0134c09
33 changed files with 196 additions and 196 deletions

View File

@ -38,9 +38,9 @@ ${tsToJs(parts.script)}
mergedParts.jsCode += isVue
? `<template>${parts.template}</template>`
: `<template>\n${parts.template
.split('\n')
.map(line => (line.length ? ` ${line}` : line))
.join('\n')}\n</template>`
.split('\n')
.map(line => (line.length ? ` ${line}` : line))
.join('\n')}\n</template>`
}
if (parts.script) {
if (parts.template) {

View File

@ -291,10 +291,10 @@ export default defineComponent({
'div',
mergeProps(this.$attrs, {
class: [
`${mergedClsPrefix}-back-top`,
this.themeClass,
this.transitionDisabled
&& `${mergedClsPrefix}-back-top--transition-disabled`
`${mergedClsPrefix}-back-top`,
this.themeClass,
this.transitionDisabled
&& `${mergedClsPrefix}-back-top--transition-disabled`
],
style: [this.style, this.cssVars],
onClick: this.handleClick

View File

@ -74,9 +74,9 @@ export default defineComponent({
return (
props.show
&& (props.dot
|| (props.value !== undefined
&& !(!props.showZero && Number(props.value) <= 0))
|| !isSlotEmpty(slots.value))
|| (props.value !== undefined
&& !(!props.showZero && Number(props.value) <= 0))
|| !isSlotEmpty(slots.value))
)
})
onMounted(() => {

View File

@ -248,7 +248,7 @@ export default defineComponent({
}}
</NBaseLoading>
) : this.checkStrategy === 'child'
&& !(this.multiple && this.cascade) ? (
&& !(this.multiple && this.cascade) ? (
<Transition name="fade-in-scale-up-transition">
{{
default: () =>
@ -282,7 +282,7 @@ export default defineComponent({
`${mergedClsPrefix}-cascader-option`,
this.keyboardPending
|| (this.hoverPending
&& `${mergedClsPrefix}-cascader-option--pending`),
&& `${mergedClsPrefix}-cascader-option--pending`),
this.disabled && `${mergedClsPrefix}-cascader-option--disabled`,
this.showCheckbox && `${mergedClsPrefix}-cascader-option--show-prefix`
]}

View File

@ -32,19 +32,19 @@ export type OnLoad = (option: CascaderOption) => Promise<void>
export type OnUpdateValue = (
value: string &
number &
string[] &
number[] &
Array<string | number> &
(string | null) &
(number | null) &
(string[] | null) &
(number[] | null) &
(Array<string | number> | null),
number &
string[] &
number[] &
Array<string | number> &
(string | null) &
(number | null) &
(string[] | null) &
(number[] | null) &
(Array<string | number> | null),
option: null &
CascaderOption &
CascaderOption[] &
Array<CascaderOption | null>,
CascaderOption &
CascaderOption[] &
Array<CascaderOption | null>,
path: null & CascaderOption[] & Array<CascaderOption[] | null>
) => void

View File

@ -192,20 +192,20 @@ interface DataTableFilterState {
```ts
type DataTableCreateSummary = (pageData: RowData[]) =>
| Array<{
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
| Array<{
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
}
}>
| {
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
}
}
}>
| {
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
}
}
```
### DataTable Methods

View File

@ -203,20 +203,20 @@ interface DataTableFilterState {
```ts
type DataTableCreateSummary = (pageData: RowData[]) =>
| Array<{
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
| Array<{
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
}
}>
| {
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
}
}
}>
| {
[columnKey: string]: {
value?: VNodeChild
colSpan?: number
rowSpan?: number
}
}
```
### DataTable Methods

View File

@ -78,9 +78,9 @@ export default defineComponent({
if (shouldUseArrayInSingleMode(props.column)) {
return (
(Array.isArray(temporalValue)
&& temporalValue.length
&& temporalValue[0])
|| null
&& temporalValue.length
&& temporalValue[0])
|| null
)
}
if (!Array.isArray(temporalValue))

View File

@ -323,8 +323,8 @@ export default defineComponent({
`${mergedClsPrefix}-data-table-th`,
(leftFixed || rightFixed)
&& `${mergedClsPrefix}-data-table-th--fixed-${
leftFixed ? 'left' : 'right'
}`,
leftFixed ? 'left' : 'right'
}`,
{
[`${mergedClsPrefix}-data-table-th--sorting`]: isColumnSorting(
column,

View File

@ -65,11 +65,11 @@ export function useCheck(
const { value: mergedInderminateRowKeySet } = mergedInderminateRowKeySetRef
return (
(countOfCurrentPageCheckedRowsRef.value > 0
&& countOfCurrentPageCheckedRowsRef.value
< length - countOfCurrentPageDisabledRowsRef.value)
|| paginatedDataRef.value.some(rowData =>
mergedInderminateRowKeySet.has(rowData.key)
)
&& countOfCurrentPageCheckedRowsRef.value
< length - countOfCurrentPageDisabledRowsRef.value)
|| paginatedDataRef.value.some(rowData =>
mergedInderminateRowKeySet.has(rowData.key)
)
)
})
const allRowsCheckedRef = computed(() => {

View File

@ -31,8 +31,8 @@ function getSortFunction(
if (
columnKey
&& (sorter === undefined
|| sorter === 'default'
|| (typeof sorter === 'object' && sorter.compare === 'default'))
|| sorter === 'default'
|| (typeof sorter === 'object' && sorter.compare === 'default'))
) {
return getDefaultSorterFn(columnKey)
}
@ -111,8 +111,8 @@ export function useSorter(
column.type !== 'selection'
&& column.sorter !== undefined
&& (column.sortOrder === 'ascend'
|| column.sortOrder === 'descend'
|| column.sortOrder === false)
|| column.sortOrder === 'descend'
|| column.sortOrder === false)
)
// if multiple columns are controlled sortable, then we need to find columns with active sortOrder
const columnToSort: TableBaseColumn[] | undefined = (

View File

@ -128,7 +128,7 @@ export function shouldUseArrayInSingleMode(column: TableBaseColumn): boolean {
return (
column.filterOptionValues !== undefined
|| (column.filterOptionValue === undefined
&& column.defaultFilterOptionValues !== undefined)
&& column.defaultFilterOptionValues !== undefined)
)
}
@ -207,10 +207,10 @@ function formatCsvCell(value: unknown): string {
export function generateCsv(columns: TableColumn[], data: RowData[]): string {
const exportableColumns = columns.filter(
(column) =>
column.type !== 'expand' &&
column.type !== 'selection' &&
column.allowExport !== false
column =>
column.type !== 'expand'
&& column.type !== 'selection'
&& column.allowExport !== false
)
const header = exportableColumns.map((col: any) => col.title).join(',')
const rows = data.map((row) => {

View File

@ -990,8 +990,8 @@ export default defineComponent({
) : type === 'month' || type === 'year' || type === 'quarter' ? (
<MonthPanel {...commonPanelProps} type={type} key={type} />
) : type === 'monthrange'
|| type === 'yearrange'
|| type === 'quarterrange' ? (
|| type === 'yearrange'
|| type === 'quarterrange' ? (
<MonthRangePanel {...commonPanelProps} type={type} />
) : (
<DatePanel

View File

@ -43,13 +43,13 @@ export type Shortcuts =
export type OnUpdateValue = (
value: number &
(number | null) &
[number, number] &
([number, number] | null),
(number | null) &
[number, number] &
([number, number] | null),
formattedValue: string &
(string | null) &
[string, string] &
([string, string] | null)
(string | null) &
[string, string] &
([string, string] | null)
) => void
export type OnConfirm = OnUpdateValue
@ -58,13 +58,13 @@ export type OnConfirmImpl = OnUpdateValueImpl
export type OnUpdateFormattedValue = (
value: string &
(string | null) &
[string, string] &
([string, string] | null),
(string | null) &
[string, string] &
([string, string] | null),
timestampValue: number &
(number | null) &
[number, number] &
([number, number] | null)
(number | null) &
[number, number] &
([number, number] | null)
) => void
export type OnUpdateFormattedValueImpl = (
@ -79,9 +79,9 @@ export type OnUpdateValueImpl = (
export type OnPanelUpdateValue = (
value: number &
(number | null) &
[number, number] &
([number, number] | null),
(number | null) &
[number, number] &
([number, number] | null),
doUpdate: boolean
) => void

View File

@ -266,8 +266,8 @@ export const NDialog = defineComponent({
{closable
? resolveWrappedSlot(this.$slots.close, (node) => {
const classNames = [
`${mergedClsPrefix}-dialog__close`,
this.rtlEnabled && `${mergedClsPrefix}-dialog--rtl`
`${mergedClsPrefix}-dialog__close`,
this.rtlEnabled && `${mergedClsPrefix}-dialog--rtl`
]
return node ? (
<div class={classNames}>{node}</div>

View File

@ -272,26 +272,26 @@ export default defineComponent({
ref: 'bodyRef',
'aria-modal': 'true',
class: [
`${mergedClsPrefix}-drawer`,
this.rtlEnabled
&& `${mergedClsPrefix}-drawer--rtl`,
`${mergedClsPrefix}-drawer--${this.placement}-placement`,
/**
* When the mouse is pressed to resize the drawer,
* disable text selection
*/
this.isDragging
&& `${mergedClsPrefix}-drawer--unselectable`,
this.nativeScrollbar
&& `${mergedClsPrefix}-drawer--native-scrollbar`
`${mergedClsPrefix}-drawer`,
this.rtlEnabled
&& `${mergedClsPrefix}-drawer--rtl`,
`${mergedClsPrefix}-drawer--${this.placement}-placement`,
/**
* When the mouse is pressed to resize the drawer,
* disable text selection
*/
this.isDragging
&& `${mergedClsPrefix}-drawer--unselectable`,
this.nativeScrollbar
&& `${mergedClsPrefix}-drawer--native-scrollbar`
]
}),
[
this.resizable ? (
<div
class={[
`${mergedClsPrefix}-drawer__resize-trigger`,
(this.isDragging
`${mergedClsPrefix}-drawer__resize-trigger`,
(this.isDragging
|| this.isHoverOnResizeTrigger)
&& `${mergedClsPrefix}-drawer__resize-trigger--hover`
]}
@ -309,8 +309,8 @@ export default defineComponent({
this.nativeScrollbar ? (
<div
class={[
`${mergedClsPrefix}-drawer-content-wrapper`,
this.contentClass
`${mergedClsPrefix}-drawer-content-wrapper`,
this.contentClass
]}
style={this.contentStyle}
role="none"
@ -322,8 +322,8 @@ export default defineComponent({
{...this.scrollbarProps}
contentStyle={this.contentStyle}
contentClass={[
`${mergedClsPrefix}-drawer-content-wrapper`,
this.contentClass
`${mergedClsPrefix}-drawer-content-wrapper`,
this.contentClass
]}
theme={this.mergedTheme.peers.Scrollbar}
themeOverrides={

View File

@ -110,10 +110,10 @@ function wrapValidator(
const validateResult = validator(...args)
if (
(!async
&& (typeof validateResult === 'boolean'
|| validateResult instanceof Error
|| Array.isArray(validateResult))) // Error[]
|| (validateResult as any)?.then
&& (typeof validateResult === 'boolean'
|| validateResult instanceof Error
|| Array.isArray(validateResult))) // Error[]
|| (validateResult as any)?.then
) {
return validateResult as any
}
@ -125,8 +125,8 @@ function wrapValidator(
'form-item/validate',
`You return a ${typeof validateResult} `
+ `typed value in the validator method, which is not recommended. Please use ${
async ? '`Promise`' : '`boolean`, `Error` or `Promise`'
} typed value instead.`
async ? '`Promise`' : '`boolean`, `Error` or `Promise`'
} typed value instead.`
)
return true
}
@ -498,8 +498,8 @@ export default defineComponent({
'form-item',
computed(() => {
return `${mergedSizeRef.value[0]}${labelPlacementRef.value[0]}${
labelTextAlignRef.value?.[0] || ''
}`
labelTextAlignRef.value?.[0] || ''
}`
}),
cssVarsRef,
props

View File

@ -257,8 +257,8 @@ export default defineComponent({
return (
!isComposing
&& (isEmptyInputValue(mergedValue)
|| (Array.isArray(mergedValue) && isEmptyInputValue(mergedValue[0])))
&& mergedPlaceholder[0]
|| (Array.isArray(mergedValue) && isEmptyInputValue(mergedValue[0])))
&& mergedPlaceholder[0]
)
})
const showPlaceholder2Ref = computed(() => {
@ -269,7 +269,7 @@ export default defineComponent({
!isComposing
&& mergedPlaceholder[1]
&& (isEmptyInputValue(mergedValue)
|| (Array.isArray(mergedValue) && isEmptyInputValue(mergedValue[1])))
|| (Array.isArray(mergedValue) && isEmptyInputValue(mergedValue[1])))
)
})
// focus
@ -575,8 +575,8 @@ export default defineComponent({
!(
e.relatedTarget !== null
&& (e.relatedTarget === inputElRef.value
|| e.relatedTarget === inputEl2Ref.value
|| e.relatedTarget === textareaElRef.value)
|| e.relatedTarget === inputEl2Ref.value
|| e.relatedTarget === textareaElRef.value)
)
) {
activatedRef.value = false
@ -617,9 +617,9 @@ export default defineComponent({
if (
e.relatedTarget !== null
&& (e.relatedTarget === inputElRef.value
|| e.relatedTarget === inputEl2Ref.value
|| e.relatedTarget === textareaElRef.value
|| e.relatedTarget === wrapperElRef.value)
|| e.relatedTarget === inputEl2Ref.value
|| e.relatedTarget === textareaElRef.value
|| e.relatedTarget === wrapperElRef.value)
) {
/**
* activeElement transfer inside the input, do nothing

View File

@ -13,7 +13,7 @@ export const positionProp = {
export interface LayoutInst {
scrollTo: ((options: ScrollToOptions) => void) &
((x: number, y: number) => void)
((x: number, y: number) => void)
}
export type LayoutSiderInst = LayoutInst

View File

@ -228,10 +228,10 @@ export default defineComponent({
uncontrolledExpandedKeysRef.value = props.defaultExpandAll
? treeMateRef.value.getNonLeafKeys()
: props.defaultExpandedNames
|| props.defaultExpandedKeys
|| treeMateRef.value.getPath(mergedValueRef.value, {
includeSelf: false
}).keyPath
|| props.defaultExpandedKeys
|| treeMateRef.value.getPath(mergedValueRef.value, {
includeSelf: false
}).keyPath
}
if (watchProps?.includes('defaultExpandedKeys')) {
watchEffect(initUncontrolledExpandedKeys)

View File

@ -256,12 +256,12 @@ export default defineComponent({
}
return withDirectives(
(this.preset === 'confirm'
|| this.preset === 'dialog' ? (
|| this.preset === 'dialog' ? (
<NDialog
{...this.$attrs}
class={[
`${mergedClsPrefix}-modal`,
this.$attrs.class
`${mergedClsPrefix}-modal`,
this.$attrs.class
]}
ref="bodyRef"
theme={this.mergedTheme.peers.Dialog}
@ -278,8 +278,8 @@ export default defineComponent({
{...this.$attrs}
ref="bodyRef"
class={[
`${mergedClsPrefix}-modal`,
this.$attrs.class
`${mergedClsPrefix}-modal`,
this.$attrs.class
]}
theme={this.mergedTheme.peers.Card}
themeOverrides={

View File

@ -626,9 +626,9 @@ export default defineComponent({
!renderPrev
&& `${mergedClsPrefix}-pagination-item--button`,
(mergedPage <= 1
|| mergedPage > mergedPageCount
|| disabled)
&& `${mergedClsPrefix}-pagination-item--disabled`
|| mergedPage > mergedPageCount
|| disabled)
&& `${mergedClsPrefix}-pagination-item--disabled`
]}
onClick={handleBackwardClick}
>
@ -765,10 +765,10 @@ export default defineComponent({
&& `${mergedClsPrefix}-pagination-item--active`,
type !== 'page'
&& ((type === 'fast-backward'
&& this.showFastBackwardMenu)
|| (type === 'fast-forward'
&& this.showFastForwardMenu))
&& `${mergedClsPrefix}-pagination-item--hover`,
&& this.showFastBackwardMenu)
|| (type === 'fast-forward'
&& this.showFastForwardMenu))
&& `${mergedClsPrefix}-pagination-item--hover`,
disabled
&& `${mergedClsPrefix}-pagination-item--disabled`,
type === 'page'

View File

@ -279,10 +279,10 @@ export default defineComponent({
function handleClickOutside(e: MouseEvent): void {
if (
(props.trigger === 'click'
&& !getTriggerElement().contains(
getPreciseEventTarget(e) as Node | null
))
|| props.onClickoutside
&& !getTriggerElement().contains(
getPreciseEventTarget(e) as Node | null
))
|| props.onClickoutside
) {
NPopover.handleClickOutside(e)
}
@ -373,8 +373,8 @@ export default defineComponent({
hasHeaderOrFooter
? undefined
: `${mergedClsPrefix}-popover__content ${
props.contentClass ?? ''
}`
props.contentClass ?? ''
}`
}
contentStyle={hasHeaderOrFooter ? undefined : props.contentStyle}
>

View File

@ -59,9 +59,9 @@ export default defineComponent({
`${
((Math.PI * v) / 100)
* (props.viewBoxWidth / 2
- (props.strokeWidth / 2) * (1 + 2 * i)
- props.circleGap * i)
* 2
- (props.strokeWidth / 2) * (1 + 2 * i)
- props.circleGap * i)
* 2
}, ${props.viewBoxWidth * 8}`
)
return strokeDasharrays

View File

@ -41,15 +41,15 @@ export type ValueAtom = string | number
export type Value = ValueAtom | string[] | number[] | ValueAtom[]
export type OnUpdateValue = (
value: string &
number &
ValueAtom &
string[] &
number[] &
ValueAtom[] &
(ValueAtom | null) &
(string[] | null) &
(number[] | null) &
(ValueAtom[] | null),
number &
ValueAtom &
string[] &
number[] &
ValueAtom[] &
(ValueAtom | null) &
(string[] | null) &
(number[] | null) &
(ValueAtom[] | null),
option: SelectBaseOption & null & SelectBaseOption[]
) => void
export type OnUpdateValueImpl = (

View File

@ -849,9 +849,9 @@ export default defineComponent({
internalLeftPadded={
index !== 0
&& (!mergedJustifyContent
|| mergedJustifyContent === 'center'
|| mergedJustifyContent === 'start'
|| mergedJustifyContent === 'end')
|| mergedJustifyContent === 'center'
|| mergedJustifyContent === 'start'
|| mergedJustifyContent === 'end')
}
>
{tabPaneVNode.children
@ -1038,7 +1038,7 @@ export default defineComponent({
</div>
{showPane
&& (this.animated
&& (resolvedPlacement === 'top' || resolvedPlacement === 'bottom') ? (
&& (resolvedPlacement === 'top' || resolvedPlacement === 'bottom') ? (
<div
ref="tabsPaneWrapperRef"
style={paneWrapperStyle}

View File

@ -102,7 +102,7 @@ export default defineComponent({
continue
}
;(overrides as any)[key] = (mergedTheme[key]?.self?.(common)
|| lightTheme[key].self?.(common)) as any
|| lightTheme[key].self?.(common)) as any
// There (last line) we must use as any, nor ts 2590 will be raised since the union
// is too complex
if (mergedThemeOverrides && (overrides as any)[key]) {

View File

@ -85,10 +85,10 @@ export default defineComponent({
<div class={`${mergedClsPrefix}-thing-main`}>
{!props.contentIndented
&& (slots.header
|| props.title
|| slots['header-extra']
|| props.titleExtra
|| slots.avatar) ? (
|| props.title
|| slots['header-extra']
|| props.titleExtra
|| slots.avatar) ? (
<div class={`${mergedClsPrefix}-thing-avatar-header-wrapper`}>
{slots.avatar ? (
<div class={`${mergedClsPrefix}-thing-avatar`}>
@ -117,8 +117,8 @@ export default defineComponent({
{slots.description || props.description ? (
<div
class={[
`${mergedClsPrefix}-thing-main__description`,
props.descriptionClass
`${mergedClsPrefix}-thing-main__description`,
props.descriptionClass
]}
style={props.descriptionStyle}
>
@ -154,8 +154,8 @@ export default defineComponent({
{slots.description || props.description ? (
<div
class={[
`${mergedClsPrefix}-thing-main__description`,
props.descriptionClass
`${mergedClsPrefix}-thing-main__description`,
props.descriptionClass
]}
style={props.descriptionStyle}
>

View File

@ -15,16 +15,16 @@ export type TreeSelectTmNode = TreeNode<TreeSelectOption>
export type OnUpdateValue = (
value: string &
number &
(string | number) &
string[] &
number[] &
Array<string | number> &
null,
number &
(string | number) &
string[] &
number[] &
Array<string | number> &
null,
option: TreeSelectOption &
null &
TreeSelectOption[] &
Array<TreeSelectOption | null>,
null &
TreeSelectOption[] &
Array<TreeSelectOption | null>,
meta:
| {
node: TreeSelectOption

View File

@ -1403,7 +1403,7 @@ export default defineComponent({
if (
draggingNode.contains(finalDropNode)
|| (finalDropPosition === 'inside'
&& draggingNode.parent?.key === finalDropNode.key)
&& draggingNode.parent?.key === finalDropNode.key)
) {
if (
draggingNode.key === droppingMouseNode.key

View File

@ -134,8 +134,8 @@ const TreeNode = defineComponent({
() =>
NTree.checkableRef.value
&& (NTree.cascadeRef.value
|| NTree.mergedCheckStrategyRef.value !== 'child'
|| props.tmNode.isLeaf)
|| NTree.mergedCheckStrategyRef.value !== 'child'
|| props.tmNode.isLeaf)
)
const checkedRef = useMemo(() =>

View File

@ -61,10 +61,10 @@ export default (level: '1' | '2' | '3' | '4' | '5' | '6') =>
})
const themeClassHandle = inlineThemeDisabled
? useThemeClass(
`h${level}`,
computed(() => props.type[0]),
cssVarsRef,
props
`h${level}`,
computed(() => props.type[0]),
cssVarsRef,
props
)
: undefined
return {

View File

@ -181,13 +181,13 @@ export default defineComponent({
canvasOffsetLeft,
canvasOffsetTop,
(props.imageWidth
|| (imageHeight
? (img.width * imageHeight) / img.height
: img.width)) * ratio,
|| (imageHeight
? (img.width * imageHeight) / img.height
: img.width)) * ratio,
(props.imageHeight
|| (imageWidth
? (img.height * imageWidth) / img.width
: img.height)) * ratio
|| (imageWidth
? (img.height * imageWidth) / img.width
: img.height)) * ratio
)
base64UrlRef.value = canvas.toDataURL()
}
@ -269,10 +269,10 @@ export default defineComponent({
: ''
: props.cross
? `calc(${rotatedImageOffset} + ${
props.width / 2
}px) calc(${rotatedImageOffset} + ${
props.height / 2
}px), ${rotatedImageOffset} ${rotatedImageOffset}`
props.width / 2
}px) calc(${rotatedImageOffset} + ${
props.height / 2
}px), ${rotatedImageOffset} ${rotatedImageOffset}`
: rotatedImageOffset,
backgroundImage: props.cross
? `url(${base64UrlRef.value}), url(${base64UrlRef.value})`