Skip to content

Commit 6ae6793

Browse files
committed
refactor: replace proptypes with jsdoc
1 parent 230e359 commit 6ae6793

39 files changed

+633
-557
lines changed

eslint.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
import { browser } from '@ugrc/eslint-config';
22

3-
export default browser;
3+
export default [
4+
...browser,
5+
{
6+
rules: {
7+
'react/prop-types': 'off',
8+
},
9+
},
10+
];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
"prettier-plugin-organize-imports": "^4.3.0",
113113
"prettier-plugin-packagejson": "^3.0.0",
114114
"prettier-plugin-tailwindcss": "^0.7.2",
115-
"prop-types": "^15.8.1",
116115
"storybook": "^10.2.8",
117116
"tailwindcss": "^4.1.18",
118117
"vite": "^7.3.1",
@@ -149,6 +148,7 @@
149148
"lodash@>=4.0.0 <=4.17.22": ">=4.17.23",
150149
"lodash-es@>=4.0.0 <=4.17.22": ">=4.17.23",
151150
"on-headers@<1.1.0": ">=1.1.0",
151+
"qs@>=6.7.0 <=6.14.1": ">=6.14.2",
152152
"qs@<6.14.1": ">=6.14.1",
153153
"tar@<7.5.7": ">=7.5.7",
154154
"tar@<=7.5.2": ">=7.5.3",

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/contexts/SubmissionContext.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import { useMachine } from '@xstate/react';
2-
import PropTypes from 'prop-types';
32
import { createContext } from 'react';
43
import { submissionMachine } from '../machines';
54

65
export const SubmissionContext = createContext({});
76

7+
/**
8+
* @typedef {Object} SubmissionProviderProps
9+
* @property {React.ReactNode} children
10+
* @property {Object} [context]
11+
*/
12+
13+
/**
14+
* @type {React.FC<SubmissionProviderProps>}
15+
*/
816
export const SubmissionProvider = ({ children, context }) => {
917
const [state, send] = useMachine(submissionMachine, {
1018
input: { ...context },
1119
});
1220

1321
return <SubmissionContext.Provider value={[state, send]}>{children}</SubmissionContext.Provider>;
1422
};
15-
16-
SubmissionProvider.propTypes = {
17-
children: PropTypes.node.isRequired,
18-
context: PropTypes.object,
19-
};

src/components/formElements/Buttons.jsx

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { ExclamationCircleIcon } from '@heroicons/react/20/solid';
22
import { useFirebaseAuth } from '@ugrc/utah-design-system';
33
import { clsx } from 'clsx';
4-
import PropTypes from 'prop-types';
54

5+
/**
6+
* @typedef {Object} LogInButtonProps
7+
* @property {string} [className]
8+
*/
9+
10+
/**
11+
* @type {React.FC<LogInButtonProps>}
12+
*/
613
export const LogInButton = () => {
714
const { login } = useFirebaseAuth();
815

@@ -73,10 +80,15 @@ export const LogInButton = () => {
7380
</Button>
7481
);
7582
};
76-
LogInButton.propTypes = {
77-
className: PropTypes.string,
78-
};
7983

84+
/**
85+
* @typedef {Object} LogOutButtonProps
86+
* @property {string} [className]
87+
*/
88+
89+
/**
90+
* @type {React.FC<LogOutButtonProps>}
91+
*/
8092
export const LogOutButton = () => {
8193
const { logout } = useFirebaseAuth();
8294

@@ -90,9 +102,6 @@ export const LogOutButton = () => {
90102
</Button>
91103
);
92104
};
93-
LogOutButton.propTypes = {
94-
className: PropTypes.string,
95-
};
96105

