Merge pull request #2014 from robintown/display-name-lints

Ensure that all our components have display names
This commit is contained in:
Robin
2024-01-03 12:09:47 -05:00
committed by GitHub
12 changed files with 52 additions and 11 deletions

View File

@@ -47,6 +47,7 @@ module.exports = {
"These components are easy to misuse, please use the 'subscribe' component wrapper instead", "These components are easy to misuse, please use the 'subscribe' component wrapper instead",
}, },
], ],
"react/display-name": "error",
}, },
settings: { settings: {
react: { react: {

View File

@@ -59,6 +59,8 @@ const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
}, },
); );
Tooltip.displayName = "Tooltip";
interface TooltipTriggerProps { interface TooltipTriggerProps {
children: ReactElement; children: ReactElement;
placement?: Placement; placement?: Placement;
@@ -112,3 +114,5 @@ export const TooltipTrigger = forwardRef<HTMLElement, TooltipTriggerProps>(
); );
}, },
); );
TooltipTrigger.displayName = "TooltipTrigger";

View File

@@ -80,6 +80,7 @@ interface Props {
// TODO: add all props for <Button> // TODO: add all props for <Button>
[index: string]: unknown; [index: string]: unknown;
} }
export const Button = forwardRef<HTMLButtonElement, Props>( export const Button = forwardRef<HTMLButtonElement, Props>(
( (
{ {
@@ -135,6 +136,8 @@ export const Button = forwardRef<HTMLButtonElement, Props>(
}, },
); );
Button.displayName = "Button";
export const MicButton: FC<{ export const MicButton: FC<{
muted: boolean; muted: boolean;
// TODO: add all props for <Button> // TODO: add all props for <Button>

View File

@@ -38,3 +38,5 @@ export const Form = forwardRef<HTMLFormElement, FormProps>(
); );
}, },
); );
Form.displayName = "Form";

View File

@@ -122,3 +122,5 @@ export const AvatarInputField = forwardRef<HTMLInputElement, Props>(
); );
}, },
); );
AvatarInputField.displayName = "AvatarInputField";

View File

@@ -166,6 +166,8 @@ export const InputField = forwardRef<
}, },
); );
InputField.displayName = "InputField";
interface ErrorMessageProps { interface ErrorMessageProps {
error: Error; error: Error;
} }

View File

@@ -58,3 +58,5 @@ export const Popover = forwardRef<HTMLDivElement, Props>(
); );
}, },
); );
Popover.displayName = "Popover";

View File

@@ -94,3 +94,5 @@ export const PopoverMenuTrigger = forwardRef<
</div> </div>
); );
}); });
PopoverMenuTrigger.displayName = "PopoverMenuTrigger";

View File

@@ -57,6 +57,8 @@ export const Headline = forwardRef<HTMLHeadingElement, TypographyProps>(
}, },
); );
Headline.displayName = "Headline";
export const Title = forwardRef<HTMLHeadingElement, TypographyProps>( export const Title = forwardRef<HTMLHeadingElement, TypographyProps>(
( (
{ {
@@ -85,6 +87,8 @@ export const Title = forwardRef<HTMLHeadingElement, TypographyProps>(
}, },
); );
Title.displayName = "Title";
export const Subtitle = forwardRef<HTMLParagraphElement, TypographyProps>( export const Subtitle = forwardRef<HTMLParagraphElement, TypographyProps>(
( (
{ {
@@ -113,6 +117,8 @@ export const Subtitle = forwardRef<HTMLParagraphElement, TypographyProps>(
}, },
); );
Subtitle.displayName = "Subtitle";
export const Body = forwardRef<HTMLParagraphElement, TypographyProps>( export const Body = forwardRef<HTMLParagraphElement, TypographyProps>(
( (
{ {
@@ -141,6 +147,8 @@ export const Body = forwardRef<HTMLParagraphElement, TypographyProps>(
}, },
); );
Body.displayName = "Body";
export const Caption = forwardRef<HTMLParagraphElement, TypographyProps>( export const Caption = forwardRef<HTMLParagraphElement, TypographyProps>(
( (
{ {
@@ -170,6 +178,8 @@ export const Caption = forwardRef<HTMLParagraphElement, TypographyProps>(
}, },
); );
Caption.displayName = "Caption";
export const Micro = forwardRef<HTMLParagraphElement, TypographyProps>( export const Micro = forwardRef<HTMLParagraphElement, TypographyProps>(
( (
{ {
@@ -199,11 +209,14 @@ export const Micro = forwardRef<HTMLParagraphElement, TypographyProps>(
}, },
); );
Micro.displayName = "Micro";
interface LinkProps extends TypographyProps { interface LinkProps extends TypographyProps {
to?: H.LocationDescriptor<unknown>; to?: H.LocationDescriptor<unknown>;
color?: string; color?: string;
href?: string; href?: string;
} }
export const Link = forwardRef<HTMLAnchorElement, LinkProps>( export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
( (
{ {
@@ -254,3 +267,5 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
); );
}, },
); );
Link.displayName = "Link";

View File

@@ -1010,6 +1010,8 @@ const Slots: FC<{ s: Grid }> = memo(({ s: g }) => {
); );
}); });
Slots.displayName = "Slots";
/** /**
* Given a tile and numbers in the range [0, 1) describing a position within the * Given a tile and numbers in the range [0, 1) describing a position within the
* tile, this returns the index of the specific cell in which that position * tile, this returns the index of the specific cell in which that position

View File

@@ -43,12 +43,8 @@ interface Props<T> {
children: (props: ChildrenProperties<T>) => ReactNode; children: (props: ChildrenProperties<T>) => ReactNode;
} }
/** const TileWrapper_ = memo(
* A wrapper around a tile in a video grid. This component exists to decouple <T,>({
* child components from the grid.
*/
export const TileWrapper = memo(
({
id, id,
onDragRef, onDragRef,
targetWidth, targetWidth,
@@ -64,7 +60,7 @@ export const TileWrapper = memo(
width, width,
height, height,
children, children,
}) => { }: Props<T>) => {
const ref = useRef<HTMLElement | null>(null); const ref = useRef<HTMLElement | null>(null);
useDrag((state) => onDragRef?.current!(id, state), { useDrag((state) => onDragRef?.current!(id, state), {
@@ -97,7 +93,15 @@ export const TileWrapper = memo(
</> </>
); );
}, },
);
TileWrapper_.displayName = "TileWrapper";
/**
* A wrapper around a tile in a video grid. This component exists to decouple
* child components from the grid.
*/
// We pretend this component is a simple function rather than a // We pretend this component is a simple function rather than a
// NamedExoticComponent, because that's the only way we can fit in a type // NamedExoticComponent, because that's the only way we can fit in a type
// parameter // parameter
) as <T>(props: Props<T>) => JSX.Element; export const TileWrapper = TileWrapper_ as <T>(props: Props<T>) => JSX.Element;

View File

@@ -281,3 +281,5 @@ export const VideoTile = forwardRef<HTMLDivElement, Props>(
); );
}, },
); );
VideoTile.displayName = "VideoTile";