Skip to content

Commit

Permalink
build(eslint): 增加 import, exoprt type 规则校验,并修复现存 imoprt 语句 (#526)
Browse files Browse the repository at this point in the history
* temp

* auto fix
  • Loading branch information
1zumii authored Dec 5, 2023
1 parent 70df4c4 commit 745e897
Show file tree
Hide file tree
Showing 133 changed files with 324 additions and 215 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
module.exports = {
extends: ['@webank/eslint-config-ts/vue.js'],

parserOptions: {
// https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
project: './tsconfig.eslint.json',
// https://typescript-eslint.io/linting/troubleshooting/#i-use-a-framework-like-vue-that-requires-custom-file-extensions-and-i-get-errors-like-you-should-add-parseroptionsextrafileextensions-to-your-config
extraFileExtensions: ['.vue'],
},

overrides: [
{
files: [
Expand Down Expand Up @@ -47,5 +55,11 @@ module.exports = {
// 保留现状,允许 vue 文件中 :a="{ b: { c: 500 } }" 的写法
'vue/object-curly-spacing': 'off',
'no-unused-expressions': 'off',
// import, export type
'@typescript-eslint/consistent-type-exports': 'warn',
'@typescript-eslint/consistent-type-imports': [
'warn',
{ fixStyle: 'inline-type-imports' },
],
},
};
2 changes: 1 addition & 1 deletion components/_theme/useTheme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ref, ref, watch } from 'vue';
import { type Ref, ref, watch } from 'vue';
import { createSharedComposable } from '@vueuse/core';

import { useConfig } from '../config-provider';
Expand Down
8 changes: 7 additions & 1 deletion components/_util/components/fadeInExpandTransition.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { h, Transition, TransitionGroup, defineComponent, PropType } from 'vue';
import {
h,
Transition,
TransitionGroup,
defineComponent,
type PropType,
} from 'vue';

export default defineComponent({
name: 'FadeInExpandTransition',
Expand Down
6 changes: 3 additions & 3 deletions components/_util/noticeManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
onMounted,
ref,
TransitionGroup,
CSSProperties,
VNodeChild,
VNode,
type CSSProperties,
type VNodeChild,
type VNode,
cloneVNode,
} from 'vue';
import {
Expand Down
2 changes: 1 addition & 1 deletion components/_util/use/useClickOutSide.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { unref, watch, onBeforeUnmount, ref, Ref } from 'vue';
import { unref, watch, onBeforeUnmount, ref, type Ref } from 'vue';
import getElementFromVueInstance from '../getElementFromVueInstance';

export default function useClickOutSide(
Expand Down
2 changes: 1 addition & 1 deletion components/_util/use/useEsc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isRef, onBeforeUnmount, onMounted, watch, Ref } from 'vue';
import { isRef, onBeforeUnmount, onMounted, watch, type Ref } from 'vue';

export default function useEsc(
action: (event: KeyboardEvent) => void,
Expand Down
2 changes: 1 addition & 1 deletion components/_util/use/useFormAdaptor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inject, isRef, watch, ref, Ref, provide } from 'vue';
import { inject, isRef, watch, ref, type Ref, provide } from 'vue';
import { isString, isFunction } from 'lodash-es';
import { noop } from '../utils';
import { FORM_ITEM_INJECTION_KEY } from '../constants';
Expand Down
2 changes: 1 addition & 1 deletion components/_util/use/useLockScreen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { watch, onUnmounted, Ref } from 'vue';
import { watch, onUnmounted, type Ref } from 'vue';
import {
addClass,
getScrollBarWidth,
Expand Down
2 changes: 1 addition & 1 deletion components/_util/use/useModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, watch, computed, WritableComputedRef } from 'vue';
import { ref, watch, computed, type WritableComputedRef } from 'vue';
import { isEqual as isEqualFunc, isArray, isUndefined } from 'lodash-es';

type UseNormalModelOptions = {
Expand Down
2 changes: 1 addition & 1 deletion components/_util/use/useResize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
watch,
computed,
unref,
Ref,
type Ref,
onMounted,
nextTick,
} from 'vue';
Expand Down
2 changes: 1 addition & 1 deletion components/_util/use/useScrollX.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { onBeforeUnmount, onMounted, Ref } from 'vue';
import { onBeforeUnmount, onMounted, type Ref } from 'vue';

export default function useScrollX(targetRef: Ref<HTMLElement>) {
function handleWheelEvent(event: WheelEvent) {
Expand Down
6 changes: 3 additions & 3 deletions components/_util/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {
Text,
Comment,
createTextVNode,
VNode,
VNodeChild,
type VNode,
type VNodeChild,
isVNode,
Slots,
type Slots,
} from 'vue';

const TEMPLATE = 'template';
Expand Down
2 changes: 1 addition & 1 deletion components/_util/withInstall.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, App, Plugin } from 'vue';
import { type Component, type App, type Plugin } from 'vue';
import { noop } from './utils';
import type { FObjectDirective } from './interface';

Expand Down
2 changes: 1 addition & 1 deletion components/alert/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, Transition, computed, defineComponent, PropType } from 'vue';
import { ref, Transition, computed, defineComponent, type PropType } from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import CloseCircleOutlined from '../icon/CloseCircleOutlined';
import { CLOSE_EVENT } from '../_util/constants';
Expand Down
2 changes: 1 addition & 1 deletion components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, computed, ref, PropType } from 'vue';
import { defineComponent, computed, ref, type PropType } from 'vue';
import LoadingOutlined from '../icon/LoadingOutlined';
import getPrefixCls from '../_util/getPrefixCls';
import { useAnimate } from '../_util/use/useAnimate';
Expand Down
8 changes: 4 additions & 4 deletions components/calendar/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
CSSProperties,
SlotsType,
VNode,
VNodeChild,
type CSSProperties,
type SlotsType,
type VNode,
type VNodeChild,
computed,
defineComponent,
} from 'vue';
Expand Down
4 changes: 2 additions & 2 deletions components/calendar/calendarNavigator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ComponentObjectPropsOptions,
PropType,
type ComponentObjectPropsOptions,
type PropType,
computed,
defineComponent,
} from 'vue';
Expand Down
10 changes: 5 additions & 5 deletions components/calendar/props.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
ComponentObjectPropsOptions,
DefineComponent,
PropType,
SetupContext,
SlotsType,
type ComponentObjectPropsOptions,
type DefineComponent,
type PropType,
type SetupContext,
type SlotsType,
} from 'vue';
import { UPDATE_MODEL_EVENT } from '../_util/constants';
import { type UnixTime } from './types';
Expand Down
2 changes: 1 addition & 1 deletion components/calendar/useWeekNames.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ref, computed } from 'vue';
import { type Ref, computed } from 'vue';
import { type Day } from 'date-fns';
import { useLocale } from '../config-provider/useLocale';
import { type CalendarMode } from './props';
Expand Down
2 changes: 1 addition & 1 deletion components/card/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withInstall } from '../_util/withInstall';
import Card from './card.vue';