97106
const primaryClasses =
98107
'h-8 border-sky-600 bg-sky-500 text-white hover:border-sky-700 hover:bg-sky-600 focus:border-sky-500 focus:ring-sky-600/50 active:bg-sky-700';
@@ -111,7 +120,7 @@ const buttonGroupMiddle = 'border-x-0';
111120
const buttonClasses = (style, buttonGroup) => {
112121
return clsx(
113122
style !== 'link' &&
114-
'flex min-h-[2rem] w-fit cursor-pointer items-center justify-center border-2 px-7 py-1 transition-all duration-200 ease-in-out focus:ring-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
123+
'flex min-h-8 w-fit cursor-pointer items-center justify-center border-2 px-7 py-1 transition-all duration-200 ease-in-out focus:ring-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
115124
style === 'primary' && primaryClasses,
116125
style === 'secondary' && secondaryClasses,
117126
style === 'alternate' && alternateClasses,
@@ -122,6 +131,23 @@ const buttonClasses = (style, buttonGroup) => {
122131
buttonGroup?.right && buttonGroupRight,
123132
);
124133
};
134+
135+
/**
136+
* @typedef {Object} ButtonProps
137+
* @property {string} [name] - The property name used by react hook form
138+
* @property {React.ReactNode} children - The children to display on the button
139+
* @property {'primary'|'secondary'|'alternate'|'link'} [style] - The style of button
140+
* @property {'idle'|'disabled'|'pending'|'success'|'error'} [state] - The state of button
141+
* @property {'button'|'submit'|'reset'} [type] - The property name used by react hook form
142+
* @property {function} [inputRef] - The ref property for use with registering with react hook form
143+
* @property {function} [onClick] - The function to execute when the button is clicked
144+
* @property {boolean} [dark]
145+
* @property {Object} [buttonGroup]
146+
*/
147+
148+
/**
149+
* @type {React.FC<ButtonProps>}
150+
*/
125151
export const Button = ({
126152
children,
127153
name,
@@ -162,39 +188,19 @@ export const Button = ({
162188
);
163189
};
164190

165-
Button.propTypes = {
166-
/**
167-
* The property name used by react hook form
168-
*/
169-
name: PropTypes.string,
170-
/**
171-
* The children to display on the button
172-
*/
173-
children: PropTypes.node.isRequired,
174-
/**
175-
* The style of button
176-
*/
177-
style: PropTypes.oneOf(['primary', 'secondary', 'alternate', 'link']),
178-
/**
179-
* The state of button
180-
*/
181-
state: PropTypes.oneOf(['idle', 'disabled', 'pending', 'success', 'error']),
182-
/**
183-
* The property name used by react hook form
184-
*/
185-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
186-
/**
187-
* The ref property for use with registering with react hook form
188-
*/
189-
inputRef: PropTypes.func,
190-
/**
191-
* The function to execute when the button is clicked
192-
*/
193-
onClick: PropTypes.func,
194-
dark: PropTypes.bool,
195-
buttonGroup: PropTypes.object,
196-
};
191+
/**
192+
* @typedef {Object} LinkProps
193+
* @property {React.ReactNode} children
194+
* @property {string} [href]
195+
* @property {string} [target]
196+
* @property {string} [rel]
197+
* @property {'primary'|'secondary'|'alternate'|'link'} [style] - The style of button
198+
* @property {Object} [buttonGroup]
199+
*/
197200

201+
/**
202+
* @type {React.FC<LinkProps>}
203+
*/
198204
export const Link = ({ href, children, target, rel, buttonGroup, style = 'link' }) => {
199205
const attributes = {
200206
target,
@@ -205,14 +211,3 @@ export const Link = ({ href, children, target, rel, buttonGroup, style = 'link'
205211

206212
return <a {...attributes}>{children}</a>;
207213
};
208-
Link.propTypes = {
209-
children: PropTypes.node.isRequired,
210-
href: PropTypes.string,
211-
target: PropTypes.string,
212-
rel: PropTypes.string,
213-
/**
214-
* The style of button
215-
*/
216-
style: PropTypes.oneOf(['primary', 'secondary', 'alternate', 'link']),
217-
buttonGroup: PropTypes.object,
218-
};

src/components/formElements/Card.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import PropTypes from 'prop-types';
1+
/**
2+
* @typedef {Object} CardProps
3+
* @property {React.ReactNode} [children]
4+
*/
25

6+
/**
7+
* @type {React.FC<CardProps>}
8+
*/
39
export default function Card({ children }) {
410
return (
511
<section className="inline-grid w-full gap-2 rounded-lg border border-slate-400 bg-white p-4 text-sm shadow-md">
612
{children}
713
</section>
814
);
915
}
10-
Card.propTypes = {
11-
children: PropTypes.node,
12-
};

src/components/formElements/FileUpload.jsx

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useFirebaseStorage } from '@ugrc/utah-design-system';
22
import { clsx } from 'clsx';
33
import { deleteObject, getDownloadURL, ref, uploadBytesResumable } from 'firebase/storage';
4-
import PropTypes from 'prop-types';
54
import { useEffect, useRef, useState } from 'react';
65
import { Button } from './Buttons.jsx';
76

@@ -21,6 +20,20 @@ const validateSize = (actualSize, megabytes) => {
2120
return actualSize > megabytes * 1024 * 1024;
2221
};
2322

23+
/**
24+
* @typedef {Object} FileUploadProps
25+
* @property {string} [id]
26+
* @property {string} path
27+
* @property {string} [defaultFileName]
28+
* @property {function} [onChange]
29+
* @property {string} [value]
30+
* @property {Array<{name: string, value: string}>} [contentTypes]
31+
* @property {number} [maxFileSize]
32+
*/
33+
34+
/**
35+
* @type {React.FC<FileUploadProps>}
36+
*/
2437
const FileUpload = ({ id, defaultFileName, path, contentTypes, maxFileSize, value, onChange }) => {
2538
const { storage } = useFirebaseStorage();
2639
const uploadReference = useRef();
@@ -140,21 +153,16 @@ const FileUpload = ({ id, defaultFileName, path, contentTypes, maxFileSize, valu
140153
</div>
141154
);
142155
};
143-
FileUpload.propTypes = {
144-
id: PropTypes.string,
145-
path: PropTypes.string.isRequired,
146-
defaultFileName: PropTypes.string,
147-
onChange: PropTypes.func,
148-
value: PropTypes.string,
149-
contentTypes: PropTypes.arrayOf(
150-
PropTypes.shape({
151-
name: PropTypes.string,
152-
value: PropTypes.string,
153-
}),
154-
),
155-
maxFileSize: PropTypes.number,
156-
};
157156

157+
/**
158+
* @typedef {Object} ObjectPreviewProps
159+
* @property {string} url
160+
* @property {React.ReactNode} [children]
161+
*/
162+
163+
/**
164+
* @type {React.FC<ObjectPreviewProps>}
165+
*/
158166
export const ObjectPreview = ({ url, children }) => {
159167
return (
160168
<div className="flex w-full flex-col rounded-sm border border-slate-400 bg-slate-50 text-slate-400 shadow-sm">
@@ -172,20 +180,21 @@ export const ObjectPreview = ({ url, children }) => {
172180
</div>
173181
);
174182
};
175-
ObjectPreview.propTypes = {
176-
url: PropTypes.string.isRequired,
177-
children: PropTypes.node,
178-
};
179183

184+
/**
185+
* @typedef {Object} AttachmentProps
186+
* @property {function} [onClick]
187+
*/
188+
189+
/**
190+
* @type {React.FC<AttachmentProps>}
191+
*/
180192
export const Attachment = ({ onClick }) => (
181193
<div className="flex justify-between">
182194
<Button style="secondary" onClick={onClick}>
183195
Remove
184196
</Button>
185197
</div>
186198
);
187-
Attachment.propTypes = {
188-
onClick: PropTypes.func,
189-
};
190199

191200
export default FileUpload;

src/components/formElements/Form.jsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import PropTypes from 'prop-types';
1+
/**
2+
* @typedef {Object} NumberedFormProps
3+
* @property {React.ReactNode} children
4+
* @property {function} [onSubmit]
5+
*/
26

7+
/**
8+
* @type {React.FC<NumberedFormProps>}
9+
*/
310
export function NumberedForm({ children, onSubmit }) {
411
return (
512
<form onSubmit={onSubmit} className="mb-10 flex w-full flex-col items-center justify-center">
@@ -9,11 +16,17 @@ export function NumberedForm({ children, onSubmit }) {
916
</form>
1017
);
1118
}
12-
NumberedForm.propTypes = {
13-
children: PropTypes.node.isRequired,
14-
onSubmit: PropTypes.func,
15-
};
1619

20+
/**
21+
* @typedef {Object} NumberedFormSectionProps
22+
* @property {React.ReactNode} children
23+
* @property {number} number
24+
* @property {string} [title]
25+
*/
26+
27+
/**
28+
* @type {React.FC<NumberedFormSectionProps>}
29+
*/
1730
export function NumberedFormSection({ children, number, title }) {
1831
return (
1932
<>
@@ -27,8 +40,3 @@ export function NumberedFormSection({ children, number, title }) {
2740
</>
2841
);
2942
}
30-
NumberedFormSection.propTypes = {
31-
children: PropTypes.node.isRequired,
32-
number: PropTypes.number.isRequired,
33-
title: PropTypes.string,
34-
};

0 commit comments

Comments
 (0)