Skip to content

Commit 345c6b9

Browse files
committed
Avoid using global React type
1 parent 656e1a8 commit 345c6b9

File tree

41 files changed

+116
-81
lines changed

Some content is hidden

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

41 files changed

+116
-81
lines changed

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ module.exports = {
119119
},
120120
},
121121
],
122+
'no-restricted-syntax': [
123+
ERROR,
124+
{
125+
selector: "TSQualifiedName[left.name='React']",
126+
message:
127+
"Avoid using the global React type, import the specific type you want from 'react'",
128+
},
129+
],
122130
'react/no-unknown-property': OFF,
123131
'react-compiler/react-compiler': [
124132
ERROR,

design-system/docs/app/(site)/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Inter } from 'next/font/google';
55
import { Layout } from '../../components/layout';
66
import { getNavigation } from '../../utils/packages';
77
import { basePageTitle } from './utils';
8+
import { ReactNode } from 'react';
89

910
const inter = Inter({
1011
subsets: ['latin'],
@@ -23,7 +24,7 @@ export const metadata: Metadata = {
2324
export default async function RootLayout({
2425
children,
2526
}: {
26-
children: React.ReactNode;
27+
children: ReactNode;
2728
}) {
2829
return (
2930
<NextRootProvider fontClassName={inter.variable}>

design-system/pkg/src/breadcrumbs/BreadcrumbItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useBreadcrumbItem } from '@react-aria/breadcrumbs';
22
import { useLocale } from '@react-aria/i18n';
33
import { useHover } from '@react-aria/interactions';
44
import { mergeProps } from '@react-aria/utils';
5-
import React, { Fragment, useMemo, useRef } from 'react';
5+
import React, { Fragment, useMemo, useRef, ElementType } from 'react';
66

77
import { Icon } from '@keystar/ui/icon';
88
import { chevronRightIcon } from '@keystar/ui/icon/icons/chevronRightIcon';
@@ -35,7 +35,7 @@ export function BreadcrumbItem(props: BreadcrumbItemProps) {
3535

3636
let { direction } = useLocale();
3737
let ref = useRef(null);
38-
let ElementType: React.ElementType = props.href ? 'a' : 'span';
38+
let ElementType: ElementType = props.href ? 'a' : 'span';
3939
let { itemProps } = useBreadcrumbItem(
4040
{ ...props, elementType: ElementType },
4141
ref

design-system/pkg/src/checkbox/Checkbox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useToggleState } from '@react-stately/toggle';
33
import {
44
HTMLAttributes,
55
InputHTMLAttributes,
6+
RefObject,
67
useContext,
78
useMemo,
89
useRef,
@@ -70,7 +71,7 @@ function CheckboxAlone(props: CheckboxProps) {
7071

7172
function CheckboxInner(
7273
props: CheckboxProps & {
73-
inputRef: React.RefObject<HTMLInputElement | null>;
74+
inputRef: RefObject<HTMLInputElement | null>;
7475
inputProps: InputHTMLAttributes<HTMLInputElement>;
7576
}
7677
) {

design-system/pkg/src/combobox/Combobox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useComboBoxState } from '@react-stately/combobox';
1010
import { AriaButtonProps } from '@react-types/button';
1111
import { LoadingState } from '@react-types/shared';
1212
import React, {
13+
CSSProperties,
1314
ForwardedRef,
1415
InputHTMLAttributes,
1516
ReactElement,
@@ -235,7 +236,7 @@ interface ComboboxInputProps<T> extends ComboboxProps<T> {
235236
inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement | null>;
236237
triggerProps: AriaButtonProps;
237238
triggerRef: RefObject<HTMLButtonElement | null>;
238-
style?: React.CSSProperties;
239+
style?: CSSProperties;
239240
isOpen?: boolean;
240241
}
241242

design-system/pkg/src/combobox/MobileCombobox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ComboBoxState, useComboBoxState } from '@react-stately/combobox';
1111
import { AriaButtonProps } from '@react-types/button';
1212
import { ValidationState } from '@react-types/shared';
1313
import React, {
14+
CSSProperties,
1415
ForwardedRef,
1516
HTMLAttributes,
1617
KeyboardEvent,
@@ -136,7 +137,7 @@ interface ComboboxButtonProps extends AriaButtonProps {
136137
isReadOnly?: boolean;
137138
isDisabled?: boolean;
138139
isPlaceholder?: boolean;
139-
style?: React.CSSProperties;
140+
style?: CSSProperties;
140141
validationState?: ValidationState;
141142
}
142143

design-system/pkg/src/combobox/MobileComboboxMulti.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { mergeProps, useId, useObjectRef } from '@react-aria/utils';
99
import { AriaButtonProps } from '@react-types/button';
1010
import { ValidationState } from '@react-types/shared';
1111
import React, {
12+
CSSProperties,
1213
ForwardedRef,
1314
HTMLAttributes,
1415
KeyboardEvent,
@@ -133,7 +134,7 @@ interface ComboboxButtonProps extends AriaButtonProps {
133134
isReadOnly?: boolean;
134135
isDisabled?: boolean;
135136
isPlaceholder?: boolean;
136-
style?: React.CSSProperties;
137+
style?: CSSProperties;
137138
validationState?: ValidationState;
138139
}
139140

design-system/pkg/src/date-time/DatePickerPopover.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
DatePickerState,
55
DateRangePickerState,
66
} from '@react-stately/datepicker';
7-
import { ReactNode, useRef } from 'react';
7+
import { ReactNode, RefObject, useRef } from 'react';
88

99
import { Popover, Tray } from '@keystar/ui/overlays';
1010
import { css, tokenSchema, useIsMobileDevice } from '@keystar/ui/style';
@@ -17,7 +17,7 @@ export function DatePickerPopover({
1717
dialogProps: AriaDialogProps;
1818
shouldFlip?: boolean;
1919
state: DatePickerState | DateRangePickerState;
20-
triggerRef: React.RefObject<HTMLElement | null>;
20+
triggerRef: RefObject<HTMLElement | null>;
2121
}) {
2222
let scrollRef = useRef<HTMLDivElement>(null);
2323
let { direction } = useLocale();

design-system/pkg/src/list-view/ListViewItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { mergeProps } from '@react-aria/utils';
1616
import { useVisuallyHidden } from '@react-aria/visually-hidden';
1717
import { DropTarget, Node } from '@react-types/shared';
1818
import { assert } from 'emery';
19-
import React, { useRef } from 'react';
19+
import React, { HTMLAttributes, useRef } from 'react';
2020

2121
import { Checkbox } from '@keystar/ui/checkbox';
2222
import { KeystarProvider } from '@keystar/ui/core';
@@ -355,7 +355,7 @@ export function ListViewItem<T>(props: ListViewItemProps<T>) {
355355
{!isDisabled && (
356356
<FocusRing>
357357
<div
358-
{...(buttonProps as React.HTMLAttributes<HTMLElement>)}
358+
{...(buttonProps as HTMLAttributes<HTMLElement>)}
359359
className={classNames(
360360
listViewItemClassList.element('draghandle'),
361361
css({

design-system/pkg/src/number-field/test/NumberField.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { RefObject } from 'react';
22
import { expect, it, describe, afterEach, jest } from '@jest/globals';
33
import { firePress, renderWithProvider } from '#test-utils';
44
import userEvent from '@testing-library/user-event';
@@ -9,7 +9,7 @@ let testId = 'test-id';
99

1010
function renderNumberField(
1111
props: Partial<NumberFieldProps> = {},
12-
ref?: React.RefObject<HTMLInputElement | null>
12+
ref?: RefObject<HTMLInputElement | null>
1313
) {
1414
let user = userEvent.setup();
1515
let result = renderWithProvider(

0 commit comments

Comments
 (0)