Skip to content

Commit

Permalink
chore: eslint add consistent-type-imports (#35419)
Browse files Browse the repository at this point in the history
* chore: eslint add consistent-type-imports

* fix avatar

* Update Item.tsx
  • Loading branch information
hengkx committed May 7, 2022
1 parent 00fb822 commit 1719748
Show file tree
Hide file tree
Showing 400 changed files with 782 additions and 649 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
'@typescript-eslint/no-unused-vars': [2, { args: 'none' }],
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 2,
'@typescript-eslint/consistent-type-imports': 2,
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion components/_util/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import useState from 'rc-util/lib/hooks/useState';
import Button from '../button';
import { LegacyButtonType, ButtonProps, convertLegacyProps } from '../button/button';
import type { LegacyButtonType, ButtonProps } from '../button/button';
import { convertLegacyProps } from '../button/button';

export interface ActionButtonProps {
type?: LegacyButtonType;
Expand Down
3 changes: 2 additions & 1 deletion components/_util/colors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ElementOf, tuple } from './type';
import type { ElementOf } from './type';
import { tuple } from './type';

export const PresetStatusColorTypes = tuple('success', 'processing', 'error', 'default', 'warning');
// eslint-disable-next-line import/prefer-default-export
Expand Down
2 changes: 1 addition & 1 deletion components/_util/getRenderPropValue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import type * as React from 'react';

export type RenderFunction = () => React.ReactNode;

Expand Down
4 changes: 2 additions & 2 deletions components/_util/motion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSSMotionProps, MotionEventHandler, MotionEndEventHandler } from 'rc-motion';
import { MotionEvent } from 'rc-motion/lib/interface';
import type { CSSMotionProps, MotionEventHandler, MotionEndEventHandler } from 'rc-motion';
import type { MotionEvent } from 'rc-motion/lib/interface';
import { tuple } from './type';

// ================== Collapse Motion ==================
Expand Down
2 changes: 1 addition & 1 deletion components/_util/placements.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { placements } from 'rc-tooltip/lib/placements';
import { BuildInPlacements } from 'rc-trigger';
import type { BuildInPlacements } from 'rc-trigger';

const autoAdjustOverflowEnabled = {
adjustX: 1,
Expand Down
2 changes: 1 addition & 1 deletion components/_util/statusUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { ValidateStatus } from '../form/FormItem';
import type { ValidateStatus } from '../form/FormItem';
import { tuple } from './type';

const InputStatuses = tuple('warning', 'error', '');
Expand Down
3 changes: 2 additions & 1 deletion components/_util/wave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from 'react';
import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS';
import { supportRef, composeRef } from 'rc-util/lib/ref';
import raf from './raf';
import { ConfigConsumer, ConfigConsumerProps, CSPConfig, ConfigContext } from '../config-provider';
import type { ConfigConsumerProps, CSPConfig } from '../config-provider';
import { ConfigConsumer, ConfigContext } from '../config-provider';
import { cloneElement } from './reactNode';

let styleForPseudo: HTMLStyleElement | null;
Expand Down
6 changes: 4 additions & 2 deletions components/affix/__tests__/Affix.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import Affix, { AffixProps, AffixState } from '..';
import type { ReactWrapper } from 'enzyme';
import { mount } from 'enzyme';
import type { AffixProps, AffixState } from '..';
import Affix from '..';
import { getObserverEntities } from '../utils';
import Button from '../../button';
import rtlTest from '../../../tests/shared/rtlTest';
Expand Down
3 changes: 2 additions & 1 deletion components/affix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from 'react';
import classNames from 'classnames';
import omit from 'rc-util/lib/omit';
import ResizeObserver from 'rc-resize-observer';
import { ConfigContext, ConfigConsumerProps } from '../config-provider';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigContext } from '../config-provider';
import { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';

import {
Expand Down
3 changes: 2 additions & 1 deletion components/anchor/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import classNames from 'classnames';
import memoizeOne from 'memoize-one';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import Affix from '../affix';
import { ConfigContext, ConfigConsumerProps } from '../config-provider';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigContext } from '../config-provider';
import scrollTo from '../_util/scrollTo';
import getScroll from '../_util/getScroll';
import AnchorContext from './context';
Expand Down
5 changes: 3 additions & 2 deletions components/anchor/AnchorLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import classNames from 'classnames';
import { AntAnchor } from './Anchor';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import type { AntAnchor } from './Anchor';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigConsumer } from '../config-provider';
import AnchorContext from './context';

