Skip to content

Commit

Permalink
fix: avoid PropTypes.any and PropTypes.object where relevant along wi…
Browse files Browse the repository at this point in the history
…th other eslint fixes (#1121)

* fix: avoid PropTypes.any and PropTypes.object where relevant along with other eslint fixes

* fix: card header title optional
  • Loading branch information
adamstankiewicz authored Mar 2, 2022
1 parent 42e2400 commit 3d3d8a2
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 45 deletions.
8 changes: 4 additions & 4 deletions src/Card/CardHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ const CardHeader = React.forwardRef(({
{title && <div className={`pgn__card-header-title-${size}`}>{title}</div>}
{subtitle && <div className={`pgn__card-header-subtitle-${size}`}>{subtitle}</div>}
</div>
{actions
&& (
{actions && (
<div className="pgn__card-header-actions">
{size !== 'md' ? cloneActions(actions) : actions}
</div>
)}
)}
</div>
);
});
Expand All @@ -49,7 +48,7 @@ CardHeader.propTypes = {
/** The class name for the CardHeader component */
className: PropTypes.string,
/** The title for the CardHeader component */
title: PropTypes.node.isRequired,
title: PropTypes.node,
/** The size of the CardHeader component */
size: PropTypes.oneOf(['sm', 'md']),
/** The subtitle of the CardHeader component */
Expand All @@ -60,6 +59,7 @@ CardHeader.defaultProps = {
actions: null,
className: null,
size: 'md',
title: null,
subtitle: null,
};

Expand Down
6 changes: 3 additions & 3 deletions src/DataTable/CollapsibleButtonGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ CollapsibleButtonGroup.defaultProps = {
};

CollapsibleButtonGroup.propTypes = {
/** class names for the div wrapping the button components */
/** Class names for the div wrapping the button components */
className: PropTypes.string,
/** Array of action objects, containing a component and their callback args */
actions: PropTypes.arrayOf(PropTypes.shape({
component: PropTypes.oneOfType([PropTypes.func, PropTypes.element]).isRequired,
// eslint-disable-next-line react/forbid-prop-types
args: PropTypes.object,
args: PropTypes.shape({}),
})).isRequired,
};

Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/filters/CheckboxFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CheckboxFilter.propTypes = {
number: PropTypes.number,
})).isRequired,
getHeaderProps: PropTypes.func.isRequired,
filterValue: PropTypes.arrayOf(PropTypes.any),
filterValue: PropTypes.string,
}).isRequired,
};

Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/filters/MultiSelectDropdownFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ MultiSelectDropdownFilter.propTypes = {
})).isRequired,
/** Generates a key unique to the column being filtered */
getHeaderProps: PropTypes.func.isRequired,
filterValue: PropTypes.arrayOf([PropTypes.number, PropTypes.string]),
filterValue: PropTypes.string,
}).isRequired,
};

Expand Down
5 changes: 4 additions & 1 deletion src/Icon/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ Icon.propTypes = {
/** An icon component to render. Example import of a Paragon icon component: `import { Check } from '@edx/paragon/dist/icon';` */
src: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
/** HTML element attributes to pass through to the underlying svg element */
svgAttrs: PropTypes.object, // eslint-disable-line
svgAttrs: PropTypes.shape({
'aria-label': PropTypes.string,
'aria-labelledby': PropTypes.string,
}),
// eslint-disable-next-line max-len
/** the `id` property of the Icon element, by default this value is generated with the `newId` function with the `prefix` of `Icon`. */
id: PropTypes.string,
Expand Down
2 changes: 1 addition & 1 deletion src/InputSelect/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Select.propTypes = {
]),
options: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.string),
PropTypes.arrayOf(PropTypes.object),
PropTypes.arrayOf(PropTypes.shape({})),
]).isRequired,
};

Expand Down
2 changes: 1 addition & 1 deletion src/Modal/ModalDialogHeroBackground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ModalDialogHeroBackground.propTypes = {
backgroundSrc: PropTypes.string,
children: PropTypes.node,
className: PropTypes.string,
style: PropTypes.object, // eslint-disable-line
style: PropTypes.shape({}),
};

