Skip to content

Commit

Permalink
LG-1318: Remove prop-types from LeafyGreen (#2619)
Browse files Browse the repository at this point in the history
* beginning to remove prop types

* major change, ensure that props are exported

* fix build issues

* turn off react/prop-types rule

* rm file
  • Loading branch information
bruugey authored Jan 7, 2025
1 parent f5d8427 commit 274d7e1
Show file tree
Hide file tree
Showing 309 changed files with 251 additions and 2,411 deletions.
60 changes: 60 additions & 0 deletions .changeset/lucky-berries-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
'@lg-chat/leafygreen-chat-provider': major
'@leafygreen-ui/leafygreen-provider': major
'@leafygreen-ui/confirmation-modal': major
'@leafygreen-ui/inline-definition': major
'@leafygreen-ui/loading-indicator': major
'@leafygreen-ui/segmented-control': major
'@leafygreen-ui/marketing-modal': major
'@leafygreen-ui/radio-box-group': major
'@leafygreen-ui/password-input': major
'@leafygreen-ui/info-sprinkle': major
'@leafygreen-ui/number-input': major
'@leafygreen-ui/ordered-list': major
'@leafygreen-ui/split-button': major
'@lg-chat/message-prompts': major
'@leafygreen-ui/date-picker': major
'@leafygreen-ui/empty-state': major
'@leafygreen-ui/form-footer': major
'@leafygreen-ui/icon-button': major
'@leafygreen-ui/radio-group': major
'@leafygreen-ui/pagination': major
'@leafygreen-ui/text-input': major
'@leafygreen-ui/typography': major
'@leafygreen-ui/guide-cue': major
'@leafygreen-ui/text-area': major
'@lg-chat/message-feed': major
'@leafygreen-ui/checkbox': major
'@leafygreen-ui/combobox': major
'@leafygreen-ui/copyable': major
'@leafygreen-ui/pipeline': major
'@leafygreen-ui/side-nav': major
'@leafygreen-ui/callout': major
'@leafygreen-ui/popover': major
'@leafygreen-ui/stepper': major
'@leafygreen-ui/tooltip': major
'@leafygreen-ui/banner': major
'@leafygreen-ui/button': major
'@leafygreen-ui/portal': major
'@leafygreen-ui/select': major
'@leafygreen-ui/toggle': major
'@leafygreen-ui/badge': major
'@leafygreen-ui/modal': major
'@leafygreen-ui/table': major
'@leafygreen-ui/toast': major
'@leafygreen-ui/a11y': major
'@leafygreen-ui/card': major
'@leafygreen-ui/chip': major
'@leafygreen-ui/code': major
'@leafygreen-ui/icon': major
'@leafygreen-ui/logo': major
'@leafygreen-ui/menu': major
'@leafygreen-ui/tabs': major
'@leafygreen-ui/box': major
'@leafygreen-ui/lib': major
'@lg-tools/lint': major
'@lg-tools/validate': minor
'@lg-tools/build': minor
---

Removes prop-types from LeafyGreen UI
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React, { useState } from 'react';
import {
storybookArgTypes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { createContext, useContext, useState } from 'react';
import PropTypes from 'prop-types';
import useResizeObserver from 'use-resize-observer';

import { LeafyGreenChatContextProps } from './LeafyGreenChatProvider.types';
Expand Down Expand Up @@ -35,7 +34,3 @@ export function LeafyGreenChatProvider({
}

LeafyGreenChatProvider.displayName = 'LeafyGreenChatProvider';

LeafyGreenChatProvider.propTypes = {
children: PropTypes.node,
};
1 change: 0 additions & 1 deletion chat/message-feed/src/MessageFeed.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React, { ChangeEvent, useState } from 'react';
import { Avatar } from '@lg-chat/avatar';
import { DisclaimerText } from '@lg-chat/chat-disclaimer';
Expand Down
5 changes: 0 additions & 5 deletions chat/message-feed/src/MessageFeed/MessageFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { ForwardedRef, forwardRef, useEffect, useRef } from 'react';
import flattenChildren from 'react-keyed-flatten-children';
import { useLeafyGreenChatContext } from '@lg-chat/leafygreen-chat-provider';
import PropTypes from 'prop-types';

import { cx } from '@leafygreen-ui/emotion';
import LeafyGreenProvider, {
Expand Down Expand Up @@ -82,7 +81,3 @@ export const MessageFeed = forwardRef(
);

MessageFeed.displayName = 'MessageFeed';

MessageFeed.propTypes = {
darkMode: PropTypes.bool,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { createContext, PropsWithChildren, useContext } from 'react';
import PropTypes from 'prop-types';

import { MessagePromptsContextProps } from './MessagePromptsContext.types';

Expand All @@ -24,7 +23,3 @@ export function MessagePromptsProvider({
}

MessagePromptsProvider.displayName = 'MessagePromptsProvider';

MessagePromptsProvider.propTypes = {
children: PropTypes.node,
};
1 change: 0 additions & 1 deletion chat/message-rating/src/MessageRating.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const Template: StoryFn<typeof MessageRating> = props => (
export const Basic: StoryFn<typeof MessageRating> = Template.bind({});

export const Controlled: StoryFn<typeof MessageRating> = ({
// eslint-disable-next-line react/prop-types
value: valueProp,
...rest
}) => {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"dotenv": "^10.0.0",
"gh-pages": "^3.1.0",
"npm-run-all": "^4.1.5",
"prop-types": "^15.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "^7.6.17",
Expand Down
6 changes: 0 additions & 6 deletions packages/a11y/src/VisuallyHidden.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import { css, cx } from '@leafygreen-ui/emotion';
import { HTMLElementProps } from '@leafygreen-ui/lib';
Expand Down Expand Up @@ -29,9 +28,4 @@ function VisuallyHidden({

VisuallyHidden.displayName = 'VisuallyHidden';

VisuallyHidden.propTypes = {
children: PropTypes.string,
className: PropTypes.string,
};

export default VisuallyHidden;
8 changes: 0 additions & 8 deletions packages/badge/src/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import { cx } from '@leafygreen-ui/emotion';
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
Expand Down Expand Up @@ -30,11 +29,4 @@ function Badge({

Badge.displayName = 'Badge';

Badge.propTypes = {
darkMode: PropTypes.bool,
className: PropTypes.string,
children: PropTypes.node,
variant: PropTypes.oneOf(Object.values(Variant)),
};

export default Badge;
1 change: 0 additions & 1 deletion packages/banner/src/Banner.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable react/jsx-key */
import React from 'react';
Expand Down
10 changes: 0 additions & 10 deletions packages/banner/src/Banner/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';

import { cx } from '@leafygreen-ui/emotion';
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
Expand Down Expand Up @@ -88,12 +87,3 @@ const Banner = forwardRef<HTMLDivElement, BannerProps>(
export default Banner;

Banner.displayName = 'Banner';

Banner.propTypes = {
darkMode: PropTypes.bool,
variant: PropTypes.oneOf(Object.values(Variant)),
onClose: PropTypes.func,
dismissible: PropTypes.bool,
image: PropTypes.element,
baseFontSize: PropTypes.oneOf(Object.values(BaseFontSize)),
};
1 change: 0 additions & 1 deletion packages/box/src/Box.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const meta: StoryMetaType<typeof Box, BoxProps> = {
};
export default meta;

// eslint-disable-next-line react/prop-types
const Template: StoryFn<BoxProps> = ({ as, ...args }: BoxProps) => (
<Box as={(as ? as : 'div') as keyof JSX.IntrinsicElements} {...args} />
);
Expand Down
11 changes: 0 additions & 11 deletions packages/box/src/Box.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

type Override<T, U> = Omit<T, keyof U> & U;
type Override2<T, U, V> = Override<Override<T, U>, V>;
Expand Down Expand Up @@ -99,16 +98,6 @@ const Box = React.forwardRef(InlineBox) as typeof InlineBox;

Box.displayName = 'Box';

// @ts-expect-error
Box.propTypes = {
as: PropTypes.oneOfType([
PropTypes.elementType,
PropTypes.element,
PropTypes.func,
]),
href: PropTypes.string,
};

export default Box;

export interface ExtendableBox<
Expand Down
2 changes: 0 additions & 2 deletions packages/button/src/Button/Button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ describe('packages/button', () => {
});

test(`renders a when passing in a NextJS Link wrapper`, () => {
// eslint-disable-next-line react/prop-types
const Linker = ({ href, children, ...props }: any) => (
<NextLink href={href} {...props}>
{children}
Expand All @@ -165,7 +164,6 @@ describe('packages/button', () => {
});

test(`renders a when passing in a legacy NextJS Link wrapper`, () => {
// eslint-disable-next-line react/prop-types
const Linker = ({ href, children, ...props }: any) => (
<NextLink legacyBehavior href={href}>
<a {...props}>{children}</a>
Expand Down
15 changes: 0 additions & 15 deletions packages/button/src/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import Box, { BoxProps } from '@leafygreen-ui/box';
import { cx } from '@leafygreen-ui/emotion';
Expand Down Expand Up @@ -87,17 +86,3 @@ export const Button = React.forwardRef(function Button(
});

Button.displayName = 'Button';

Button.propTypes = {
variant: PropTypes.oneOf(Object.values(Variant)),
baseFontSize: PropTypes.oneOf(Object.values(BaseFontSize)),
size: PropTypes.oneOf(Object.values(Size)),
darkMode: PropTypes.bool,
disabled: PropTypes.bool,
leftGlyph: PropTypes.element,
rightGlyph: PropTypes.element,
href: PropTypes.string,
isLoading: PropTypes.bool,
loadingText: PropTypes.string,
loadingIndicator: PropTypes.element,
};
1 change: 0 additions & 1 deletion packages/callout/src/Callout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ LiveExample.parameters = {
};

export const WithRichContent: StoryFn<CalloutProps> = ({
// eslint-disable-next-line react/prop-types
darkMode,
...args
}) => {
Expand Down
10 changes: 0 additions & 10 deletions packages/callout/src/Callout/Callout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import { cx } from '@leafygreen-ui/emotion';
import LeafyGreenProvider, {
Expand Down Expand Up @@ -63,13 +62,4 @@ function Callout({
);
}

Callout.propTypes = {
darkMode: PropTypes.bool,
variant: PropTypes.oneOf(Object.values(Variant)).isRequired,
title: PropTypes.string,
children: PropTypes.node.isRequired,
className: PropTypes.string,
baseFontSize: PropTypes.oneOf(Object.values(BaseFontSize)),
};

export default Callout;
1 change: 0 additions & 1 deletion packages/card/src/Card.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint react/prop-types: 0 */
import React from 'react';
import { storybookArgTypes, StoryMetaType } from '@lg-tools/storybook-utils';
import { StoryFn } from '@storybook/react';
Expand Down
7 changes: 0 additions & 7 deletions packages/card/src/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import { cx } from '@leafygreen-ui/emotion';
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
Expand Down Expand Up @@ -57,9 +56,3 @@ export const Card = InferredPolymorphic<CardProps, 'div'>(
);

Card.displayName = 'Card';

Card.propTypes = {
className: PropTypes.string,
darkMode: PropTypes.bool,
contentStyle: PropTypes.oneOf(Object.values(ContentStyle)),
};
14 changes: 0 additions & 14 deletions packages/checkbox/src/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';

import { css, cx } from '@leafygreen-ui/emotion';
import { useIdAllocator } from '@leafygreen-ui/hooks';
Expand Down Expand Up @@ -180,17 +179,4 @@ function Checkbox({

Checkbox.displayName = 'Checkbox';

Checkbox.propTypes = {
darkMode: PropTypes.bool,
description: PropTypes.string,
checked: PropTypes.bool,
label: PropTypes.node,
disabled: PropTypes.bool,
indeterminate: PropTypes.bool,
className: PropTypes.string,
onChange: PropTypes.func,
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
animate: PropTypes.bool,
};

export default Checkbox;
1 change: 0 additions & 1 deletion packages/chip/src/Chip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ Truncate.parameters = {
},
};

// eslint-disable-next-line react/prop-types
export const LiveExample: StoryType<typeof Chip> = ({ glyph, ...rest }) => (
<Chip // @ts-expect-error - glyph type error
glyph={glyph ? <Icon glyph={glyph} /> : undefined}
Expand Down
12 changes: 0 additions & 12 deletions packages/chip/src/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';

import { cx } from '@leafygreen-ui/emotion';
import InlineDefinition from '@leafygreen-ui/inline-definition';
Expand Down Expand Up @@ -105,14 +104,3 @@ export const Chip = React.forwardRef<HTMLSpanElement, ChipProps>(
},
);
Chip.displayName = 'Chip';

Chip.propTypes = {
glyph: PropTypes.node,
label: PropTypes.string.isRequired,
chipCharacterLimit: PropTypes.number,
chipTruncationLocation: PropTypes.oneOf(Object.values(TruncationLocation)),
baseFontSize: PropTypes.oneOf(Object.values(BaseFontSize)),
variant: PropTypes.oneOf(Object.values(Variant)),
onDismiss: PropTypes.func,
dismissButtonAriaLabel: PropTypes.string,
} as any; // avoid inferred types from interfering;
21 changes: 0 additions & 21 deletions packages/code/src/Code/Code.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import ClipboardJS from 'clipboard';
import debounce from 'lodash/debounce';
import PropTypes from 'prop-types';

import { cx } from '@leafygreen-ui/emotion';
import { useIsomorphicLayoutEffect } from '@leafygreen-ui/hooks';
Expand Down Expand Up @@ -294,24 +293,4 @@ function Code({

Code.displayName = 'Code';

Code.propTypes = {
children: PropTypes.string.isRequired,
language: PropTypes.oneOfType([
PropTypes.oneOf(Object.values(Language)),
PropTypes.string,
]),
darkMode: PropTypes.bool,
className: PropTypes.string,
showLineNumbers: PropTypes.bool,
lineNumberStart: PropTypes.number,
showWindowChrome: PropTypes.bool,
chromeTitle: PropTypes.string,
highlightLines: PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.number),
PropTypes.number,
]),
),
};

export default Code;
Loading

0 comments on commit 274d7e1

Please sign in to comment.