mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
chore: fix lgtm errors (#38711)
This commit is contained in:
parent
e6016632d5
commit
c2fb6f4842
@ -121,7 +121,7 @@ const GlobalHolder = React.forwardRef<GlobalHolderRef, {}>((_, ref) => {
|
|||||||
React.useImperativeHandle(ref, () => {
|
React.useImperativeHandle(ref, () => {
|
||||||
const instance: any = { ...api };
|
const instance: any = { ...api };
|
||||||
|
|
||||||
Object.keys(instance).forEach(method => {
|
Object.keys(instance).forEach((method) => {
|
||||||
instance[method] = (...args: any[]) => {
|
instance[method] = (...args: any[]) => {
|
||||||
sync();
|
sync();
|
||||||
return (api as any)[method](...args);
|
return (api as any)[method](...args);
|
||||||
@ -155,7 +155,7 @@ function flushNotice() {
|
|||||||
act(() => {
|
act(() => {
|
||||||
render(
|
render(
|
||||||
<GlobalHolder
|
<GlobalHolder
|
||||||
ref={node => {
|
ref={(node) => {
|
||||||
const { instance, sync } = node || {};
|
const { instance, sync } = node || {};
|
||||||
|
|
||||||
// React 18 test env will throw if call immediately in ref
|
// React 18 test env will throw if call immediately in ref
|
||||||
@ -176,12 +176,12 @@ function flushNotice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Notification not ready
|
// Notification not ready
|
||||||
if (message && !message.instance) {
|
if (!message.instance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// >>> Execute task
|
// >>> Execute task
|
||||||
taskQueue.forEach(task => {
|
taskQueue.forEach((task) => {
|
||||||
const { type, skipped } = task;
|
const { type, skipped } = task;
|
||||||
|
|
||||||
// Only `skipped` when user call notice but cancel it immediately
|
// Only `skipped` when user call notice but cancel it immediately
|
||||||
@ -242,14 +242,14 @@ function setMessageGlobalConfig(config: ConfigOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function open(config: ArgsProps): MessageType {
|
function open(config: ArgsProps): MessageType {
|
||||||
const result = wrapPromiseFn(resolve => {
|
const result = wrapPromiseFn((resolve) => {
|
||||||
let closeFn: VoidFunction;
|
let closeFn: VoidFunction;
|
||||||
|
|
||||||
const task: OpenTask = {
|
const task: OpenTask = {
|
||||||
type: 'open',
|
type: 'open',
|
||||||
config,
|
config,
|
||||||
resolve,
|
resolve,
|
||||||
setCloseFn: fn => {
|
setCloseFn: (fn) => {
|
||||||
closeFn = fn;
|
closeFn = fn;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -272,14 +272,14 @@ function open(config: ArgsProps): MessageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function typeOpen(type: NoticeType, args: Parameters<TypeOpen>): MessageType {
|
function typeOpen(type: NoticeType, args: Parameters<TypeOpen>): MessageType {
|
||||||
const result = wrapPromiseFn(resolve => {
|
const result = wrapPromiseFn((resolve) => {
|
||||||
let closeFn: VoidFunction;
|
let closeFn: VoidFunction;
|
||||||
|
|
||||||
const task: TypeTask = {
|
const task: TypeTask = {
|
||||||
type,
|
type,
|
||||||
args,
|
args,
|
||||||
resolve,
|
resolve,
|
||||||
setCloseFn: fn => {
|
setCloseFn: (fn) => {
|
||||||
closeFn = fn;
|
closeFn = fn;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -328,7 +328,7 @@ const baseStaticMethods: {
|
|||||||
const staticMethods: typeof baseStaticMethods & Record<MethodType, TypeOpen> =
|
const staticMethods: typeof baseStaticMethods & Record<MethodType, TypeOpen> =
|
||||||
baseStaticMethods as any;
|
baseStaticMethods as any;
|
||||||
|
|
||||||
methods.forEach(type => {
|
methods.forEach((type) => {
|
||||||
staticMethods[type] = (...args: Parameters<TypeOpen>) => typeOpen(type, args);
|
staticMethods[type] = (...args: Parameters<TypeOpen>) => typeOpen(type, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ const noop = () => {};
|
|||||||
export let actWrapper: (wrapper: any) => void = noop;
|
export let actWrapper: (wrapper: any) => void = noop;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'test') {
|
if (process.env.NODE_ENV === 'test') {
|
||||||
actWrapper = wrapper => {
|
actWrapper = (wrapper) => {
|
||||||
act = wrapper;
|
act = wrapper;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ const GlobalHolder = React.forwardRef<GlobalHolderRef, {}>((_, ref) => {
|
|||||||
React.useImperativeHandle(ref, () => {
|
React.useImperativeHandle(ref, () => {
|
||||||
const instance: any = { ...api };
|
const instance: any = { ...api };
|
||||||
|
|
||||||
Object.keys(instance).forEach(method => {
|
Object.keys(instance).forEach((method) => {
|
||||||
instance[method] = (...args: any[]) => {
|
instance[method] = (...args: any[]) => {
|
||||||
sync();
|
sync();
|
||||||
return (api as any)[method](...args);
|
return (api as any)[method](...args);
|
||||||
@ -134,7 +134,7 @@ function flushNotice() {
|
|||||||
act(() => {
|
act(() => {
|
||||||
render(
|
render(
|
||||||
<GlobalHolder
|
<GlobalHolder
|
||||||
ref={node => {
|
ref={(node) => {
|
||||||
const { instance, sync } = node || {};
|
const { instance, sync } = node || {};
|
||||||
|
|
||||||
Promise.resolve().then(() => {
|
Promise.resolve().then(() => {
|
||||||
@ -154,12 +154,12 @@ function flushNotice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Notification not ready
|
// Notification not ready
|
||||||
if (notification && !notification.instance) {
|
if (!notification.instance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// >>> Execute task
|
// >>> Execute task
|
||||||
taskQueue.forEach(task => {
|
taskQueue.forEach((task) => {
|
||||||
// eslint-disable-next-line default-case
|
// eslint-disable-next-line default-case
|
||||||
switch (task.type) {
|
switch (task.type) {
|
||||||
case 'open': {
|
case 'open': {
|
||||||
@ -236,8 +236,8 @@ const baseStaticMethods: {
|
|||||||
const staticMethods: typeof baseStaticMethods & Record<MethodType, (config: ArgsProps) => void> =
|
const staticMethods: typeof baseStaticMethods & Record<MethodType, (config: ArgsProps) => void> =
|
||||||
baseStaticMethods as any;
|
baseStaticMethods as any;
|
||||||
|
|
||||||
methods.forEach(type => {
|
methods.forEach((type) => {
|
||||||
staticMethods[type] = config =>
|
staticMethods[type] = (config) =>
|
||||||
open({
|
open({
|
||||||
...config,
|
...config,
|
||||||
type,
|
type,
|
||||||
@ -254,7 +254,7 @@ const noop = () => {};
|
|||||||
export let actWrapper: (wrapper: any) => void = noop;
|
export let actWrapper: (wrapper: any) => void = noop;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'test') {
|
if (process.env.NODE_ENV === 'test') {
|
||||||
actWrapper = wrapper => {
|
actWrapper = (wrapper) => {
|
||||||
act = wrapper;
|
act = wrapper;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ export type HandleGeneratorFn = (config: {
|
|||||||
}) => React.ReactElement;
|
}) => React.ReactElement;
|
||||||
|
|
||||||
export type Formatter = (value?: number) => React.ReactNode;
|
export type Formatter = (value?: number) => React.ReactNode;
|
||||||
const defaultFormatter: Formatter = val => (typeof val === 'number' ? val.toString() : '');
|
const defaultFormatter: Formatter = (val) => (typeof val === 'number' ? val.toString() : '');
|
||||||
|
|
||||||
export interface SliderTooltipProps {
|
export interface SliderTooltipProps {
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
@ -187,7 +187,7 @@ const Slider = React.forwardRef<unknown, SliderSingleProps | SliderRangeProps>(
|
|||||||
formatter: tipFormatter,
|
formatter: tipFormatter,
|
||||||
} = tooltipProps;
|
} = tooltipProps;
|
||||||
|
|
||||||
let mergedTipFormatter = tipFormatter;
|
let mergedTipFormatter;
|
||||||
if (tipFormatter || tipFormatter === null) {
|
if (tipFormatter || tipFormatter === null) {
|
||||||
mergedTipFormatter = tipFormatter;
|
mergedTipFormatter = tipFormatter;
|
||||||
} else if (legacyTipFormatter || legacyTipFormatter === null) {
|
} else if (legacyTipFormatter || legacyTipFormatter === null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user