ModalDialogHeroBackground.defaultProps = {
Expand Down
7 changes: 4 additions & 3 deletions src/Modal/PopperElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const PopperElement = ({

PopperElement.propTypes = {
children: PropTypes.node,
// eslint-disable-next-line react/forbid-prop-types
target: PropTypes.object.isRequired,
target: PropTypes.shape({
current: PropTypes.node,
}).isRequired,
strategy: PropTypes.oneOf(['absolute', 'fixed']),
placement: PropTypes.oneOf([
'auto',
Expand All @@ -41,7 +42,7 @@ PopperElement.propTypes = {
'left-start',
'left-end',
]),
modifiers: PropTypes.arrayOf(PropTypes.object),
modifiers: PropTypes.arrayOf(PropTypes.shape({})),
};

PopperElement.defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/Modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Modal.propTypes = {
/** an array of either elements or shapes that take the form of the buttonPropTypes. See the [buttonPropTypes](https://github.com/edx/paragon/blob/master/src/Button/index.jsx#L40) for a list of acceptable props to pass as part of a button. */
buttons: PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.element,
PropTypes.object, // TODO: Only accept nodes in the future
PropTypes.shape({}), // TODO: Only accept nodes in the future
])),
/** specifies the display text of the default Close button. It defaults to "Close". */
closeText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
Expand Down
8 changes: 3 additions & 5 deletions src/Overlay/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ Overlay.propTypes = {
/** The placement of the `Overlay` in relation to it's target. */
placement: PropTypes.oneOf(PLACEMENT_VARIANTS),
/** A set of popper options and props passed directly to `Popper`. */
// eslint-disable-next-line react/forbid-prop-types
popperConfig: PropTypes.object,
popperConfig: PropTypes.shape({}),
/** Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay. */
rootClose: PropTypes.bool,
/** Specify event for triggering a “root close” toggle. */
Expand Down Expand Up @@ -97,7 +96,7 @@ OverlayTrigger.propTypes = {
/** The initial visibility state of the `Overlay`. */
defaultShow: PropTypes.bool,
/** A millisecond delay amount to show and hide the `Overlay` once triggered. */
delay: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
delay: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({})]),
/** The initial flip state of the `Overlay`. */
flip: PropTypes.bool,
onHide: PropTypes.instanceOf(null),
Expand All @@ -112,8 +111,7 @@ OverlayTrigger.propTypes = {
/** The placement of the `Overlay` in relation to it's target. */
placement: PropTypes.oneOf(PLACEMENT_VARIANTS),
/** A `Popper.js` config object passed to the the underlying popper instance. */
// eslint-disable-next-line react/forbid-prop-types
popperConfig: PropTypes.object,
popperConfig: PropTypes.shape({}),
/**
* The visibility of the `Overlay`. `show` is a controlled prop so should
* be paired with `onToggle` to avoid breaking user interactions.
Expand Down
5 changes: 2 additions & 3 deletions src/Popover/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ WrapperPopover.propTypes = {
PropTypes.func,
PropTypes.shape({ current: PropTypes.element }),
]),
style: PropTypes.object, // eslint-disable-line
style: PropTypes.shape({}),
}),
/**
* When this prop is set, it creates a `Popover` with
* a `Popover.Content` inside passing the children directly to it.
*/
content: PropTypes.bool,
/** A `Popper.js` config object passed to the the underlying popper instance. */
// eslint-disable-next-line react/forbid-prop-types
popper: PropTypes.any,
popper: PropTypes.shape({}),
/** Whether the `Overlay` is shown. */
show: PropTypes.bool,
/** Specifies the content of the `Overlay` */
Expand Down
6 changes: 4 additions & 2 deletions src/SearchField/SearchFieldClearButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ const SearchFieldClearButton = (props) => {
}

const handleClick = () => {
refs.input.current?.focus();
if (refs.input.current) {
refs.input.current.focus();
}
};

return (
// eslint-disable-next-line react/button-has-type
<button type="reset" className="btn" {...props} disabled={disabled} onClick={handleClick}>
<button type="reset" className="btn" disabled={disabled} onClick={handleClick} {...props}>
{icons.clear}
<span className="sr-only">{screenReaderText.clearButton}</span>
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/Table/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Table.propTypes = {
6. `width` (string; conditionally required) only if `hasFixedColumnWidths` is set to `true`, the `<td>` elements' `class` attributes will be set to this value. This allows restricting columns to specific widths. See [Bootstrap's grid documentation](https://getbootstrap.com/docs/4.0/layout/grid/) for `col` class names that can be used.
The order of objects in `columns` specifies the order of the columns in the table. */
data: PropTypes.arrayOf(PropTypes.object).isRequired,
data: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
/** specifies the order and contents of the table's columns and provides display strings for each column's heading. It is composed of an ordered array of objects. Each object contains the following keys:
1. `label` (string or element; required) contains the display string for each column's heading.
Expand Down
4 changes: 2 additions & 2 deletions src/Tooltip/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ Tooltip.propTypes = {
PropTypes.func,
PropTypes.shape({ current: PropTypes.element }),
]),
style: PropTypes.object, // eslint-disable-line
style: PropTypes.shape({}),
}),
/** Whether the `Overlay` is shown. */
show: PropTypes.bool,
/** A `Popper.js` config object passed to the the underlying popper instance. */
popper: PropTypes.any, // eslint-disable-line
popper: PropTypes.shape({}),
/** Overrides underlying component base CSS class name */
bsPrefix: PropTypes.string,
/** Specifies the content of the `Tooltip` */
Expand Down
10 changes: 4 additions & 6 deletions src/TransitionReplace/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,11 @@ TransitionReplace.propTypes = {
*/
onChildExited: PropTypes.func,
/** An object that specifies transition styles. */
/* eslint-disable react/forbid-prop-types */
transitionStyles: PropTypes.shape({
entering: PropTypes.object,
entered: PropTypes.object,
exiting: PropTypes.object,
exited: PropTypes.object,
/* eslint-enable react/forbid-prop-types */
entering: PropTypes.shape({}),
entered: PropTypes.shape({}),
exiting: PropTypes.shape({}),
exited: PropTypes.shape({}),
}),
/** Specifies class name to append to the `Transition`. */
transitionClassNames: PropTypes.string,
Expand Down
8 changes: 4 additions & 4 deletions www/src/components/PropType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const PropTypeArrayOf = ({ value, isRequired }) => (

PropTypeArrayOf.propTypes = {
isRequired: PropTypes.bool,
value: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
value: PropTypes.shape({}).isRequired,
};

PropTypeArrayOf.defaultProps = {
Expand All @@ -123,7 +123,7 @@ const PropTypeObjectOf = ({ value, isRequired }) => (

PropTypeObjectOf.propTypes = {
isRequired: PropTypes.bool,
value: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
value: PropTypes.shape({}).isRequired,
};

PropTypeObjectOf.defaultProps = {
Expand All @@ -147,7 +147,7 @@ const PropTypeShape = ({ name, value, isRequired }) => (
PropTypeShape.propTypes = {
isRequired: PropTypes.bool,
name: PropTypes.string.isRequired,
value: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
value: PropTypes.shape({}).isRequired,
};

PropTypeShape.defaultProps = {
Expand All @@ -171,7 +171,7 @@ const PropTypeExact = ({ name, value, isRequired }) => (
PropTypeExact.propTypes = {
isRequired: PropTypes.bool,
name: PropTypes.string.isRequired,
value: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
value: PropTypes.shape({}).isRequired,
};

PropTypeExact.defaultProps = {
Expand Down
8 changes: 4 additions & 4 deletions www/src/components/PropsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ const Prop = ({

Prop.propTypes = {
name: PropTypes.string.isRequired,
type: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
type: PropTypes.shape({}).isRequired,
required: PropTypes.bool,
defaultValue: PropTypes.object, // eslint-disable-line react/forbid-prop-types
defaultValue: PropTypes.shape({}), // eslint-disable-line react/forbid-prop-types
description: PropTypes.shape({
childMdx: PropTypes.object, // eslint-disable-line react/forbid-prop-types
childMdx: PropTypes.shape({}), // eslint-disable-line react/forbid-prop-types
}),
};
Prop.defaultProps = {
Expand All @@ -76,7 +76,7 @@ const PropsTable = ({ props: componentProps, displayName, content }) => (
);

PropsTable.propTypes = {
props: PropTypes.arrayOf(PropTypes.object),
props: PropTypes.arrayOf(PropTypes.shape({})),
content: PropTypes.string,
displayName: PropTypes.string,
};
Expand Down
2 changes: 1 addition & 1 deletion www/src/components/SEO.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SEO.defaultProps = {
SEO.propTypes = {
description: PropTypes.string,
lang: PropTypes.string,
meta: PropTypes.arrayOf(PropTypes.object),
meta: PropTypes.arrayOf(PropTypes.shape({})),
title: PropTypes.string.isRequired,
};

Expand Down
2 changes: 1 addition & 1 deletion www/src/templates/component-page-template.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ PageTemplate.propTypes = {
body: PropTypes.any, // eslint-disable-line react/forbid-prop-types
}),
components: PropTypes.shape({
nodes: PropTypes.arrayOf(PropTypes.object),
nodes: PropTypes.arrayOf(PropTypes.shape({})),
}),
}).isRequired,
pageContext: PropTypes.shape({
Expand Down

0 comments on commit 3d3d8a2

Please sign in to comment.