Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 33daa7d

Browse files
Anton BilovusTigge
authored andcommitted
feat: lint unused locals and parameters with tsc
- Lints unused locals and parameters with tsc during `yarn build`. - Removes leftovers of react imports.
1 parent 802dfc8 commit 33daa7d

Some content is hidden

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

77 files changed

+614
-424
lines changed

packages/core/src/Button/index.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import React, { useCallback } from 'react'
1+
import {
2+
useCallback,
3+
ButtonHTMLAttributes,
4+
MouseEventHandler,
5+
forwardRef,
6+
FocusEventHandler,
7+
PointerEventHandler,
8+
} from 'react'
29
import styled, { css } from 'styled-components'
310
import { useVisibleFocus } from 'react-hooks-shareable'
411
import { Icon, IconType } from '../Icon'
@@ -203,10 +210,10 @@ const LabelContainer = styled.span.attrs({ className: 'sc-LabelContainer' })<{
203210
`
204211

205212
type BaseElement = HTMLButtonElement
206-
type BaseProps = React.ButtonHTMLAttributes<BaseElement>
213+
type BaseProps = ButtonHTMLAttributes<BaseElement>
207214
type ButtonType = 'button' | 'submit' | 'reset'
208215
export type ButtonVariantType = 'primary' | 'secondary'
209-
export type ButtonClickHandler = React.MouseEventHandler<BaseElement>
216+
export type ButtonClickHandler = MouseEventHandler<BaseElement>
210217

211218
interface BaseButtonProps extends BaseProps {
212219
/**
@@ -246,7 +253,7 @@ export interface ButtonProps extends BaseButtonProps {
246253
}
247254

248255
/* eslint-disable-next-line react/display-name */
249-
export const Button = React.forwardRef<BaseElement, ButtonProps>(
256+
export const Button = forwardRef<BaseElement, ButtonProps>(
250257
(
251258
{
252259
disabled = false,
@@ -265,23 +272,21 @@ export const Button = React.forwardRef<BaseElement, ButtonProps>(
265272
const { isPointerOn, isPointerOff, determineVisibleFocus, visibleFocus } =
266273
useVisibleFocus()
267274

268-
const handleFocus = useCallback<React.FocusEventHandler<BaseElement>>(
275+
const handleFocus = useCallback<FocusEventHandler<BaseElement>>(
269276
e => {
270277
onFocus?.(e)
271278
determineVisibleFocus()
272279
},
273280
[determineVisibleFocus, onFocus]
274281
)
275-
const handlePointerDown = useCallback<
276-
React.PointerEventHandler<BaseElement>
277-
>(
282+
const handlePointerDown = useCallback<PointerEventHandler<BaseElement>>(
278283
e => {
279284
onPointerDown?.(e)
280285
isPointerOn()
281286
},
282287
[isPointerOn, onPointerDown]
283288
)
284-
const handlePointerUp = useCallback<React.PointerEventHandler<BaseElement>>(
289+
const handlePointerUp = useCallback<PointerEventHandler<BaseElement>>(
285290
e => {
286291
onPointerUp?.(e)
287292
isPointerOff()
@@ -430,7 +435,7 @@ export interface IconButtonProps extends BaseButtonProps {
430435
}
431436

432437
/* eslint-disable-next-line react/display-name */
433-
export const IconButton = React.forwardRef<BaseElement, IconButtonProps>(
438+
export const IconButton = forwardRef<BaseElement, IconButtonProps>(
434439
(
435440
{
436441
disabled,
@@ -448,23 +453,21 @@ export const IconButton = React.forwardRef<BaseElement, IconButtonProps>(
448453
const { isPointerOn, isPointerOff, determineVisibleFocus, visibleFocus } =
449454
useVisibleFocus()
450455

451-
const handleFocus = useCallback<React.FocusEventHandler<BaseElement>>(
456+
const handleFocus = useCallback<FocusEventHandler<BaseElement>>(
452457
e => {
453458
onFocus?.(e)
454459
determineVisibleFocus()
455460
},
456461
[determineVisibleFocus, onFocus]
457462
)
458-
const handlePointerDown = useCallback<
459-
React.PointerEventHandler<BaseElement>
460-
>(
463+
const handlePointerDown = useCallback<PointerEventHandler<BaseElement>>(
461464
e => {
462465
onPointerDown?.(e)
463466
isPointerOn()
464467
},
465468
[isPointerOn, onPointerDown]
466469
)
467-
const handlePointerUp = useCallback<React.PointerEventHandler<BaseElement>>(
470+
const handlePointerUp = useCallback<PointerEventHandler<BaseElement>>(
468471
e => {
469472
onPointerUp?.(e)
470473
isPointerOff()
@@ -573,10 +576,7 @@ export interface IconTextButtonProps
573576
}
574577

575578
// eslint-disable-next-line react/display-name
576-
export const IconTextButton = React.forwardRef<
577-
BaseElement,
578-
IconTextButtonProps
579-
>(
579+
export const IconTextButton = forwardRef<BaseElement, IconTextButtonProps>(
580580
(
581581
{
582582
disabled = false,
@@ -593,23 +593,21 @@ export const IconTextButton = React.forwardRef<
593593
const { isPointerOn, isPointerOff, determineVisibleFocus, visibleFocus } =
594594
useVisibleFocus()
595595

596-
const handleFocus = useCallback<React.FocusEventHandler<BaseElement>>(
596+
const handleFocus = useCallback<FocusEventHandler<BaseElement>>(
597597
e => {
598598
onFocus?.(e)
599599
determineVisibleFocus()
600600
},
601601
[determineVisibleFocus, onFocus]
602602
)
603-
const handlePointerDown = useCallback<
604-
React.PointerEventHandler<BaseElement>
605-
>(
603+
const handlePointerDown = useCallback<PointerEventHandler<BaseElement>>(
606604
e => {
607605
onPointerDown?.(e)
608606
isPointerOn()
609607
},
610608
[isPointerOn, onPointerDown]
611609
)
612-
const handlePointerUp = useCallback<React.PointerEventHandler<BaseElement>>(
610+
const handlePointerUp = useCallback<PointerEventHandler<BaseElement>>(
613611
e => {
614612
onPointerUp?.(e)
615613
isPointerOff()

packages/core/src/Card/CardHeader.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from 'react'
1+
import { useCallback, HTMLAttributes, FC, MouseEventHandler } from 'react'
22
import styled, { css } from 'styled-components'
33

44
import { CARD_PADDING } from './padding'
@@ -8,7 +8,7 @@ import { spacing } from '../designparams'
88

99
export type CardHeaderHeightType = 'small' | 'normal' | 'large'
1010
type BaseElement = HTMLDivElement
11-
type BaseProps = React.HTMLAttributes<BaseElement>
11+
type BaseProps = HTMLAttributes<BaseElement>
1212

1313
/**
1414
* Empty header with just a bottom border
@@ -56,10 +56,9 @@ export interface CardHeaderProps extends BaseProps {
5656
readonly className?: string
5757
}
5858

59-
export const CardHeader: React.FC<CardHeaderProps> = ({
60-
children,
61-
...props
62-
}) => <TitleHeader {...props}>{children}</TitleHeader>
59+
export const CardHeader: FC<CardHeaderProps> = ({ children, ...props }) => (
60+
<TitleHeader {...props}>{children}</TitleHeader>
61+
)
6362

6463
/**
6564
* Expandable header
@@ -88,14 +87,14 @@ export interface CardExpandableHeaderProps extends CardHeaderProps {
8887
readonly onToggle: (expanded: boolean) => void
8988
}
9089

91-
export const CardExpandableHeader: React.FC<CardExpandableHeaderProps> = ({
90+
export const CardExpandableHeader: FC<CardExpandableHeaderProps> = ({
9291
disabled = false,
9392
expanded = false,
9493
onToggle,
9594
children,
9695
...props
9796
}) => {
98-
const onClick = useCallback<React.MouseEventHandler<HTMLDivElement>>(() => {
97+
const onClick = useCallback<MouseEventHandler<HTMLDivElement>>(() => {
9998
if (!disabled) {
10099
onToggle(!expanded)
101100
}

packages/core/src/Card/CardTabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, { useCallback } from 'react'
1+
import { useCallback, HTMLAttributes, MouseEventHandler } from 'react'
22
import styled, { css } from 'styled-components'
33

44
import { componentSize, opacity, shape, spacing } from '../designparams'
55
import { Typography } from '../Typography'
66

77
type BaseElement = HTMLDivElement
8-
type BaseProps = React.HTMLAttributes<BaseElement>
9-
type OnClickHandler = React.MouseEventHandler<BaseElement>
8+
type BaseProps = HTMLAttributes<BaseElement>
9+
type OnClickHandler = MouseEventHandler<BaseElement>
1010
type TabVariant = 'inside' | 'outside'
1111

1212
const OUTSIDE_TAB_HEIGHT = componentSize.small

packages/core/src/Card/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const Card: FC<CardProps> = ({
103103
</CardContainer>
104104
)
105105

106-
export const PanelCard: React.FC<CardProps> = ({
106+
export const PanelCard: FC<CardProps> = ({
107107
width = 'full',
108108
square = true,
109109
children,

packages/core/src/Checkbox/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
// Libs
2-
import React, { useCallback, useMemo } from 'react'
1+
import {
2+
useCallback,
3+
useMemo,
4+
InputHTMLAttributes,
5+
ChangeEventHandler,
6+
FC,
7+
} from 'react'
38

49
import styled, { css } from 'styled-components'
510
import { useVisibleFocus } from 'react-hooks-shareable'
@@ -156,9 +161,9 @@ const CSSBlankCheckbox = styled(BaseCheckbox)`
156161
border: 2px solid ${({ theme }) => theme.color.element01()};
157162
`
158163
type BaseElement = HTMLInputElement
159-
type BaseProps = React.InputHTMLAttributes<BaseElement>
164+
type BaseProps = InputHTMLAttributes<BaseElement>
160165

161-
export type CheckboxChangeHandler = React.ChangeEventHandler<BaseElement>
166+
export type CheckboxChangeHandler = ChangeEventHandler<BaseElement>
162167
export type CheckboxValueChangeHandler = (value: boolean) => void
163168

164169
export interface CheckboxProps extends BaseProps {
@@ -198,7 +203,7 @@ export interface CheckboxProps extends BaseProps {
198203
readonly onPartialValueChange?: CheckboxValueChangeHandler
199204
}
200205

201-
export const Checkbox: React.FunctionComponent<CheckboxProps> = ({
206+
export const Checkbox: FC<CheckboxProps> = ({
202207
checked,
203208
label,
204209
disabled = false,

packages/core/src/Chip/BaseChip.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, { ReactNode } from 'react'
1+
import { ReactNode, HTMLAttributes, forwardRef } from 'react'
22
import styled, { css } from 'styled-components'
33

44
import { Icon } from '../Icon'
55
import { opacity, shape, spacing, componentSize } from '../designparams'
66
import { ErrorWithoutCircleIcon } from './icons'
77

88
type BaseElement = HTMLDivElement
9-
type BaseProps = React.HTMLAttributes<BaseElement>
9+
type BaseProps = HTMLAttributes<BaseElement>
1010

1111
const ChipArea = styled.div<{
1212
readonly error: boolean
@@ -79,7 +79,7 @@ export interface BaseChipProps extends BaseProps {
7979
}
8080

8181
/* eslint-disable-next-line react/display-name */
82-
export const BaseChip = React.forwardRef<HTMLDivElement, BaseChipProps>(
82+
export const BaseChip = forwardRef<HTMLDivElement, BaseChipProps>(
8383
({ error = false, disabled = false, component, ...props }, ref) => (
8484
<ChipArea ref={ref} error={error} disabled={disabled} {...props}>
8585
{error ? <ChipErrorIcon /> : null}

0 commit comments

Comments
 (0)