From 3109ee80159617ccb7089bb3c7d96fc3f08d7d38 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 16 Mar 2023 11:19:53 -0700 Subject: [PATCH] eslint: Enable @typescript-eslint/recommended plugin. This is not automatically enabled by @typescript-eslint/recommended-requiring-type-checking for some reason. https://typescript-eslint.io/linting/configs/#recommended Signed-off-by: Anders Kaseorg --- .eslintrc.json | 3 ++- web/e2e-tests/stream_create.test.ts | 5 +---- web/src/global.d.ts | 2 +- web/src/timerender.ts | 2 +- web/src/ui_report.ts | 2 +- web/src/ui_util.ts | 2 +- web/src/util.ts | 2 +- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index a2753f03ab..77632591a1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -145,6 +145,7 @@ { "files": ["**/*.ts"], "extends": [ + "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking", "plugin:import/typescript" ], @@ -164,7 +165,6 @@ "rules": { // Disable base rule to avoid conflict "no-duplicate-imports": "off", - "no-unused-vars": "off", "no-useless-constructor": "off", "no-use-before-define": "off", @@ -178,6 +178,7 @@ "@typescript-eslint/member-ordering": "error", "@typescript-eslint/no-duplicate-imports": "error", "@typescript-eslint/no-extraneous-class": "error", + "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-parameter-properties": "error", "@typescript-eslint/no-unnecessary-qualifier": "error", "@typescript-eslint/no-unsafe-argument": "off", diff --git a/web/e2e-tests/stream_create.test.ts b/web/e2e-tests/stream_create.test.ts index 14e8fd1e89..b62a76d39b 100644 --- a/web/e2e-tests/stream_create.test.ts +++ b/web/e2e-tests/stream_create.test.ts @@ -22,10 +22,7 @@ async function await_user_hidden(page: Page, name: string): Promise { async function add_user_to_stream(page: Page, name: string): Promise { const user_id = await common.get_user_id_from_name(page, name); - await page.evaluate( - (user_id: Number) => zulip_test.add_user_id_to_new_stream(user_id), - user_id, - ); + await page.evaluate((user_id) => zulip_test.add_user_id_to_new_stream(user_id), user_id); await await_user_visible(page, name); } diff --git a/web/src/global.d.ts b/web/src/global.d.ts index 5bdd7711fb..f40ae0dc17 100644 --- a/web/src/global.d.ts +++ b/web/src/global.d.ts @@ -3,7 +3,7 @@ // remove each declaration when the corresponding module is migrated // to TS. -declare let zulip_test: any; +declare let zulip_test: any; // eslint-disable-line @typescript-eslint/no-explicit-any interface JQuery { expectOne(): JQuery; diff --git a/web/src/timerender.ts b/web/src/timerender.ts index fe343c048f..d178fe9f28 100644 --- a/web/src/timerender.ts +++ b/web/src/timerender.ts @@ -367,7 +367,7 @@ export function stringify_time(time: number | Date): string { return get_localized_date_or_time_for_format(time, "time"); } -export function format_time_modern(time: number | Date, today = new Date()): String { +export function format_time_modern(time: number | Date, today = new Date()): string { const hours = differenceInHours(today, time); const days_old = differenceInCalendarDays(today, time); diff --git a/web/src/ui_report.ts b/web/src/ui_report.ts index 3420ac56e4..55e29888ff 100644 --- a/web/src/ui_report.ts +++ b/web/src/ui_report.ts @@ -94,7 +94,7 @@ export function show_error($target: JQuery): void { export function loading( response_html: string, $status_box: JQuery, - successfully_loaded: boolean = false, + successfully_loaded = false, ): void { $status_box.find(".alert-content").html(response_html); if (!successfully_loaded) { diff --git a/web/src/ui_util.ts b/web/src/ui_util.ts index bf39984512..c3a0960d8e 100644 --- a/web/src/ui_util.ts +++ b/web/src/ui_util.ts @@ -49,7 +49,7 @@ export function update_unread_count_in_dom($unread_count_elem: JQuery, count: nu export function update_unread_mention_info_in_dom( $unread_mention_info_elem: JQuery, - stream_has_any_unread_mention_messages: Boolean, + stream_has_any_unread_mention_messages: boolean, ): void { const $unread_mention_info_span = $unread_mention_info_elem.find(".unread_mention_info"); if (!stream_has_any_unread_mention_messages) { diff --git a/web/src/util.ts b/web/src/util.ts index c8e750684a..0f62aeaa27 100644 --- a/web/src/util.ts +++ b/web/src/util.ts @@ -347,7 +347,7 @@ export function filter_by_word_prefix_match( items: T[], search_term: string, item_to_text: (item: T) => string, - word_separator_regex: RegExp = /\s/, + word_separator_regex = /\s/, ): T[] { if (search_term === "") { return items;