Browse Source

chore: fix lgtm errors (#38711)

pull/38722/head
afc163 2 years ago
committed by GitHub
parent
commit
c2fb6f4842
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      components/message/index.tsx
  2. 14
      components/notification/index.tsx
  3. 4
      components/slider/index.tsx

20
components/message/index.tsx

@ -121,7 +121,7 @@ const GlobalHolder = React.forwardRef<GlobalHolderRef, {}>((_, ref) => {
React.useImperativeHandle(ref, () => {
const instance: any = { ...api };
Object.keys(instance).forEach(method => {
Object.keys(instance).forEach((method) => {
instance[method] = (...args: any[]) => {
sync();
return (api as any)[method](...args);
@ -155,7 +155,7 @@ function flushNotice() {
act(() => {
render(
<GlobalHolder
ref={node => {
ref={(node) => {
const { instance, sync } = node || {};
// React 18 test env will throw if call immediately in ref
@ -176,12 +176,12 @@ function flushNotice() {
}
// Notification not ready
if (message && !message.instance) {
if (!message.instance) {
return;
}
// >>> Execute task
taskQueue.forEach(task => {
taskQueue.forEach((task) => {
const { type, skipped } = task;
// Only `skipped` when user call notice but cancel it immediately
@ -242,14 +242,14 @@ function setMessageGlobalConfig(config: ConfigOptions) {
}
function open(config: ArgsProps): MessageType {
const result = wrapPromiseFn(resolve => {
const result = wrapPromiseFn((resolve) => {
let closeFn: VoidFunction;
const task: OpenTask = {
type: 'open',
config,
resolve,
setCloseFn: fn => {
setCloseFn: (fn) => {
closeFn = fn;
},
};
@ -272,14 +272,14 @@ function open(config: ArgsProps): MessageType {
}
function typeOpen(type: NoticeType, args: Parameters<TypeOpen>): MessageType {
const result = wrapPromiseFn(resolve => {
const result = wrapPromiseFn((resolve) => {
let closeFn: VoidFunction;
const task: TypeTask = {
type,
args,
resolve,
setCloseFn: fn => {
setCloseFn: (fn) => {
closeFn = fn;
},
};
@ -328,7 +328,7 @@ const baseStaticMethods: {
const staticMethods: typeof baseStaticMethods & Record<MethodType, TypeOpen> =
baseStaticMethods as any;
methods.forEach(type => {
methods.forEach((type) => {
staticMethods[type] = (...args: Parameters<TypeOpen>) => typeOpen(type, args);
});
@ -342,7 +342,7 @@ const noop = () => {};
export let actWrapper: (wrapper: any) => void = noop;
if (process.env.NODE_ENV === 'test') {
actWrapper = wrapper => {
actWrapper = (wrapper) => {
act = wrapper;
};
}

14
components/notification/index.tsx

@ -100,7 +100,7 @@ const GlobalHolder = React.forwardRef<GlobalHolderRef, {}>((_, ref) => {
React.useImperativeHandle(ref, () => {
const instance: any = { ...api };
Object.keys(instance).forEach(method => {
Object.keys(instance).forEach((method) => {
instance[method] = (...args: any[]) => {
sync();
return (api as any)[method](...args);
@ -134,7 +134,7 @@ function flushNotice() {
act(() => {
render(
<GlobalHolder
ref={node => {
ref={(node) => {
const { instance, sync } = node || {};
Promise.resolve().then(() => {
@ -154,12 +154,12 @@ function flushNotice() {
}
// Notification not ready
if (notification && !notification.instance) {
if (!notification.instance) {
return;
}
// >>> Execute task
taskQueue.forEach(task => {
taskQueue.forEach((task) => {
// eslint-disable-next-line default-case
switch (task.type) {
case 'open': {
@ -236,8 +236,8 @@ const baseStaticMethods: {
const staticMethods: typeof baseStaticMethods & Record<MethodType, (config: ArgsProps) => void> =
baseStaticMethods as any;
methods.forEach(type => {
staticMethods[type] = config =>
methods.forEach((type) => {
staticMethods[type] = (config) =>
open({
...config,
type,
@ -254,7 +254,7 @@ const noop = () => {};
export let actWrapper: (wrapper: any) => void = noop;
if (process.env.NODE_ENV === 'test') {
actWrapper = wrapper => {
actWrapper = (wrapper) => {
act = wrapper;
};
}

4
components/slider/index.tsx

@ -24,7 +24,7 @@ export type HandleGeneratorFn = (config: {
}) => React.ReactElement;
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 {
prefixCls?: string;
@ -187,7 +187,7 @@ const Slider = React.forwardRef<unknown, SliderSingleProps | SliderRangeProps>(
formatter: tipFormatter,
} = tooltipProps;
let mergedTipFormatter = tipFormatter;
let mergedTipFormatter;
if (tipFormatter || tipFormatter === null) {
mergedTipFormatter = tipFormatter;
} else if (legacyTipFormatter || legacyTipFormatter === null) {

Loading…
Cancel
Save