Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Fix @typescript-eslint/require-array-sort-compare.

Anders Kaseorge9351f25c580
diff --git a/web/debug-require-webpack-plugin.ts b/web/debug-require-webpack-plugin.ts
index e71e9a269de..2ddd2cc70a2 100644
--- a/web/debug-require-webpack-plugin.ts
+++ b/web/debug-require-webpack-plugin.ts
@@ -109,7 +109,7 @@ export default class DebugRequirePlugin implements webpack.WebpackPluginInstance
return source;
}
- ids.sort();
+ ids.sort(([a], [b]) => Number(a > b) - Number(a < b));
return webpack.Template.asString([
source,
`__webpack_require__.debugRequireIds = ${JSON.stringify(
diff --git a/web/src/alert_words_ui.ts b/web/src/alert_words_ui.ts
index 915b9f2001a..8ed5dbdca9e 100644
--- a/web/src/alert_words_ui.ts
+++ b/web/src/alert_words_ui.ts
@@ -21,7 +21,7 @@ export function rerender_alert_words_ui(): void {
}
const words = alert_words.get_word_list();
- words.sort();
+ words.sort((a, b) => Number(a.word > b.word) - Number(a.word < b.word));
const $word_list = $("#alert-words-table");
ListWidget.create($word_list, words, {
diff --git a/web/src/settings_components.ts b/web/src/settings_components.ts
index 6a4efb7ea76..f914ca503c4 100644
--- a/web/src/settings_components.ts
+++ b/web/src/settings_components.ts
@@ -205,7 +205,7 @@ export function get_realm_default_setting_property_value(
export function realm_authentication_methods_to_boolean_dict(): Record<string, boolean> {
return Object.fromEntries(
Object.entries(realm.realm_authentication_methods)
- .toSorted()
+ .toSorted(([a], [b]) => Number(a > b) - Number(a < b))
.map(([auth_method_name, auth_method_info]) => [
auth_method_name,
auth_method_info.enabled,
diff --git a/web/src/typing_events.ts b/web/src/typing_events.ts
index ae0013f20c1..5605e03b273 100644
--- a/web/src/typing_events.ts
+++ b/web/src/typing_events.ts
@@ -150,7 +150,6 @@ function get_key(event: TypingEvent): string {
}
if (event.message_type === "direct") {
const recipients = event.recipients.map((user) => user.user_id);
- recipients.sort();
return typing_data.get_direct_message_conversation_key(recipients);
}
throw new Error("Invalid typing notification type", event);
diff --git a/web/tests/alert_words_ui.test.cjs b/web/tests/alert_words_ui.test.cjs
index 4e97561ffdb..8ac00d95726 100644
--- a/web/tests/alert_words_ui.test.cjs
+++ b/web/tests/alert_words_ui.test.cjs
@@ -23,7 +23,7 @@ run_test("rerender_alert_words_ui", ({mock_template}) => {
mock_esm("../src/list_widget", {
create(_container, words, opts) {
- assert.deepEqual(words, [{word: "foo"}, {word: "bar"}]);
+ assert.deepEqual(words, [{word: "bar"}, {word: "foo"}]);
for (const word of words) {
opts.modifier_html(word);
}