import { cardProps } from './props';
import { type cardProps } from './props';
import type {
SFCWithInstall,
ExtractPublicPropTypes,
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/carousel-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
onUnmounted,
inject,
getCurrentInstance,
ComputedRef,
type ComputedRef,
} from 'vue';
import { useTheme } from '../_theme/useTheme';
import {
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, watch, ref, PropType } from 'vue';
import { defineComponent, watch, ref, type PropType } from 'vue';
import { useTheme } from '../_theme/useTheme';
import useResize from '../_util/use/useResize';
import { CAROUSEL_NAME, CHANGE_EVENT } from './const';
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import useCarousel from './useCarousel';
import type useCarousel from './useCarousel';
import type { ExtractPublicPropTypes } from '../_util/interface';

export type Placement = 'top' | 'bottom' | 'left' | 'right';
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/useCarouselItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, Ref } from 'vue';
import { ref, type Ref } from 'vue';
import { CAROUSEL_NAME } from './const';
import type { CarouselItemData } from './interface';

Expand Down
2 changes: 1 addition & 1 deletion components/carousel/useCarouselPlay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { watch, onMounted, onBeforeUnmount, nextTick, Ref } from 'vue';
import { watch, onMounted, onBeforeUnmount, nextTick, type Ref } from 'vue';

interface UseCarouselPlayType {
loop: boolean;
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/useCarouselStyle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, ComputedRef } from 'vue';
import { computed, type ComputedRef } from 'vue';
import type { Direction } from './interface';

