Add eslint rule and fix as many issues as possible

This commit is contained in:
Khoa Le
2023-06-19 23:42:04 -04:00
parent e9eacc445d
commit 9d33e4756b
689 changed files with 9446 additions and 21821 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
import { useCallback, useState } from 'react';
import { useCallback, useState } from "react";
interface UsePopUpProps {
name: Readonly<string>;
@@ -11,7 +11,7 @@ interface UsePopUpProps {
* SIDENOTE: On inputting give it as const and not string with (as const)
*/
type UsePopUpState<T extends Readonly<string[]> | UsePopUpProps[]> = {
[P in T extends UsePopUpProps[] ? T[number]['name'] : T[number]]: {
[P in T extends UsePopUpProps[] ? T[number]["name"] : T[number]]: {
isOpen: boolean;
data?: unknown;
};
@@ -35,7 +35,7 @@ export const usePopUp = <T extends Readonly<string[]> | UsePopUpProps[]>(
const [popUp, setPopUp] = useState<UsePopUpState<T>>(
Object.fromEntries(
popUpNames.map((popUpName) =>
typeof popUpName === 'string'
typeof popUpName === "string"
? [popUpName, { isOpen: false }]
: [popUpName.name, { isOpen: popUpName.isOpen }]
) // convert into an array of [[popUpName,state]] then into Object
@@ -53,7 +53,7 @@ export const usePopUp = <T extends Readonly<string[]> | UsePopUpProps[]>(
const handlePopUpToggle = useCallback((popUpName: keyof UsePopUpState<T>, state?: boolean) => {
setPopUp((oldState) => ({
...oldState,
[popUpName]: { isOpen: typeof state === 'undefined' ? !oldState[popUpName].isOpen : state }
[popUpName]: { isOpen: typeof state === "undefined" ? !oldState[popUpName].isOpen : state }
}));
}, []);