Skip to content

Commit

Permalink
Merge pull request #2014 from robintown/display-name-lints
Browse files Browse the repository at this point in the history
Ensure that all our components have display names
  • Loading branch information
robintown authored Jan 3, 2024
2 parents f25f577 + d95336a commit 76d3658
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = {
"These components are easy to misuse, please use the 'subscribe' component wrapper instead",
},
],
"react/display-name": "error",
},
settings: {
react: {
Expand Down
4 changes: 4 additions & 0 deletions src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
},
);

Tooltip.displayName = "Tooltip";

interface TooltipTriggerProps {
children: ReactElement;
placement?: Placement;
Expand Down Expand Up @@ -112,3 +114,5 @@ export const TooltipTrigger = forwardRef<HTMLElement, TooltipTriggerProps>(
);
},
);

TooltipTrigger.displayName = "TooltipTrigger";
3 changes: 3 additions & 0 deletions src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ interface Props {
// TODO: add all props for <Button>
[index: string]: unknown;
}

export const Button = forwardRef<HTMLButtonElement, Props>(
(
{
Expand Down Expand Up @@ -135,6 +136,8 @@ export const Button = forwardRef<HTMLButtonElement, Props>(
},
);

Button.displayName = "Button";

export const MicButton: FC<{
muted: boolean;
// TODO: add all props for <Button>
Expand Down
2 changes: 2 additions & 0 deletions src/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ export const Form = forwardRef<HTMLFormElement, FormProps>(
);
},
);

Form.displayName = "Form";
2 changes: 2 additions & 0 deletions src/input/AvatarInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@ export const AvatarInputField = forwardRef<HTMLInputElement, Props>(
);
},
);

AvatarInputField.displayName = "AvatarInputField";
2 changes: 2 additions & 0 deletions src/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export const InputField = forwardRef<
},
);

InputField.displayName = "InputField";

interface ErrorMessageProps {
error: Error;
}
Expand Down
2 changes: 2 additions & 0 deletions src/popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ export const Popover = forwardRef<HTMLDivElement, Props>(
);
},
);

Popover.displayName = "Popover";
2 changes: 2 additions & 0 deletions src/popover/PopoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ export const PopoverMenuTrigger = forwardRef<
</div>
);
});

PopoverMenuTrigger.displayName = "PopoverMenuTrigger";
15 changes: 15 additions & 0 deletions src/typography/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export const Headline = forwardRef<HTMLHeadingElement, TypographyProps>(
},
);

Headline.displayName = "Headline";

export const Title = forwardRef<HTMLHeadingElement, TypographyProps>(
(
{
Expand Down Expand Up @@ -85,6 +87,8 @@ export const Title = forwardRef<HTMLHeadingElement, TypographyProps>(
},
);

Title.displayName = "Title";

export const Subtitle = forwardRef<HTMLParagraphElement, TypographyProps>(
(
{
Expand Down Expand Up @@ -113,6 +117,8 @@ export const Subtitle = forwardRef<HTMLParagraphElement, TypographyProps>(
},
);

Subtitle.displayName = "Subtitle";

export const Body = forwardRef<HTMLParagraphElement, TypographyProps>(
(
{
Expand Down Expand Up @@ -141,6 +147,8 @@ export const Body = forwardRef<HTMLParagraphElement, TypographyProps>(
},
);

Body.displayName = "Body";

export const Caption = forwardRef<HTMLParagraphElement, TypographyProps>(
(
{
Expand Down Expand Up @@ -170,6 +178,8 @@ export const Caption = forwardRef<HTMLParagraphElement, TypographyProps>(
},
);

Caption.displayName = "Caption";

export const Micro = forwardRef<HTMLParagraphElement, TypographyProps>(
(
{
Expand Down Expand Up @@ -199,11 +209,14 @@ export const Micro = forwardRef<HTMLParagraphElement, TypographyProps>(
},
);

Micro.displayName = "Micro";

interface LinkProps extends TypographyProps {
to?: H.LocationDescriptor<unknown>;
color?: string;
href?: string;
}

export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
(
{
Expand Down Expand Up @@ -254,3 +267,5 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
);
},
);

Link.displayName = "Link";
2 changes: 2 additions & 0 deletions src/video-grid/BigGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
* tile, this returns the index of the specific cell in which that position
Expand Down
26 changes: 15 additions & 11 deletions src/video-grid/TileWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ interface Props<T> {
children: (props: ChildrenProperties<T>) => ReactNode;
}

/**
* A wrapper around a tile in a video grid. This component exists to decouple
* child components from the grid.
*/
export const TileWrapper = memo(
({
const TileWrapper_ = memo(
<T,>({
id,
onDragRef,
targetWidth,
Expand All @@ -64,7 +60,7 @@ export const TileWrapper = memo(
width,
height,
children,
}) => {
}: Props<T>) => {
const ref = useRef<HTMLElement | null>(null);

useDrag((state) => onDragRef?.current!(id, state), {
Expand Down Expand Up @@ -97,7 +93,15 @@ export const TileWrapper = memo(
</>
);
},
// We pretend this component is a simple function rather than a
// NamedExoticComponent, because that's the only way we can fit in a type
// parameter
) as <T>(props: Props<T>) => JSX.Element;
);

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
// NamedExoticComponent, because that's the only way we can fit in a type
// parameter
export const TileWrapper = TileWrapper_ as <T>(props: Props<T>) => JSX.Element;
2 changes: 2 additions & 0 deletions src/video-grid/VideoTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,5 @@ export const VideoTile = forwardRef<HTMLDivElement, Props>(
);
},
);

VideoTile.displayName = "VideoTile";

0 comments on commit 76d3658

Please sign in to comment.