Skip to content

Commit 251b639

Browse files
committed
refactor(typeutils): add noop and migration arrow function () => {}
1 parent 519d514 commit 251b639

File tree

42 files changed

+121
-68
lines changed

Some content is hidden

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

42 files changed

+121
-68
lines changed

packages/bezier-react/src/components/Avatars/Avatar/Avatar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import React, { forwardRef, useMemo } from 'react'
55
import { backgroundImageVariable } from 'Foundation'
66
import {
77
isEmpty,
8+
noop,
89
} from 'Utils/typeUtils'
910
import { Status, StatusSize } from 'Components/Status'
1011
// eslint-disable-next-line no-restricted-imports
@@ -26,9 +27,9 @@ export const Avatar = forwardRef(function Avatar({
2627
disabled = false,
2728
showBorder = false,
2829
status,
29-
onClick = () => {},
30-
onMouseEnter = () => {},
31-
onMouseLeave = () => {},
30+
onClick = noop,
31+
onMouseEnter = noop,
32+
onMouseLeave = noop,
3233
className,
3334
wrapperClassName,
3435
interpolation,

packages/bezier-react/src/components/Avatars/AvatarGroup/AvatarGroup.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { forwardRef, useCallback, useMemo } from 'react'
44
/* Internal dependencies */
55
import { Typography } from 'Foundation'
66
import { isLastIndex } from 'Utils/arrayUtils'
7+
import { noop } from 'Utils/typeUtils'
78
import { Icon, IconSize, MoreIcon } from 'Components/Icon'
89
import { AvatarProps, AvatarSize } from 'Components/Avatars/Avatar'
910
import { AVATAR_GROUP_DEFAULT_SPACING } from 'Components/Avatars/AvatarStyle'
@@ -66,8 +67,8 @@ export const AvatarGroup = forwardRef(function AvatarGroup({
6667
size = AvatarSize.Size24,
6768
spacing = AVATAR_GROUP_DEFAULT_SPACING,
6869
ellipsisType = AvatarGroupEllipsisType.Icon,
69-
onMouseEnterEllipsis = () => {},
70-
onMouseLeaveEllipsis = () => {},
70+
onMouseEnterEllipsis = noop,
71+
onMouseLeaveEllipsis = noop,
7172
ellipsisInterpolation,
7273
style,
7374
className,

packages/bezier-react/src/components/Banner/Banner.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Meta, Story } from '@storybook/react'
55

66
/* Internal dependencies */
77
import { getTitle, getObjectFromEnum } from 'Utils/storyUtils'
8+
import { noop } from 'Utils/typeUtils'
89
import {
910
StackItem,
1011
VStack,
@@ -63,7 +64,7 @@ Playground.args = {
6364
icon: 'lightbulb',
6465
content: 'Information here.',
6566
actionIcon: 'cancel-small',
66-
onClickAction: () => {},
67+
onClickAction: noop,
6768
}
6869

6970
export const Overview: Story<{}> = () => (

packages/bezier-react/src/components/Button/Button.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from 'Utils/arrayUtils'
99
import {
1010
isArray,
11+
noop,
1112
} from 'Utils/typeUtils'
1213
import { LegacyIcon, IconSize, isIconName } from 'Components/Icon'
1314
import { Spinner, SpinnerSize } from 'Components/Spinner'
@@ -109,10 +110,10 @@ export const Button = forwardRef(function Button(
109110
colorVariant = ButtonColorVariant.Blue,
110111
leftContent,
111112
rightContent,
112-
onClick = () => {},
113-
onMouseEnter = () => {},
114-
onMouseLeave = () => {},
115-
onBlur = () => {},
113+
onClick = noop,
114+
onMouseEnter = noop,
115+
onMouseLeave = noop,
116+
onBlur = noop,
116117
...rest
117118
}: ButtonProps,
118119
forwardedRef: React.Ref<HTMLElement>,

packages/bezier-react/src/components/Emoji/Emoji.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useMemo, forwardRef } from 'react'
33

44
/* Internal dependencies */
55
import { backgroundImageVariable } from 'Foundation'
6+
import { noop } from 'Utils/typeUtils'
67
import type EmojiProps from './Emoji.types'
78
import { EmojiSize } from './Emoji.types'
89
import { Icon } from './Emoji.styled'
@@ -19,7 +20,7 @@ function Emoji(
1920
interpolation,
2021
size = EmojiSize.Size24,
2122
testId = EMOJI_TEST_ID,
22-
onClick = () => {},
23+
onClick = noop,
2324
}: EmojiProps,
2425
forwardedRef: React.Ref<HTMLDivElement>,
2526
) {

packages/bezier-react/src/components/Forms/Checkbox/Checkbox.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from 'react'
44
/* Internal dependencies */
55
import { Themes } from 'Foundation'
66
import { render } from 'Utils/testUtils'
7+
import { noop } from 'Utils/typeUtils'
78
import DisabledOpacity from 'Constants/DisabledOpacity'
89
import Checkbox, { CHECKBOX_TEST_ID, CHECKBOX_CHECKER_TEST_ID } from './Checkbox'
910
import CheckboxProps from './Checkbox.types'
@@ -17,7 +18,7 @@ describe('Checkbox test >', () => {
1718
contentClassName: undefined,
1819
disabled: false,
1920
checked: CheckType.False,
20-
onClick: () => {},
21+
onClick: noop,
2122
}
2223
})
2324

packages/bezier-react/src/components/Forms/Checkbox/Checkbox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import React, { Ref, forwardRef, useMemo } from 'react'
55
import {
66
isBoolean,
77
isEmpty,
8+
noop,
89
} from 'Utils/typeUtils'
910
import { IconSize, IconProps, CheckBoldIcon, HyphenBoldIcon } from 'Components/Icon'
1011
import useFormFieldProps from 'Components/Forms/useFormFieldProps'
@@ -29,7 +30,7 @@ function Checkbox(
2930
contentClassName,
3031
checked = false,
3132
children,
32-
onClick = () => {},
33+
onClick = noop,
3334
...rest
3435
}: CheckboxProps,
3536
forwardedRef: Ref<any>,
@@ -71,7 +72,7 @@ function Checkbox(
7172
<Styled.Wrapper
7273
ref={forwardedRef}
7374
disabled={disabled}
74-
onClick={disabled ? () => {} : onClick}
75+
onClick={disabled ? noop : onClick}
7576
data-testid={testId}
7677
{...ownProps}
7778
>

packages/bezier-react/src/components/Forms/Inputs/Select/Select.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import React, {
1414
import { Typography } from 'Foundation'
1515
import {
1616
isEmpty,
17+
noop,
1718
} from 'Utils/typeUtils'
1819
import { LegacyIcon, Icon, IconSize, isIconName, ChevronUpIcon, ChevronDownIcon } from 'Components/Icon'
1920
import { OverlayPosition } from 'Components/Overlay'
@@ -56,8 +57,8 @@ function Select({
5657
dropdownMarginY = DEFAULT_DROPDOWN_MARGIN_Y,
5758
dropdownZIndex = DEFAULT_DROPDOWN_Z_INDEX,
5859
dropdownPosition = OverlayPosition.BottomLeft,
59-
onClickTrigger = () => {},
60-
onHideDropdown = () => {},
60+
onClickTrigger = noop,
61+
onHideDropdown = noop,
6162
children,
6263
...rest
6364
}: SelectProps,

packages/bezier-react/src/components/Forms/SegmentedControl/SegmentedControl.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useResizeDetector } from 'react-resize-detector'
77
import useMergeRefs from 'Hooks/useMergeRefs'
88
import {
99
isNumber,
10+
noop,
1011
} from 'Utils/typeUtils'
1112
import {
1213
range,
@@ -53,7 +54,7 @@ function SegmentedControl(
5354
size = SegmentedControlSize.M,
5455
/* OptionItemHost props */
5556
selectedOptionIndex = 0,
56-
onChangeOption = () => {},
57+
onChangeOption = noop,
5758
/* HTMLAttribute props */
5859
children,
5960
...rest
@@ -116,7 +117,7 @@ function SegmentedControl(
116117
width: optionItemWidth,
117118
left: optionItemLeft(index),
118119
}}
119-
onClick={() => (disabled ? () => {} : handleClickOptionItem(index))}
120+
onClick={() => (disabled ? noop : handleClickOptionItem(index))}
120121
>
121122
<Text
122123
typo={SIZE_TO_OPTION_TYPOGRAPHY[size]}

packages/bezier-react/src/components/Forms/Slider/Slider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React, {
88
import * as SliderPrimitive from '@radix-ui/react-slider'
99

1010
/* Internal dependencies */
11+
import { noop } from 'Utils/typeUtils'
1112
import SliderProps from './Slider.types'
1213
import * as Styled from './Slider.styled'
1314

@@ -18,8 +19,8 @@ export const Slider = forwardRef(function Slider(
1819
{
1920
width = 36,
2021
guide,
21-
onThumbPointerDown = () => {},
22-
onThumbPointerUp = () => {},
22+
onThumbPointerDown = noop,
23+
onThumbPointerUp = noop,
2324
defaultValue = [5],
2425
value,
2526
disabled = false,

0 commit comments

Comments
 (0)