diff --git a/.eslintrc b/.eslintrc index f2afeec4c8..01f18c0ce5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,19 +1,12 @@ { - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:vue/vue3-recommended", - "plugin:prettier/recommended" - ], + "extends": ["plugin:@typescript-eslint/recommended", "plugin:vue/vue3-recommended", "plugin:prettier/recommended"], "env": { "browser": true, "node": true, "jest": true, "es6": true }, - "plugins": [ - "vue", - "@typescript-eslint" - ], + "plugins": ["vue", "@typescript-eslint", "import"], "globals": { "cy": "readonly", "Cypress": "readonly", @@ -31,12 +24,7 @@ } }, "settings": { - "import/extensions": [ - ".js", - ".jsx", - ".ts", - ".tsx" - ] + "import/extensions": [".js", ".jsx", ".ts", ".tsx"] }, "rules": { "no-console": [ @@ -49,8 +37,8 @@ "no-continue": "off", "no-restricted-syntax": "off", "no-plusplus": "off", - "no-param-reassign": "off", - "no-shadow": "off", + "no-param-reassign": "off", + "no-shadow": "off", "no-underscore-dangle": ["error"], "no-unused-vars": "off", "no-unused-expressions": "off", @@ -70,7 +58,27 @@ "import/no-extraneous-dependencies": "off", "import/prefer-default-export": "off", "import/no-relative-packages": "off", - + "import/no-duplicates": "error", + "import/order": [ + "error", + { + "groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type", "unknown"], + "pathGroups": [ + { + "pattern": "vue", + "group": "external", + "position": "before" + } + ], + "pathGroupsExcludedImportTypes": ["builtin"], + "newlines-between": "always", + "alphabetize": { + "order": "asc", + "caseInsensitive": true + } + } + ], + // typescript config "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/explicit-module-boundary-types": "off", @@ -78,7 +86,7 @@ "@typescript-eslint/no-var-requires": 0, "@typescript-eslint/prefer-for-of": 0, "@typescript-eslint/ban-types": 0, - "@typescript-eslint/no-unused-vars": [ + "@typescript-eslint/no-unused-vars": [ 1, { "argsIgnorePattern": "^_", @@ -100,15 +108,7 @@ } }, { - "files": [ - "**/_example/*", - "**/_example-ts/*", - "script/**/*", - "script/*", - "*.js", - "site/**/*", - "site/*" - ], + "files": ["**/_example/*", "**/_example-ts/*", "script/**/*", "script/*", "*.js", "site/**/*", "site/*"], "rules": { "no-var-requires": 0, "no-console": 0, @@ -117,18 +117,13 @@ } }, { - "files": [ - "*.ts", - "*.tsx" - ], + "files": ["*.ts", "*.tsx"], "rules": { "@typescript-eslint/explicit-function-return-type": 0 } }, { - "files": [ - "*.test.js" - ], + "files": ["*.test.js"], "rules": { "import/no-dynamic-require": "off", "global-require": "off" diff --git a/src/affix/_example-ts/container.vue b/src/affix/_example-ts/container.vue index 77c82efc03..3d112d38a0 100644 --- a/src/affix/_example-ts/container.vue +++ b/src/affix/_example-ts/container.vue @@ -19,6 +19,7 @@ diff --git a/src/alert/alert.tsx b/src/alert/alert.tsx index 6aec3ad6ec..2790e19a9a 100644 --- a/src/alert/alert.tsx +++ b/src/alert/alert.tsx @@ -1,4 +1,7 @@ import { defineComponent, VNode, ref, onMounted, onBeforeUnmount } from 'vue'; + +import isArray from 'lodash/isArray'; +import isString from 'lodash/isString'; import { CheckCircleFilledIcon as TdCheckCircleFilledIcon, CloseIcon as TdCloseIcon, @@ -6,17 +9,15 @@ import { HelpCircleFilledIcon as TdHelpCircleFilledIcon, InfoCircleFilledIcon as TdInfoCircleFilledIcon, } from 'tdesign-icons-vue-next'; -import isString from 'lodash/isString'; -import isArray from 'lodash/isArray'; -import { on, off, addClass } from '../utils/dom'; -import props from './props'; import { SlotReturnValue } from '../common'; import { useIcon } from '../hooks/icon'; -import { useGlobalIcon } from '../hooks/useGlobalIcon'; +import { useTNodeJSX } from '../hooks/tnode'; import { useConfig, usePrefixClass } from '../hooks/useConfig'; +import { useGlobalIcon } from '../hooks/useGlobalIcon'; +import { on, off, addClass } from '../utils/dom'; -import { useTNodeJSX } from '../hooks/tnode'; +import props from './props'; export default defineComponent({ name: 'TAlert', diff --git a/src/alert/index.ts b/src/alert/index.ts index f1cc7a1cbd..dce5fa8608 100644 --- a/src/alert/index.ts +++ b/src/alert/index.ts @@ -1,5 +1,6 @@ -import _Alert from './alert'; import withInstall from '../utils/withInstall'; + +import _Alert from './alert'; import { TdAlertProps } from './type'; import './style'; diff --git a/src/anchor/_example-ts/base.vue b/src/anchor/_example-ts/base.vue index d28cff12df..6f6b5d318f 100644 --- a/src/anchor/_example-ts/base.vue +++ b/src/anchor/_example-ts/base.vue @@ -12,6 +12,7 @@ diff --git a/src/avatar/_example-ts/group-cascading.vue b/src/avatar/_example-ts/group-cascading.vue index b7167a662e..68cfe660d1 100644 --- a/src/avatar/_example-ts/group-cascading.vue +++ b/src/avatar/_example-ts/group-cascading.vue @@ -18,8 +18,8 @@ diff --git a/src/avatar/_example-ts/group-max.vue b/src/avatar/_example-ts/group-max.vue index ad4a97cef4..46f757e0b2 100644 --- a/src/avatar/_example-ts/group-max.vue +++ b/src/avatar/_example-ts/group-max.vue @@ -20,8 +20,8 @@ diff --git a/src/avatar/_example/base.vue b/src/avatar/_example/base.vue index f35c9e0ab8..fad03ef48b 100644 --- a/src/avatar/_example/base.vue +++ b/src/avatar/_example/base.vue @@ -7,6 +7,7 @@ diff --git a/src/card/_example-ts/header-footer-actions.vue b/src/card/_example-ts/header-footer-actions.vue index 8f4f40b78f..0a778b5450 100644 --- a/src/card/_example-ts/header-footer-actions.vue +++ b/src/card/_example-ts/header-footer-actions.vue @@ -26,8 +26,8 @@ diff --git a/src/date-picker/_example-ts/date-presets-alt.vue b/src/date-picker/_example-ts/date-presets-alt.vue index d686745cfc..c73e1af26e 100644 --- a/src/date-picker/_example-ts/date-presets-alt.vue +++ b/src/date-picker/_example-ts/date-presets-alt.vue @@ -6,8 +6,9 @@ diff --git a/src/input/_example/base.vue b/src/input/_example/base.vue index f8e50ea322..b2c7cf9c06 100644 --- a/src/input/_example/base.vue +++ b/src/input/_example/base.vue @@ -16,6 +16,7 @@ diff --git a/src/list/_example-ts/virtual-scroll.vue b/src/list/_example-ts/virtual-scroll.vue index 624bf678d6..f7bfee0229 100644 --- a/src/list/_example-ts/virtual-scroll.vue +++ b/src/list/_example-ts/virtual-scroll.vue @@ -6,6 +6,7 @@ diff --git a/src/space/index.ts b/src/space/index.ts index 656d0ad27e..2241323eaa 100644 --- a/src/space/index.ts +++ b/src/space/index.ts @@ -1,5 +1,6 @@ -import _Space from './space'; import withInstall from '../utils/withInstall'; + +import _Space from './space'; import { TdSpaceProps } from './type'; import './style'; diff --git a/src/space/space.tsx b/src/space/space.tsx index c7dcd2c951..eabc4272ce 100644 --- a/src/space/space.tsx +++ b/src/space/space.tsx @@ -1,12 +1,15 @@ import { defineComponent, computed, CSSProperties, Fragment } from 'vue'; -import props from './props'; -import { usePrefixClass } from '../hooks/useConfig'; -import { useTNodeJSX } from '../hooks/tnode'; -import { useChildSlots } from '../hooks/slot'; + +import isArray from 'lodash/isArray'; import isNumber from 'lodash/isNumber'; import isString from 'lodash/isString'; -import isArray from 'lodash/isArray'; + import { getFlexGapPolyFill } from '../_common/js/utils/helper'; +import { useChildSlots } from '../hooks/slot'; +import { useTNodeJSX } from '../hooks/tnode'; +import { usePrefixClass } from '../hooks/useConfig'; + +import props from './props'; const sizeMap = { small: '8px', medium: '16px', large: '24px' }; const defaultNeedPolyfill = getFlexGapPolyFill(); diff --git a/src/statistic/_example-ts/animation.vue b/src/statistic/_example-ts/animation.vue index e7d0128f26..115afd2ec4 100644 --- a/src/statistic/_example-ts/animation.vue +++ b/src/statistic/_example-ts/animation.vue @@ -22,6 +22,7 @@ diff --git a/src/steps/_example-ts/icon.vue b/src/steps/_example-ts/icon.vue index 9e8c190d54..46456a0067 100644 --- a/src/steps/_example-ts/icon.vue +++ b/src/steps/_example-ts/icon.vue @@ -8,8 +8,8 @@