fix all eslint warnings

This commit is contained in:
Tom
2023-04-25 21:30:10 +02:00
parent 323ec1e6c0
commit 610ea65c67
14 changed files with 144 additions and 83 deletions
+3 -3
View File
@@ -125,7 +125,7 @@ export default function App() {
return () => { return () => {
darkModeMediaQuery.removeEventListener('change', darkModeListener); darkModeMediaQuery.removeEventListener('change', darkModeListener);
}; };
}, [isHomeRoute]); }, [isHomeRoute, setBodyStyle, setSelectedStyle]);
// fetch default subplebbits // fetch default subplebbits
useEffect(() => { useEffect(() => {
@@ -143,7 +143,7 @@ export default function App() {
return () => { return () => {
didCancel = true; didCancel = true;
}; };
}, []); }, [setDefaultSubplebbits]);
// handle nested routes // handle nested routes
useEffect(() => { useEffect(() => {
@@ -162,7 +162,7 @@ export default function App() {
setIsSettingsOpen(false); setIsSettingsOpen(false);
} }
}, [location.pathname]); }, [location.pathname, setIsSettingsOpen, setShowPostForm, setShowPostFormLink]);
return ( return (
<div> <div>
+22 -22
View File
@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import { Link } from 'react-router-dom'; // import { Link } from 'react-router-dom';
import rehypeSanitize from 'rehype-sanitize'; import rehypeSanitize from 'rehype-sanitize';
import breaks from 'remark-breaks'; import breaks from 'remark-breaks';
@@ -28,28 +28,28 @@ const blockquoteToGreentext = () => (tree) => {
}); });
}; };
const createQuotelink = (handlequoteclick, comment, children) => { // const createQuotelink = (handlequoteclick, comment, children) => {
const text = children.map((child) => (typeof child === 'string' ? child : child.props.children)).join(''); // const text = children.map((child) => (typeof child === 'string' ? child : child.props.children)).join('');
const regex = /(\s|^)(c\/[A-Za-z0-9]{12}|c\/[A-Za-z0-9]{45})(?=\s|$)/g; // const regex = /(\s|^)(c\/[A-Za-z0-9]{12}|c\/[A-Za-z0-9]{45})(?=\s|$)/g;
const parts = text.split(regex); // const parts = text.split(regex);
return parts.flatMap((part, i) => { // return parts.flatMap((part, i) => {
if (regex.test(part)) { // if (regex.test(part)) {
return [ // return [
<Link // <Link
key={`link-${i}`} // key={`link-${i}`}
className="quotelink" // className="quotelink"
to="" // to=""
onClick={handlequoteclick} // onClick={handlequoteclick}
> // >
{part.trim()} // {part.trim()}
</Link>, // </Link>,
]; // ];
} else { // } else {
return [part]; // return [part];
} // }
}); // });
}; // };
const Post = ({ content, handlequoteclick, comment }) => { const Post = ({ content, handlequoteclick, comment }) => {
+2 -2
View File
@@ -83,7 +83,7 @@ const ReplyModal = ({ isOpen, closeModal }) => {
if (index !== undefined) { if (index !== undefined) {
setPendingCommentIndex(index); setPendingCommentIndex(index);
} }
}, [index, location]); }, [index, location, setPendingCommentIndex]);
const resetFields = () => { const resetFields = () => {
@@ -116,7 +116,7 @@ const ReplyModal = ({ isOpen, closeModal }) => {
closeModal(); closeModal();
})(); })();
} }
}, [publishCommentOptions]); }, [publishCommentOptions, closeModal, publishComment]);
const getChallengeAnswersFromUser = async (challenges) => { const getChallengeAnswersFromUser = async (challenges) => {
+45 -14
View File
@@ -220,7 +220,10 @@ export const NavBar = styled.div`
background-color: #ddd; background-color: #ddd;
border-bottom: 2px solid #ccc; border-bottom: 2px solid #ccc;
}`; }`;
}
default:
return '';
}
}}`; }}`;
export const Header = styled.div` export const Header = styled.div`
@@ -410,7 +413,10 @@ export const Header = styled.div`
margin-top: 5px; margin-top: 5px;
font-size: 9pt; font-size: 9pt;
}`; }`;
}
default:
return '';
}
}} }}
`; `;
@@ -445,8 +451,11 @@ export const Break = styled.hr`
return `width: 90%; return `width: 90%;
border: none; border: none;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
height: 0;`; height: 0;`;
}
default:
return '';
}
}} }}
`; `;
@@ -600,7 +609,9 @@ export const PostFormLink = styled.div`
color: #333 !important; color: #333 !important;
white-space: nowrap; white-space: nowrap;
}`; }`;
default:
return '';
} }
}} }}
`; `;
@@ -1123,7 +1134,10 @@ export const PostFormTable = styled.table`
width: 100% width: 100%
} }
}`; }`;
}
default:
return '';
}
}} }}
#t-help { #t-help {
@@ -1224,8 +1238,10 @@ export const PostForm = styled.div`
a:hover { a:hover {
color: #ff3300; color: #ff3300;
}`; }`;
} default:
return '';
}
}} }}
`; `;
@@ -1369,8 +1385,10 @@ export const TopBar = styled.div`
a:hover { a:hover {
color: #ff3300; color: #ff3300;
}`; }`;
} default:
return '';
}
}} }}
@media (min-width: 480px) { @media (min-width: 480px) {
@@ -1533,6 +1551,9 @@ export const TopBar = styled.div`
color: #333 !important; color: #333 !important;
white-space: nowrap; white-space: nowrap;
}`; }`;
default:
return '';
} }
}} }}
`; `;
@@ -1598,8 +1619,10 @@ export const BoardForm = styled.div`
background-color: #ccc !important; background-color: #ccc !important;
border: 1px solid #ccc !important; border: 1px solid #ccc !important;
}`; }`;
} default:
return '';
}
}} }}
} }
@@ -2873,8 +2896,10 @@ export const BoardForm = styled.div`
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
height: 0; height: 0;
}`; }`;
} default:
return '';
}
}} }}
@media (max-width: 480px) { @media (max-width: 480px) {
@@ -2934,6 +2959,9 @@ export const BoardForm = styled.div`
return `.highlighted { return `.highlighted {
background-color: #ccc !important; background-color: #ccc !important;
}`; }`;
default:
return '';
} }
}} }}
@@ -3635,6 +3663,9 @@ export const BoardForm = styled.div`
} }
} }
}`; }`;
default:
return '';
} }
}} }}
} }
@@ -236,6 +236,9 @@ export const StyledModal = styled(Modal)`
span { span {
color: #333; color: #333;
}`; }`;
}
default:
return '';
}
}} }}
`; `;
+4 -1
View File
@@ -254,6 +254,9 @@ export const StyledModal = styled(Modal)`
span { span {
color: #000; color: #000;
}`; }`;
}
default:
return '';
}
}} }}
`; `;
@@ -364,7 +364,9 @@ export const StyledModal = styled(Modal)`
color: #f30 !important; color: #f30 !important;
} }
}`; }`;
} default:
return '';
}
}} }}
`; `;
+30 -10
View File
@@ -164,6 +164,9 @@ export const ReplyFormLink = styled.div`
color: #333 !important; color: #333 !important;
white-space: nowrap; white-space: nowrap;
}`; }`;
default:
return '';
} }
}} }}
`; `;
@@ -386,7 +389,8 @@ export const TopBar = styled.div`
color: #ff3300 !important; color: #ff3300 !important;
} }
}`; }`;
default:
return '';
} }
}} }}
@@ -514,7 +518,9 @@ export const TopBar = styled.div`
color: #333 !important; color: #333 !important;
white-space: nowrap; white-space: nowrap;
}`; }`;
default:
return '';
} }
}} }}
`; `;
@@ -678,7 +684,9 @@ export const BottomBar = styled.div`
padding-bottom: 5px; padding-bottom: 5px;
padding-top: 5px; padding-top: 5px;
}`; }`;
default:
return '';
} }
}} }}
`; `;
@@ -735,16 +743,17 @@ export const BoardForm = styled.div`
return `.highlighted { return `.highlighted {
background-color: #1d1d21 !important; background-color: #1d1d21 !important;
border: 1px solid #111 !important; border: 1px solid #111 !important;
} }`;
`;
case 'Photon': case 'Photon':
return `.highlighted { return `.highlighted {
background-color: #ccc !important; background-color: #ccc !important;
border: 1px solid #ccc !important; border: 1px solid #ccc !important;
}`; }`;
} default:
return '';
}
}} }}
} }
@@ -2018,7 +2027,9 @@ export const BoardForm = styled.div`
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
height: 0; height: 0;
}`; }`;
default:
return '';
} }
}} }}
@@ -2079,7 +2090,10 @@ export const BoardForm = styled.div`
return `.highlighted { return `.highlighted {
background-color: #ccc !important; background-color: #ccc !important;
}`; }`;
}
default:
return '';
}
}} }}
${({ selectedStyle }) => { ${({ selectedStyle }) => {
@@ -2780,6 +2794,9 @@ export const BoardForm = styled.div`
} }
} }
}`; }`;
default:
return '';
} }
}} }}
} }
@@ -2896,6 +2913,9 @@ export const Footer = styled.div`
color: #f30; color: #f30;
} }
}`; }`;
}
default:
return '';
}
}} }}
`; `;
+4 -5
View File
@@ -207,7 +207,7 @@ const Board = () => {
setPendingCommentIndex(index); setPendingCommentIndex(index);
navigate(`/profile/c/${index}`); navigate(`/profile/c/${index}`);
} }
}, [index]); }, [index, navigate, setPendingCommentIndex]);
const resetFields = () => { const resetFields = () => {
@@ -240,7 +240,7 @@ const Board = () => {
resetFields(); resetFields();
})(); })();
} }
}, [publishCommentOptions]); }, [publishCommentOptions, publishComment]);
const getChallengeAnswersFromUser = async (challenges) => { const getChallengeAnswersFromUser = async (challenges) => {
@@ -369,12 +369,12 @@ const Board = () => {
<PostFormLink id="post-form-link" showPostFormLink={showPostFormLink} selectedStyle={selectedStyle} > <PostFormLink id="post-form-link" showPostFormLink={showPostFormLink} selectedStyle={selectedStyle} >
<div id="post-form-link-desktop"> <div id="post-form-link-desktop">
[ [
<a onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a> <a href={() => {}} onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a>
] ]
</div> </div>
<div id="post-form-link-mobile"> <div id="post-form-link-mobile">
<span className="btn-wrap"> <span className="btn-wrap">
<a onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a> <a href={() => {}} onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a>
</span> </span>
</div> </div>
</PostFormLink> </PostFormLink>
@@ -452,7 +452,6 @@ const Board = () => {
hasMore={hasMore} hasMore={hasMore}
> >
{selectedFeed.map((thread) => { {selectedFeed.map((thread) => {
const { replies: { pages: { topAll: {} = {} } = {} } = {} } = thread;
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
const commentMediaInfo = getCommentMediaInfo(thread); const commentMediaInfo = getCommentMediaInfo(thread);
const fallbackImgUrl = "/assets/filedeleted-res.gif"; const fallbackImgUrl = "/assets/filedeleted-res.gif";
+4 -4
View File
@@ -133,7 +133,7 @@ const Catalog = () => {
setPendingCommentIndex(index); setPendingCommentIndex(index);
navigate(`/profile/c/${index}`); navigate(`/profile/c/${index}`);
} }
}, [index]); }, [index, navigate, setPendingCommentIndex]);
const resetFields = () => { const resetFields = () => {
@@ -166,7 +166,7 @@ const Catalog = () => {
resetFields(); resetFields();
})(); })();
} }
}, [publishCommentOptions]); }, [publishCommentOptions, publishComment]);
const getChallengeAnswersFromUser = async (challenges) => { const getChallengeAnswersFromUser = async (challenges) => {
@@ -284,12 +284,12 @@ const Catalog = () => {
<PostFormLink id="post-form-link" showPostFormLink={showPostFormLink} selectedStyle={selectedStyle} > <PostFormLink id="post-form-link" showPostFormLink={showPostFormLink} selectedStyle={selectedStyle} >
<div id="post-form-link-desktop"> <div id="post-form-link-desktop">
[ [
<a onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a> <a href={() => {}} onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a>
] ]
</div> </div>
<div id="post-form-link-mobile"> <div id="post-form-link-mobile">
<span className="btn-wrap"> <span className="btn-wrap">
<a onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a> <a href={() => {}} onClick={useClickForm()} onMouseOver={(event) => event.target.style.cursor='pointer'}>Start a New Thread</a>
</span> </span>
</div> </div>
</PostFormLink> </PostFormLink>
+2 -1
View File
@@ -184,7 +184,8 @@ const Pending = () => {
<div key={`f-${"pending"}`} className="file" style={{marginBottom: "5px"}}> <div key={`f-${"pending"}`} className="file" style={{marginBottom: "5px"}}>
<div key={`ft-${"pending"}`} className="file-text"> <div key={`ft-${"pending"}`} className="file-text">
Link:&nbsp; Link:&nbsp;
<a key={`fa-${"pending"}`} href={commentMediaInfo.url} target="_blank">{ <a key={`fa-${"pending"}`} href={commentMediaInfo.url}
target="_blank" rel="noreferrer">{
commentMediaInfo?.url.length > 30 ? commentMediaInfo?.url.length > 30 ?
commentMediaInfo?.url.slice(0, 30) + "(...)" : commentMediaInfo?.url.slice(0, 30) + "(...)" :
commentMediaInfo?.url commentMediaInfo?.url
+16 -14
View File
@@ -75,7 +75,7 @@ const Thread = () => {
parentCids: [ parentCids: [
selectedThread || 'n/a', ...flattenedReplies.map(reply => reply.cid) selectedThread || 'n/a', ...flattenedReplies.map(reply => reply.cid)
] ]
}), [flattenedReplies]); }), [flattenedReplies, selectedThread]);
const { accountComments } = useAccountComments({filter}); const { accountComments } = useAccountComments({filter});
@@ -100,7 +100,7 @@ const Thread = () => {
if (selectedSubplebbit) { if (selectedSubplebbit) {
setSelectedTitle(selectedSubplebbit.title); setSelectedTitle(selectedSubplebbit.title);
} }
}, [subplebbitAddress, setSelectedAddress, setSelectedTitle, defaultSubplebbits]); }, [subplebbitAddress, setSelectedAddress, setSelectedTitle, defaultSubplebbits, setSelectedThread, threadCid]);
// mobile navbar scroll effect // mobile navbar scroll effect
useEffect(() => { useEffect(() => {
@@ -167,7 +167,7 @@ const Thread = () => {
if (index !== undefined) { if (index !== undefined) {
setPendingCommentIndex(index); setPendingCommentIndex(index);
} }
}, [index]); }, [index, setPendingCommentIndex]);
const resetFields = () => { const resetFields = () => {
@@ -199,7 +199,7 @@ const Thread = () => {
resetFields(); resetFields();
})(); })();
} }
}, [publishCommentOptions]); }, [publishCommentOptions, publishComment]);
const getChallengeAnswersFromUser = async (challenges) => { const getChallengeAnswersFromUser = async (challenges) => {
@@ -338,17 +338,17 @@ const Thread = () => {
</div> </div>
<div id="bottom-button-mobile"> <div id="bottom-button-mobile">
<span className="btn-wrap"> <span className="btn-wrap">
<a onClick={() => window.scrollTo(0, document.body.scrollHeight)} onMouseOver={(event) => event.target.style.cursor='pointer'}>Bottom</a> <a href={()=> {}} onClick={() => window.scrollTo(0, document.body.scrollHeight)} onMouseOver={(event) => event.target.style.cursor='pointer'}>Bottom</a>
</span> </span>
</div> </div>
<div id="post-form-link-desktop"> <div id="post-form-link-desktop">
[ [
<a onClick={() => {handleClickForm(); setSelectedShortCid(comment.shortCid)}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a> <a href={()=> {}} onClick={() => {handleClickForm(); setSelectedShortCid(comment.shortCid)}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a>
] ]
</div> </div>
<div id="post-form-link-mobile"> <div id="post-form-link-mobile">
<span className="btn-wrap"> <span className="btn-wrap">
<a onClick={() => {handleClickForm(); setSelectedShortCid(comment.shortCid)}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a> <a href={()=> {}} onClick={() => {handleClickForm(); setSelectedShortCid(comment.shortCid)}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a>
</span> </span>
</div> </div>
</ReplyFormLink> </ReplyFormLink>
@@ -407,7 +407,7 @@ const Thread = () => {
</span> </span>
<span className="return-button catalog-button" id="bottom-button-desktop"> <span className="return-button catalog-button" id="bottom-button-desktop">
[ [
<a onClick={() => window.scrollTo(0, document.body.scrollHeight)} <a href={()=> {}} onClick={() => window.scrollTo(0, document.body.scrollHeight)}
onMouseOver={(event) => event.target.style.cursor='pointer'} onMouseOver={(event) => event.target.style.cursor='pointer'}
onTouchStart={() => window.scrollTo(0, document.body.scrollHeight)}>Bottom</a> onTouchStart={() => window.scrollTo(0, document.body.scrollHeight)}>Bottom</a>
] ]
@@ -443,7 +443,8 @@ const Thread = () => {
<div key={`f-${comment.cid}`} className="file" style={{marginBottom: "5px"}}> <div key={`f-${comment.cid}`} className="file" style={{marginBottom: "5px"}}>
<div key={`ft-${comment.cid}`} className="file-text"> <div key={`ft-${comment.cid}`} className="file-text">
Link:&nbsp; Link:&nbsp;
<a key={`fa-${comment.cid}`} href={commentMediaInfo.url} target="_blank">{ <a key={`fa-${comment.cid}`} href={commentMediaInfo.url}
target="_blank" rel="noreferrer">{
commentMediaInfo?.url.length > 30 ? commentMediaInfo?.url.length > 30 ?
commentMediaInfo?.url.slice(0, 30) + "(...)" : commentMediaInfo?.url.slice(0, 30) + "(...)" :
commentMediaInfo?.url commentMediaInfo?.url
@@ -628,7 +629,8 @@ const Thread = () => {
style={{marginBottom: "5px"}}> style={{marginBottom: "5px"}}>
<div key={`ft-${index}`} className="reply-file-text"> <div key={`ft-${index}`} className="reply-file-text">
Link:&nbsp; Link:&nbsp;
<a key={`fa-${index}`} href={replyMediaInfo.url} target="_blank">{ <a key={`fa-${index}`} href={replyMediaInfo.url}
target="_blank" rel="noreferrer">{
replyMediaInfo?.url.length > 30 ? replyMediaInfo?.url.length > 30 ?
replyMediaInfo?.url.slice(0, 30) + "(...)" : replyMediaInfo?.url.slice(0, 30) + "(...)" :
replyMediaInfo?.url replyMediaInfo?.url
@@ -917,14 +919,14 @@ const Thread = () => {
</span> </span>
<span className="bottom-bar-top"> <span className="bottom-bar-top">
[ [
<a onClick={() => window.scrollTo(0, 0)} <a href={()=> {}} onClick={() => window.scrollTo(0, 0)}
onMouseOver={(event) => event.target.style.cursor='pointer'} onMouseOver={(event) => event.target.style.cursor='pointer'}
onTouchStart={() => window.scrollTo(0, 0)}>Top</a> onTouchStart={() => window.scrollTo(0, 0)}>Top</a>
] ]
</span> </span>
<span className="quickreply-button"> <span className="quickreply-button">
[ [
<a onClick={() => {setIsReplyOpen(true); setSelectedParentCid(comment.cid); setSelectedShortCid(comment.shortCid);}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a> <a href={()=> {}} onClick={() => {setIsReplyOpen(true); setSelectedParentCid(comment.cid); setSelectedShortCid(comment.shortCid);}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a>
] ]
</span> </span>
{comment.replyCount > 0 ? ( {comment.replyCount > 0 ? (
@@ -973,7 +975,7 @@ const Thread = () => {
<ReplyFormLink id="post-form-link" selectedStyle={selectedStyle} > <ReplyFormLink id="post-form-link" selectedStyle={selectedStyle} >
<div id="post-form-link-mobile" className="post-button-mobile"> <div id="post-form-link-mobile" className="post-button-mobile">
<span className="btn-wrap"> <span className="btn-wrap">
<a onClick={() => {setIsReplyOpen(true); setSelectedParentCid(comment.cid); setSelectedShortCid(comment.shortCid);}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a> <a href={()=> {}} onClick={() => {setIsReplyOpen(true); setSelectedParentCid(comment.cid); setSelectedShortCid(comment.shortCid);}} onMouseOver={(event) => event.target.style.cursor='pointer'}>Post a Reply</a>
</span> </span>
</div> </div>
<div id="btns-container"> <div id="btns-container">
@@ -989,7 +991,7 @@ const Thread = () => {
</div> </div>
<span className="bottom-bar-top"> <span className="bottom-bar-top">
<span className="btn-wrap"> <span className="btn-wrap">
<a onClick={() => window.scrollTo(0, 0)} <a href={()=> {}} onClick={() => window.scrollTo(0, 0)}
onMouseOver={(event) => event.target.style.cursor='pointer'} onMouseOver={(event) => event.target.style.cursor='pointer'}
onTouchStart={() => window.scrollTo(0, 0)} onTouchStart={() => window.scrollTo(0, 0)}
style={{marginRight: "10px", marginLeft: "10px"}} style={{marginRight: "10px", marginLeft: "10px"}}
+2 -2
View File
@@ -1,7 +1,7 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
const useError = (message, deps) => { const useError = (message) => {
useEffect(() => { useEffect(() => {
if (message) { if (message) {
const toastId = toast.error(message.toString(), { const toastId = toast.error(message.toString(), {
@@ -19,7 +19,7 @@ const useError = (message, deps) => {
toast.dismiss(toastId); toast.dismiss(toastId);
}; };
} }
}, deps); }, [message]);
}; };
export default useError; export default useError;
+2 -2
View File
@@ -1,7 +1,7 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
const useSuccess = (message, deps) => { const useSuccess = (message) => {
useEffect(() => { useEffect(() => {
if (message) { if (message) {
const toastId = toast.success(message.toString(), { const toastId = toast.success(message.toString(), {
@@ -19,7 +19,7 @@ const useSuccess = (message, deps) => {
toast.dismiss(toastId); toast.dismiss(toastId);
}; };
} }
}, deps); }, [message]);
}; };
export default useSuccess; export default useSuccess;