From c4ea14358e14aa59d95c50895c0f7990bc55c001 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 1 Sep 2021 21:21:20 +0800 Subject: [PATCH] style: format ts type --- .eslintrc.js | 5 ++--- components/anchor/index.tsx | 9 ++++++--- components/avatar/index.ts | 6 +++--- components/calendar/date-fns.tsx | 2 +- components/calendar/dayjs.tsx | 2 +- components/calendar/moment.tsx | 2 +- components/dropdown/dropdown-button.tsx | 2 +- components/grid/index.ts | 4 ++-- components/layout/index.ts | 4 ++-- components/list/index.tsx | 2 +- components/menu/index.tsx | 9 ++------- components/modal/index.tsx | 4 ++-- components/pagination/index.ts | 3 ++- components/radio/index.ts | 2 +- components/skeleton/index.tsx | 3 ++- components/spin/Spin.tsx | 6 +++--- components/spin/index.ts | 3 ++- components/table/interface.ts | 4 ++-- components/tooltip/Tooltip.tsx | 5 ++--- components/vc-overflow/index.ts | 5 +++-- components/vc-picker/index.tsx | 9 ++++++--- components/vc-tree-select/index.tsx | 3 ++- package.json | 2 +- tsconfig.json | 3 ++- 24 files changed, 52 insertions(+), 47 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3c7e1c9d8..45170813b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,7 +12,7 @@ module.exports = { parser: 'babel-eslint', }, extends: ['plugin:vue/vue3-recommended', 'prettier'], - plugins: ['markdown', 'jest', '@typescript-eslint', 'eslint-plugin-no-explicit-type-exports'], + plugins: ['markdown', 'jest', '@typescript-eslint'], overrides: [ { files: ['**/demo/*.md'], @@ -28,10 +28,9 @@ module.exports = { project: './tsconfig.json', }, rules: { - 'no-explicit-type-exports/no-explicit-type-exports': 2, '@typescript-eslint/no-explicit-any': 0, '@typescript-eslint/ban-types': 0, - '@typescript-eslint/consistent-type-imports': 1, + '@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/explicit-module-boundary-types': 0, '@typescript-eslint/no-empty-function': 0, '@typescript-eslint/no-non-null-assertion': 0, diff --git a/components/anchor/index.tsx b/components/anchor/index.tsx index 2cb681347..c4d6e7fdf 100644 --- a/components/anchor/index.tsx +++ b/components/anchor/index.tsx @@ -1,6 +1,8 @@ import type { App, Plugin } from 'vue'; -import Anchor, { AnchorProps } from './Anchor'; -import AnchorLink, { AnchorLinkProps } from './AnchorLink'; +import type { AnchorProps } from './Anchor'; +import type { AnchorLinkProps } from './AnchorLink'; +import Anchor from './Anchor'; +import AnchorLink from './AnchorLink'; Anchor.Link = AnchorLink; @@ -11,7 +13,8 @@ Anchor.install = function (app: App) { return app; }; -export { AnchorLinkProps, AnchorProps, AnchorLink, AnchorLink as Link }; +export type { AnchorLinkProps, AnchorProps }; +export { AnchorLink, AnchorLink as Link }; export default Anchor as typeof Anchor & Plugin & { diff --git a/components/avatar/index.ts b/components/avatar/index.ts index 3fceeaf26..802b0237e 100644 --- a/components/avatar/index.ts +++ b/components/avatar/index.ts @@ -1,9 +1,9 @@ import type { App, Plugin } from 'vue'; import Avatar from './Avatar'; import Group from './Group'; - -export { AvatarProps, AvatarSize, avatarProps } from './Avatar'; -export { AvatarGroupProps } from './Group'; +export { avatarProps } from './Avatar'; +export type { AvatarProps, AvatarSize } from './Avatar'; +export type { AvatarGroupProps } from './Group'; Avatar.Group = Group; diff --git a/components/calendar/date-fns.tsx b/components/calendar/date-fns.tsx index d5496d151..8e5a182a9 100644 --- a/components/calendar/date-fns.tsx +++ b/components/calendar/date-fns.tsx @@ -4,5 +4,5 @@ import generateCalendar, { CalendarProps } from './generateCalendar'; const Calendar = generateCalendar(generateConfig); -export { CalendarProps }; +export type { CalendarProps }; export default withInstall(Calendar); diff --git a/components/calendar/dayjs.tsx b/components/calendar/dayjs.tsx index fc3222303..14e4a5954 100644 --- a/components/calendar/dayjs.tsx +++ b/components/calendar/dayjs.tsx @@ -5,5 +5,5 @@ import generateCalendar, { CalendarProps } from './generateCalendar'; const Calendar = generateCalendar(generateConfig); -export { CalendarProps }; +export type { CalendarProps }; export default withInstall(Calendar); diff --git a/components/calendar/moment.tsx b/components/calendar/moment.tsx index 4acc05a03..31ea43ff0 100644 --- a/components/calendar/moment.tsx +++ b/components/calendar/moment.tsx @@ -5,5 +5,5 @@ import generateCalendar, { CalendarProps } from './generateCalendar'; const Calendar = generateCalendar(generateConfig); -export { CalendarProps }; +export type { CalendarProps }; export default withInstall(Calendar); diff --git a/components/dropdown/dropdown-button.tsx b/components/dropdown/dropdown-button.tsx index c839e26c2..a7b8e870d 100644 --- a/components/dropdown/dropdown-button.tsx +++ b/components/dropdown/dropdown-button.tsx @@ -82,7 +82,7 @@ export default defineComponent({ return ( {slots.leftButton ? slots.leftButton({ button: leftButton }) : leftButton} - + overlay }}> {slots.rightButton ? slots.rightButton({ button: rightButton }) : rightButton} diff --git a/components/grid/index.ts b/components/grid/index.ts index d8eddbf16..e031fec67 100644 --- a/components/grid/index.ts +++ b/components/grid/index.ts @@ -2,9 +2,9 @@ import Row from './Row'; import Col from './Col'; import useBreakpoint from '../_util/hooks/useBreakpoint'; -export { RowProps } from './Row'; +export type { RowProps } from './Row'; -export { ColProps, ColSize } from './Col'; +export type { ColProps, ColSize } from './Col'; export { Row, Col }; diff --git a/components/layout/index.ts b/components/layout/index.ts index 0beaa33bc..e9552c736 100644 --- a/components/layout/index.ts +++ b/components/layout/index.ts @@ -2,8 +2,8 @@ import type { App, Plugin } from 'vue'; import Layout from './layout'; import Sider from './Sider'; -export { BasicProps as LayoutProps } from './layout'; -export { SiderProps } from './Sider'; +export type { BasicProps as LayoutProps } from './layout'; +export type { SiderProps } from './Sider'; Layout.Sider = Sider; diff --git a/components/list/index.tsx b/components/list/index.tsx index d5bf8a26e..5f8c9f66c 100644 --- a/components/list/index.tsx +++ b/components/list/index.tsx @@ -19,7 +19,7 @@ import type { Breakpoint } from '../_util/responsiveObserve'; import { responsiveArray } from '../_util/responsiveObserve'; export { ListItemProps } from './Item'; -export { ListItemMetaProps } from './ItemMeta'; +export type { ListItemMetaProps } from './ItemMeta'; export type ColumnType = 'gutter' | 'column' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; diff --git a/components/menu/index.tsx b/components/menu/index.tsx index e000c414a..7cfde6365 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -4,7 +4,7 @@ import SubMenu, { SubMenuProps } from './src/SubMenu'; import ItemGroup, { MenuItemGroupProps } from './src/ItemGroup'; import Divider from './src/Divider'; import type { App, Plugin } from 'vue'; -import { MenuTheme } from './src/interface'; +import type { MenuTheme } from './src/interface'; /* istanbul ignore next */ Menu.install = function (app: App) { app.component(Menu.name, Menu); @@ -19,7 +19,7 @@ Menu.Item = MenuItem; Menu.Divider = Divider; Menu.SubMenu = SubMenu; Menu.ItemGroup = ItemGroup; - +export type { MenuProps, SubMenuProps, MenuItemProps, MenuItemGroupProps, MenuTheme }; export { SubMenu, MenuItem as Item, @@ -28,11 +28,6 @@ export { ItemGroup as MenuItemGroup, Divider, Divider as MenuDivider, - MenuProps, - SubMenuProps, - MenuItemProps, - MenuItemGroupProps, - MenuTheme, }; export default Menu as typeof Menu & diff --git a/components/modal/index.tsx b/components/modal/index.tsx index f2533f17c..d3c1024a6 100644 --- a/components/modal/index.tsx +++ b/components/modal/index.tsx @@ -7,8 +7,8 @@ import CheckCircleOutlined from '@ant-design/icons-vue/CheckCircleOutlined'; import CloseCircleOutlined from '@ant-design/icons-vue/CloseCircleOutlined'; import ExclamationCircleOutlined from '@ant-design/icons-vue/ExclamationCircleOutlined'; -export { IActionButtonProps as ActionButtonProps } from './ActionButton'; -export { ModalProps, ModalFuncProps } from './Modal'; +export type { IActionButtonProps as ActionButtonProps } from './ActionButton'; +export type { ModalProps, ModalFuncProps } from './Modal'; const info = function (props: ModalFuncProps) { const config = { diff --git a/components/pagination/index.ts b/components/pagination/index.ts index 86626c0c7..f045a8443 100644 --- a/components/pagination/index.ts +++ b/components/pagination/index.ts @@ -1,6 +1,7 @@ import Pagination from './Pagination'; import { withInstall } from '../_util/type'; -export { paginationProps, PaginationProps, PaginationConfig, paginationConfig } from './Pagination'; +export { paginationProps, paginationConfig } from './Pagination'; +export type { PaginationProps, PaginationConfig } from './Pagination'; export default withInstall(Pagination); diff --git a/components/radio/index.ts b/components/radio/index.ts index d833116c5..a12b45c6e 100644 --- a/components/radio/index.ts +++ b/components/radio/index.ts @@ -3,7 +3,7 @@ import Radio from './Radio'; import Group from './Group'; import Button from './RadioButton'; -export { RadioChangeEventTarget, RadioChangeEvent } from './interface'; +export type { RadioChangeEventTarget, RadioChangeEvent } from './interface'; Radio.Group = Group; Radio.Button = Button; diff --git a/components/skeleton/index.tsx b/components/skeleton/index.tsx index c83f0c718..9dd5cbc5e 100644 --- a/components/skeleton/index.tsx +++ b/components/skeleton/index.tsx @@ -5,7 +5,8 @@ import SkeletonInput from './Input'; import SkeletonImage from './Image'; import SkeletonAvatar from './Avatar'; -export { SkeletonProps, skeletonProps } from './Skeleton'; +export type { SkeletonProps } from './Skeleton'; +export { skeletonProps } from './Skeleton'; Skeleton.Button = SkeletonButton; Skeleton.Avatar = SkeletonAvatar; diff --git a/components/spin/Spin.tsx b/components/spin/Spin.tsx index 44d22ffca..ca81d9d80 100644 --- a/components/spin/Spin.tsx +++ b/components/spin/Spin.tsx @@ -10,7 +10,7 @@ import { defaultConfigProvider } from '../config-provider'; export const SpinSize = PropTypes.oneOf(tuple('small', 'default', 'large')); -export const getSpinProps = () => ({ +export const spinProps = () => ({ prefixCls: PropTypes.string, spinning: PropTypes.looseBool, size: SpinSize, @@ -20,7 +20,7 @@ export const getSpinProps = () => ({ indicator: PropTypes.any, }); -export type SpinProps = Partial>>; +export type SpinProps = Partial>>; // Render indicator let defaultIndicator: () => VNode = null; @@ -38,7 +38,7 @@ export default defineComponent({ name: 'ASpin', mixins: [BaseMixin], inheritAttrs: false, - props: initDefaultProps(getSpinProps(), { + props: initDefaultProps(spinProps(), { size: 'default', spinning: true, wrapperClassName: '', diff --git a/components/spin/index.ts b/components/spin/index.ts index 44651afdf..93dd801b7 100644 --- a/components/spin/index.ts +++ b/components/spin/index.ts @@ -1,7 +1,8 @@ import type { App, Plugin } from 'vue'; import Spin, { setDefaultIndicator } from './Spin'; -export { SpinProps, getSpinProps } from './Spin'; +export type { SpinProps } from './Spin'; +export { spinProps } from './Spin'; Spin.setDefaultIndicator = setDefaultIndicator; diff --git a/components/table/interface.ts b/components/table/interface.ts index fe56d5133..7f8a2ac77 100644 --- a/components/table/interface.ts +++ b/components/table/interface.ts @@ -1,7 +1,7 @@ import type { ExtractPropTypes, PropType, UnwrapRef } from 'vue'; import PropTypes, { withUndefined } from '../_util/vue-types'; import { paginationProps as getPaginationProps, paginationConfig } from '../pagination'; -import { getSpinProps } from '../spin'; +import { spinProps } from '../spin'; import { tuple } from '../_util/type'; const PaginationProps = getPaginationProps(); @@ -140,7 +140,7 @@ export const tableProps = { expandIconAsCell: PropTypes.looseBool, expandIconColumnIndex: PropTypes.number, expandRowByClick: PropTypes.looseBool, - loading: PropTypes.oneOfType([PropTypes.shape(getSpinProps()).loose, PropTypes.looseBool]), + loading: PropTypes.oneOfType([PropTypes.shape(spinProps()).loose, PropTypes.looseBool]), locale: TableLocale, indentSize: PropTypes.number, customRow: PropTypes.func, diff --git a/components/tooltip/Tooltip.tsx b/components/tooltip/Tooltip.tsx index c03796a09..f1ab5d1ea 100644 --- a/components/tooltip/Tooltip.tsx +++ b/components/tooltip/Tooltip.tsx @@ -11,10 +11,9 @@ import { cloneElement } from '../_util/vnode'; import type { triggerTypes, placementTypes } from './abstractTooltipProps'; import abstractTooltipProps from './abstractTooltipProps'; import useConfigInject from '../_util/hooks/useConfigInject'; -import getPlacements, { AdjustOverflow, PlacementsConfig } from './placements'; +import getPlacements from './placements'; import firstNotUndefined from '../_util/firstNotUndefined'; - -export { AdjustOverflow, PlacementsConfig }; +export type { AdjustOverflow, PlacementsConfig } from './placements'; export type TooltipPlacement = typeof placementTypes[number]; diff --git a/components/vc-overflow/index.ts b/components/vc-overflow/index.ts index dbd789dc0..91e839ddb 100644 --- a/components/vc-overflow/index.ts +++ b/components/vc-overflow/index.ts @@ -1,5 +1,6 @@ -import Overflow, { OverflowProps } from './Overflow'; +import type { OverflowProps } from './Overflow'; +import Overflow from './Overflow'; -export { OverflowProps }; +export type { OverflowProps }; export default Overflow; diff --git a/components/vc-picker/index.tsx b/components/vc-picker/index.tsx index 10a59da73..296fb4145 100644 --- a/components/vc-picker/index.tsx +++ b/components/vc-picker/index.tsx @@ -1,7 +1,10 @@ import Picker, { PickerProps } from './Picker'; -import PickerPanel, { PickerPanelProps } from './PickerPanel'; -import RangePicker, { RangePickerProps } from './RangePicker'; +import PickerPanel from './PickerPanel'; +import RangePicker from './RangePicker'; +import type { PickerPanelProps } from './PickerPanel'; +import type { RangePickerProps } from './RangePicker'; -export { PickerPanel, RangePicker, PickerProps, PickerPanelProps, RangePickerProps }; +export { PickerPanel, RangePicker }; +export type { PickerProps, PickerPanelProps, RangePickerProps }; export default Picker; diff --git a/components/vc-tree-select/index.tsx b/components/vc-tree-select/index.tsx index 59b815d7c..83330e95c 100644 --- a/components/vc-tree-select/index.tsx +++ b/components/vc-tree-select/index.tsx @@ -3,6 +3,7 @@ import TreeNode from './TreeNode'; import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from './utils/strategyUtil'; import { TreeSelectProps, treeSelectProps } from './props'; -export { TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeSelectProps, treeSelectProps }; +export { TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT, treeSelectProps }; +export type { TreeSelectProps }; export default TreeSelect; diff --git a/package.json b/package.json index d45bc4897..2d9772936 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "prettier": "prettier -c --write '**/*'", "pretty-quick": "pretty-quick", "dist": "node --max_old_space_size=8192 antd-tools/cli/run.js dist", - "lint": "eslint -c ./.eslintrc.js --fix --ext .jsx,.js,.vue,.ts,.tsx ./components", + "lint": "eslint -c ./.eslintrc.js --fix --ext .jsx,.js,.ts,.tsx ./components", "lint:style": "stylelint \"{site,components}/**/*.less\" --syntax less", "codecov": "codecov" }, diff --git a/tsconfig.json b/tsconfig.json index 836611422..91c26f392 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,8 @@ "target": "es6", "lib": ["dom", "es2017"], "skipLibCheck": true, - "allowJs": true + "allowJs": true, + "importsNotUsedAsValues": "error" }, "exclude": [ "node_modules",