From: SleeplessOne1917 <abias1122@gmail.com> Date: Fri, 28 Jul 2023 20:07:16 +0000 (+0000) Subject: ES-Lint tweak (#2001) X-Git-Url: http://these/git/%7B%27/docs/%7BelementUrl%7D?a=commitdiff_plain;h=dd42bc2a3dc75a33d20bb5b2f9dfbbfb7e12b153;p=lemmy-ui.git ES-Lint tweak (#2001) --- diff --git a/.eslintrc.json b/.eslintrc.json index ad77740..ea26ba3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -20,10 +20,11 @@ "@typescript-eslint/no-explicit-any": 0, "@typescript-eslint/explicit-module-boundary-types": 0, "@typescript-eslint/no-empty-function": 0, + "@typescript-eslint/no-non-null-assertion": 0, "arrow-body-style": 0, "curly": 0, "eol-last": 0, - "eqeqeq": 0, + "eqeqeq": "error", "func-style": 0, "import/no-duplicates": 0, "max-statements": 0, @@ -39,7 +40,7 @@ "no-useless-constructor": 0, "no-useless-escape": 0, "no-var": 0, - "prefer-const": 1, + "prefer-const": "error", "prefer-rest-params": 0, "prettier/prettier": "error", "quote-props": 0, diff --git a/src/server/handlers/catch-all-handler.tsx b/src/server/handlers/catch-all-handler.tsx index 06d38f3..a40136b 100644 --- a/src/server/handlers/catch-all-handler.tsx +++ b/src/server/handlers/catch-all-handler.tsx @@ -48,7 +48,7 @@ export default async (req: Request, res: Response) => { let errorPageData: ErrorPageData | undefined = undefined; let try_site = await client.getSite(getSiteForm); - if (try_site.state === "failed" && try_site.msg == "not_logged_in") { + if (try_site.state === "failed" && try_site.msg === "not_logged_in") { console.error( "Incorrect JWT token, skipping auth so frontend can remove jwt cookie" ); diff --git a/src/shared/components/app/navbar.tsx b/src/shared/components/app/navbar.tsx index 5c01718..10b465d 100644 --- a/src/shared/components/app/navbar.tsx +++ b/src/shared/components/app/navbar.tsx @@ -480,7 +480,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> { } get unreadInboxCount(): number { - if (this.state.unreadInboxCountRes.state == "success") { + if (this.state.unreadInboxCountRes.state === "success") { const data = this.state.unreadInboxCountRes.data; return data.replies + data.mentions + data.private_messages; } else { @@ -489,7 +489,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> { } get unreadReportCount(): number { - if (this.state.unreadReportCountRes.state == "success") { + if (this.state.unreadReportCountRes.state === "success") { const data = this.state.unreadReportCountRes.data; return ( data.post_reports + @@ -502,7 +502,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> { } get unreadApplicationCount(): number { - if (this.state.unreadApplicationCountRes.state == "success") { + if (this.state.unreadApplicationCountRes.state === "success") { const data = this.state.unreadApplicationCountRes.data; return data.registration_applications; } else { diff --git a/src/shared/components/app/theme.tsx b/src/shared/components/app/theme.tsx index 93f6aed..07c4f8c 100644 --- a/src/shared/components/app/theme.tsx +++ b/src/shared/components/app/theme.tsx @@ -22,8 +22,8 @@ export class Theme extends Component<Props> { </Helmet> ); } else if ( - this.props.defaultTheme != "browser" && - this.props.defaultTheme != "browser-compact" + this.props.defaultTheme !== "browser" && + this.props.defaultTheme !== "browser-compact" ) { return ( <Helmet> @@ -34,7 +34,7 @@ export class Theme extends Component<Props> { /> </Helmet> ); - } else if (this.props.defaultTheme == "browser-compact") { + } else if (this.props.defaultTheme === "browser-compact") { return ( <Helmet> <link diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index 2576cda..bbbd820 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -243,7 +243,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> { const cv = this.commentView; const purgeTypeText = - this.state.purgeType == PurgeType.Comment + this.state.purgeType === PurgeType.Comment ? I18NextService.i18n.t("purge_comment") : `${I18NextService.i18n.t("purge")} ${cv.creator.name}`; @@ -278,9 +278,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> { : colorList[0]; const showMoreChildren = - this.props.viewType == CommentViewType.Tree && + this.props.viewType === CommentViewType.Tree && !this.state.collapsed && - node.children.length == 0 && + node.children.length === 0 && node.comment_view.counts.child_count > 0; return ( @@ -1210,19 +1210,19 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> { get myComment(): boolean { return ( - UserService.Instance.myUserInfo?.local_user_view.person.id == + UserService.Instance.myUserInfo?.local_user_view.person.id === this.commentView.creator.id ); } get isPostCreator(): boolean { - return this.commentView.creator.id == this.commentView.post.creator_id; + return this.commentView.creator.id === this.commentView.post.creator_id; } get scoreColor() { - if (this.commentView.my_vote == 1) { + if (this.commentView.my_vote === 1) { return "text-info"; - } else if (this.commentView.my_vote == -1) { + } else if (this.commentView.my_vote === -1) { return "text-danger"; } else { return "text-muted"; @@ -1499,7 +1499,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> { handleModBanBothSubmit(i: CommentNode, event: any) { event.preventDefault(); - if (i.state.banType == BanType.Community) { + if (i.state.banType === BanType.Community) { i.handleBanPersonFromCommunity(i); } else { i.handleBanPerson(i); @@ -1552,7 +1552,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> { event.preventDefault(); i.setState({ purgeLoading: true }); - if (i.state.purgeType == PurgeType.Person) { + if (i.state.purgeType === PurgeType.Person) { i.props.onPurgePerson({ person_id: i.commentView.creator.id, reason: i.state.purgeReason, diff --git a/src/shared/components/comment/comment-report.tsx b/src/shared/components/comment/comment-report.tsx index 3b328f6..473481b 100644 --- a/src/shared/components/comment/comment-report.tsx +++ b/src/shared/components/comment/comment-report.tsx @@ -35,7 +35,7 @@ export class CommentReport extends Component< componentWillReceiveProps( nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps> ): void { - if (this.props != nextProps) { + if (this.props !== nextProps) { this.setState({ loading: false }); } } diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index c6b42d7..1404bdb 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -360,7 +360,7 @@ export class MarkdownTextArea extends Component< handleEmoji(i: MarkdownTextArea, e: any) { let value = e.native; - if (value == null) { + if (value === null) { const emoji = customEmojisLookup.get(e.id)?.custom_emoji; if (emoji) { value = `![${emoji.alt_text}](${emoji.image_url} "${emoji.shortcode}")`; diff --git a/src/shared/components/common/paginator.tsx b/src/shared/components/common/paginator.tsx index bd4ecf8..ed0ed21 100644 --- a/src/shared/components/common/paginator.tsx +++ b/src/shared/components/common/paginator.tsx @@ -15,7 +15,7 @@ export class Paginator extends Component<PaginatorProps, any> { <div className="paginator my-2"> <button className="btn btn-secondary me-2" - disabled={this.props.page == 1} + disabled={this.props.page === 1} onClick={linkEvent(this, this.handlePrev)} > {I18NextService.i18n.t("prev")} diff --git a/src/shared/components/common/password-input.tsx b/src/shared/components/common/password-input.tsx index 47005a0..3949686 100644 --- a/src/shared/components/common/password-input.tsx +++ b/src/shared/components/common/password-input.tsx @@ -146,7 +146,7 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> { if (strength && ["weak", "medium"].includes(strength)) { return "text-warning"; - } else if (strength == "strong") { + } else if (strength === "strong") { return "text-success"; } else { return "text-danger"; diff --git a/src/shared/components/common/pictrs-image.tsx b/src/shared/components/common/pictrs-image.tsx index 5c3d823..f128512 100644 --- a/src/shared/components/common/pictrs-image.tsx +++ b/src/shared/components/common/pictrs-image.tsx @@ -56,7 +56,7 @@ export class PictrsImage extends Component<PictrsImageProps, any> { const split = this.props.src.split("/pictrs/image/"); // If theres not multiple, then its not a pictrs image - if (split.length == 1) { + if (split.length === 1) { return this.props.src; } diff --git a/src/shared/components/common/registration-application.tsx b/src/shared/components/common/registration-application.tsx index 3857c49..58ae57d 100644 --- a/src/shared/components/common/registration-application.tsx +++ b/src/shared/components/common/registration-application.tsx @@ -44,7 +44,7 @@ export class RegistrationApplication extends Component< { children?: InfernoNode } & RegistrationApplicationProps > ): void { - if (this.props != nextProps) { + if (this.props !== nextProps) { this.setState({ denyExpanded: false, approveLoading: false, diff --git a/src/shared/components/common/vote-buttons.tsx b/src/shared/components/common/vote-buttons.tsx index 0664e76..8a89a2c 100644 --- a/src/shared/components/common/vote-buttons.tsx +++ b/src/shared/components/common/vote-buttons.tsx @@ -193,7 +193,7 @@ export class VoteButtons extends Component<VoteButtonsProps, VoteButtonsState> { <button type="button" className={`btn-animate btn btn-link p-0 ${ - this.props.my_vote == 1 ? "text-info" : "text-muted" + this.props.my_vote === 1 ? "text-info" : "text-muted" }`} onClick={linkEvent(this, handleUpvote)} data-tippy-content={I18NextService.i18n.t("upvote")} @@ -220,7 +220,7 @@ export class VoteButtons extends Component<VoteButtonsProps, VoteButtonsState> { <button type="button" className={`btn-animate btn btn-link p-0 ${ - this.props.my_vote == -1 ? "text-danger" : "text-muted" + this.props.my_vote === -1 ? "text-danger" : "text-muted" }`} onClick={linkEvent(this, handleDownvote)} data-tippy-content={I18NextService.i18n.t("downvote")} diff --git a/src/shared/components/community/communities.tsx b/src/shared/components/community/communities.tsx index 4ab1bfe..966b6c9 100644 --- a/src/shared/components/community/communities.tsx +++ b/src/shared/components/community/communities.tsx @@ -172,7 +172,7 @@ export class Communities extends Component<any, CommunitiesState> { {numToSI(cv.counts.comments)} </td> <td className="text-right"> - {cv.subscribed == "Subscribed" && ( + {cv.subscribed === "Subscribed" && ( <button className="btn btn-link d-inline-block" onClick={linkEvent( @@ -369,8 +369,8 @@ export class Communities extends Component<any, CommunitiesState> { findAndUpdateCommunity(res: RequestState<CommunityResponse>) { this.setState(s => { if ( - s.listCommunitiesResponse.state == "success" && - res.state == "success" + s.listCommunitiesResponse.state === "success" && + res.state === "success" ) { s.listCommunitiesResponse.data.communities = editCommunity( res.data.community_view, diff --git a/src/shared/components/community/community-link.tsx b/src/shared/components/community/community-link.tsx index 9583333..77accf6 100644 --- a/src/shared/components/community/community-link.tsx +++ b/src/shared/components/community/community-link.tsx @@ -22,7 +22,7 @@ export class CommunityLink extends Component<CommunityLinkProps, any> { render() { const community = this.props.community; let name_: string, title: string, link: string; - const local = community.local == null ? true : community.local; + const local = community.local === null ? true : community.local; if (local) { name_ = community.name; title = community.title; diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index f89eb83..7df6985 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -290,7 +290,7 @@ export class Community extends Component< get documentTitle(): string { const cRes = this.state.communityRes; - return cRes.state == "success" + return cRes.state === "success" ? `${cRes.data.community_view.community.title} - ${this.isoData.site_res.site_view.site.name}` : ""; } @@ -626,11 +626,11 @@ export class Community extends Component< this.updateCommunity(followCommunityRes); // Update myUserInfo - if (followCommunityRes.state == "success") { + if (followCommunityRes.state === "success") { const communityId = followCommunityRes.data.community_view.community.id; const mui = UserService.Instance.myUserInfo; if (mui) { - mui.follows = mui.follows.filter(i => i.community.id != communityId); + mui.follows = mui.follows.filter(i => i.community.id !== communityId); } } } @@ -657,10 +657,10 @@ export class Community extends Component< async handleBlockCommunity(form: BlockCommunity) { const blockCommunityRes = await HttpService.client.blockCommunity(form); - if (blockCommunityRes.state == "success") { + if (blockCommunityRes.state === "success") { updateCommunityBlock(blockCommunityRes.data); this.setState(s => { - if (s.communityRes.state == "success") { + if (s.communityRes.state === "success") { s.communityRes.data.community_view.blocked = blockCommunityRes.data.blocked; } @@ -670,7 +670,7 @@ export class Community extends Component< async handleBlockPerson(form: BlockPerson) { const blockPersonRes = await HttpService.client.blockPerson(form); - if (blockPersonRes.state == "success") { + if (blockPersonRes.state === "success") { updatePersonBlock(blockPersonRes.data); } } @@ -753,14 +753,14 @@ export class Community extends Component< async handleCommentReport(form: CreateCommentReport) { const reportRes = await HttpService.client.createCommentReport(form); - if (reportRes.state == "success") { + if (reportRes.state === "success") { toast(I18NextService.i18n.t("report_created")); } } async handlePostReport(form: CreatePostReport) { const reportRes = await HttpService.client.createPostReport(form); - if (reportRes.state == "success") { + if (reportRes.state === "success") { toast(I18NextService.i18n.t("report_created")); } } @@ -778,7 +778,7 @@ export class Community extends Component< async handleAddAdmin(form: AddAdmin) { const addAdminRes = await HttpService.client.addAdmin(form); - if (addAdminRes.state == "success") { + if (addAdminRes.state === "success") { this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s)); } } @@ -813,18 +813,18 @@ export class Community extends Component< updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { - if (s.postsRes.state == "success") { + if (s.postsRes.state === "success") { s.postsRes.data.posts - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( c => (c.creator_banned_from_community = banRes.data.banned) ); } - if (s.commentsRes.state == "success") { + if (s.commentsRes.state === "success") { s.commentsRes.data.comments - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( c => (c.creator_banned_from_community = banRes.data.banned) ); @@ -836,16 +836,16 @@ export class Community extends Component< updateBan(banRes: RequestState<BanPersonResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { - if (s.postsRes.state == "success") { + if (s.postsRes.state === "success") { s.postsRes.data.posts - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); } - if (s.commentsRes.state == "success") { + if (s.commentsRes.state === "success") { s.commentsRes.data.comments - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); } return s; @@ -855,7 +855,7 @@ export class Community extends Component< updateCommunity(res: RequestState<CommunityResponse>) { this.setState(s => { - if (s.communityRes.state == "success" && res.state == "success") { + if (s.communityRes.state === "success" && res.state === "success") { s.communityRes.data.community_view = res.data.community_view; s.communityRes.data.discussion_languages = res.data.discussion_languages; @@ -866,7 +866,7 @@ export class Community extends Component< updateCommunityFull(res: RequestState<GetCommunityResponse>) { this.setState(s => { - if (s.communityRes.state == "success" && res.state == "success") { + if (s.communityRes.state === "success" && res.state === "success") { s.communityRes.data.community_view = res.data.community_view; s.communityRes.data.moderators = res.data.moderators; } @@ -875,7 +875,7 @@ export class Community extends Component< } purgeItem(purgeRes: RequestState<PurgeItemResponse>) { - if (purgeRes.state == "success") { + if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } @@ -883,7 +883,7 @@ export class Community extends Component< findAndUpdateComment(res: RequestState<CommentResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editComment( res.data.comment_view, s.commentsRes.data.comments @@ -896,7 +896,7 @@ export class Community extends Component< createAndUpdateComments(res: RequestState<CommentResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments.unshift(res.data.comment_view); // Set finished for the parent @@ -911,7 +911,7 @@ export class Community extends Component< findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editWith( res.data.comment_reply_view, s.commentsRes.data.comments @@ -923,7 +923,7 @@ export class Community extends Component< findAndUpdatePost(res: RequestState<PostResponse>) { this.setState(s => { - if (s.postsRes.state == "success" && res.state == "success") { + if (s.postsRes.state === "success" && res.state === "success") { s.postsRes.data.posts = editPost( res.data.post_view, s.postsRes.data.posts @@ -936,7 +936,7 @@ export class Community extends Component< updateModerators(res: RequestState<AddModToCommunityResponse>) { // Update the moderators this.setState(s => { - if (s.communityRes.state == "success" && res.state == "success") { + if (s.communityRes.state === "success" && res.state === "success") { s.communityRes.data.moderators = res.data.moderators; } return s; diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index ec454de..ace58f9 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -81,13 +81,13 @@ export class Sidebar extends Component<SidebarProps, SidebarState> { componentWillReceiveProps( nextProps: Readonly<{ children?: InfernoNode } & SidebarProps> ): void { - if (this.props.moderators != nextProps.moderators) { + if (this.props.moderators !== nextProps.moderators) { this.setState({ showConfirmLeaveModTeam: false, }); } - if (this.props.community_view != nextProps.community_view) { + if (this.props.community_view !== nextProps.community_view) { this.setState({ showEdit: false, showPurgeDialog: false, diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx index b56dc42..d3c998d 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -274,7 +274,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> { onClick={linkEvent(this, this.handleLeaveAdminTeam)} className="btn btn-danger mb-2" > - {this.state.leaveAdminTeamRes.state == "loading" ? ( + {this.state.leaveAdminTeamRes.state === "loading" ? ( <Spinner /> ) : ( I18NextService.i18n.t("leave_admin_team") diff --git a/src/shared/components/home/emojis-form.tsx b/src/shared/components/home/emojis-form.tsx index cd20ed6..9e65adf 100644 --- a/src/shared/components/home/emojis-form.tsx +++ b/src/shared/components/home/emojis-form.tsx @@ -290,8 +290,8 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> { cv.shortcode.length > 0; const noDuplicateShortCodes = this.state.customEmojis.filter( - x => x.shortcode == cv.shortcode && x.id != cv.id - ).length == 0; + x => x.shortcode === cv.shortcode && x.id !== cv.id + ).length === 0; return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed; } @@ -308,7 +308,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> { const view = customEmojisLookup.get(e.id); if (view) { const page = this.state.customEmojis.find( - x => x.id == view.custom_emoji.id + x => x.id === view.custom_emoji.id )?.page; if (page) { this.setState({ page: page }); @@ -420,7 +420,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> { cv: CustomEmojiViewForm; }) { const pagedIndex = (d.i.state.page - 1) * d.i.itemsPerPage + d.index; - if (d.cv.id != 0) { + if (d.cv.id !== 0) { d.i.props.onDelete({ id: d.cv.id, auth: myAuthRequired(), diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 5d949f3..a7564d4 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -900,7 +900,7 @@ export class Home extends Component<any, HomeState> { async handleBlockPerson(form: BlockPerson) { const blockPersonRes = await HttpService.client.blockPerson(form); - if (blockPersonRes.state == "success") { + if (blockPersonRes.state === "success") { updatePersonBlock(blockPersonRes.data); } } @@ -971,14 +971,14 @@ export class Home extends Component<any, HomeState> { async handleCommentReport(form: CreateCommentReport) { const reportRes = await HttpService.client.createCommentReport(form); - if (reportRes.state == "success") { + if (reportRes.state === "success") { toast(I18NextService.i18n.t("report_created")); } } async handlePostReport(form: CreatePostReport) { const reportRes = await HttpService.client.createPostReport(form); - if (reportRes.state == "success") { + if (reportRes.state === "success") { toast(I18NextService.i18n.t("report_created")); } } @@ -996,7 +996,7 @@ export class Home extends Component<any, HomeState> { async handleAddAdmin(form: AddAdmin) { const addAdminRes = await HttpService.client.addAdmin(form); - if (addAdminRes.state == "success") { + if (addAdminRes.state === "success") { this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s)); } } @@ -1028,18 +1028,18 @@ export class Home extends Component<any, HomeState> { updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { - if (s.postsRes.state == "success") { + if (s.postsRes.state === "success") { s.postsRes.data.posts - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( c => (c.creator_banned_from_community = banRes.data.banned) ); } - if (s.commentsRes.state == "success") { + if (s.commentsRes.state === "success") { s.commentsRes.data.comments - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( c => (c.creator_banned_from_community = banRes.data.banned) ); @@ -1051,16 +1051,16 @@ export class Home extends Component<any, HomeState> { updateBan(banRes: RequestState<BanPersonResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { - if (s.postsRes.state == "success") { + if (s.postsRes.state === "success") { s.postsRes.data.posts - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); } - if (s.commentsRes.state == "success") { + if (s.commentsRes.state === "success") { s.commentsRes.data.comments - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); } return s; @@ -1069,7 +1069,7 @@ export class Home extends Component<any, HomeState> { } purgeItem(purgeRes: RequestState<PurgeItemResponse>) { - if (purgeRes.state == "success") { + if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } @@ -1077,7 +1077,7 @@ export class Home extends Component<any, HomeState> { findAndUpdateComment(res: RequestState<CommentResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editComment( res.data.comment_view, s.commentsRes.data.comments @@ -1090,7 +1090,7 @@ export class Home extends Component<any, HomeState> { createAndUpdateComments(res: RequestState<CommentResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments.unshift(res.data.comment_view); // Set finished for the parent @@ -1105,7 +1105,7 @@ export class Home extends Component<any, HomeState> { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editWith( res.data.comment_reply_view, s.commentsRes.data.comments @@ -1117,7 +1117,7 @@ export class Home extends Component<any, HomeState> { findAndUpdatePost(res: RequestState<PostResponse>) { this.setState(s => { - if (s.postsRes.state == "success" && res.state == "success") { + if (s.postsRes.state === "success" && res.state === "success") { s.postsRes.data.posts = editPost( res.data.post_view, s.postsRes.data.posts diff --git a/src/shared/components/home/login-reset.tsx b/src/shared/components/home/login-reset.tsx index 7d1d002..aeca845 100644 --- a/src/shared/components/home/login-reset.tsx +++ b/src/shared/components/home/login-reset.tsx @@ -127,7 +127,7 @@ export class LoginReset extends Component<any, State> { const res = await HttpService.client.passwordReset({ email }); - if (res.state == "success") { + if (res.state === "success") { toast(I18NextService.i18n.t("reset_password_mail_sent")); i.context.router.history.push("/login"); } diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 828cbb5..ad5afca 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -48,7 +48,7 @@ export class Login extends Component<any, State> { } get isLemmyMl(): boolean { - return isBrowser() && window.location.hostname == "lemmy.ml"; + return isBrowser() && window.location.hostname === "lemmy.ml"; } render() { @@ -124,7 +124,7 @@ export class Login extends Component<any, State> { <div className="mb-3 row"> <div className="col-sm-10"> <button type="submit" className="btn btn-secondary"> - {this.state.loginRes.state == "loading" ? ( + {this.state.loginRes.state === "loading" ? ( <Spinner /> ) : ( I18NextService.i18n.t("login") diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx index 7b3d4c2..7dd433a 100644 --- a/src/shared/components/home/setup.tsx +++ b/src/shared/components/home/setup.tsx @@ -141,7 +141,7 @@ export class Setup extends Component<any, State> { <div className="mb-3 row"> <div className="col-sm-10"> <button type="submit" className="btn btn-secondary"> - {this.state.registerRes.state == "loading" ? ( + {this.state.registerRes.state === "loading" ? ( <Spinner /> ) : ( I18NextService.i18n.t("sign_up") @@ -184,7 +184,7 @@ export class Setup extends Component<any, State> { registerRes: await HttpService.client.register(form), }); - if (i.state.registerRes.state == "success") { + if (i.state.registerRes.state === "success") { const data = i.state.registerRes.data; UserService.Instance.login({ res: data }); diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index c57d545..b6f7233 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -71,7 +71,7 @@ export class Signup extends Component<any, State> { }); this.setState(s => { - if (s.captchaRes.state == "success") { + if (s.captchaRes.state === "success") { s.form.captcha_uuid = s.captchaRes.data.ok?.uuid; } return s; @@ -90,7 +90,7 @@ export class Signup extends Component<any, State> { } get isLemmyMl(): boolean { - return isBrowser() && window.location.hostname == "lemmy.ml"; + return isBrowser() && window.location.hostname === "lemmy.ml"; } render() { @@ -269,7 +269,7 @@ export class Signup extends Component<any, State> { <div className="mb-3 row"> <div className="col-sm-10"> <button type="submit" className="btn btn-secondary"> - {this.state.registerRes.state == "loading" ? ( + {this.state.registerRes.state === "loading" ? ( <Spinner /> ) : ( this.titleName(siteView) @@ -424,7 +424,7 @@ export class Signup extends Component<any, State> { handleRegisterEmailChange(i: Signup, event: any) { i.state.form.email = event.target.value; - if (i.state.form.email == "") { + if (i.state.form.email === "") { i.state.form.email = undefined; } i.setState(i.state); @@ -469,7 +469,7 @@ export class Signup extends Component<any, State> { // This was a bad bug, it should only build the new audio on a new file. // Replays would stop prematurely if this was rebuilt every time. - if (i.state.captchaRes.state == "success" && i.state.captchaRes.data.ok) { + if (i.state.captchaRes.state === "success" && i.state.captchaRes.data.ok) { const captchaRes = i.state.captchaRes.data.ok; if (!i.audio) { const base64 = `data:audio/wav;base64,${captchaRes.wav}`; diff --git a/src/shared/components/home/site-form.tsx b/src/shared/components/home/site-form.tsx index 25e02c8..da44718 100644 --- a/src/shared/components/home/site-form.tsx +++ b/src/shared/components/home/site-form.tsx @@ -293,7 +293,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> { </select> </div> </div> - {this.state.siteForm.registration_mode == "RequireApplication" && ( + {this.state.siteForm.registration_mode === "RequireApplication" && ( <div className="mb-3 row"> <label className="col-12 col-form-label"> {I18NextService.i18n.t("application_questionnaire")} diff --git a/src/shared/components/home/tagline-form.tsx b/src/shared/components/home/tagline-form.tsx index c933ffe..4059003 100644 --- a/src/shared/components/home/tagline-form.tsx +++ b/src/shared/components/home/tagline-form.tsx @@ -48,7 +48,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> { {this.state.taglines.map((cv, index) => ( <tr key={index}> <td> - {this.state.editingRow == index && ( + {this.state.editingRow === index && ( <MarkdownTextArea initialContent={cv} onContentChange={s => @@ -59,7 +59,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> { siteLanguages={[]} /> )} - {this.state.editingRow != index && <div>{cv}</div>} + {this.state.editingRow !== index && <div>{cv}</div>} </td> <td className="text-right"> <button @@ -141,7 +141,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> { handleEditTaglineClick(d: { i: TaglineForm; index: number }, event: any) { event.preventDefault(); - if (d.i.state.editingRow == d.index) { + if (d.i.state.editingRow === d.index) { d.i.setState({ editingRow: undefined }); } else { d.i.setState({ editingRow: d.index }); diff --git a/src/shared/components/modlog.tsx b/src/shared/components/modlog.tsx index ca1cb33..b91da87 100644 --- a/src/shared/components/modlog.tsx +++ b/src/shared/components/modlog.tsx @@ -698,7 +698,7 @@ export class Modlog extends Component< get combined() { const res = this.state.res; - const combined = res.state == "success" ? buildCombined(res.data) : []; + const combined = res.state === "success" ? buildCombined(res.data) : []; return ( <tbody> @@ -723,7 +723,7 @@ export class Modlog extends Component< get amAdminOrMod(): boolean { const amMod_ = - this.state.communityRes.state == "success" && + this.state.communityRes.state === "success" && amMod(this.state.communityRes.data.moderators); return amAdmin() || amMod_; } diff --git a/src/shared/components/person/inbox.tsx b/src/shared/components/person/inbox.tsx index bf246f6..a76fdec 100644 --- a/src/shared/components/person/inbox.tsx +++ b/src/shared/components/person/inbox.tsx @@ -194,14 +194,14 @@ export class Inbox extends Component<any, InboxState> { } get hasUnreads(): boolean { - if (this.state.unreadOrAll == UnreadOrAll.Unread) { + if (this.state.unreadOrAll === UnreadOrAll.Unread) { const { repliesRes, mentionsRes, messagesRes } = this.state; const replyCount = - repliesRes.state == "success" ? repliesRes.data.replies.length : 0; + repliesRes.state === "success" ? repliesRes.data.replies.length : 0; const mentionCount = - mentionsRes.state == "success" ? mentionsRes.data.mentions.length : 0; + mentionsRes.state === "success" ? mentionsRes.data.mentions.length : 0; const messageCount = - messagesRes.state == "success" + messagesRes.state === "success" ? messagesRes.data.private_messages.length : 0; @@ -242,7 +242,7 @@ export class Inbox extends Component<any, InboxState> { className="btn btn-secondary mb-2 mb-sm-3" onClick={linkEvent(this, this.handleMarkAllAsRead)} > - {this.state.markAllAsReadRes.state == "loading" ? ( + {this.state.markAllAsReadRes.state === "loading" ? ( <Spinner /> ) : ( capitalizeFirstLetter( @@ -445,15 +445,15 @@ export class Inbox extends Component<any, InboxState> { buildCombined(): ReplyType[] { const replies: ReplyType[] = - this.state.repliesRes.state == "success" + this.state.repliesRes.state === "success" ? this.state.repliesRes.data.replies.map(this.replyToReplyType) : []; const mentions: ReplyType[] = - this.state.mentionsRes.state == "success" + this.state.mentionsRes.state === "success" ? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType) : []; const messages: ReplyType[] = - this.state.messagesRes.state == "success" + this.state.messagesRes.state === "success" ? this.state.messagesRes.data.private_messages.map( this.messageToReplyType ) @@ -559,9 +559,9 @@ export class Inbox extends Component<any, InboxState> { all() { if ( - this.state.repliesRes.state == "loading" || - this.state.mentionsRes.state == "loading" || - this.state.messagesRes.state == "loading" + this.state.repliesRes.state === "loading" || + this.state.mentionsRes.state === "loading" || + this.state.messagesRes.state === "loading" ) { return ( <h1 className="h4"> @@ -754,7 +754,7 @@ export class Inbox extends Component<any, InboxState> { async refetch() { const sort = this.state.sort; - const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread; + const unread_only = this.state.unreadOrAll === UnreadOrAll.Unread; const page = this.state.page; const limit = fetchLimit; const auth = myAuthRequired(); @@ -806,7 +806,7 @@ export class Inbox extends Component<any, InboxState> { }), }); - if (i.state.markAllAsReadRes.state == "success") { + if (i.state.markAllAsReadRes.state === "success") { i.setState({ repliesRes: { state: "empty" }, mentionsRes: { state: "empty" }, @@ -837,7 +837,7 @@ export class Inbox extends Component<any, InboxState> { async handleBlockPerson(form: BlockPerson) { const blockPersonRes = await HttpService.client.blockPerson(form); - if (blockPersonRes.state == "success") { + if (blockPersonRes.state === "success") { updatePersonBlock(blockPersonRes.data); } } @@ -868,7 +868,7 @@ export class Inbox extends Component<any, InboxState> { async handleDeleteComment(form: DeleteComment) { const res = await HttpService.client.deleteComment(form); - if (res.state == "success") { + if (res.state === "success") { toast(I18NextService.i18n.t("deleted")); this.findAndUpdateComment(res); } @@ -876,7 +876,7 @@ export class Inbox extends Component<any, InboxState> { async handleRemoveComment(form: RemoveComment) { const res = await HttpService.client.removeComment(form); - if (res.state == "success") { + if (res.state === "success") { toast(I18NextService.i18n.t("remove_comment")); this.findAndUpdateComment(res); } @@ -958,7 +958,7 @@ export class Inbox extends Component<any, InboxState> { async handleCreateMessage(form: CreatePrivateMessage) { const res = await HttpService.client.createPrivateMessage(form); this.setState(s => { - if (s.messagesRes.state == "success" && res.state == "success") { + if (s.messagesRes.state === "success" && res.state === "success") { s.messagesRes.data.private_messages.unshift( res.data.private_message_view ); @@ -982,18 +982,18 @@ export class Inbox extends Component<any, InboxState> { updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { - if (s.repliesRes.state == "success") { + if (s.repliesRes.state === "success") { s.repliesRes.data.replies - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( c => (c.creator_banned_from_community = banRes.data.banned) ); } - if (s.mentionsRes.state == "success") { + if (s.mentionsRes.state === "success") { s.mentionsRes.data.mentions - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( c => (c.creator_banned_from_community = banRes.data.banned) ); @@ -1005,16 +1005,16 @@ export class Inbox extends Component<any, InboxState> { updateBan(banRes: RequestState<BanPersonResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { - if (s.repliesRes.state == "success") { + if (s.repliesRes.state === "success") { s.repliesRes.data.replies - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); } - if (s.mentionsRes.state == "success") { + if (s.mentionsRes.state === "success") { s.mentionsRes.data.mentions - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); } return s; @@ -1023,7 +1023,7 @@ export class Inbox extends Component<any, InboxState> { } purgeItem(purgeRes: RequestState<PurgeItemResponse>) { - if (purgeRes.state == "success") { + if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } @@ -1032,22 +1032,22 @@ export class Inbox extends Component<any, InboxState> { reportToast( res: RequestState<PrivateMessageReportResponse | CommentReportResponse> ) { - if (res.state == "success") { + if (res.state === "success") { toast(I18NextService.i18n.t("report_created")); } } // A weird case, since you have only replies and mentions, not comment responses findAndUpdateComment(res: RequestState<CommentResponse>) { - if (res.state == "success") { + if (res.state === "success") { this.setState(s => { - if (s.repliesRes.state == "success") { + if (s.repliesRes.state === "success") { s.repliesRes.data.replies = editWith( res.data.comment_view, s.repliesRes.data.replies ); } - if (s.mentionsRes.state == "success") { + if (s.mentionsRes.state === "success") { s.mentionsRes.data.mentions = editWith( res.data.comment_view, s.mentionsRes.data.mentions @@ -1065,7 +1065,7 @@ export class Inbox extends Component<any, InboxState> { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { this.setState(s => { - if (s.repliesRes.state == "success" && res.state == "success") { + if (s.repliesRes.state === "success" && res.state === "success") { s.repliesRes.data.replies = editCommentReply( res.data.comment_reply_view, s.repliesRes.data.replies @@ -1077,7 +1077,7 @@ export class Inbox extends Component<any, InboxState> { findAndUpdateMention(res: RequestState<PersonMentionResponse>) { this.setState(s => { - if (s.mentionsRes.state == "success" && res.state == "success") { + if (s.mentionsRes.state === "success" && res.state === "success") { s.mentionsRes.data.mentions = editMention( res.data.person_mention_view, s.mentionsRes.data.mentions diff --git a/src/shared/components/person/password-change.tsx b/src/shared/components/person/password-change.tsx index 1a60c96..bfbeb71 100644 --- a/src/shared/components/person/password-change.tsx +++ b/src/shared/components/person/password-change.tsx @@ -81,7 +81,7 @@ export class PasswordChange extends Component<any, State> { <div className="mb-3 row"> <div className="col-sm-10"> <button type="submit" className="btn btn-secondary"> - {this.state.passwordChangeRes.state == "loading" ? ( + {this.state.passwordChangeRes.state === "loading" ? ( <Spinner /> ) : ( capitalizeFirstLetter(I18NextService.i18n.t("save")) diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index d493f78..9aaa3d3 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -300,7 +300,7 @@ export class Profile extends Component< get documentTitle(): string { const siteName = this.state.siteRes.site_view.site.name; const res = this.state.personRes; - return res.state == "success" + return res.state === "success" ? `@${res.data.person_view.person.name} - ${siteName}` : siteName; } @@ -764,7 +764,7 @@ export class Profile extends Component< const personRes = i.state.personRes; - if (personRes.state == "success") { + if (personRes.state === "success") { const person = personRes.data.person_view.person; const ban = !person.banned; @@ -793,7 +793,7 @@ export class Profile extends Component< block, auth: myAuthRequired(), }); - if (res.state == "success") { + if (res.state === "success") { updatePersonBlock(res.data); } } @@ -924,7 +924,7 @@ export class Profile extends Component< async handleAddAdmin(form: AddAdmin) { const addAdminRes = await HttpService.client.addAdmin(form); - if (addAdminRes.state == "success") { + if (addAdminRes.state === "success") { this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s)); } } @@ -958,7 +958,7 @@ export class Profile extends Component< // Maybe not necessary if (banRes.state === "success") { this.setState(s => { - if (s.personRes.state == "success") { + if (s.personRes.state === "success") { s.personRes.data.posts .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( @@ -978,14 +978,14 @@ export class Profile extends Component< updateBan(banRes: RequestState<BanPersonResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { - if (s.personRes.state == "success") { + if (s.personRes.state === "success") { s.personRes.data.posts - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); s.personRes.data.comments - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); s.personRes.data.person_view.person.banned = banRes.data.banned; } @@ -995,7 +995,7 @@ export class Profile extends Component< } purgeItem(purgeRes: RequestState<PurgeItemResponse>) { - if (purgeRes.state == "success") { + if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } @@ -1003,7 +1003,7 @@ export class Profile extends Component< findAndUpdateComment(res: RequestState<CommentResponse>) { this.setState(s => { - if (s.personRes.state == "success" && res.state == "success") { + if (s.personRes.state === "success" && res.state === "success") { s.personRes.data.comments = editComment( res.data.comment_view, s.personRes.data.comments @@ -1016,7 +1016,7 @@ export class Profile extends Component< createAndUpdateComments(res: RequestState<CommentResponse>) { this.setState(s => { - if (s.personRes.state == "success" && res.state == "success") { + if (s.personRes.state === "success" && res.state === "success") { s.personRes.data.comments.unshift(res.data.comment_view); // Set finished for the parent s.finished.set( @@ -1030,7 +1030,7 @@ export class Profile extends Component< findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { this.setState(s => { - if (s.personRes.state == "success" && res.state == "success") { + if (s.personRes.state === "success" && res.state === "success") { s.personRes.data.comments = editWith( res.data.comment_reply_view, s.personRes.data.comments @@ -1042,7 +1042,7 @@ export class Profile extends Component< findAndUpdatePost(res: RequestState<PostResponse>) { this.setState(s => { - if (s.personRes.state == "success" && res.state == "success") { + if (s.personRes.state === "success" && res.state === "success") { s.personRes.data.posts = editPost( res.data.post_view, s.personRes.data.posts diff --git a/src/shared/components/person/registration-applications.tsx b/src/shared/components/person/registration-applications.tsx index 757170f..fbf5f46 100644 --- a/src/shared/components/person/registration-applications.tsx +++ b/src/shared/components/person/registration-applications.tsx @@ -220,7 +220,7 @@ export class RegistrationApplications extends Component< } async refetch() { - const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread; + const unread_only = this.state.unreadOrAll === UnreadOrAll.Unread; this.setState({ appsRes: { state: "loading" }, }); @@ -239,7 +239,7 @@ export class RegistrationApplications extends Component< form ); this.setState(s => { - if (s.appsRes.state == "success" && approveRes.state == "success") { + if (s.appsRes.state === "success" && approveRes.state === "success") { s.appsRes.data.registration_applications = editRegistrationApplication( approveRes.data.registration_application, s.appsRes.data.registration_applications diff --git a/src/shared/components/person/reports.tsx b/src/shared/components/person/reports.tsx index d298930..ba488f6 100644 --- a/src/shared/components/person/reports.tsx +++ b/src/shared/components/person/reports.tsx @@ -352,18 +352,18 @@ export class Reports extends Component<any, ReportsState> { get buildCombined(): ItemType[] { const commentRes = this.state.commentReportsRes; const comments = - commentRes.state == "success" + commentRes.state === "success" ? commentRes.data.comment_reports.map(this.commentReportToItemType) : []; const postRes = this.state.postReportsRes; const posts = - postRes.state == "success" + postRes.state === "success" ? postRes.data.post_reports.map(this.postReportToItemType) : []; const pmRes = this.state.messageReportsRes; const privateMessages = - pmRes.state == "success" + pmRes.state === "success" ? pmRes.data.private_message_reports.map( this.privateMessageReportToItemType ) @@ -565,7 +565,7 @@ export class Reports extends Component<any, ReportsState> { } async refetch() { - const unresolved_only = this.state.unreadOrAll == UnreadOrAll.Unread; + const unresolved_only = this.state.unreadOrAll === UnreadOrAll.Unread; const page = this.state.page; const limit = fetchLimit; const auth = myAuthRequired(); @@ -617,7 +617,7 @@ export class Reports extends Component<any, ReportsState> { findAndUpdateCommentReport(res: RequestState<CommentReportResponse>) { this.setState(s => { - if (s.commentReportsRes.state == "success" && res.state == "success") { + if (s.commentReportsRes.state === "success" && res.state === "success") { s.commentReportsRes.data.comment_reports = editCommentReport( res.data.comment_report_view, s.commentReportsRes.data.comment_reports @@ -629,7 +629,7 @@ export class Reports extends Component<any, ReportsState> { findAndUpdatePostReport(res: RequestState<PostReportResponse>) { this.setState(s => { - if (s.postReportsRes.state == "success" && res.state == "success") { + if (s.postReportsRes.state === "success" && res.state === "success") { s.postReportsRes.data.post_reports = editPostReport( res.data.post_report_view, s.postReportsRes.data.post_reports @@ -643,7 +643,7 @@ export class Reports extends Component<any, ReportsState> { res: RequestState<PrivateMessageReportResponse> ) { this.setState(s => { - if (s.messageReportsRes.state == "success" && res.state == "success") { + if (s.messageReportsRes.state === "success" && res.state === "success") { s.messageReportsRes.data.private_message_reports = editPrivateMessageReport( res.data.private_message_report_view, diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx index 1db77c9..4a6a21c 100644 --- a/src/shared/components/person/settings.tsx +++ b/src/shared/components/person/settings.tsx @@ -887,7 +887,7 @@ export class Settings extends Component<any, SettingsState> { id="user-remove-totp" type="checkbox" checked={ - this.state.saveUserSettingsForm.generate_totp_2fa == false + this.state.saveUserSettingsForm.generate_totp_2fa === false } onChange={linkEvent(this, this.handleRemoveTotp)} /> @@ -1132,13 +1132,13 @@ export class Settings extends Component<any, SettingsState> { handleNewPasswordChange(i: Settings, event: any) { const newPass: string | undefined = - event.target.value == "" ? undefined : event.target.value; + event.target.value === "" ? undefined : event.target.value; i.setState(s => ((s.changePasswordForm.new_password = newPass), s)); } handleNewPasswordVerifyChange(i: Settings, event: any) { const newPassVerify: string | undefined = - event.target.value == "" ? undefined : event.target.value; + event.target.value === "" ? undefined : event.target.value; i.setState( s => ((s.changePasswordForm.new_password_verify = newPassVerify), s) ); @@ -1146,7 +1146,7 @@ export class Settings extends Component<any, SettingsState> { handleOldPasswordChange(i: Settings, event: any) { const oldPass: string | undefined = - event.target.value == "" ? undefined : event.target.value; + event.target.value === "" ? undefined : event.target.value; i.setState(s => ((s.changePasswordForm.old_password = oldPass), s)); } diff --git a/src/shared/components/person/verify-email.tsx b/src/shared/components/person/verify-email.tsx index 66e5959..b736146 100644 --- a/src/shared/components/person/verify-email.tsx +++ b/src/shared/components/person/verify-email.tsx @@ -35,7 +35,7 @@ export class VerifyEmail extends Component<any, State> { }), }); - if (this.state.verifyRes.state == "success") { + if (this.state.verifyRes.state === "success") { toast(I18NextService.i18n.t("email_verified")); this.props.history.push("/login"); } @@ -61,7 +61,7 @@ export class VerifyEmail extends Component<any, State> { <div className="row"> <div className="col-12 col-lg-6 offset-lg-3 mb-4"> <h1 className="h4 mb-4">{I18NextService.i18n.t("verify_email")}</h1> - {this.state.verifyRes.state == "loading" && ( + {this.state.verifyRes.state === "loading" && ( <h5> <Spinner large /> </h5> diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index 98def03..afa2fff 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -312,7 +312,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> { componentWillReceiveProps( nextProps: Readonly<{ children?: InfernoNode } & PostFormProps> ): void { - if (this.props != nextProps) { + if (this.props !== nextProps) { this.setState( s => ( (s.form.community_id = getIdFromString( diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 30b1865..d661443 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -765,7 +765,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { get unreadCount(): number | undefined { const pv = this.postView; - return pv.unread_comments == pv.counts.comments || pv.unread_comments == 0 + return pv.unread_comments === pv.counts.comments || pv.unread_comments === 0 ? undefined : pv.unread_comments; } @@ -1136,7 +1136,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { removeAndBanDialogs() { const post = this.postView; const purgeTypeText = - this.state.purgeType == PurgeType.Post + this.state.purgeType === PurgeType.Post ? I18NextService.i18n.t("purge_post") : `${I18NextService.i18n.t("purge")} ${post.creator.name}`; return ( @@ -1405,7 +1405,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { private get myPost(): boolean { return ( - this.postView.creator.id == + this.postView.creator.id === UserService.Instance.myUserInfo?.local_user_view.person.id ); } @@ -1644,7 +1644,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { const ban = !i.props.post_view.creator_banned_from_community; // If its an unban, restore all their data - if (ban == false) { + if (ban === false) { i.setState({ removeData: false }); } const person_id = i.props.post_view.creator.id; @@ -1652,7 +1652,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> { const reason = i.state.banReason; const expires = futureDaysToUnixTime(i.state.banExpireDays); - if (i.state.banType == BanType.Community) { + if (i.state.banType === BanType.Community) { const community_id = i.postView.community.id; i.props.onBanPersonFromCommunity({ community_id, diff --git a/src/shared/components/post/post-listings.tsx b/src/shared/components/post/post-listings.tsx index 1fdaeba..3f6c304 100644 --- a/src/shared/components/post/post-listings.tsx +++ b/src/shared/components/post/post-listings.tsx @@ -141,7 +141,7 @@ export class PostListings extends Component<PostListingsProps, any> { // Sort by oldest // Remove the ones that have no length for (const e of urlMap.entries()) { - if (e[1].length == 1) { + if (e[1].length === 1) { urlMap.delete(e[0]); } else { e[1].sort((a, b) => a.post.published.localeCompare(b.post.published)); @@ -155,7 +155,7 @@ export class PostListings extends Component<PostListingsProps, any> { const found = urlMap.get(url); if (found) { // If its the oldest, add - if (pv.post.id == found[0].post.id) { + if (pv.post.id === found[0].post.id) { this.duplicatesMap.set(pv.post.id, found.slice(1)); } // Otherwise, delete it diff --git a/src/shared/components/post/post-report.tsx b/src/shared/components/post/post-report.tsx index 9b2540b..8de646f 100644 --- a/src/shared/components/post/post-report.tsx +++ b/src/shared/components/post/post-report.tsx @@ -28,7 +28,7 @@ export class PostReport extends Component<PostReportProps, PostReportState> { componentWillReceiveProps( nextProps: Readonly<{ children?: InfernoNode } & PostReportProps> ): void { - if (this.props != nextProps) { + if (this.props !== nextProps) { this.setState({ loading: false }); } } diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 003ad71..b1b8e32 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -309,7 +309,7 @@ export class Post extends Component<any, PostState> { const wrappedElement = document.getElementsByClassName("comments")[0]; if (wrappedElement && this.isBottom(wrappedElement)) { const commentCount = - this.state.commentsRes.state == "success" + this.state.commentsRes.state === "success" ? this.state.commentsRes.data.comments.length : 0; @@ -323,13 +323,13 @@ export class Post extends Component<any, PostState> { get documentTitle(): string { const siteName = this.state.siteRes.site_view.site.name; - return this.state.postRes.state == "success" + return this.state.postRes.state === "success" ? `${this.state.postRes.data.post_view.post.name} - ${siteName}` : siteName; } get imageTag(): string | undefined { - if (this.state.postRes.state == "success") { + if (this.state.postRes.state === "success") { const post = this.state.postRes.data.post_view.post; const thumbnail = post.thumbnail_url; const url = post.url; @@ -413,9 +413,9 @@ export class Post extends Component<any, PostState> { {this.state.showSidebarMobile && this.sidebar()} </div> {this.sortRadios()} - {this.state.commentViewType == CommentViewType.Tree && + {this.state.commentViewType === CommentViewType.Tree && this.commentsTree()} - {this.state.commentViewType == CommentViewType.Flat && + {this.state.commentViewType === CommentViewType.Flat && this.commentsFlat()} </main> <aside className="d-none d-md-block col-md-4 col-lg-3"> @@ -535,7 +535,7 @@ export class Post extends Component<any, PostState> { const commentsRes = this.state.commentsRes; const postRes = this.state.postRes; - if (commentsRes.state == "success" && postRes.state == "success") { + if (commentsRes.state === "success" && postRes.state === "success") { return ( <div> <CommentNodes @@ -607,7 +607,7 @@ export class Post extends Component<any, PostState> { const showContextButton = depth ? depth > 0 : false; return ( - res.state == "success" && ( + res.state === "success" && ( <div> {!!this.state.commentId && ( <> @@ -664,7 +664,7 @@ export class Post extends Component<any, PostState> { } commentTree(): CommentNodeI[] { - if (this.state.commentsRes.state == "success") { + if (this.state.commentsRes.state === "success") { return buildCommentsTree( this.state.commentsRes.data.comments, !!this.state.commentId @@ -696,14 +696,14 @@ export class Post extends Component<any, PostState> { } handleViewPost(i: Post) { - if (i.state.postRes.state == "success") { + if (i.state.postRes.state === "success") { const id = i.state.postRes.data.post_view.post.id; i.context.router.history.push(`/post/${id}`); } } handleViewContext(i: Post) { - if (i.state.commentsRes.state == "success") { + if (i.state.commentsRes.state === "success") { const parentId = getCommentParentId( i.state.commentsRes.data.comments.at(0)?.comment ); @@ -732,7 +732,7 @@ export class Post extends Component<any, PostState> { const communityId = followCommunityRes.data.community_view.community.id; const mui = UserService.Instance.myUserInfo; if (mui) { - mui.follows = mui.follows.filter(i => i.community.id != communityId); + mui.follows = mui.follows.filter(i => i.community.id !== communityId); } } } @@ -759,10 +759,10 @@ export class Post extends Component<any, PostState> { async handleBlockCommunity(form: BlockCommunity) { const blockCommunityRes = await HttpService.client.blockCommunity(form); - if (blockCommunityRes.state == "success") { + if (blockCommunityRes.state === "success") { updateCommunityBlock(blockCommunityRes.data); this.setState(s => { - if (s.postRes.state == "success") { + if (s.postRes.state === "success") { s.postRes.data.community_view.blocked = blockCommunityRes.data.blocked; } @@ -772,7 +772,7 @@ export class Post extends Component<any, PostState> { async handleBlockPerson(form: BlockPerson) { const blockPersonRes = await HttpService.client.blockPerson(form); - if (blockPersonRes.state == "success") { + if (blockPersonRes.state === "success") { updatePersonBlock(blockPersonRes.data); } } @@ -855,14 +855,14 @@ export class Post extends Component<any, PostState> { async handleCommentReport(form: CreateCommentReport) { const reportRes = await HttpService.client.createCommentReport(form); - if (reportRes.state == "success") { + if (reportRes.state === "success") { toast(I18NextService.i18n.t("report_created")); } } async handlePostReport(form: CreatePostReport) { const reportRes = await HttpService.client.createPostReport(form); - if (reportRes.state == "success") { + if (reportRes.state === "success") { toast(I18NextService.i18n.t("report_created")); } } @@ -895,8 +895,8 @@ export class Post extends Component<any, PostState> { async handleFetchChildren(form: GetComments) { const moreCommentsRes = await HttpService.client.getComments(form); if ( - this.state.commentsRes.state == "success" && - moreCommentsRes.state == "success" + this.state.commentsRes.state === "success" && + moreCommentsRes.state === "success" ) { const newComments = moreCommentsRes.data.comments; // Remove the first comment, since it is the parent @@ -929,19 +929,19 @@ export class Post extends Component<any, PostState> { updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { if ( - s.postRes.state == "success" && - s.postRes.data.post_view.creator.id == + s.postRes.state === "success" && + s.postRes.data.post_view.creator.id === banRes.data.person_view.person.id ) { s.postRes.data.post_view.creator_banned_from_community = banRes.data.banned; } - if (s.commentsRes.state == "success") { + if (s.commentsRes.state === "success") { s.commentsRes.data.comments - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach( c => (c.creator_banned_from_community = banRes.data.banned) ); @@ -953,18 +953,18 @@ export class Post extends Component<any, PostState> { updateBan(banRes: RequestState<BanPersonResponse>) { // Maybe not necessary - if (banRes.state == "success") { + if (banRes.state === "success") { this.setState(s => { if ( - s.postRes.state == "success" && - s.postRes.data.post_view.creator.id == + s.postRes.state === "success" && + s.postRes.data.post_view.creator.id === banRes.data.person_view.person.id ) { s.postRes.data.post_view.creator.banned = banRes.data.banned; } - if (s.commentsRes.state == "success") { + if (s.commentsRes.state === "success") { s.commentsRes.data.comments - .filter(c => c.creator.id == banRes.data.person_view.person.id) + .filter(c => c.creator.id === banRes.data.person_view.person.id) .forEach(c => (c.creator.banned = banRes.data.banned)); } return s; @@ -974,7 +974,7 @@ export class Post extends Component<any, PostState> { updateCommunity(communityRes: RequestState<CommunityResponse>) { this.setState(s => { - if (s.postRes.state == "success" && communityRes.state == "success") { + if (s.postRes.state === "success" && communityRes.state === "success") { s.postRes.data.community_view = communityRes.data.community_view; } return s; @@ -983,7 +983,7 @@ export class Post extends Component<any, PostState> { updateCommunityFull(res: RequestState<GetCommunityResponse>) { this.setState(s => { - if (s.postRes.state == "success" && res.state == "success") { + if (s.postRes.state === "success" && res.state === "success") { s.postRes.data.community_view = res.data.community_view; s.postRes.data.moderators = res.data.moderators; } @@ -993,7 +993,7 @@ export class Post extends Component<any, PostState> { updatePost(post: RequestState<PostResponse>) { this.setState(s => { - if (s.postRes.state == "success" && post.state == "success") { + if (s.postRes.state === "success" && post.state === "success") { s.postRes.data.post_view = post.data.post_view; } return s; @@ -1001,7 +1001,7 @@ export class Post extends Component<any, PostState> { } purgeItem(purgeRes: RequestState<PurgeItemResponse>) { - if (purgeRes.state == "success") { + if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } @@ -1024,7 +1024,7 @@ export class Post extends Component<any, PostState> { findAndUpdateComment(res: RequestState<CommentResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editComment( res.data.comment_view, s.commentsRes.data.comments @@ -1037,7 +1037,7 @@ export class Post extends Component<any, PostState> { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { this.setState(s => { - if (s.commentsRes.state == "success" && res.state == "success") { + if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editWith( res.data.comment_reply_view, s.commentsRes.data.comments @@ -1050,7 +1050,7 @@ export class Post extends Component<any, PostState> { updateModerators(res: RequestState<AddModToCommunityResponse>) { // Update the moderators this.setState(s => { - if (s.postRes.state == "success" && res.state == "success") { + if (s.postRes.state === "success" && res.state === "success") { s.postRes.data.moderators = res.data.moderators; } return s; diff --git a/src/shared/components/private_message/create-private-message.tsx b/src/shared/components/private_message/create-private-message.tsx index f2b84f0..805b3ec 100644 --- a/src/shared/components/private_message/create-private-message.tsx +++ b/src/shared/components/private_message/create-private-message.tsx @@ -94,7 +94,7 @@ export class CreatePrivateMessage extends Component< } get documentTitle(): string { - if (this.state.recipientRes.state == "success") { + if (this.state.recipientRes.state === "success") { const name_ = this.state.recipientRes.data.person_view.person.name; return `${I18NextService.i18n.t("create_private_message")} - ${name_}`; } else { @@ -144,7 +144,7 @@ export class CreatePrivateMessage extends Component< async handlePrivateMessageCreate(form: CreatePrivateMessageI) { const res = await HttpService.client.createPrivateMessage(form); - if (res.state == "success") { + if (res.state === "success") { toast(I18NextService.i18n.t("message_sent")); // Navigate to the front diff --git a/src/shared/components/private_message/private-message-form.tsx b/src/shared/components/private_message/private-message-form.tsx index 4645f8c..60d064f 100644 --- a/src/shared/components/private_message/private-message-form.tsx +++ b/src/shared/components/private_message/private-message-form.tsx @@ -58,7 +58,7 @@ export class PrivateMessageForm extends Component< componentWillReceiveProps( nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageFormProps> ): void { - if (this.props != nextProps) { + if (this.props !== nextProps) { this.setState({ loading: false, content: undefined, previewMode: false }); } } diff --git a/src/shared/components/private_message/private-message-report.tsx b/src/shared/components/private_message/private-message-report.tsx index d15f18c..de6ef77 100644 --- a/src/shared/components/private_message/private-message-report.tsx +++ b/src/shared/components/private_message/private-message-report.tsx @@ -31,7 +31,7 @@ export class PrivateMessageReport extends Component<Props, State> { componentWillReceiveProps( nextProps: Readonly<{ children?: InfernoNode } & Props> ): void { - if (this.props != nextProps) { + if (this.props !== nextProps) { this.setState({ loading: false }); } } diff --git a/src/shared/components/private_message/private-message.tsx b/src/shared/components/private_message/private-message.tsx index 14270b6..099d875 100644 --- a/src/shared/components/private_message/private-message.tsx +++ b/src/shared/components/private_message/private-message.tsx @@ -59,7 +59,7 @@ export class PrivateMessage extends Component< get mine(): boolean { return ( - UserService.Instance.myUserInfo?.local_user_view.person.id == + UserService.Instance.myUserInfo?.local_user_view.person.id === this.props.private_message_view.creator.id ); } @@ -67,7 +67,7 @@ export class PrivateMessage extends Component< componentWillReceiveProps( nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps> ): void { - if (this.props != nextProps) { + if (this.props !== nextProps) { this.setState({ showReply: false, showEdit: false, diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 36bfca8..2891870 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -545,7 +545,7 @@ export class Search extends Component<any, SearchState> { } = this.state; const hasCommunities = - communitiesRes.state == "success" && + communitiesRes.state === "success" && communitiesRes.data.communities.length > 0; return ( @@ -619,7 +619,7 @@ export class Search extends Component<any, SearchState> { } = this.state; // Push the possible resolve / federated objects first - if (resolveObjectResponse.state == "success") { + if (resolveObjectResponse.state === "success") { const { comment, post, community, person } = resolveObjectResponse.data; if (comment) { diff --git a/src/shared/markdown.ts b/src/shared/markdown.ts index 142000d..4762d4b 100644 --- a/src/shared/markdown.ts +++ b/src/shared/markdown.ts @@ -197,7 +197,7 @@ export function setupMarkdown() { const item = tokens[idx] as any; const title = item.attrs.length >= 3 ? item.attrs[2][1] : ""; const customEmoji = customEmojisLookup.get(title); - const isCustomEmoji = customEmoji != undefined; + const isCustomEmoji = customEmoji !== undefined; if (!isCustomEmoji) { return defaultRenderer?.(tokens, idx, options, env, self) ?? ""; } @@ -242,9 +242,9 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) { skins: [{ src: custom_emoji_view.custom_emoji.image_url }], }; const categoryIndex = customEmojis.findIndex( - x => x.id == custom_emoji_view.custom_emoji.category + x => x.id === custom_emoji_view.custom_emoji.category ); - if (categoryIndex == -1) { + if (categoryIndex === -1) { customEmojis.push({ id: custom_emoji_view.custom_emoji.category, name: custom_emoji_view.custom_emoji.category, @@ -252,9 +252,9 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) { }); } else { const emojiIndex = customEmojis[categoryIndex].emojis.findIndex( - x => x.id == custom_emoji_view.custom_emoji.shortcode + x => x.id === custom_emoji_view.custom_emoji.shortcode ); - if (emojiIndex == -1) { + if (emojiIndex === -1) { customEmojis[categoryIndex].emojis.push(emoji); } else { customEmojis[categoryIndex].emojis[emojiIndex] = emoji; @@ -276,10 +276,10 @@ export function removeFromEmojiDataModel(id: number) { } if (!view) return; const categoryIndex = customEmojis.findIndex( - x => x.id == view?.custom_emoji.category + x => x.id === view?.custom_emoji.category ); const emojiIndex = customEmojis[categoryIndex].emojis.findIndex( - x => x.id == view?.custom_emoji.shortcode + x => x.id === view?.custom_emoji.shortcode ); customEmojis[categoryIndex].emojis = customEmojis[ categoryIndex @@ -317,7 +317,7 @@ export function setupTribute() { const customEmoji = customEmojisLookup.get( item.original.key )?.custom_emoji; - if (customEmoji == undefined) return `${item.original.val}`; + if (customEmoji === undefined) return `${item.original.val}`; else return `![${customEmoji.alt_text}](${customEmoji.image_url} "${customEmoji.shortcode}")`; }, diff --git a/src/shared/utils/app/new-vote.ts b/src/shared/utils/app/new-vote.ts index 030fa79..431d07b 100644 --- a/src/shared/utils/app/new-vote.ts +++ b/src/shared/utils/app/new-vote.ts @@ -1,9 +1,9 @@ import { VoteType } from "../../interfaces"; export default function newVote(voteType: VoteType, myVote?: number): number { - if (voteType == VoteType.Upvote) { - return myVote == 1 ? 0 : 1; + if (voteType === VoteType.Upvote) { + return myVote === 1 ? 0 : 1; } else { - return myVote == -1 ? 0 : -1; + return myVote === -1 ? 0 : -1; } } diff --git a/src/shared/utils/app/selectable-languages.ts b/src/shared/utils/app/selectable-languages.ts index 8079abd..d1754cc 100644 --- a/src/shared/utils/app/selectable-languages.ts +++ b/src/shared/utils/app/selectable-languages.ts @@ -17,8 +17,8 @@ export default function selectableLanguages( ): Language[] { const allLangIds = allLanguages.map(l => l.id); let myLangs = myUserInfo?.discussion_languages ?? allLangIds; - myLangs = myLangs.length == 0 ? allLangIds : myLangs; - const siteLangs = siteLanguages.length == 0 ? allLangIds : siteLanguages; + myLangs = myLangs.length === 0 ? allLangIds : myLangs; + const siteLangs = siteLanguages.length === 0 ? allLangIds : siteLanguages; if (showAll) { return allLanguages; diff --git a/src/shared/utils/app/set-theme.ts b/src/shared/utils/app/set-theme.ts index 6d9d46c..9c6488f 100644 --- a/src/shared/utils/app/set-theme.ts +++ b/src/shared/utils/app/set-theme.ts @@ -9,7 +9,7 @@ export default async function setTheme(theme: string, forceReload = false) { return; } // This is only run on a force reload - if (theme == "browser") { + if (theme === "browser") { theme = "darkly"; } diff --git a/src/shared/utils/env/get-external-host.ts b/src/shared/utils/env/get-external-host.ts index 7e2635d..093055e 100644 --- a/src/shared/utils/env/get-external-host.ts +++ b/src/shared/utils/env/get-external-host.ts @@ -6,7 +6,7 @@ export default function getExternalHost() { ? `${window.location.hostname}${ ["1234", "1235"].includes(window.location.port) ? ":8536" - : window.location.port == "" + : window.location.port === "" ? "" : `:${window.location.port}` }` diff --git a/src/shared/utils/helpers/get-random-from-list.ts b/src/shared/utils/helpers/get-random-from-list.ts index 065eb7a..a0ddecb 100644 --- a/src/shared/utils/helpers/get-random-from-list.ts +++ b/src/shared/utils/helpers/get-random-from-list.ts @@ -1,5 +1,5 @@ export default function getRandomFromList<T>(list: T[]): T | undefined { - return list.length == 0 + return list.length === 0 ? undefined : list.at(Math.floor(Math.random() * list.length)); } diff --git a/src/shared/utils/roles/am-community-creator.ts b/src/shared/utils/roles/am-community-creator.ts index 3671ef2..3fcd228 100644 --- a/src/shared/utils/roles/am-community-creator.ts +++ b/src/shared/utils/roles/am-community-creator.ts @@ -8,5 +8,5 @@ export default function amCommunityCreator( ): boolean { const myId = myUserInfo?.local_user_view.person.id; // Don't allow mod actions on yourself - return myId == mods?.at(0)?.moderator.id && myId != creator_id; + return myId === mods?.at(0)?.moderator.id && myId !== creator_id; } diff --git a/src/shared/utils/roles/am-site-creator.ts b/src/shared/utils/roles/am-site-creator.ts index 9da2840..071d28c 100644 --- a/src/shared/utils/roles/am-site-creator.ts +++ b/src/shared/utils/roles/am-site-creator.ts @@ -7,5 +7,5 @@ export default function amSiteCreator( myUserInfo = UserService.Instance.myUserInfo ): boolean { const myId = myUserInfo?.local_user_view.person.id; - return myId == admins?.at(0)?.person.id && myId != creator_id; + return myId === admins?.at(0)?.person.id && myId !== creator_id; } diff --git a/src/shared/utils/roles/am-top-mod.ts b/src/shared/utils/roles/am-top-mod.ts index 9163d7c..3f96208 100644 --- a/src/shared/utils/roles/am-top-mod.ts +++ b/src/shared/utils/roles/am-top-mod.ts @@ -5,5 +5,5 @@ export default function amTopMod( mods: CommunityModeratorView[], myUserInfo = UserService.Instance.myUserInfo ): boolean { - return mods.at(0)?.moderator.id == myUserInfo?.local_user_view.person.id; + return mods.at(0)?.moderator.id === myUserInfo?.local_user_view.person.id; } diff --git a/src/shared/utils/roles/can-mod.ts b/src/shared/utils/roles/can-mod.ts index df639b7..ae2bf44 100644 --- a/src/shared/utils/roles/can-mod.ts +++ b/src/shared/utils/roles/can-mod.ts @@ -16,9 +16,9 @@ export default function canMod( if (myUserInfo) { const myIndex = adminsThenMods.findIndex( - id => id == myUserInfo.local_user_view.person.id + id => id === myUserInfo.local_user_view.person.id ); - if (myIndex == -1) { + if (myIndex === -1) { return false; } else { // onSelf +1 on mod actions not for yourself, IE ban, remove, etc