interface UseCarouselStyleType {
Expand Down
6 changes: 3 additions & 3 deletions components/cascader/cascaderMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
defineComponent,
ExtractPropTypes,
type ExtractPropTypes,
nextTick,
onMounted,
PropType,
type PropType,
ref,
VNodeChild,
type VNodeChild,
watch,
} from 'vue';
import { isFunction, isString } from 'lodash-es';
Expand Down
4 changes: 2 additions & 2 deletions components/cascader/cascaderNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
defineComponent,
computed,
ref,
ExtractPropTypes,
PropType,
type ExtractPropTypes,
type PropType,
nextTick,
} from 'vue';
import { isArray, isUndefined } from 'lodash-es';
Expand Down
2 changes: 1 addition & 1 deletion components/cascader/useData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, reactive, watch, computed, Ref, nextTick } from 'vue';
import { ref, reactive, watch, computed, type Ref, nextTick } from 'vue';
import { isArray, isEmpty, isNil } from 'lodash-es';
import { ROOT_MENU_KEY } from './const';
import type {
Expand Down
2 changes: 1 addition & 1 deletion components/checkbox/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</template>

<script lang="ts">
import { PropType, computed, defineComponent } from 'vue';
import { type PropType, computed, defineComponent } from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import useSelect from '../_util/use/useSelect';
import { name, checkboxGroupKey } from '../checkbox-group/const';
Expand Down
2 changes: 1 addition & 1 deletion components/collapse/useCollapseItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ref, computed, inject, ref, unref } from 'vue';
import { type Ref, computed, inject, ref, unref } from 'vue';
import { collapseContextKey, generateId } from './common';
import { useNamespace } from './useNamespace';
import type { CollapseItemProps } from './collapseItemExpose';
Expand Down
8 changes: 4 additions & 4 deletions components/date-picker/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ import {
watch,
computed,
defineComponent,
PropType,
ExtractPropTypes,
Ref,
type PropType,
type ExtractPropTypes,
type Ref,
} from 'vue';
import { isValid, format } from 'date-fns';
import {
Expand All @@ -141,7 +141,7 @@ import {
RANGE_POSITION,
COMMON_PROPS,
YEAR_COUNT,
SELECTED_STATUS,
type SELECTED_STATUS,
} from './const';
import {
Expand Down
4 changes: 2 additions & 2 deletions components/date-picker/calendars.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ import {
computed,
watch,
defineComponent,
PropType,
ExtractPropTypes,
type PropType,
type ExtractPropTypes,
} from 'vue';
import { isFunction, isArray, isNumber } from 'lodash-es';
import getPrefixCls from '../_util/getPrefixCls';
Expand Down
8 changes: 4 additions & 4 deletions components/date-picker/datePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ import {
computed,
ref,
watch,
Ref,
type Ref,
defineComponent,
PropType,
ComputedRef,
ComponentPublicInstance,
type PropType,
type ComputedRef,
type ComponentPublicInstance,
} from 'vue';
import { format, isValid } from 'date-fns';
import { isEqual, isNil, isArray } from 'lodash-es';
Expand Down
4 changes: 2 additions & 2 deletions components/date-picker/rangeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import {
watch,
ref,
defineComponent,
PropType,
ExtractPropTypes,
type PropType,
type ExtractPropTypes,
nextTick,
} from 'vue';
import { isArray } from 'lodash-es';
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/useCalendar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { watch, watchEffect, ref, reactive, computed, Ref } from 'vue';
import { watch, watchEffect, ref, reactive, computed, type Ref } from 'vue';
import { isNil } from 'lodash-es';
import { endOfMonth } from 'date-fns';
import getPrefixCls from '../_util/getPrefixCls';
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/useRange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { watch, ref, Ref } from 'vue';
import { watch, ref, type Ref } from 'vue';

import { getTimestampFromFormat, isBeyondRangeTime } from './helper';
import { SELECTED_STATUS, RANGE_POSITION } from './const';
Expand Down
4 changes: 2 additions & 2 deletions components/descriptions/descriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
defineComponent,
provide,
computed,
PropType,
CSSProperties,
type PropType,
type CSSProperties,
} from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import { DESCRIPTIONS_PROVIDE_KEY } from './constants';
Expand Down
4 changes: 2 additions & 2 deletions components/descriptions/descriptionsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
defineComponent,
inject,
computed,
PropType,
CSSProperties,
type PropType,
type CSSProperties,
} from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import { DESCRIPTIONS_PROVIDE_KEY } from './constants';
Expand Down
2 changes: 1 addition & 1 deletion components/divider/divider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, computed, PropType } from 'vue';
import { defineComponent, computed, type PropType } from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import { useTheme } from '../_theme/useTheme';
import type { ExtractPublicPropTypes } from '../_util/interface';
Expand Down
6 changes: 3 additions & 3 deletions components/draggable/directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {
computed,
reactive,
ref,
SetupContext,
type SetupContext,
watch,
DirectiveBinding,
type DirectiveBinding,
} from 'vue';
import {
DraggableItem,
type DraggableItem,
DRAG_END_EVENT,
DRAG_START_EVENT,
UPDATE_MODEL_EVENT,
Expand Down
4 changes: 2 additions & 2 deletions components/draggable/draggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
computed,
defineComponent,
ref,
SetupContext,
PropType,
type SetupContext,
type PropType,
cloneVNode,
} from 'vue';
import { mergeWith } from 'lodash-es';
Expand Down
Loading

0 comments on commit 745e897

Please sign in to comment.