Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: lodash-es instead of lodash #3486

Merged
merged 8 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@
{
"checkLoops": false
}
]
],
"no-restricted-imports": ["error", {
"paths": [{
"name": "lodash",
"message": "Please use lodash-es instead."
}]
}]
},
"overrides": [
{
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@
"@babel/runtime": "^7.14.8",
"@popperjs/core": "^2.4.0",
"@types/clipboard": "^2.0.1",
"@types/lodash": "4.14.182",
"@types/raf": "^3.4.0",
"@types/sortablejs": "^1.10.7",
"@types/tinycolor2": "^1.4.3",
"@types/validator": "^13.1.3",
"@vue/composition-api": "^1.4.1",
"clipboard": "^2.0.8",
"dayjs": "1.11.10",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"mitt": "^3.0.0",
"raf": "^3.4.1",
"sortablejs": "^1.15.0",
Expand All @@ -108,8 +107,8 @@
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "~7.22.5",
"@babel/helper-module-imports": "7.24.7",
"@babel/eslint-parser": "~7.23.10",
"@babel/helper-module-imports": "7.24.7",
"@babel/plugin-transform-class-properties": "^7.22.3",
"@babel/plugin-transform-modules-commonjs": "^7.9.6",
"@babel/plugin-transform-object-assign": "^7.2.0",
Expand All @@ -125,6 +124,7 @@
"@rollup/plugin-url": "^5.0.1",
"@testing-library/dom": "^10.2.0",
"@types/estree": "0.0.50",
"@types/lodash-es": "^4.17.12",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/experimental-utils": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
Expand Down Expand Up @@ -182,7 +182,7 @@
"tdesign-publish-cli": "^0.0.12",
"tdesign-site-components": "^0.15.3",
"tdesign-theme-generator": "^1.0.0",
"typescript": "~4.5.4",
"typescript": "~4.8.4",
"unplugin-vue2-script-setup": "^0.10.2",
"vite": "^2.7.6",
"vite-plugin-pwa": "^0.11.11",
Expand Down
4 changes: 2 additions & 2 deletions script/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const { template } = require('lodash-es');
const utils = require('../utils');
const config = require('./config');

Expand Down Expand Up @@ -75,7 +75,7 @@ function deleteComponent(toBeCreatedFiles, component) {
function outputFileWithTemplate(item, component, desc, _d) {
const tplPath = path.resolve(__dirname, `./tpl/${item.template}`);
let data = fs.readFileSync(tplPath).toString();
const compiled = _.template(data);
const compiled = template(data);
data = compiled({
component,
upperComponent: getFirstLetterUpper(component),
Expand Down
4 changes: 2 additions & 2 deletions script/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const umdConfig = {
banner,
format: 'umd',
exports: 'named',
globals: { vue: 'Vue', lodash: '_' },
globals: { vue: 'Vue' },
sourcemap: true,
file: `dist/${name}.js`,
},
Expand All @@ -227,7 +227,7 @@ const umdMinConfig = {
banner,
format: 'umd',
exports: 'named',
globals: { vue: 'Vue', lodash: '_' },
globals: { vue: 'Vue' },
sourcemap: true,
file: `dist/${name}.min.js`,
},
Expand Down
2 changes: 2 additions & 0 deletions site/src/components/codesandbox/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ export const packageJSONContent = JSON.stringify(
'tdesign-vue': orgPkg.version,
'tdesign-icons-vue': orgPkg.dependencies['tdesign-icons-vue'],
vue: orgPkg.devDependencies.vue,
'lodash-es': orgPkg.dependencies['lodash-es'],
},
devDependencies: {
vite: orgPkg.devDependencies.vite,
less: orgPkg.devDependencies.less,
'vite-plugin-vue2': orgPkg.devDependencies['vite-plugin-vue2'],
'vue-template-compiler': orgPkg.devDependencies['vue-template-compiler'],
'@types/lodash-es': orgPkg.devDependencies['@types/lodash-es'],
},
},
null,
Expand Down
2 changes: 2 additions & 0 deletions site/src/components/stackblitz/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ export const packageJSONContentForComposition = JSON.stringify(
'tdesign-vue': orgPkg.version + '-naruto',
'tdesign-icons-vue': orgPkg.dependencies['tdesign-icons-vue'],
vue: '2.7.14',
'lodash-es': orgPkg.dependencies['lodash-es'],
},
devDependencies: {
vite: '^2.9.6',
less: orgPkg.devDependencies.less,
'@vitejs/plugin-vue2': '^1.1.2',
'vue-template-compiler': '2.7.14',
'@vitejs/plugin-vue2-jsx': '^1.1.0',
'@types/lodash-es': orgPkg.devDependencies['@types/lodash-es'],
},
},
null,
Expand Down
2 changes: 1 addition & 1 deletion src/_common
Submodule _common updated 46 files
+3 −0 .eslintrc.js
+20 −7 .github/workflows/pull-request.yml
+229 −0 .github/workflows/tdesign-component-repositories-ci.yml
+2 −1 .vscode/settings.json
+0 −6 babel.config.js
+4 −3 js/color-picker/color.ts
+2 −3 js/color-picker/gradient.ts
+8 −2 js/date-picker/format.ts
+2 −10 js/date-picker/utils.ts
+1 −3 js/input-number/large-number.ts
+1 −3 js/input-number/number.ts
+1 −1 js/loading/circle-adapter.ts
+9 −0 js/package.json
+1 −1 js/slider/utils.ts
+1 −3 js/table/tree-store.ts
+1 −3 js/table/utils.ts
+1 −5 js/tree-v1/tree-node-model.ts
+8 −7 js/tree-v1/tree-node.ts
+9 −9 js/tree-v1/tree-store.ts
+4 −7 js/tree/tree-node-model.ts
+5 −7 js/tree/tree-node.ts
+9 −9 js/tree/tree-store.ts
+1 −2 js/upload/main.ts
+1 −1 js/upload/utils.ts
+1 −1 js/upload/xhr.ts
+1 −1 js/utils/calcTextareaHeight.ts
+42 −0 js/utils/easing.ts
+16 −0 js/utils/general.ts
+20 −10 js/utils/helper.ts
+17 −0 js/utils/responsive.ts
+4 −1 js/utils/setStyle.ts
+9 −0 js/utils/stringTemplate.ts
+13 −0 js/utils/types.ts
+6 −8 package.json
+0 −1 style/mobile/.stylelintignore
+34 −1 style/mobile/components/calendar/v2/_index.less
+2 −0 style/mobile/components/calendar/v2/_var.less
+0 −31 style/mobile/package.json
+0 −36 style/mobile/webpack.config.js
+6 −0 style/package.json
+0 −1 style/web/.stylelintignore
+1 −1 style/web/_global.less
+0 −14 style/web/package.json
+2 −2 test/script/generate-demo-test.js
+1 −1 test/unit/date-picker/utils.test.js
+23 −12 tsconfig.json
2 changes: 1 addition & 1 deletion src/affix/affix.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue, { VueConstructor } from 'vue';
import isFunction from 'lodash/isFunction';
import { isFunction } from 'lodash-es';
import { on, off, getScrollContainer } from '../utils/dom';
import affixProps from './props';
import { ScrollContainerElement } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion src/anchor/__tests__/anchor-link.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import omit from 'lodash/omit';
import { omit } from 'lodash-es';
import { AnchorItem } from '@/src/anchor/index.ts';

const defaultProvide = {
Expand Down
2 changes: 1 addition & 1 deletion src/anchor/anchor-item.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue, { VueConstructor } from 'vue';
import { ScopedSlotReturnValue } from 'vue/types/vnode';
import isEmpty from 'lodash/isEmpty';
import { isEmpty } from 'lodash-es';
import { VNode } from 'vue/types/umd';
import { ANCHOR_SHARP_REGEXP } from './utils';
import props from './anchor-item-props';
Expand Down
2 changes: 1 addition & 1 deletion src/anchor/anchor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue, { VueConstructor } from 'vue';
import { ScopedSlotReturnValue } from 'vue/types/vnode';
import isFunction from 'lodash/isFunction';
import { isFunction } from 'lodash-es';
import { ANCHOR_SHARP_REGEXP, ANCHOR_CONTAINER, getOffsetTop } from './utils';
import {
on, off, getScroll, scrollTo, getScrollContainer,
Expand Down
2 changes: 1 addition & 1 deletion src/auto-complete/_example-composition/filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<script setup>
import { ref } from 'vue';
import escapeRegExp from 'lodash/escapeRegExp';
import { escapeRegExp } from 'lodash-es';

const LIST = ['第一个 AutoComplete 默认联想词', '第二个 AutoComplete 默认联想词', '第三个 AutoComplete 默认联想词'];
const value1 = ref('');
Expand Down
2 changes: 1 addition & 1 deletion src/auto-complete/_example/filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</template>

<script>
import escapeRegExp from 'lodash/escapeRegExp';
import { escapeRegExp } from 'lodash-es';

const LIST = ['第一个 AutoComplete 默认联想词', '第二个 AutoComplete 默认联想词', '第三个 AutoComplete 默认联想词'];

Expand Down
2 changes: 1 addition & 1 deletion src/auto-complete/highlight-option.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, defineComponent } from '@vue/composition-api';
import escapeRegExp from 'lodash/escapeRegExp';
import { escapeRegExp } from 'lodash-es';
import { usePrefixClass } from '../hooks/useConfig';

export default defineComponent({
Expand Down
3 changes: 1 addition & 2 deletions src/auto-complete/option-list.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
ref, computed, defineComponent, PropType, h, watch, onBeforeUnmount,
} from '@vue/composition-api';
import isFunction from 'lodash/isFunction';
import escapeRegExp from 'lodash/escapeRegExp';
import { isFunction, escapeRegExp } from 'lodash-es';
import HighlightOption from './highlight-option';
import { CommonClassNameType } from '../hooks/useCommonClassName';
import { AutoCompleteOptionObj, TdAutoCompleteProps } from './type';
Expand Down
2 changes: 1 addition & 1 deletion src/calendar/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from 'vue';
// 通用库
import dayjs from 'dayjs';
import remove from 'lodash/remove';
import { remove } from 'lodash-es';
import calendar from 'dayjs/plugin/calendar';
import props from './props';
import mixins from '../utils/mixins';
Expand Down
2 changes: 1 addition & 1 deletion src/cascader/cascader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineComponent, computed } from '@vue/composition-api';
import omit from 'lodash/omit';
import { omit } from 'lodash-es';
import Panel from './components/Panel';
import SelectInput, {
SelectInputChangeContext,
Expand Down
4 changes: 1 addition & 3 deletions src/cascader/core/effect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import isNumber from 'lodash/isNumber';
import isFunction from 'lodash/isFunction';
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep, isFunction, isNumber } from 'lodash-es';
import {
TreeNode, CascaderContextType, TdCascaderProps, TreeNodeValue, TreeNodeModel,
} from '../interface';
Expand Down
2 changes: 1 addition & 1 deletion src/cascader/core/helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isEmpty from 'lodash/isEmpty';
import { isEmpty } from 'lodash-es';
import {
TreeNode,
CascaderContextType,
Expand Down
3 changes: 1 addition & 2 deletions src/cascader/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
Ref, reactive, computed, toRefs, watch, nextTick,
} from '@vue/composition-api';
import isEqual from 'lodash/isEqual';
import isFunction from 'lodash/isFunction';
import { isEqual, isFunction } from 'lodash-es';

import TreeStore from '../_common/js/tree/tree-store';
import useVModel from '../hooks/useVModel';
Expand Down
4 changes: 1 addition & 3 deletions src/checkbox/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {
nextTick,
onMounted,
} from '@vue/composition-api';
import intersection from 'lodash/intersection';
import isObject from 'lodash/isObject';
import isUndefined from 'lodash/isUndefined';
import { intersection, isObject, isUndefined } from 'lodash-es';
import { VNode } from 'vue';
import { getVNodeComponentName, getVueComponentName } from '../utils/helper';
import Checkbox from './checkbox';
Expand Down
2 changes: 1 addition & 1 deletion src/color-picker/panel/format/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
defineComponent, PropType, ref, watch,
} from '@vue/composition-api';
import upperCase from 'lodash/upperCase';
import { upperCase } from 'lodash-es';
import { TdColorHandler } from '../../../color-picker/interfaces';
import { TdColorPickerProps } from '../../type';
import props from '../../props';
Expand Down
2 changes: 1 addition & 1 deletion src/color-picker/panel/format/inputs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
computed, defineComponent, PropType, reactive, watch,
} from '@vue/composition-api';
import throttle from 'lodash/throttle';
import { throttle } from 'lodash-es';
import { TdColorHandler } from '../../interfaces';
import props from '../../props';
import { Color } from '../../utils';
Expand Down
2 changes: 1 addition & 1 deletion src/color-picker/panel/linear-gradient.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
computed, defineComponent, onBeforeUnmount, onMounted, reactive, ref, watch,
} from '@vue/composition-api';
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash-es';
import { GRADIENT_SLIDER_DEFAULT_WIDTH } from '../../_common/js/color-picker/constants';
import { genGradientPoint, gradientColors2string, GradientColorPoint } from '../utils';
import { InputNumber as TInputNumber } from '../../input-number';
Expand Down
2 changes: 1 addition & 1 deletion src/color-picker/panel/swatches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
computed, defineComponent, PropType, ref,
} from '@vue/composition-api';
import { DeleteIcon as TdDeleteIcon, AddIcon as TdAddIcon } from 'tdesign-icons-vue';
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash-es';
import { Select as TSelect, Option as TOption } from '../../select';
import { Color } from '../utils';
import { useBaseClassName } from '../hooks';
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example-composition/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script setup>
import { ref } from 'vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

const MONTHS = [
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example-composition/date-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<script setup>
import { reactive } from 'vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';
// import dayjs from 'dayjs';

Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example-composition/global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup>
import { ref } from 'vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';
// 全局特性配置,引入英文语言配置包 enConfig
const globalConfig = ref(
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example-composition/others.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import { ref, reactive } from 'vue';
import {
ErrorIcon, ChevronRightIcon, CloseIcon, CloseCircleIcon,
} from 'tdesign-icons-vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

const initialTransferList = [];
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example-composition/pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script setup>
import { ref } from 'vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

const current = ref(1);
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example-composition/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<script setup lang="jsx">
import { ref } from 'vue';
import { ChevronRightIcon, CaretDownSmallIcon /** , ChevronDownIcon */ } from 'tdesign-icons-vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

const initialColumns = [
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>

<script>
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

const MONTHS = [
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example/date-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</template>

<script>
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';
// import dayjs from 'dayjs';

Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example/global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</template>

<script>
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example/others.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import {
ErrorIcon, ChevronRightIcon, CloseIcon, CloseCircleIcon,
} from 'tdesign-icons-vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

const initialTransferList = [];
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example/pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>

<script>
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/_example/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script lang="jsx">
import { ChevronRightIcon, CaretDownSmallIcon /** , ChevronDownIcon */ } from 'tdesign-icons-vue';
import merge from 'lodash/merge';
import { merge } from 'lodash-es';
import enConfig from 'tdesign-vue/es/locale/en_US';

const initialColumns = [
Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/config-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue, { PropType, VNode } from 'vue';
import cloneDeep from 'lodash/cloneDeep';
import { cloneDeep } from 'lodash-es';
import { GlobalConfigProvider } from './type';
import { defaultGlobalConfig, mergeWith } from './context';

Expand Down
Loading