chore(deps-dev): bump eslint-config-prettier from 6.15.0 to 7.0.0 (#28253)

* chore(deps-dev): bump eslint-config-prettier from 6.15.0 to 7.0.0

Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 6.15.0 to 7.0.0.
- [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v6.15.0...v7.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

* chore: fix eslint style

* chore: prettier code style

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
dependabot[bot] 2020-12-09 17:12:32 +08:00 committed by GitHub
parent e408593725
commit 775d1800bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 526 additions and 651 deletions

View File

@ -1,5 +1,3 @@
const isNumeric = (value: any): boolean => {
return !isNaN(parseFloat(value)) && isFinite(value);
};
const isNumeric = (value: any): boolean => !isNaN(parseFloat(value)) && isFinite(value);
export default isNumeric;

View File

@ -138,9 +138,7 @@ class Affix extends React.Component<AffixProps, AffixState> {
return offsetTop;
};
getOffsetBottom = () => {
return this.props.offsetBottom;
};
getOffsetBottom = () => this.props.offsetBottom;
savePlaceholderNode = (node: HTMLDivElement) => {
this.placeholderNode = node;

View File

@ -121,8 +121,8 @@ const Alert: AlertInterface = ({
return React.createElement(iconType, { className: `${prefixCls}-icon` });
};
const renderCloseIcon = () => {
return isClosable ? (
const renderCloseIcon = () =>
isClosable ? (
<button
type="button"
onClick={handleClose}
@ -136,7 +136,6 @@ const Alert: AlertInterface = ({
)}
</button>
) : null;
};
// banner 模式默认有 Icon
const isShowIcon = banner && showIcon === undefined ? true : showIcon;

View File

@ -37,11 +37,11 @@ const Group: React.FC<GroupProps> = props => {
);
const { children, maxPopoverPlacement = 'top' } = props;
const childrenWithProps = toArray(children).map((child, index) => {
return cloneElement(child, {
const childrenWithProps = toArray(children).map((child, index) =>
cloneElement(child, {
key: `avatar-key-${index}`,
});
});
}),
);
const numOfChildren = childrenWithProps.length;
if (maxCount && maxCount < numOfChildren) {

View File

@ -31,9 +31,8 @@ const BackTop: React.FC<BackTopProps> = props => {
const ref = React.createRef<HTMLDivElement>();
const scrollEvent = React.useRef<any>();
const getDefaultTarget = () => {
return ref.current && ref.current.ownerDocument ? ref.current.ownerDocument : window;
};
const getDefaultTarget = () =>
ref.current && ref.current.ownerDocument ? ref.current.ownerDocument : window;
const handleScroll = throttleByAnimationFrame(
(e: React.UIEvent<HTMLElement> | { target: any }) => {

View File

@ -141,13 +141,11 @@ describe('Breadcrumb', () => {
// https://github.com/ant-design/ant-design/issues/25975
it('should support Breadcrumb.Item default separator', () => {
const MockComponent = () => {
return (
<span>
<Breadcrumb.Item>Mock Node</Breadcrumb.Item>
</span>
);
};
const MockComponent = () => (
<span>
<Breadcrumb.Item>Mock Node</Breadcrumb.Item>
</span>
);
const wrapper = render(
<Breadcrumb>
<Breadcrumb.Item>Location</Breadcrumb.Item>

View File

@ -38,13 +38,11 @@ const LoadingIcon: React.FC<LoadingIconProps> = ({ prefixCls, loading, existIcon
onLeaveStart={getRealWidth}
onLeaveActive={getCollapsedWidth}
>
{({ className, style }: { className?: string; style?: React.CSSProperties }, ref: any) => {
return (
<span className={`${prefixCls}-loading-icon`} style={style} ref={ref}>
<LoadingOutlined className={className} />
</span>
);
}}
{({ className, style }: { className?: string; style?: React.CSSProperties }, ref: any) => (
<span className={`${prefixCls}-loading-icon`} style={style} ref={ref}>
<LoadingOutlined className={className} />
</span>
)}
</CSSMotion>
);
};

View File

@ -153,9 +153,8 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
const buttonRef = (ref as any) || React.createRef<HTMLElement>();
const delayTimeoutRef = React.useRef<number>();
const isNeedInserted = () => {
return React.Children.count(children) === 1 && !icon && !isUnborderedButtonType(type);
};
const isNeedInserted = () =>
React.Children.count(children) === 1 && !icon && !isUnborderedButtonType(type);
const fixTwoCNChar = () => {
// Fix for HOC usage like <FormatMessage />
@ -275,7 +274,7 @@ const InternalButton: React.ForwardRefRenderFunction<unknown, ButtonProps> = (pr
const buttonNode = (
<button
{...rest as NativeButtonProps}
{...(rest as NativeButtonProps)}
type={htmlType}
className={classes}
onClick={handleClick}

View File

@ -363,14 +363,12 @@ describe('Calendar', () => {
expect(onMonthChange).toHaveBeenCalled();
// Type
const headerRenderWithTypeChange = jest.fn(({ type }) => {
return (
<Group size="small" onChange={onTypeChange} value={type}>
<Button value="month">Month</Button>
<Button value="year">Year</Button>
</Group>
);
});
const headerRenderWithTypeChange = jest.fn(({ type }) => (
<Group size="small" onChange={onTypeChange} value={type}>
<Button value="month">Month</Button>
<Button value="year">Year</Button>
</Group>
));
const wrapperWithTypeChange = mount(
<Calendar fullscreen={false} headerRender={headerRenderWithTypeChange} />,

View File

@ -238,57 +238,55 @@ function generateCalendar<DateType>(generateConfig: GenerateConfig<DateType>) {
return (
<LocaleReceiver componentName="Calendar" defaultLocale={getDefaultLocale}>
{(mergedLocale: any) => {
return (
<div
className={classNames(
calendarPrefixCls,
{
[`${calendarPrefixCls}-full`]: fullscreen,
[`${calendarPrefixCls}-mini`]: !fullscreen,
[`${calendarPrefixCls}-rtl`]: direction === 'rtl',
},
className,
)}
style={style}
>
{headerRender ? (
headerRender({
value: mergedValue,
type: mergedMode,
onChange: onInternalSelect,
onTypeChange: triggerModeChange,
})
) : (
<CalendarHeader
prefixCls={calendarPrefixCls}
value={mergedValue}
generateConfig={generateConfig}
mode={mergedMode}
fullscreen={fullscreen}
locale={mergedLocale.lang}
validRange={validRange}
onChange={onInternalSelect}
onModeChange={triggerModeChange}
/>
)}
<RCPickerPanel
{(mergedLocale: any) => (
<div
className={classNames(
calendarPrefixCls,
{
[`${calendarPrefixCls}-full`]: fullscreen,
[`${calendarPrefixCls}-mini`]: !fullscreen,
[`${calendarPrefixCls}-rtl`]: direction === 'rtl',
},
className,
)}
style={style}
>
{headerRender ? (
headerRender({
value: mergedValue,
type: mergedMode,
onChange: onInternalSelect,
onTypeChange: triggerModeChange,
})
) : (
<CalendarHeader
prefixCls={calendarPrefixCls}
value={mergedValue}
prefixCls={prefixCls}
locale={mergedLocale.lang}
generateConfig={generateConfig}
dateRender={dateRender}
monthCellRender={date => monthRender(date, mergedLocale.lang)}
onSelect={onInternalSelect}
mode={panelMode}
picker={panelMode as any}
disabledDate={mergedDisabledDate}
hideHeader
mode={mergedMode}
fullscreen={fullscreen}
locale={mergedLocale.lang}
validRange={validRange}
onChange={onInternalSelect}
onModeChange={triggerModeChange}
/>
</div>
);
}}
)}
<RCPickerPanel
value={mergedValue}
prefixCls={prefixCls}
locale={mergedLocale.lang}
generateConfig={generateConfig}
dateRender={dateRender}
monthCellRender={date => monthRender(date, mergedLocale.lang)}
onSelect={onInternalSelect}
mode={panelMode}
picker={panelMode as any}
disabledDate={mergedDisabledDate}
hideHeader
/>
</div>
)}
</LocaleReceiver>
);
};

View File

@ -13,13 +13,9 @@ const Grid: React.FC<CardGridProps> = ({ prefixCls, className, hoverable = true,
<ConfigConsumer>
{({ getPrefixCls }: ConfigConsumerProps) => {
const prefix = getPrefixCls('card', prefixCls);
const classString = classNames(
`${prefix}-grid`,
className,
{
[`${prefix}-grid-hoverable`]: hoverable,
},
);
const classString = classNames(`${prefix}-grid`, className, {
[`${prefix}-grid-hoverable`]: hoverable,
});
return <div {...props} className={classString} />;
}}

View File

@ -84,7 +84,7 @@
visibility: hidden;
}
}
.slick-slide {
display: none;
float: left;

View File

@ -444,16 +444,17 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
// Fix issue: https://github.com/ant-design/ant-design/issues/26554
const field = names.value === names.label ? keepFilteredValueField : names.value;
return filtered.map((path: CascaderOptionType[]) => {
return {
__IS_FILTERED_OPTION: true,
path,
[field]: path.map((o: CascaderOptionType) => o[names.value]),
[names.label]: render(inputValue, path, prefixCls, names),
disabled: path.some((o: CascaderOptionType) => !!o.disabled),
isEmptyNode: true,
} as CascaderOptionType;
});
return filtered.map(
(path: CascaderOptionType[]) =>
({
__IS_FILTERED_OPTION: true,
path,
[field]: path.map((o: CascaderOptionType) => o[names.value]),
[names.label]: render(inputValue, path, prefixCls, names),
disabled: path.some((o: CascaderOptionType) => !!o.disabled),
isEmptyNode: true,
} as CascaderOptionType),
);
}
return [getEmptyNode(renderEmpty, names, notFoundContent)];
}

View File

@ -64,8 +64,8 @@ const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
}
}, [restProps.value]);
const getOptions = () => {
return options.map(option => {
const getOptions = () =>
options.map(option => {
if (typeof option === 'string') {
return {
label: option,
@ -74,7 +74,6 @@ const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
}
return option;
});
};
const cancelValue = (val: string) => {
setRegisteredValues(prevValues => prevValues.filter(v => v !== val));

View File

@ -36,9 +36,9 @@ const Comment: React.FC<CommentProps> = ({
}) => {
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const renderNested = (prefixCls: string, nestedChildren: any) => {
return <div className={classNames(`${prefixCls}-nested`)}>{nestedChildren}</div>;
};
const renderNested = (prefixCls: string, nestedChildren: any) => (
<div className={classNames(`${prefixCls}-nested`)}>{nestedChildren}</div>
);
const prefixCls = getPrefixCls('comment', customizePrefixCls);

View File

@ -129,9 +129,8 @@ class Page extends React.Component {
);
// ==== Cascader ====
cascaderFilter = (inputValue, path) => {
return path.some(option => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
};
cascaderFilter = (inputValue, path) =>
path.some(option => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
onCascaderChange = value => {
console.log(value);

View File

@ -82,16 +82,17 @@ const ConfigProvider: React.FC<ConfigProviderProps> & {
}
}, [props.direction]);
const getPrefixClsWrapper = (context: ConfigConsumerProps) => {
return (suffixCls: string, customizePrefixCls?: string) => {
const { prefixCls } = props;
const getPrefixClsWrapper = (context: ConfigConsumerProps) => (
suffixCls: string,
customizePrefixCls?: string,
) => {
const { prefixCls } = props;
if (customizePrefixCls) return customizePrefixCls;
if (customizePrefixCls) return customizePrefixCls;
const mergedPrefixCls = prefixCls || context.getPrefixCls('');
const mergedPrefixCls = prefixCls || context.getPrefixCls('');
return suffixCls ? `${mergedPrefixCls}-${suffixCls}` : mergedPrefixCls;
};
return suffixCls ? `${mergedPrefixCls}-${suffixCls}` : mergedPrefixCls;
};
const renderProvider = (context: ConfigConsumerProps, legacyLocale: Locale) => {

View File

@ -24,9 +24,7 @@ const monthFormat = 'YYYY/MM';
const dateFormatList = ['DD/MM/YYYY', 'DD/MM/YY'];
const customFormat = value => {
return `custom format: ${value.format(dateFormat)}`;
};
const customFormat = value => `custom format: ${value.format(dateFormat)}`;
ReactDOM.render(
<Space direction="vertical" size={12}>

View File

@ -16,37 +16,35 @@ Responsive configuration enables perfect presentation on small screen devices.
```jsx
import { Descriptions } from 'antd';
const Demo = () => {
return (
<div>
<Descriptions
title="Responsive Descriptions"
bordered
column={{ xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }}
>
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
<Descriptions.Item label="Discount">$20.00</Descriptions.Item>
<Descriptions.Item label="Official">$60.00</Descriptions.Item>
<Descriptions.Item label="Config Info">
Data disk type: MongoDB
<br />
Database version: 3.4
<br />
Package: dds.mongo.mid
<br />
Storage space: 10 GB
<br />
Replication factor: 3
<br />
Region: East China 1
</Descriptions.Item>
</Descriptions>
</div>
);
};
const Demo = () => (
<div>
<Descriptions
title="Responsive Descriptions"
bordered
column={{ xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }}
>
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
<Descriptions.Item label="Discount">$20.00</Descriptions.Item>
<Descriptions.Item label="Official">$60.00</Descriptions.Item>
<Descriptions.Item label="Config Info">
Data disk type: MongoDB
<br />
Database version: 3.4
<br />
Package: dds.mongo.mid
<br />
Storage space: 10 GB
<br />
Replication factor: 3
<br />
Region: East China 1
</Descriptions.Item>
</Descriptions>
</div>
);
ReactDOM.render(<Demo />, mountNode);
```

View File

@ -5,15 +5,13 @@ import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
const DrawerTest = ({ getContainer }) => {
return (
<div>
<Drawer visible width={400} getContainer={getContainer}>
Here is content of Drawer
</Drawer>
</div>
);
};
const DrawerTest = ({ getContainer }) => (
<div>
<Drawer visible width={400} getContainer={getContainer}>
Here is content of Drawer
</Drawer>
</div>
);
describe('Drawer', () => {
mountTest(Drawer);

View File

@ -69,27 +69,25 @@ export default function ErrorList({
motionAppear
removeOnLeave
>
{({ className: motionClassName }: { className?: string }) => {
return (
<div
className={classNames(
baseClassName,
{
[`${baseClassName}-${innerStatus}`]: innerStatus,
},
motionClassName,
)}
key="help"
>
{memoErrors.map((error, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={index} role="alert">
{error}
</div>
))}
</div>
);
}}
{({ className: motionClassName }: { className?: string }) => (
<div
className={classNames(
baseClassName,
{
[`${baseClassName}-${innerStatus}`]: innerStatus,
},
motionClassName,
)}
key="help"
>
{memoErrors.map((error, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={index} role="alert">
{error}
</div>
))}
</div>
)}
</CSSMotion>
);
}

View File

@ -35,9 +35,7 @@ interface MemoInputProps {
const MemoInput = React.memo(
({ children }: MemoInputProps) => children as JSX.Element,
(prev, next) => {
return prev.value === next.value && prev.update === next.update;
},
(prev, next) => prev.value === next.value && prev.update === next.update,
);
export interface FormItemProps<Values = any>
@ -114,12 +112,13 @@ function FormItem<Values = any>(props: FormItemProps<Values>): React.ReactElemen
const nameRef = useRef<(string | number)[]>([]);
// Should clean up if Field removed
React.useEffect(() => {
return () => {
React.useEffect(
() => () => {
destroyRef.current = true;
updateItemErrors(nameRef.current.join('__SPLIT__'), []);
};
}, []);
},
[],
);
const prefixCls = getPrefixCls('form', customizePrefixCls);

View File

@ -41,19 +41,17 @@ const FormList: React.FC<FormListProps> = ({
return (
<List {...props}>
{(fields, operation, meta) => {
return (
<FormItemPrefixContext.Provider value={{ prefixCls, status: 'error' }}>
{children(
fields.map(field => ({ ...field, fieldKey: field.key })),
operation,
{
errors: meta.errors,
},
)}
</FormItemPrefixContext.Provider>
);
}}
{(fields, operation, meta) => (
<FormItemPrefixContext.Provider value={{ prefixCls, status: 'error' }}>
{children(
fields.map(field => ({ ...field, fieldKey: field.key })),
operation,
{
errors: meta.errors,
},
)}
</FormItemPrefixContext.Provider>
)}
</List>
);
};

View File

@ -779,15 +779,13 @@ describe('Form', () => {
name="light"
_internalItemRender={{
mark: 'pro_table_render',
render: (_, doms) => {
return (
<div id="test">
{doms.input}
{doms.errorList}
{doms.extra}
</div>
);
},
render: (_, doms) => (
<div id="test">
{doms.input}
{doms.errorList}
{doms.extra}
</div>
),
}}
>
<input defaultValue="should warning" />

View File

@ -18,7 +18,7 @@
&&-has-sider {
flex-direction: row;
> .@{layout-prefix-cls},
> .@{layout-prefix-cls}-content {
width: 0; // https://segmentfault.com/a/1190000019498300

View File

@ -101,14 +101,12 @@ function List<T>({
const keys: { [key: string]: string } = {};
const triggerPaginationEvent = (eventName: string) => {
return (page: number, pageSize: number) => {
setPaginationCurrent(page);
setPaginationSize(pageSize);
if (pagination && (pagination as any)[eventName]) {
(pagination as any)[eventName](page, pageSize);
}
};
const triggerPaginationEvent = (eventName: string) => (page: number, pageSize: number) => {
setPaginationCurrent(page);
setPaginationSize(pageSize);
if (pagination && (pagination as any)[eventName]) {
(pagination as any)[eventName](page, pageSize);
}
};
const onPaginationChange = triggerPaginationEvent('onChange');
@ -137,17 +135,13 @@ function List<T>({
return renderItem(item, index);
};
const isSomethingAfterLastItem = () => {
return !!(loadMore || pagination || footer);
};
const isSomethingAfterLastItem = () => !!(loadMore || pagination || footer);
const renderEmptyFunc = (prefixCls: string, renderEmptyHandler: RenderEmptyHandler) => {
return (
<div className={`${prefixCls}-empty-text`}>
{(locale && locale.emptyText) || renderEmptyHandler('List')}
</div>
);
};
const renderEmptyFunc = (prefixCls: string, renderEmptyHandler: RenderEmptyHandler) => (
<div className={`${prefixCls}-empty-text`}>
{(locale && locale.emptyText) || renderEmptyHandler('List')}
</div>
);
const prefixCls = getPrefixCls('list', customizePrefixCls);
let loadingProp = loading;

View File

@ -39,11 +39,7 @@ class App extends React.Component {
<Menu.Item key="app" disabled icon={<AppstoreOutlined />}>
Navigation Two
</Menu.Item>
<SubMenu
key="SubMenu"
icon={<SettingOutlined />}
title="Navigation Three - Submenu"
>
<SubMenu key="SubMenu" icon={<SettingOutlined />} title="Navigation Three - Submenu">
<Menu.ItemGroup title="Item 1">
<Menu.Item key="setting:1">Option 1</Menu.Item>
<Menu.Item key="setting:2">Option 2</Menu.Item>

View File

@ -3,9 +3,7 @@ import message, { getInstance } from '..';
describe('message.config', () => {
// Mock for rc-util raf
window.requestAnimationFrame = callback => {
return window.setTimeout(callback, 16);
};
window.requestAnimationFrame = callback => window.setTimeout(callback, 16);
window.cancelAnimationFrame = id => {
window.clearTimeout(id);
};

View File

@ -248,8 +248,6 @@ export interface MessageApi extends MessageInstance {
}
/** @private test only function. Not work on production */
export const getInstance = () => {
return process.env.NODE_ENV === 'test' ? messageInstance : null;
};
export const getInstance = () => (process.env.NODE_ENV === 'test' ? messageInstance : null);
export default api as MessageApi;

View File

@ -18,9 +18,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
});
// Mock for rc-util raf
window.requestAnimationFrame = callback => {
return window.setTimeout(callback, 16);
};
window.requestAnimationFrame = callback => window.setTimeout(callback, 16);
window.cancelAnimationFrame = id => {
window.clearTimeout(id);
};
@ -145,9 +143,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
it('should emit error when onOk return Promise.reject', async () => {
const error = new Error('something wrong');
open({
onOk: () => {
return Promise.reject(error);
},
onOk: () => Promise.reject(error),
});
$$('.ant-btn-primary')[0].click();

View File

@ -37,19 +37,14 @@ const App = () => {
<Button type="primary" onClick={showModal}>
Open Modal
</Button>
<Modal
title="Basic Modal"
visible={isModalVisible}
onOk={handleOk}
onCancel={handleCancel}
>
<Modal title="Basic Modal" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
</>
);
}
};
ReactDOM.render(<App />, mountNode);
```

View File

@ -22,11 +22,9 @@ const ElementsHolder = React.memo(
const [elements, patchElement] = usePatchElement();
React.useImperativeHandle(
ref,
() => {
return {
patchElement,
};
},
() => ({
patchElement,
}),
[],
);
return <>{elements}</>;
@ -37,8 +35,8 @@ export default function useModal(): [Omit<ModalStaticFunctions, 'warn'>, React.R
const holderRef = React.useRef<ElementsHolderRef>(null as any);
const getConfirmFunc = React.useCallback(
(withFunc: (config: ModalFuncProps) => ModalFuncProps) => {
return function hookConfirm(config: ModalFuncProps) {
(withFunc: (config: ModalFuncProps) => ModalFuncProps) =>
function hookConfirm(config: ModalFuncProps) {
uuid += 1;
const modalRef = React.createRef<HookModalRef>();
@ -69,8 +67,7 @@ export default function useModal(): [Omit<ModalStaticFunctions, 'warn'>, React.R
}
},
};
};
},
},
[],
);

View File

@ -127,9 +127,9 @@ describe('notification', () => {
expect(document.querySelectorAll(`${iconPrefix}-${type}`).length).toBe(1);
};
const promises = ['success', 'info', 'warning', 'error'].map(type => {
return openNotificationWithIcon(type);
});
const promises = ['success', 'info', 'warning', 'error'].map(type =>
openNotificationWithIcon(type),
);
await Promise.all(promises);
});

View File

@ -281,8 +281,7 @@ export interface NotificationApi extends NotificationInstance {
}
/** @private test only function. Not work on production */
export const getInstance = async (cacheKey: string) => {
return process.env.NODE_ENV === 'test' ? notificationInstance[cacheKey] : null;
};
export const getInstance = async (cacheKey: string) =>
process.env.NODE_ENV === 'test' ? notificationInstance[cacheKey] : null;
export default api as NotificationApi;

View File

@ -39,25 +39,23 @@ const menu = (
</Menu>
);
const DropdownMenu = () => {
return (
<Dropdown key="more" overlay={menu}>
<Button
const DropdownMenu = () => (
<Dropdown key="more" overlay={menu}>
<Button
style={{
border: 'none',
padding: 0,
}}
>
<EllipsisOutlined
style={{
border: 'none',
padding: 0,
fontSize: 20,
verticalAlign: 'top',
}}
>
<EllipsisOutlined
style={{
fontSize: 20,
verticalAlign: 'top',
}}
/>
</Button>
</Dropdown>
);
};
/>
</Button>
</Dropdown>
);
const routes = [
{
@ -109,14 +107,12 @@ const content = (
</>
);
const Content = ({ children, extraContent }) => {
return (
<Row>
<div style={{ flex: 1 }}>{children}</div>
<div className="image">{extraContent}</div>
</Row>
);
};
const Content = ({ children, extraContent }) => (
<Row>
<div style={{ flex: 1 }}>{children}</div>
<div className="image">{extraContent}</div>
</Row>
);
ReactDOM.render(
<PageHeader

View File

@ -52,14 +52,12 @@ const extraContent = (
</div>
);
const Content = ({ children, extra }) => {
return (
<div className="content">
<div className="main">{children}</div>
<div className="extra">{extra}</div>
</div>
);
};
const Content = ({ children, extra }) => (
<div className="content">
<div className="main">{children}</div>
<div className="extra">{extra}</div>
</div>
);
ReactDOM.render(
<>

View File

@ -55,9 +55,7 @@ const renderBack = (
);
};
const renderBreadcrumb = (breadcrumb: BreadcrumbProps) => {
return <Breadcrumb {...breadcrumb} />;
};
const renderBreadcrumb = (breadcrumb: BreadcrumbProps) => <Breadcrumb {...breadcrumb} />;
const getBackIcon = (props: PageHeaderProps, direction: DirectionType = 'ltr') => {
if (props.backIcon !== undefined) {
@ -118,9 +116,9 @@ const renderFooter = (prefixCls: string, footer: React.ReactNode) => {
return null;
};
const renderChildren = (prefixCls: string, children: React.ReactNode) => {
return <div className={`${prefixCls}-content`}>{children}</div>;
};
const renderChildren = (prefixCls: string, children: React.ReactNode) => (
<div className={`${prefixCls}-content`}>{children}</div>
);
const PageHeader: React.FC<PageHeaderProps> = props => {
const [compact, updateCompact] = React.useState(false);

View File

@ -12,14 +12,12 @@ const Popover = React.forwardRef<unknown, PopoverProps>(
({ prefixCls: customizePrefixCls, title, content, ...otherProps }, ref) => {
const { getPrefixCls } = React.useContext(ConfigContext);
const getOverlay = (prefixCls: string) => {
return (
<>
{title && <div className={`${prefixCls}-title`}>{getRenderPropValue(title)}</div>}
<div className={`${prefixCls}-inner-content`}>{getRenderPropValue(content)}</div>
</>
);
};
const getOverlay = (prefixCls: string) => (
<>
{title && <div className={`${prefixCls}-title`}>{getRenderPropValue(title)}</div>}
<div className={`${prefixCls}-inner-content`}>{getRenderPropValue(content)}</div>
</>
);
const prefixCls = getPrefixCls('popover', customizePrefixCls);
return (

View File

@ -27,19 +27,9 @@ const customIcons = {
ReactDOM.render(
<>
<Rate
defaultValue={2}
character={({ index }) => {
return index + 1;
}}
/>
<Rate defaultValue={2} character={({ index }) => index + 1} />
<br />
<Rate
defaultValue={3}
character={({ index }) => {
return customIcons[index + 1];
}}
/>
<Rate defaultValue={3} character={({ index }) => customIcons[index + 1]} />
</>,
mountNode,
);

View File

@ -76,9 +76,7 @@ const Slider = React.forwardRef<unknown, SliderSingleProps | SliderRangeProps>(
const [visibles, setVisibles] = React.useState<Visibles>({});
const toggleTooltipVisible = (index: number, visible: boolean) => {
setVisibles((prev: Visibles) => {
return { ...prev, [index]: visible };
});
setVisibles((prev: Visibles) => ({ ...prev, [index]: visible }));
};
const getTooltipPlacement = (tooltipPlacement?: TooltipPlacement, vertical?: boolean) => {

View File

@ -16,16 +16,14 @@ Auto wrap line.
```jsx
import { Space, Button } from 'antd';
const Demo = () => {
return (
<Space size={[8, 16]} wrap>
{new Array(20).fill(null).map((_, index) => (
// eslint-disable-next-line react/no-array-index-key
<Button key={index}>Button</Button>
))}
</Space>
);
};
const Demo = () => (
<Space size={[8, 16]} wrap>
{new Array(20).fill(null).map((_, index) => (
// eslint-disable-next-line react/no-array-index-key
<Button key={index}>Button</Button>
))}
</Space>
);
ReactDOM.render(<Demo />, mountNode);
```

View File

@ -44,9 +44,7 @@ describe('Spin', () => {
});
it('should render 0', () => {
const wrapper = mount(
<Spin>{0}</Spin>,
);
const wrapper = mount(<Spin>{0}</Spin>);
expect(wrapper.find('.ant-spin-container').at(0).text()).toBe('0');
});
});

View File

@ -46,9 +46,7 @@ const Steps: StepsType = props => {
const { xs } = useBreakpoint();
const { getPrefixCls, direction: rtlDirection } = React.useContext(ConfigContext);
const getDirection = React.useCallback(() => {
return xs ? 'vertical' : direction;
}, [xs, direction]);
const getDirection = React.useCallback(() => (xs ? 'vertical' : direction), [xs, direction]);
const prefixCls = getPrefixCls('steps', props.prefixCls);
const iconPrefix = getPrefixCls('', props.iconPrefix);

View File

@ -9,11 +9,13 @@
.ant-motion-collapse-legacy {
overflow: hidden;
&-active {
transition: height @animation-duration-base @ease-in-out, opacity @animation-duration-base @ease-in-out !important;
transition: height @animation-duration-base @ease-in-out,
opacity @animation-duration-base @ease-in-out !important;
}
}
.ant-motion-collapse {
overflow: hidden;
transition: height @animation-duration-base @ease-in-out, opacity @animation-duration-base @ease-in-out !important;
transition: height @animation-duration-base @ease-in-out,
opacity @animation-duration-base @ease-in-out !important;
}

View File

@ -410,11 +410,10 @@ function Table<RecordType extends object = any>(props: TableProps<RecordType>) {
// ============================ Render ============================
const transformColumns = React.useCallback(
(innerColumns: ColumnsType<RecordType>): ColumnsType<RecordType> => {
return transformTitleColumns(
(innerColumns: ColumnsType<RecordType>): ColumnsType<RecordType> =>
transformTitleColumns(
transformSelectionColumns(transformFilterColumns(transformSorterColumns(innerColumns))),
);
},
),
[transformSorterColumns, transformFilterColumns, transformSelectionColumns],
);

View File

@ -855,9 +855,7 @@ describe('Table.filter', () => {
title: 'Name',
dataIndex: 'name',
filters,
onFilter: (value, record) => {
return record.name.indexOf(value) === 0;
},
onFilter: (value, record) => record.name.indexOf(value) === 0,
sorter: (a, b) => a.name.length - b.name.length,
sortDirections: ['descend'],
},
@ -940,25 +938,23 @@ describe('Table.filter', () => {
const filterDropdownMock = jest.fn().mockReturnValue(<span>test</span>);
const filterDropdown = (...args) => filterDropdownMock(...args);
const Test = () => {
return (
<Table
rowKey="name"
columns={[
{
title: 'Name',
dataIndex: 'name',
filterDropdown,
},
]}
dataSource={[
{
name: 'Jack',
},
]}
/>
);
};
const Test = () => (
<Table
rowKey="name"
columns={[
{
title: 'Name',
dataIndex: 'name',
filterDropdown,
},
]}
dataSource={[
{
name: 'Jack',
},
]}
/>
);
mount(<Test />);
expect(filterDropdownMock).toHaveBeenCalledWith(
@ -972,25 +968,23 @@ describe('Table.filter', () => {
const filterDropdownMock = jest.fn().mockReturnValue(<span>test</span>);
const filterDropdown = (...args) => filterDropdownMock(...args);
const Test = () => {
return (
<Table
rowKey="name"
columns={[
{
title: 'Name',
dataIndex: 'name',
filterDropdown,
},
]}
dataSource={[
{
name: 'Jack',
},
]}
/>
);
};
const Test = () => (
<Table
rowKey="name"
columns={[
{
title: 'Name',
dataIndex: 'name',
filterDropdown,
},
]}
dataSource={[
{
name: 'Jack',
},
]}
/>
);
const wrapper = mount(<Test />);

View File

@ -52,13 +52,11 @@ const columns = [
},
];
const getRandomuserParams = params => {
return {
results: params.pagination.pageSize,
page: params.pagination.current,
...params,
};
};
const getRandomuserParams = params => ({
results: params.pagination.pageSize,
page: params.pagination.current,
...params,
});
class App extends React.Component {
state = {

View File

@ -26,51 +26,49 @@ const menu = (
);
function NestedTable() {
const createExpandedRowRender = bordered => {
return () => {
const columns = [
{ title: 'Date', dataIndex: 'date', key: 'date' },
{ title: 'Name', dataIndex: 'name', key: 'name' },
{
title: 'Status',
key: 'state',
render: () => (
<span>
<Badge status="success" />
Finished
</span>
),
},
{ title: 'Upgrade Status', dataIndex: 'upgradeNum', key: 'upgradeNum' },
{
title: 'Action',
dataIndex: 'operation',
key: 'operation',
render: () => (
<Space size="middle">
<a>Pause</a>
<a>Stop</a>
<Dropdown overlay={menu}>
<a>
More <DownOutlined />
</a>
</Dropdown>
</Space>
),
},
];
const createExpandedRowRender = bordered => () => {
const columns = [
{ title: 'Date', dataIndex: 'date', key: 'date' },
{ title: 'Name', dataIndex: 'name', key: 'name' },
{
title: 'Status',
key: 'state',
render: () => (
<span>
<Badge status="success" />
Finished
</span>
),
},
{ title: 'Upgrade Status', dataIndex: 'upgradeNum', key: 'upgradeNum' },
{
title: 'Action',
dataIndex: 'operation',
key: 'operation',
render: () => (
<Space size="middle">
<a>Pause</a>
<a>Stop</a>
<Dropdown overlay={menu}>
<a>
More <DownOutlined />
</a>
</Dropdown>
</Space>
),
},
];
const data = [];
for (let i = 0; i < 3; ++i) {
data.push({
key: i,
date: '2014-12-24 23:12:00',
name: 'This is production name',
upgradeNum: 'Upgraded: 56',
});
}
return <Table columns={columns} dataSource={data} pagination={false} bordered={bordered} />;
};
const data = [];
for (let i = 0; i < 3; ++i) {
data.push({
key: i,
date: '2014-12-24 23:12:00',
name: 'This is production name',
upgradeNum: 'Upgraded: 56',
});
}
return <Table columns={columns} dataSource={data} pagination={false} bordered={bordered} />;
};
const columns = [

View File

@ -151,11 +151,12 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
const onMenuClick = () => {
window.clearTimeout(openRef.current);
};
React.useEffect(() => {
return () => {
React.useEffect(
() => () => {
window.clearTimeout(openRef.current);
};
}, []);
},
[],
);
// ======================= Submit ========================
const internalTriggerFilter = (keys: Key[] | undefined | null) => {

View File

@ -53,13 +53,11 @@ export default function usePagination(
const [innerPagination, setInnerPagination] = useState<{
current?: number;
pageSize?: number;
}>(() => {
return {
current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,
pageSize:
'defaultPageSize' in paginationObj ? paginationObj.defaultPageSize : DEFAULT_PAGE_SIZE,
};
});
}>(() => ({
current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,
pageSize:
'defaultPageSize' in paginationObj ? paginationObj.defaultPageSize : DEFAULT_PAGE_SIZE,
}));
// ============ Basic Pagination Config ============
const mergedPagination = extendsObject<Partial<TablePaginationConfig>>(

View File

@ -150,9 +150,7 @@ export default function useSelection<RecordType>(
}, [flattedData, getRowKey, getCheckboxProps]);
const isCheckboxDisabled: GetCheckDisabled<RecordType> = useCallback(
(r: RecordType) => {
return !!checkboxPropsMap.get(getRowKey(r))?.disabled;
},
(r: RecordType) => !!checkboxPropsMap.get(getRowKey(r))?.disabled,
[checkboxPropsMap, getRowKey],
);
@ -173,9 +171,10 @@ export default function useSelection<RecordType>(
const keys = selectionType === 'radio' ? derivedSelectedKeys.slice(0, 1) : derivedSelectedKeys;
return new Set(keys);
}, [derivedSelectedKeys, selectionType]);
const derivedHalfSelectedKeySet = useMemo(() => {
return selectionType === 'radio' ? new Set() : new Set(derivedHalfSelectedKeys);
}, [derivedHalfSelectedKeys, selectionType]);
const derivedHalfSelectedKeySet = useMemo(
() => (selectionType === 'radio' ? new Set() : new Set(derivedHalfSelectedKeys)),
[derivedHalfSelectedKeys, selectionType],
);
// Save last selected key to enable range selection
const [lastSelectedKey, setLastSelectedKey] = useState<Key | null>(null);

View File

@ -254,9 +254,9 @@ export function getSortData<RecordType>(
const cloneData = data.slice();
const runningSorters = innerSorterStates.filter(({ column: { sorter }, sortOrder }) => {
return getSortFunction(sorter) && sortOrder;
});
const runningSorters = innerSorterStates.filter(
({ column: { sorter }, sortOrder }) => getSortFunction(sorter) && sortOrder,
);
// Skip if no sorter needed
if (!runningSorters.length) {
@ -417,9 +417,7 @@ export default function useFilterSorter<RecordType>({
showSorterTooltip,
);
const getSorters = () => {
return generateSorterInfo(mergedSorterStates);
};
const getSorters = () => generateSorterInfo(mergedSorterStates);
return [transformColumns, mergedSorterStates, columnTitleSorterProps, getSorters];
}

View File

@ -14,9 +14,9 @@ export interface TimePickerLocale {
export interface TimeRangePickerProps extends Omit<RangePickerTimeProps<Moment>, 'picker'> {}
const RangePicker = React.forwardRef<any, TimeRangePickerProps>((props, ref) => {
return <InternalRangePicker {...props} picker="time" mode={undefined} ref={ref} />;
});
const RangePicker = React.forwardRef<any, TimeRangePickerProps>((props, ref) => (
<InternalRangePicker {...props} picker="time" mode={undefined} ref={ref} />
));
export interface TimePickerProps extends Omit<PickerTimeProps<Moment>, 'picker'> {
addon?: () => React.ReactNode;

View File

@ -25,7 +25,7 @@ const TimelineItem: React.FC<TimelineItemProps> = ({
color = 'blue',
dot,
pending = false,
position, /** dead, but do not pass in <li {...omit()} */
position /** dead, but do not pass in <li {...omit()} */,
label,
children,
...restProps

View File

@ -172,9 +172,11 @@ class Transfer<RecordType extends TransferItem = TransferItem> extends React.Com
return transferLocale.titles;
}
getLocale = (transferLocale: TransferLocale, renderEmpty: RenderEmptyHandler) => {
return { ...transferLocale, notFoundContent: renderEmpty('Transfer'), ...this.props.locale };
};
getLocale = (transferLocale: TransferLocale, renderEmpty: RenderEmptyHandler) => ({
...transferLocale,
notFoundContent: renderEmpty('Transfer'),
...this.props.locale,
});
moveTo = (direction: TransferDirection) => {
const { targetKeys = [], dataSource = [], onChange } = this.props;

View File

@ -7,9 +7,7 @@ export type DraggerProps = UploadProps & { height?: number };
const InternalDragger: React.ForwardRefRenderFunction<unknown, DraggerProps> = (
{ style, height, ...restProps },
ref,
) => {
return <Upload ref={ref} {...restProps} type="drag" style={{ ...style, height }} />;
};
) => <Upload ref={ref} {...restProps} type="drag" style={{ ...style, height }} />;
const Dragger = React.forwardRef(InternalDragger) as React.FC<DraggerProps>;

View File

@ -195,47 +195,45 @@ const InternalUploadList: React.ForwardRefRenderFunction<unknown, UploadListProp
return (
<div className={listClassNames}>
<CSSMotionList {...motionConfig} component={false}>
{({ key, file, className: motionClassName, style: motionStyle }) => {
return (
<ListItem
key={key}
locale={locale}
prefixCls={prefixCls}
className={motionClassName}
style={motionStyle}
file={file}
items={items}
progress={progress}
listType={listType}
isImgUrl={isImgUrl}
showPreviewIcon={showPreviewIcon}
showRemoveIcon={showRemoveIcon}
showDownloadIcon={showDownloadIcon}
removeIcon={removeIcon}
downloadIcon={downloadIcon}
iconRender={internalIconRender}
actionIconRender={actionIconRender}
itemRender={itemRender}
onPreview={onInternalPreview}
onDownload={onInternalDownload}
onClose={onInternalClose}
/>
);
}}
{({ key, file, className: motionClassName, style: motionStyle }) => (
<ListItem
key={key}
locale={locale}
prefixCls={prefixCls}
className={motionClassName}
style={motionStyle}
file={file}
items={items}
progress={progress}
listType={listType}
isImgUrl={isImgUrl}
showPreviewIcon={showPreviewIcon}
showRemoveIcon={showRemoveIcon}
showDownloadIcon={showDownloadIcon}
removeIcon={removeIcon}
downloadIcon={downloadIcon}
iconRender={internalIconRender}
actionIconRender={actionIconRender}
itemRender={itemRender}
onPreview={onInternalPreview}
onDownload={onInternalDownload}
onClose={onInternalClose}
/>
)}
</CSSMotionList>
{/* Append action */}
{appendAction && (
<CSSMotion {...motionConfig}>
{({ className: motionClassName, style: motionStyle }) => {
return cloneElement(appendAction, oriProps => ({
{({ className: motionClassName, style: motionStyle }) =>
cloneElement(appendAction, oriProps => ({
className: classNames(oriProps.className, motionClassName),
style: {
...motionStyle,
...oriProps.style,
},
}));
}}
}))
}
</CSSMotion>
)}
</div>

View File

@ -762,9 +762,7 @@ describe('Upload List', () => {
function test(name, renderInstance) {
it(name, async () => {
const mockThumbnail = 'mock-image';
const previewFile = jest.fn(() => {
return Promise.resolve(mockThumbnail);
});
const previewFile = jest.fn(() => Promise.resolve(mockThumbnail));
const file = {
...fileList[0],
originFileObj: renderInstance(),
@ -811,9 +809,7 @@ describe('Upload List', () => {
expect(imgNode.length).toBe(2);
});
it('should render <img /> when custom imageUrl return true', () => {
const isImageUrl = jest.fn(() => {
return true;
});
const isImageUrl = jest.fn(() => true);
const wrapper = mount(
<Upload listType="picture-card" fileList={list} isImageUrl={isImageUrl}>
<button type="button">button</button>
@ -824,9 +820,7 @@ describe('Upload List', () => {
expect(imgNode.length).toBe(3);
});
it('should not render <img /> when custom imageUrl return false', () => {
const isImageUrl = jest.fn(() => {
return false;
});
const isImageUrl = jest.fn(() => false);
const wrapper = mount(
<Upload listType="picture-card" fileList={list} isImageUrl={isImageUrl}>
<button type="button">button</button>

View File

@ -127,16 +127,14 @@ const DragSortingUpload: React.FC = () => {
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
fileList={fileList}
onChange={onChange}
itemRender={(originNode, file, currFileList) => {
return (
<DragableUploadListItem
originNode={originNode}
file={file}
fileList={currFileList}
moveRow={moveRow}
/>
);
}}
itemRender={(originNode, file, currFileList) => (
<DragableUploadListItem
originNode={originNode}
file={file}
fileList={currFileList}
moveRow={moveRow}
/>
)}
>
<Button>
<UploadOutlined /> Click to Upload

View File

@ -40,16 +40,14 @@ class AliyunOSSUpload extends React.Component {
// Mock get OSS api
// https://help.aliyun.com/document_detail/31988.html
mockGetOSSData = () => {
return {
dir: 'user-dir/',
expire: '1577811661',
host: '//www.mocky.io/v2/5cc8019d300000980a055e76',
accessId: 'c2hhb2RhaG9uZw==',
policy: 'eGl4aWhhaGFrdWt1ZGFkYQ==',
signature: 'ZGFob25nc2hhbw==',
};
};
mockGetOSSData = () => ({
dir: 'user-dir/',
expire: '1577811661',
host: '//www.mocky.io/v2/5cc8019d300000980a055e76',
accessId: 'c2hhb2RhaG9uZw==',
policy: 'eGl4aWhhaGFrdWt1ZGFkYQ==',
signature: 'ZGFob25nc2hhbw==',
});
onChange = ({ fileList }) => {
const { onChange } = this.props;

View File

@ -197,7 +197,7 @@
"esbuild-webpack-plugin": "^1.0.0",
"eslint": "^7.9.0",
"eslint-config-airbnb": "^18.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.21.1",
"eslint-plugin-jest": "^24.0.1",

View File

@ -199,9 +199,9 @@ async function printLog() {
console.log('\n');
console.log(chalk.yellow('🇨🇳 Chinese changelog:'));
console.log('\n');
printPR('chinese', chinese => {
return chinese[chinese.length - 1] === '。' || !chinese ? chinese : `${chinese}`;
});
printPR('chinese', chinese =>
chinese[chinese.length - 1] === '。' || !chinese ? chinese : `${chinese}`,
);
console.log('\n-----\n');

View File

@ -19,38 +19,36 @@ interface MoreProps {
loading?: boolean;
}
const MoreCard = ({ title, description, date, img, source, href, icons, loading }: MoreProps) => {
return (
<Col xs={24} sm={6}>
<a
href={href}
target="_blank"
rel="noopener noreferrer"
onClick={() => {
window?.gtag('event', '点击', {
event_category: '首页文章',
event_label: href,
});
}}
const MoreCard = ({ title, description, date, img, source, href, icons, loading }: MoreProps) => (
<Col xs={24} sm={6}>
<a
href={href}
target="_blank"
rel="noopener noreferrer"
onClick={() => {
window?.gtag('event', '点击', {
event_category: '首页文章',
event_label: href,
});
}}
>
<Card
hoverable
cover={loading ? undefined : <img alt={title} src={img} />}
loading={loading}
className="more-card"
>
<Card
hoverable
cover={loading ? undefined : <img alt={title} src={img} />}
loading={loading}
className="more-card"
>
<Card.Meta title={title} description={description} />
<div>
{date}
<span className="more-card-source">
{icons ? <img src={icons[source]} alt={source} /> : null}
</span>
</div>
</Card>
</a>
</Col>
);
};
<Card.Meta title={title} description={description} />
<div>
{date}
<span className="more-card-source">
{icons ? <img src={icons[source]} alt={source} /> : null}
</span>
</div>
</Card>
</a>
</Col>
);
export default function MorePage() {
const { locale } = useIntl();

View File

@ -28,36 +28,34 @@ const RecommendBlock = ({
img,
href,
loading,
}: RecommendBlockProps) => {
return (
<a
className={classNames('recommend-block', {
'recommend-block-main': !!main,
'recommend-block-loading': loading,
})}
href={href}
target="_blank"
rel="noopener noreferrer"
onClick={() => {
window?.gtag('event', '点击', {
event_category: '首页推广',
event_label: href,
});
}}
>
<img src={img} alt={title} />
{popularize && (
<span className="recommend-popularize">
<FormattedMessage id="app.home.popularize" />
</span>
)}
<div className="recommend-content">
<Title level={4}>{title}</Title>
<Paragraph style={{ fontSize: 13 }}>{description}</Paragraph>
</div>
</a>
);
};
}: RecommendBlockProps) => (
<a
className={classNames('recommend-block', {
'recommend-block-main': !!main,
'recommend-block-loading': loading,
})}
href={href}
target="_blank"
rel="noopener noreferrer"
onClick={() => {
window?.gtag('event', '点击', {
event_category: '首页推广',
event_label: href,
});
}}
>
<img src={img} alt={title} />
{popularize && (
<span className="recommend-popularize">
<FormattedMessage id="app.home.popularize" />
</span>
)}
<div className="recommend-content">
<Title level={4}>{title}</Title>
<Paragraph style={{ fontSize: 13 }}>{description}</Paragraph>
</div>
</a>
);
export default function RecommendPage() {
const { locale } = useIntl();

View File

@ -49,18 +49,16 @@ class Category extends React.Component<CategoryProps, CategoryState> {
theme,
intl: { messages },
} = this.props;
const items = icons.map(name => {
return (
<CopyableIcon
key={name}
name={name}
theme={theme}
isNew={newIcons.indexOf(name) >= 0}
justCopied={this.state.justCopied}
onCopied={this.onCopied}
/>
);
});
const items = icons.map(name => (
<CopyableIcon
key={name}
name={name}
theme={theme}
isNew={newIcons.indexOf(name) >= 0}
justCopied={this.state.justCopied}
onCopied={this.onCopied}
/>
));
return (
<div>

View File

@ -95,8 +95,8 @@ class PicSearcher extends Component<PicSearcherProps, PicSearcherState> {
reader.readAsDataURL(file);
};
toImage = (url: any) => {
return new Promise(resolve => {
toImage = (url: any) =>
new Promise(resolve => {
const img = new Image();
img.setAttribute('crossOrigin', 'anonymous');
img.src = url;
@ -104,7 +104,6 @@ class PicSearcher extends Component<PicSearcherProps, PicSearcherState> {
resolve(img);
};
});
};
predict = (imgEl: any) => {
try {

View File

@ -7,17 +7,15 @@ export interface GithubProps {
responsive: null | 'narrow' | 'crowded';
}
export default ({ responsive }: GithubProps) => {
return (
<GitHubButton
id="github-btn"
className={classNames({
'responsive-mode': responsive,
[`responsive-${responsive}`]: responsive,
})}
type="stargazers"
namespace="ant-design"
repo="ant-design"
/>
);
};
export default ({ responsive }: GithubProps) => (
<GitHubButton
id="github-btn"
className={classNames({
'responsive-mode': responsive,
[`responsive-${responsive}`]: responsive,
})}
type="stargazers"
namespace="ant-design"
repo="ant-design"
/>
);

View File

@ -9,15 +9,13 @@ export interface LogoProps {
location: any;
}
const Logo = ({ isZhCN, location }: LogoProps) => {
return (
<h1>
<Link to={utils.getLocalizedPathname('/', isZhCN, location.query)} id="logo">
<img alt="logo" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" />
Ant Design
</Link>
</h1>
);
};
const Logo = ({ isZhCN, location }: LogoProps) => (
<h1>
<Link to={utils.getLocalizedPathname('/', isZhCN, location.query)} id="logo">
<img alt="logo" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" />
Ant Design
</Link>
</h1>
);
export default Logo;

View File

@ -216,6 +216,4 @@ export function getMetaDescription(jml?: any[] | null) {
return paragraph;
}
export const getThemeConfig = () => {
return themeConfig;
};
export const getThemeConfig = () => themeConfig;