Skip to content

Commit

Permalink
enable react/prop-types rule
Browse files Browse the repository at this point in the history
  • Loading branch information
sickelap committed Nov 5, 2023
1 parent fd18eca commit 3b3e0f3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
"no-param-reassign": "warn",
"import/prefer-default-export": "off",
"import/no-cycle": "warn",
"react/prop-types": "warn",
"react/jsx-props-no-spreading": "off", // some Mantine components need to use spread operator
"react-hooks/exhaustive-deps": "off", // at this stage it is too risky to enable this
"react/require-default-props": "warn",
Expand Down
21 changes: 20 additions & 1 deletion src/components/react-pig/components/GroupHeader/GroupHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import PropTypes from "prop-types";
import React from "react";

import styles from "./styles.module.css";

export default function ({ settings, group, activeTileUrl }) {
function GroupHeader({ settings, group, activeTileUrl }) {
return (
<header
className={styles.headerPositioner}
Expand All @@ -24,3 +25,21 @@ export default function ({ settings, group, activeTileUrl }) {
</header>
);
}

GroupHeader.propTypes = {
settings: PropTypes.shape({
gridGap: PropTypes.number,
bgColor: PropTypes.string,
thumbnailSize: PropTypes.number,
expandedSize: PropTypes.number,
}).isRequired,
group: PropTypes.shape({
groupTranslateY: PropTypes.number,
height: PropTypes.number,
location: PropTypes.string,
date: PropTypes.string,
}).isRequired,
activeTileUrl: PropTypes.string.isRequired,
};

export default GroupHeader;
40 changes: 40 additions & 0 deletions src/components/react-pig/components/Tile/Tile.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from "prop-types";
import React, { useState } from "react";
import { animated, useSpring } from "react-spring";

Expand Down Expand Up @@ -181,4 +182,43 @@ const Tile = React.memo(
}
);

const ItemType = PropTypes.shape({
id: PropTypes.string,
dominantColor: PropTypes.string,
isTemp: PropTypes.bool,
url: PropTypes.string,
type: PropTypes.string,
style: PropTypes.shape({
height: PropTypes.number,
width: PropTypes.number,
translateX: PropTypes.number,
translateY: PropTypes.number,
}),
});

const SettingsType = PropTypes.shape({
gridGap: PropTypes.number,
bgColor: PropTypes.string,
thumbnailSize: PropTypes.number,
expandedSize: PropTypes.number,
});

Tile.propTypes = {
item: ItemType.isRequired,
useLqip: PropTypes.bool.isRequired,
containerWidth: PropTypes.number.isRequired,
containerOffsetTop: PropTypes.number.isRequired,
getUrl: PropTypes.func.isRequired,
activeTileUrl: PropTypes.string.isRequired,
handleClick: PropTypes.func.isRequired,
handleSelection: PropTypes.func.isRequired,
selected: PropTypes.bool.isRequired,
selectable: PropTypes.bool.isRequired,
windowHeight: PropTypes.number.isRequired,
scrollSpeed: PropTypes.string.isRequired,
settings: SettingsType.isRequired,
toprightoverlay: PropTypes.func,
bottomleftoverlay: PropTypes.func,
};

export default Tile;
26 changes: 24 additions & 2 deletions src/components/react-pig/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,23 @@ Pig.defaultProps = {
groupGapLg: 50,
gridGap: 8,
bgColor: "#fff",
getUrl: null,
sortByDate: false,
sortFunc: null,
handleClick: null,
selectable: false,
handleSelection: null,
numberOfItems: null,
scaleOfImages: null,
updateGroups: null,
updateItems: null,
selectedItems: null,
toprightoverlay: null,
bottomleftoverlay: null,
};

Pig.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
imageData: PropTypes.array.isRequired,
imageData: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
useLqip: PropTypes.bool,
gridGap: PropTypes.number,
getUrl: PropTypes.func,
Expand All @@ -322,4 +334,14 @@ Pig.propTypes = {
expandedSize: PropTypes.number,
thumbnailSize: PropTypes.number,
bgColor: PropTypes.string,
handleClick: PropTypes.func,
selectable: PropTypes.bool,
handleSelection: PropTypes.func,
numberOfItems: PropTypes.number,
scaleOfImages: PropTypes.number,
updateGroups: PropTypes.func,
updateItems: PropTypes.func,
selectedItems: PropTypes.arrayOf(PropTypes.shape({})),
toprightoverlay: PropTypes.shape({}),
bottomleftoverlay: PropTypes.shape({}),
};

0 comments on commit 3b3e0f3

Please sign in to comment.