lint: Replace local variables named 'msgid' with 'message_id'.

Follow up of commit 2a1305d. Replace all local variables named 'msgid'
with 'message_id' in all JS and HTML files, and adds a linter rule for
it as well.

Resolves #12952.
This commit is contained in:
Vinit Singh 2019-08-28 21:16:10 +05:30 committed by Tim Abbott
parent c6fb8c048a
commit d09a80260b
8 changed files with 28 additions and 26 deletions

View File

@ -714,7 +714,7 @@ exports.register_click_handlers = function () {
});
$("body").on("click", ".actions_popover .reaction_button", function (e) {
var msgid = $(e.currentTarget).data('message-id');
var message_id = $(e.currentTarget).data('message-id');
e.preventDefault();
e.stopPropagation();
// HACK: Because we need the popover to be based off an
@ -723,7 +723,7 @@ exports.register_click_handlers = function () {
// element is not present, we use the message's
// .fa-chevron-down element as the base for the popover.
var elem = $(".selected_message .actions_hover")[0];
emoji_picker.toggle_emoji_popover(elem, msgid);
emoji_picker.toggle_emoji_popover(elem, message_id);
});
$("body").on("click", ".emoji-popover-tab-item", function (e) {

View File

@ -704,24 +704,24 @@ exports.reify_message_id = function (opts) {
// update that link as well
_.each($('#out-of-view-notification a'), function (e) {
var elem = $(e);
var msgid = elem.data('msgid');
var message_id = elem.data('message-id');
if (msgid === old_id) {
elem.data('msgid', new_id);
if (message_id === old_id) {
elem.data('message-id', new_id);
}
});
};
exports.register_click_handlers = function () {
$('#out-of-view-notification').on('click', '.compose_notification_narrow_by_topic', function (e) {
var msgid = $(e.currentTarget).data('msgid');
narrow.by_topic(msgid, {trigger: 'compose_notification'});
var message_id = $(e.currentTarget).data('message-id');
narrow.by_topic(message_id, {trigger: 'compose_notification'});
e.stopPropagation();
e.preventDefault();
});
$('#out-of-view-notification').on('click', '.compose_notification_scroll_to_message', function (e) {
var msgid = $(e.currentTarget).data('msgid');
current_msg_list.select_id(msgid);
var message_id = $(e.currentTarget).data('message-id');
current_msg_list.select_id(message_id);
navigate.scroll_to_selected();
e.stopPropagation();
e.preventDefault();

View File

@ -901,8 +901,8 @@ exports.register_click_handlers = function () {
});
$('body').on('click', '.reminder_button', function (e) {
var msgid = $(e.currentTarget).data('message-id');
popovers.render_actions_remind_popover($(".selected_message .actions_hover")[0], msgid);
var message_id = $(e.currentTarget).data('message-id');
popovers.render_actions_remind_popover($(".selected_message .actions_hover")[0], message_id);
e.stopPropagation();
e.preventDefault();
});
@ -967,8 +967,8 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
$('body').on('click', '.popover_toggle_collapse', function (e) {
var msgid = $(e.currentTarget).data('message-id');
var row = current_msg_list.get_row(msgid);
var message_id = $(e.currentTarget).data('message-id');
var row = current_msg_list.get_row(message_id);
var message = current_msg_list.get(rows.id(row));
popovers.hide_actions_popover();
@ -985,16 +985,16 @@ exports.register_click_handlers = function () {
e.preventDefault();
});
$('body').on('click', '.popover_edit_message', function (e) {
var msgid = $(e.currentTarget).data('message-id');
var row = current_msg_list.get_row(msgid);
var message_id = $(e.currentTarget).data('message-id');
var row = current_msg_list.get_row(message_id);
popovers.hide_actions_popover();
message_edit.start(row);
e.stopPropagation();
e.preventDefault();
});
$('body').on('click', '.view_edit_history', function (e) {
var msgid = $(e.currentTarget).data('msgid');
var row = current_msg_list.get_row(msgid);
var message_id = $(e.currentTarget).data('message-id');
var row = current_msg_list.get_row(message_id);
var message = current_msg_list.get(rows.id(row));
var message_history_cancel_btn = $('#message-history-cancel');
@ -1026,9 +1026,9 @@ exports.register_click_handlers = function () {
});
$('body').on('click', '.delete_message', function (e) {
var msgid = $(e.currentTarget).data('message-id');
var message_id = $(e.currentTarget).data('message-id');
popovers.hide_actions_popover();
message_edit.delete_message(msgid);
message_edit.delete_message(message_id);
e.stopPropagation();
e.preventDefault();
});

View File

@ -91,8 +91,8 @@ exports.schedule_message = function (request) {
transmit.send_message(request, success, error);
};
exports.do_set_reminder_for_message = function (msgid, timestamp) {
var row = $("[zid='" + msgid + "']");
exports.do_set_reminder_for_message = function (message_id, timestamp) {
var row = $("[zid='" + message_id + "']");
function error() {
row.find(".alert-msg")
.text(i18n.t("Reminder not set!"))
@ -103,7 +103,7 @@ exports.do_set_reminder_for_message = function (msgid, timestamp) {
});
}
var message = current_msg_list.get(msgid);
var message = current_msg_list.get(message_id);
if (!message.raw_content) {
var msg_list = current_msg_list;
@ -113,7 +113,7 @@ exports.do_set_reminder_for_message = function (msgid, timestamp) {
success: function (data) {
if (current_msg_list === msg_list) {
message.raw_content = data.raw_content;
exports.do_set_reminder_for_message(msgid, timestamp);
exports.do_set_reminder_for_message(message_id, timestamp);
}
},
error: error,

View File

@ -42,7 +42,7 @@ function message_hover(message_row) {
!message.status_message) {
message_row.find(".edit_content").html('<i class="fa fa-pencil edit_content_button" aria-hidden="true" title="Edit (e)"></i>');
} else {
message_row.find(".edit_content").html('<i class="fa fa-file-text-o edit_content_button" aria-hidden="true" title="View source (e)" data-msgid="' + id + '"></i>');
message_row.find(".edit_content").html('<i class="fa fa-file-text-o edit_content_button" aria-hidden="true" title="View source (e)" data-message-id="' + id + '"></i>');
}
}

View File

@ -45,7 +45,7 @@
{{#if should_display_edit_history_option}}
<li>
<a href="#" class="view_edit_history" data-msgid="{{message_id}}">
<a href="#" class="view_edit_history" data-message-id="{{message_id}}">
<i class="fa fa-clock-o" aria-hidden="true"></i>
{{t "View edit history" }}
</a>

View File

@ -1,5 +1,5 @@
{{! Content of sent-message notifications }}
<div class="compose-notifications-content">
{{note}} {{#if link_class}}<a href="#" class="{{link_class}}" data-msgid="{{link_msg_id}}">{{link_text}}</a>{{/if}}
{{note}} {{#if link_class}}<a href="#" class="{{link_class}}" data-message-id="{{link_msg_id}}">{{link_text}}</a>{{/if}}
<button type="button" class="out-of-view-notification-close close">&times;</button>
</div>

View File

@ -119,6 +119,8 @@ js_rules = RuleList(
'bad_lines': ['subject="foo"', ' MAX_SUBJECT_LEN']},
{'pattern': r'[^_]function\(',
'description': 'The keyword "function" should be followed by a space'},
{'pattern': 'msgid|MSGID',
'description': 'Avoid using "msgid" as a variable name; use "message_id" instead.'},
{'pattern': r'.*blueslip.warning\(.*',
'description': 'The module blueslip has no function warning, try using blueslip.warn'},
{'pattern': '[)]{$',