export interface AnchorLinkProps {
Expand Down
2 changes: 1 addition & 1 deletion components/anchor/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { AntAnchor } from './Anchor';
import type { AntAnchor } from './Anchor';

const AnchorContext = React.createContext<AntAnchor>(null as any);

Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/demo/uncertain-category.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Demonstration of [Lookup Patterns: Uncertain Category](https://ant.design/docs/s
```tsx
import React, { useState } from 'react';
import { Input, AutoComplete } from 'antd';
import { SelectProps } from 'antd/es/select';
import type { SelectProps } from 'antd/es/select';

function getRandomInt(max: number, min: number = 0) {
return Math.floor(Math.random() * (max - min + 1)) + min; // eslint-disable-line no-mixed-operators
Expand Down
8 changes: 5 additions & 3 deletions components/auto-complete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import toArray from 'rc-util/lib/Children/toArray';
import classNames from 'classnames';
import omit from 'rc-util/lib/omit';
import type { BaseSelectRef } from 'rc-select';
import Select, {
import type {
BaseOptionType,
DefaultOptionType,
InternalSelectProps,
RefSelectProps,
} from '../select';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import Select from '../select';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigConsumer } from '../config-provider';
import devWarning from '../_util/devWarning';
import { isValidElement } from '../_util/reactNode';
import { InputStatus } from '../_util/statusUtils';
import type { InputStatus } from '../_util/statusUtils';

const { Option } = Select;

Expand Down
2 changes: 1 addition & 1 deletion components/avatar/SizeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { ScreenSizeMap } from '../_util/responsiveObserve';
import type { ScreenSizeMap } from '../_util/responsiveObserve';

export type AvatarSize = 'large' | 'small' | 'default' | number | ScreenSizeMap;

Expand Down
6 changes: 4 additions & 2 deletions components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import ResizeObserver from 'rc-resize-observer';
import { composeRef } from 'rc-util/lib/ref';
import { ConfigContext } from '../config-provider';
import devWarning from '../_util/devWarning';
import { Breakpoint, responsiveArray } from '../_util/responsiveObserve';
import type { Breakpoint } from '../_util/responsiveObserve';
import { responsiveArray } from '../_util/responsiveObserve';
import useBreakpoint from '../grid/hooks/useBreakpoint';
import SizeContext, { AvatarSize } from './SizeContext';
import type { AvatarSize } from './SizeContext';
import SizeContext from './SizeContext';

export interface AvatarProps {
/** Shape of avatar, options: `circle`, `square` */
Expand Down
3 changes: 2 additions & 1 deletion components/avatar/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { cloneElement } from '../_util/reactNode';
import { ConfigContext } from '../config-provider';
import Avatar from './avatar';
import Popover from '../popover';
import { AvatarSize, SizeContextProvider } from './SizeContext';
import type { AvatarSize } from './SizeContext';
import { SizeContextProvider } from './SizeContext';

export interface GroupProps {
className?: string;
Expand Down
7 changes: 4 additions & 3 deletions components/avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from 'react';
import InternalAvatar, { AvatarProps } from './avatar';
import type { ForwardRefExoticComponent, RefAttributes } from 'react';
import type { AvatarProps } from './avatar';
import InternalAvatar from './avatar';
import Group from './group';

export { AvatarProps } from './avatar';
export { GroupProps } from './group';

interface CompoundedComponent
extends React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLElement>> {
extends ForwardRefExoticComponent<AvatarProps & RefAttributes<HTMLElement>> {
Group: typeof Group;
}

Expand Down
4 changes: 2 additions & 2 deletions components/badge/Ribbon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import classNames from 'classnames';
import { LiteralUnion } from '../_util/type';
import { PresetColorType } from '../_util/colors';
import type { LiteralUnion } from '../_util/type';
import type { PresetColorType } from '../_util/colors';
import { ConfigContext } from '../config-provider';
import { isPresetColor } from './utils';

Expand Down
4 changes: 2 additions & 2 deletions components/badge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import CSSMotion from 'rc-motion';
import classNames from 'classnames';
import ScrollNumber from './ScrollNumber';
import Ribbon from './Ribbon';
import { PresetColorType, PresetStatusColorType } from '../_util/colors';
import type { PresetColorType, PresetStatusColorType } from '../_util/colors';
import { ConfigContext } from '../config-provider';
import { LiteralUnion } from '../_util/type';
import type { LiteralUnion } from '../_util/type';
import { cloneElement } from '../_util/reactNode';
import { isPresetColor } from './utils';

Expand Down
3 changes: 2 additions & 1 deletion components/breadcrumb/BreadcrumbItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import DownOutlined from '@ant-design/icons/DownOutlined';

import Dropdown, { DropdownProps } from '../dropdown/dropdown';
import type { DropdownProps } from '../dropdown/dropdown';
import Dropdown from '../dropdown/dropdown';
import { ConfigContext } from '../config-provider';

export interface BreadcrumbItemProps {
Expand Down
2 changes: 1 addition & 1 deletion components/button/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { sleep, render, fireEvent } from '../../../tests/utils';
import { SizeType } from '../../config-provider/SizeContext';
import type { SizeType } from '../../config-provider/SizeContext';

describe('Button', () => {
mountTest(Button);
Expand Down
2 changes: 1 addition & 1 deletion components/button/button-group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import classNames from 'classnames';
import { SizeType } from '../config-provider/SizeContext';
import type { SizeType } from '../config-provider/SizeContext';
import { ConfigContext } from '../config-provider';
import devWarning from '../_util/devWarning';

Expand Down
3 changes: 2 additions & 1 deletion components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { ConfigContext } from '../config-provider';
import Wave from '../_util/wave';
import { tuple } from '../_util/type';
import devWarning from '../_util/devWarning';
import SizeContext, { SizeType } from '../config-provider/SizeContext';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import LoadingIcon from './LoadingIcon';
import { cloneElement } from '../_util/reactNode';

Expand Down
3 changes: 2 additions & 1 deletion components/button/demo/multiple.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ title:
If you need several buttons, we recommend that you use 1 primary button + n secondary buttons, and if there are more than three operations, you can group some of them into [Dropdown.Button](/components/dropdown/#components-dropdown-demo-dropdown-button).

```tsx
import { Button, Menu, Dropdown, MenuProps } from 'antd';
import type { MenuProps } from 'antd';
import { Button, Menu, Dropdown } from 'antd';

const onMenuClick: MenuProps['onClick'] = e => {
console.log('click', e);
Expand Down
6 changes: 3 additions & 3 deletions components/calendar/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';
import { GenerateConfig } from 'rc-picker/lib/generate';
import { Locale } from 'rc-picker/lib/interface';
import type { GenerateConfig } from 'rc-picker/lib/generate';
import type { Locale } from 'rc-picker/lib/interface';
import { useContext, useMemo } from 'react';
import { FormItemInputContext } from '../form/context';
import Select from '../select';
import { Group, Button } from '../radio';
import { CalendarMode } from './generateCalendar';
import type { CalendarMode } from './generateCalendar';

const YearSelectOffset = 10;
const YearSelectTotal = 20;
Expand Down
6 changes: 3 additions & 3 deletions components/calendar/generateCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import useMergedState from 'rc-util/lib/hooks/useMergedState';
import classNames from 'classnames';
import padStart from 'lodash/padStart';
import { PickerPanel as RCPickerPanel } from 'rc-picker';
import { Locale } from 'rc-picker/lib/interface';
import { GenerateConfig } from 'rc-picker/lib/generate';
import {
import type { Locale } from 'rc-picker/lib/interface';
import type { GenerateConfig } from 'rc-picker/lib/generate';
import type {
PickerPanelBaseProps as RCPickerPanelBaseProps,
PickerPanelDateProps as RCPickerPanelDateProps,
PickerPanelTimeProps as RCPickerPanelTimeProps,
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Moment } from 'moment';
import type { Moment } from 'moment';
import momentGenerateConfig from 'rc-picker/lib/generate/moment';
import generateCalendar, { CalendarProps } from './generateCalendar';

Expand Down
3 changes: 2 additions & 1 deletion components/card/Grid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import classNames from 'classnames';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigConsumer } from '../config-provider';

export interface CardGridProps extends React.HTMLAttributes<HTMLDivElement> {
prefixCls?: string;
Expand Down
3 changes: 2 additions & 1 deletion components/card/Meta.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import classNames from 'classnames';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import type { ConfigConsumerProps } from '../config-provider';
import { ConfigConsumer } from '../config-provider';

export interface CardMetaProps {
prefixCls?: string;
Expand Down
3 changes: 2 additions & 1 deletion components/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import classNames from 'classnames';
import omit from 'rc-util/lib/omit';
import Grid from './Grid';
import Meta from './Meta';
import Tabs, { TabsProps } from '../tabs';
import type { TabsProps } from '../tabs';
import Tabs from '../tabs';
import Row from '../row';
import Col from '../col';
import { ConfigContext } from '../config-provider';
Expand Down
3 changes: 2 additions & 1 deletion components/carousel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import SlickCarousel, { Settings } from '@ant-design/react-slick';
import type { Settings } from '@ant-design/react-slick';
import SlickCarousel from '@ant-design/react-slick';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider';

Expand Down
3 changes: 2 additions & 1 deletion components/cascader/__tests__/type.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mount } from 'enzyme';
import * as React from 'react';
import Cascader, { BaseOptionType } from '..';
import type { BaseOptionType } from '..';
import Cascader from '..';

describe('Cascader.typescript', () => {
it('options value', () => {
Expand Down
6 changes: 4 additions & 2 deletions components/cascader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import { ConfigContext } from '../config-provider';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import getIcons from '../select/utils/iconUtil';
import { getTransitionName, getTransitionDirection, SelectCommonPlacement } from '../_util/motion';
import type { SelectCommonPlacement } from '../_util/motion';
import { getTransitionName, getTransitionDirection } from '../_util/motion';
import { FormItemInputContext } from '../form/context';
import { getMergedStatus, getStatusClassNames, InputStatus } from '../_util/statusUtils';
import type { InputStatus } from '../_util/statusUtils';
import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils';

// Align the design since we use `rc-select` in root. This help:
// - List search content will show all content
Expand Down
3 changes: 2 additions & 1 deletion components/checkbox/Group.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import classNames from 'classnames';
import omit from 'rc-util/lib/omit';
import Checkbox, { CheckboxChangeEvent } from './Checkbox';
import type { CheckboxChangeEvent } from './Checkbox';
import Checkbox from './Checkbox';
import { ConfigContext } from '../config-provider';

export type CheckboxValueType = string | number | boolean;
Expand Down
5 changes: 3 additions & 2 deletions components/checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import InternalCheckbox, { CheckboxProps } from './Checkbox';
import type * as React from 'react';
import type { CheckboxProps } from './Checkbox';
import InternalCheckbox from './Checkbox';
import Group from './Group';

export { CheckboxProps, CheckboxChangeEvent } from './Checkbox';
Expand Down
5 changes: 3 additions & 2 deletions components/collapse/Collapse.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from 'react';
import RcCollapse from 'rc-collapse';
import { CSSMotionProps } from 'rc-motion';
import type { CSSMotionProps } from 'rc-motion';
import classNames from 'classnames';
import RightOutlined from '@ant-design/icons/RightOutlined';

import toArray from 'rc-util/lib/Children/toArray';
import omit from 'rc-util/lib/omit';
import CollapsePanel, { CollapsibleType } from './CollapsePanel';
import type { CollapsibleType } from './CollapsePanel';
import CollapsePanel from './CollapsePanel';
import { ConfigContext } from '../config-provider';
import collapseMotion from '../_util/motion';
import { cloneElement } from '../_util/reactNode';
Expand Down

0 comments on commit 1719748

Please sign in to comment.