From: SleeplessOne1917 Date: Fri, 28 Jul 2023 20:07:16 +0000 (+0000) Subject: ES-Lint tweak (#2001) X-Git-Url: http://these/git/%7B%60/feeds/c/static/gitweb.css?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 { } 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 { } 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 { } 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 { ); } else if ( - this.props.defaultTheme != "browser" && - this.props.defaultTheme != "browser-compact" + this.props.defaultTheme !== "browser" && + this.props.defaultTheme !== "browser-compact" ) { return ( @@ -34,7 +34,7 @@ export class Theme extends Component { /> ); - } else if (this.props.defaultTheme == "browser-compact") { + } else if (this.props.defaultTheme === "browser-compact") { return ( { 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 { : 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 { 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 { 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 { 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 {
- {this.state.siteForm.registration_mode == "RequireApplication" && ( + {this.state.siteForm.registration_mode === "RequireApplication" && (