mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
eslint: Fix unicorn/prefer-date-now.
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v24.0.0/docs/rules/prefer-date-now.md Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
2f80415756
commit
dd8e14d3e6
@@ -54,7 +54,7 @@ function stub_timestamp(timestamp, func) {
|
||||
function fake_time() {
|
||||
return timestamp;
|
||||
}
|
||||
with_field(Date.prototype, "getTime", fake_time, func);
|
||||
with_field(Date, "now", fake_time, func);
|
||||
}
|
||||
|
||||
const legacy_draft = {
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
to the console along with the name "foo". */
|
||||
|
||||
export function print_elapsed_time(name, fun) {
|
||||
const t0 = new Date().getTime();
|
||||
const t0 = Date.now();
|
||||
const out = fun();
|
||||
const t1 = new Date().getTime();
|
||||
const t1 = Date.now();
|
||||
console.log(name + ": " + (t1 - t0) + " ms");
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ const draft_model = (function () {
|
||||
ls.version = 1;
|
||||
|
||||
function getTimestamp() {
|
||||
return new Date().getTime();
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
function get() {
|
||||
|
||||
@@ -33,7 +33,7 @@ const animate = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (meta.hide_me_time < new Date().getTime() && !meta.alert_hover_state) {
|
||||
if (meta.hide_me_time < Date.now() && !meta.alert_hover_state) {
|
||||
animate.fadeOut();
|
||||
return;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ function set_up_handlers() {
|
||||
meta.alert_hover_state = false;
|
||||
// add at least 2000ms but if more than that exists just keep the
|
||||
// current amount.
|
||||
meta.hide_me_time = Math.max(meta.hide_me_time, new Date().getTime() + 2000);
|
||||
meta.hide_me_time = Math.max(meta.hide_me_time, Date.now() + 2000);
|
||||
});
|
||||
|
||||
meta.$container.on("click", ".exit-me", () => {
|
||||
@@ -128,7 +128,7 @@ exports.show = function (opts) {
|
||||
meta.undo = opts.on_undo;
|
||||
|
||||
// add a four second delay before closing up.
|
||||
meta.hide_me_time = new Date().getTime() + 4000;
|
||||
meta.hide_me_time = Date.now() + 4000;
|
||||
|
||||
meta.$container.find(".feedback_title").text(opts.title_text);
|
||||
meta.$container.find(".feedback_undo").text(opts.undo_button_text);
|
||||
|
||||
@@ -26,7 +26,7 @@ const ls = {
|
||||
return {
|
||||
data,
|
||||
__valid: true,
|
||||
expires: new Date().getTime() + expires,
|
||||
expires: Date.now() + expires,
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -758,7 +758,7 @@ exports.save_message_row_edit = function (row) {
|
||||
// Settings these attributes causes a "SAVING" notice to
|
||||
// briefly appear where "EDITED" would normally appear until
|
||||
// the message is acknowledged by the server.
|
||||
message.local_edit_timestamp = Math.round(new Date().getTime() / 1000);
|
||||
message.local_edit_timestamp = Math.round(Date.now() / 1000);
|
||||
|
||||
echo.edit_locally(message, currently_echoing_messages.get(message_id));
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const render_muted_topic_ui_row = require("../templates/muted_topic_ui_row.hbs")
|
||||
const render_topic_muted = require("../templates/topic_muted.hbs");
|
||||
|
||||
function timestamp_ms() {
|
||||
return new Date().getTime();
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
let last_topic_update = 0;
|
||||
|
||||
@@ -1260,7 +1260,7 @@ exports.register_click_handlers = function () {
|
||||
return;
|
||||
}
|
||||
|
||||
const date = new Date().getTime();
|
||||
const date = Date.now();
|
||||
|
||||
// only run `popovers.hide_all()` if the last scroll was more
|
||||
// than 250ms ago.
|
||||
|
||||
@@ -15,7 +15,7 @@ $(() => {
|
||||
page_params.needs_tutorial = false;
|
||||
}
|
||||
|
||||
page_params.page_load_time = new Date().getTime();
|
||||
page_params.page_load_time = Date.now();
|
||||
|
||||
// Display loading indicator. This disappears after the first
|
||||
// get_events completes.
|
||||
|
||||
@@ -43,7 +43,7 @@ function is_valid_conversation() {
|
||||
}
|
||||
|
||||
function get_current_time() {
|
||||
return new Date().getTime();
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
function notify_server_start(user_ids_array) {
|
||||
|
||||
Reference in New Issue
Block a user