Skip to content

Commit 36456c0

Browse files
authored
fix: import lodash methods directly (#581)
1 parent 131dff3 commit 36456c0

File tree

43 files changed

+87
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+87
-86
lines changed

src/blocks/HeaderSlider/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import omit from 'lodash/omit';
22

33
import {HeaderProperties, SliderProps} from '../../schema/validators/blocks';
44
import {BlockBaseProps} from '../../schema/validators/common';
@@ -9,7 +9,7 @@ export const HeaderSliderBlock = {
99
required: ['items'],
1010
properties: {
1111
...BlockBaseProps,
12-
..._.omit(SliderProps, ['loadable', 'children']),
12+
...omit(SliderProps, ['loadable', 'children']),
1313
items: {
1414
type: 'array',
1515
items: {

src/blocks/Info/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import omit from 'lodash/omit';
22

33
import {
44
BaseProps,
@@ -12,7 +12,7 @@ import {ContentBase} from '../../sub-blocks/Content/schema';
1212

1313
const ContentProps = {
1414
additionalProperties: false,
15-
properties: _.omit(ContentBase, ['size', 'colSizes', 'theme']),
15+
properties: omit(ContentBase, ['size', 'colSizes', 'theme']),
1616
};
1717

1818
export const InfoBlock = {

src/blocks/Media/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {omit} from 'lodash';
1+
import omit from 'lodash/omit';
22

33
import {
44
AnimatableProps,

src/blocks/Questions/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import _ from 'lodash';
1+
import omit from 'lodash/omit';
22

33
import {BlockBaseProps, LinkProps} from '../../schema/validators/common';
44
import {filteredArray} from '../../schema/validators/utils';
55
import {ContentBase} from '../../sub-blocks/Content/schema';
66

7-
const QuestionsBlockContentProps = _.omit(ContentBase, ['size', 'theme']);
7+
const QuestionsBlockContentProps = omit(ContentBase, ['size', 'theme']);
88

99
export const QuestionsBlock = {
1010
'questions-block': {

src/blocks/Slider/Slider.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import React, {
88
useState,
99
} from 'react';
1010

11-
import _ from 'lodash';
11+
import debounce from 'lodash/debounce';
12+
import get from 'lodash/get';
13+
import noop from 'lodash/noop';
1214
import SlickSlider, {Settings} from 'react-slick';
1315

1416
import Anchor from '../../components/Anchor/Anchor';
@@ -113,12 +115,12 @@ export const SliderBlock = (props: WithChildren<SliderProps>) => {
113115

114116
// eslint-disable-next-line react-hooks/exhaustive-deps
115117
const onResize = useCallback(
116-
_.debounce(() => {
118+
debounce(() => {
117119
if (!slider) {
118120
return;
119121
}
120122

121-
const newBreakpoint = _.get(slider, 'state.breakpoint') || BREAKPOINTS.xl;
123+
const newBreakpoint = get(slider, 'state.breakpoint') || BREAKPOINTS.xl;
122124

123125
if (newBreakpoint !== breakpoint) {
124126
setBreakpoint(newBreakpoint);
@@ -343,7 +345,7 @@ export const SliderBlock = (props: WithChildren<SliderProps>) => {
343345
};
344346

345347
return (
346-
<OutsideClick onOutsideClick={isMobile ? unsetFocus : _.noop}>
348+
<OutsideClick onOutsideClick={isMobile ? unsetFocus : noop}>
347349
<SlickSlider {...settings}>{disclosedChildren}</SlickSlider>
348350
<div className={b('footer')}>
349351
{renderDisclaimer()}

src/blocks/Slider/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import pickBy from 'lodash/pickBy';
22

33
import {BREAKPOINTS} from '../../constants';
44

@@ -38,7 +38,7 @@ export function getSlidesToShowWithDefaults({
3838

3939
return {
4040
...DEFAULT_SLIDE_BREAKPOINTS,
41-
..._.pickBy(result, (value) => !isNaN(value)),
41+
...pickBy(result, (value) => !isNaN(value)),
4242
sm: !mobileFullscreen && contentLength > 1 ? DEFAULT_SLIDE_BREAKPOINTS.sm : 1,
4343
};
4444
}

src/blocks/Tabs/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import omit from 'lodash/omit';
22

33
import {ImageProps} from '../../components/Image/schema';
44
import {
@@ -15,7 +15,7 @@ import {
1515
import {filteredArray} from '../../schema/validators/utils';
1616
import {ContentBase} from '../../sub-blocks/Content/schema';
1717

18-
const TabsItemContentProps = _.omit(ContentBase, ['size', 'colSizes', 'centered', 'theme']);
18+
const TabsItemContentProps = omit(ContentBase, ['size', 'colSizes', 'centered', 'theme']);
1919

2020
export const tabsItem = {
2121
type: 'object',

src/components/BalancedMasonry/BalancedMasonry.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, {ReactNode, useCallback, useContext, useEffect, useRef, useState} from 'react';
22

3-
import _ from 'lodash';
3+
import debounce from 'lodash/debounce';
4+
import first from 'lodash/first';
5+
import minBy from 'lodash/minBy';
46

57
import {SSRContext} from '../../context/ssrContext';
68
import {QAProps, WithChildren} from '../../models';
@@ -31,7 +33,7 @@ const BalancedMasonry = (props: WithChildren<BalancedMasonryProps>) => {
3133
);
3234

3335
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
34-
let [, result] = _.first(breakpoints)!;
36+
let [, result] = first(breakpoints)!;
3537

3638
if (isServer) {
3739
return result;
@@ -54,7 +56,7 @@ const BalancedMasonry = (props: WithChildren<BalancedMasonryProps>) => {
5456

5557
// eslint-disable-next-line react-hooks/exhaustive-deps
5658
const balanceColumns = useCallback(
57-
_.debounce(() => {
59+
debounce(() => {
5860
if (!containerRef.current) {
5961
return;
6062
}
@@ -74,7 +76,7 @@ const BalancedMasonry = (props: WithChildren<BalancedMasonryProps>) => {
7476
continue;
7577
}
7678

77-
const minColumn = _.minBy(columnsMeta, 'height') || {id: 0, height: 0};
79+
const minColumn = minBy(columnsMeta, 'height') || {id: 0, height: 0};
7880
const {id: columnId} = minColumn;
7981

8082
localColumns[columnId].push(children[i]);

src/components/BalancedMasonry/__tests__/BalancedMasonry.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
import {render, screen, waitFor} from '@testing-library/react';
4-
import {omit} from 'lodash';
4+
import omit from 'lodash/omit';
55

66
import {testCustomClassName} from '../../../../test-utils/shared/common';
77
import {CardBase} from '../../../components';

src/components/FullWidthBackground/FullWidthBackground.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {CSSProperties, Component, PropsWithChildren, createRef} from 'react';
22

3-
import _ from 'lodash';
3+
import debounce from 'lodash/debounce';
44

55
import {BREAKPOINTS} from '../../constants';
66
import {ClassNameProps} from '../../models';
@@ -24,7 +24,7 @@ export default class FullWidthBackground extends Component<
2424
> {
2525
private ref = createRef<HTMLDivElement>();
2626

27-
private setBg = _.debounce(() => {
27+
private setBg = debounce(() => {
2828
if (this.ref && this.ref.current) {
2929
const bg = this.ref.current;
3030
const width = document.documentElement.clientWidth || document.body.clientWidth;

0 commit comments

Comments
 (0)