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.

js: Avoid href="#" for buttons with a JavaScript click handler.

Tim Abbott729c09074a52
diff --git a/static/templates/actions_popover_content.hbs b/static/templates/actions_popover_content.hbs
index b3a5a8a001f..5b33f01f3d5 100644
--- a/static/templates/actions_popover_content.hbs
+++ b/static/templates/actions_popover_content.hbs
@@ -2,7 +2,7 @@
<ul class="nav nav-list actions_popover">
{{#if should_display_hide_option}}
<li>
- <a href="#" class="rehide_muted_user_message" data-message-id="{{message_id}}">
+ <a class="rehide_muted_user_message" data-message-id="{{message_id}}">
<i class="fa fa-eye-slash" aria-hidden="true"></i>
{{t "Hide muted message again" }}
</a>
@@ -11,7 +11,7 @@
{{#if should_display_edit_and_view_source}}
<li>
- <a href="#" class="popover_edit_message" data-message-id="{{message_id}}">
+ <a class="popover_edit_message" data-message-id="{{message_id}}">
<i class="{{#if use_edit_icon}}fa fa-pencil{{else}}fa fa-file-code-o{{/if}}" aria-hidden="true"></i> {{editability_menu_item}}
<span class="hotkey-hint">(e)</span>
</a>
@@ -20,7 +20,7 @@
{{#if should_display_quote_and_reply}}
<li>
- <a href="#" class="respond_button" data-message-id="{{message_id}}">
+ <a class="respond_button" data-message-id="{{message_id}}">
<i class="fa fa-reply" aria-hidden="true"></i> {{t "Quote and reply or forward" }}
<span class="hotkey-hint">(>)</span>
</a>
@@ -29,7 +29,7 @@
{{#if should_display_reminder_option}}
<li>
- <a href="#" class='reminder_button' data-message-id="{{message_id}}">
+ <a class='reminder_button' data-message-id="{{message_id}}">
<i class="fa fa-bell" aria-hidden="true"></i> {{t "Remind me about this" }}
</a>
</li>
@@ -37,7 +37,7 @@
{{#if should_display_collapse}}
<li>
- <a href="#" class="popover_toggle_collapse" data-message-id="{{message_id}}">
+ <a class="popover_toggle_collapse" data-message-id="{{message_id}}">
<i class="fa fa-minus" aria-hidden="true"></i>
{{t "Collapse" }} <span class="hotkey-hint">(–)</span>
</a>
@@ -46,7 +46,7 @@
{{#if should_display_uncollapse}}
<li>
- <a href="#" class="popover_toggle_collapse" data-message-id="{{message_id}}">
+ <a class="popover_toggle_collapse" data-message-id="{{message_id}}">
<i class="fa fa-plus" aria-hidden="true"></i>
{{t "Un-collapse" }} <span class="hotkey-hint">(–)</span>
</a>
@@ -55,7 +55,7 @@
{{#if should_display_edit_history_option}}
<li>
- <a href="#" class="view_edit_history" data-message-id="{{message_id}}">
+ <a class="view_edit_history" data-message-id="{{message_id}}">
<i class="fa fa-clock-o" aria-hidden="true"></i>
{{t "View edit history" }}
</a>
@@ -63,7 +63,7 @@
{{/if}}
{{#if should_display_delete_option}}
<li>
- <a href="#" class="delete_message" data-message-id="{{message_id}}">
+ <a class="delete_message" data-message-id="{{message_id}}">
<i class="fa fa-times" aria-hidden="true"></i>
{{t "Delete message" }}
</a>
@@ -71,7 +71,7 @@
{{/if}}
{{#if can_mute_topic}}
<li>
- <a href="#" class="popover_mute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
+ <a class="popover_mute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
<i class="fa fa-bell-slash" aria-hidden="true"></i>
{{#tr}}Mute the topic <b>{topic}</b>{{/tr}} <span class="hotkey-hint">(M)</span>
</a>
@@ -80,7 +80,7 @@
{{#if can_unmute_topic}}
<li>
- <a href="#" class="popover_unmute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
+ <a class="popover_unmute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
<i class="fa fa-bell" aria-hidden="true"></i>
{{#tr}}Unmute the topic <b>{topic}</b>{{/tr}}
</a>
@@ -89,7 +89,7 @@
{{#if should_display_add_reaction_option}}
<li>
- <a href="#" class="reaction_button" data-message-id="{{message_id}}">
+ <a class="reaction_button" data-message-id="{{message_id}}">
<i class="fa fa-smile-o" aria-hidden="true"></i>
{{#tr}}Add emoji reaction{{/tr}}
</a>
diff --git a/static/templates/gear_menu.hbs b/static/templates/gear_menu.hbs
index b56bb671826..7fbb8745aaf 100644
--- a/static/templates/gear_menu.hbs
+++ b/static/templates/gear_menu.hbs
@@ -1,6 +1,6 @@
<ul class="nav" role="navigation">
<li class="dropdown actual-dropdown-menu" id="gear-menu">
- <a id="settings-dropdown" href="#" role="button" class="dropdown-toggle" data-target="nada" data-toggle="dropdown" title="{{t 'Menu' }} (g)">
+ <a id="settings-dropdown" role="button" class="dropdown-toggle" data-target="nada" data-toggle="dropdown" title="{{t 'Menu' }} (g)">
<i class="fa fa-cog settings-dropdown-cog" aria-hidden="true"></i>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown">
diff --git a/static/templates/left_sidebar.hbs b/static/templates/left_sidebar.hbs
index e6425d0b7fb..cc5ace7b5cd 100644
--- a/static/templates/left_sidebar.hbs
+++ b/static/templates/left_sidebar.hbs
@@ -83,7 +83,7 @@
</div>
</div>
<div id="topics_header">
- <a href="" class="show-all-streams"> <i class="fa fa-chevron-left" aria-hidden="true"></i>{{t 'Back to streams' }}</a>
+ <a class="show-all-streams"> <i class="fa fa-chevron-left" aria-hidden="true"></i>{{t 'Back to streams' }}</a>
</div>
<div id="stream-filters-container" class="scrolling_list" data-simplebar>
<ul id="stream_filters" class="filters"></ul>
diff --git a/static/templates/more_topics.hbs b/static/templates/more_topics.hbs
index 885a6f591c4..d4424ce22bf 100644
--- a/static/templates/more_topics.hbs
+++ b/static/templates/more_topics.hbs
@@ -1,6 +1,6 @@
<li class="topic-list-item show-more-topics bottom_left_row {{#unless more_topics_unreads}}zero-topic-unreads{{/unless}}">
<span class='topic-box'>
- <a class="topic-name" href="#">{{t "more topics" }}</a>
+ <a class="topic-name">{{t "more topics" }}</a>
<span class="unread_count {{#unless more_topics_unreads}}zero_count{{/unless}}">
{{more_topics_unreads}}
</span>
diff --git a/static/templates/navbar.hbs b/static/templates/navbar.hbs
index e9e2bdff85d..7c7f1cb92e3 100644
--- a/static/templates/navbar.hbs
+++ b/static/templates/navbar.hbs
@@ -8,7 +8,7 @@
<div class="column-middle" id="navbar-middle">
<div class="column-middle-inner">
<div id="streamlist-toggle" {{#if embedded}}class="hide-streamlist-toggle-visibility"{{/if}} title="{{t 'Stream list' }} (q)">
- <a href="#" id="streamlist-toggle-button" role="button"><i class="fa fa-reorder" aria-hidden="true"></i>
+ <a id="streamlist-toggle-button" role="button"><i class="fa fa-reorder" aria-hidden="true"></i>
<span id="streamlist-toggle-unreadcount">0</span>
</a>
</div>
@@ -46,7 +46,7 @@
</div>
<div class="column-right">
<div id="userlist-toggle" title="{{t 'User list' }} (w)">
- <a href="#" id="userlist-toggle-button" role="button"><i class="fa fa-group" aria-hidden="true"></i>
+ <a id="userlist-toggle-button" role="button"><i class="fa fa-group" aria-hidden="true"></i>
<span id="userlist-toggle-unreadcount">0</span>
</a>
</div>
diff --git a/static/templates/remind_me_popover_content.hbs b/static/templates/remind_me_popover_content.hbs
index 02c705d2558..9a9f0f07c6d 100644
--- a/static/templates/remind_me_popover_content.hbs
+++ b/static/templates/remind_me_popover_content.hbs
@@ -1,37 +1,37 @@
{{! Contents of the "remind me about this actions" popup }}
<ul class="nav nav-list remind_me_popover">
<li>
- <a href="#" class="remind in_20m" data-message-id="{{message.id}}">
+ <a class="remind in_20m" data-message-id="{{message.id}}">
{{t "in 20 minutes" }}
</a>
</li>
<li>
- <a href="#" class="remind in_1h" data-message-id="{{message.id}}">
+ <a class="remind in_1h" data-message-id="{{message.id}}">
{{t "in 1 hour" }}
</a>
</li>
<li>
- <a href="#" class="remind in_3h" data-message-id="{{message.id}}">
+ <a class="remind in_3h" data-message-id="{{message.id}}">
{{t "in 3 hours" }}
</a>
</li>
<li>
- <a href="#" class="remind tomo" data-message-id="{{message.id}}">
+ <a class="remind tomo" data-message-id="{{message.id}}">
{{t "Tomorrow" }}
</a>
</li>
<li>
- <a href="#" class="remind nxtw" data-message-id="{{message.id}}">
+ <a class="remind nxtw" data-message-id="{{message.id}}">
{{t "Next week" }}
</a>
</li>
<li>
- <a href="#" class='remind custom' data-message-id="{{message.id}}">
+ <a class='remind custom' data-message-id="{{message.id}}">
{{t "Select date and time" }}
</a>
</li>
diff --git a/static/templates/settings/admin_invites_list.hbs b/static/templates/settings/admin_invites_list.hbs
index e088cdbccad..8298ef01b14 100644
--- a/static/templates/settings/admin_invites_list.hbs
+++ b/static/templates/settings/admin_invites_list.hbs
@@ -14,7 +14,7 @@
{{#if is_admin}}
<td>
<span class="referred_by">
- <a data-user-id="{{invited_by_user_id}}" href="#" class="view_user_profile">{{referrer_name}}</a>
+ <a data-user-id="{{invited_by_user_id}}" class="view_user_profile">{{referrer_name}}</a>
</span>
</td>
{{/if}}
diff --git a/static/templates/settings/admin_user_list.hbs b/static/templates/settings/admin_user_list.hbs
index 8f53caa2145..035465f1726 100644
--- a/static/templates/settings/admin_user_list.hbs
+++ b/static/templates/settings/admin_user_list.hbs
@@ -26,7 +26,7 @@
{{#if no_owner }}
{{bot_owner_full_name}}
{{else}}
- <a data-user-id="{{bot_owner_id}}" href="#" class="view_user_profile">{{bot_owner_full_name}}</a>
+ <a data-user-id="{{bot_owner_id}}" class="view_user_profile">{{bot_owner_full_name}}</a>
{{/if}}
</span>
</td>
diff --git a/static/templates/stream_settings/new_stream_users.hbs b/static/templates/stream_settings/new_stream_users.hbs
index f970f0fbfaf..7c08c24b72f 100644
--- a/static/templates/stream_settings/new_stream_users.hbs
+++ b/static/templates/stream_settings/new_stream_users.hbs
@@ -23,8 +23,8 @@
<div>
- <a href="#" draggable="false" class="subs_set_all_users">{{t "Check all" }}</a> |
- <a href="#" draggable="false" class="subs_unset_all_users">{{t "Uncheck all" }}</a>
+ <a draggable="false" class="subs_set_all_users">{{t "Check all" }}</a> |
+ <a draggable="false" class="subs_unset_all_users">{{t "Uncheck all" }}</a>
</div>
<div id="user-checkboxes-simplebar-wrapper" data-simplebar>
diff --git a/static/templates/topic_sidebar_actions.hbs b/static/templates/topic_sidebar_actions.hbs
index 8968d43ab22..776fba0c75e 100644
--- a/static/templates/topic_sidebar_actions.hbs
+++ b/static/templates/topic_sidebar_actions.hbs
@@ -26,7 +26,7 @@
{{#if has_starred_messages}}
<li class="hidden-for-spectators">
- <a href="#" class="sidebar-popover-unstar-all-in-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
+ <a class="sidebar-popover-unstar-all-in-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
<i class="fa fa-star-o" aria-hidden="true"></i>
{{#tr}}Unstar all messages in topic{{/tr}}
</a>
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py
index b50acaf8414..02c60bc4ac8 100644
--- a/tools/linter_lib/custom_check.py
+++ b/tools/linter_lib/custom_check.py
@@ -766,6 +766,11 @@ handlebars_rules = RuleList(
"pattern": r'"{{t "',
"description": "Invalid quoting for HTML element with translated string.",
},
+ {
+ "pattern": r'href="#"',
+ "description": 'Avoid href="#" for elements with a JavaScript click handler.',
+ "exclude": {"static/templates/navbar.hbs"},
+ },
],
)