Skip to content

Commit 8ea33ba

Browse files
yp05327silverwind
andauthored
Introduce eslint-plugin-no-jquery/no-event-shorthand (#24198)
#24098 (comment) --------- Co-authored-by: silverwind <[email protected]>
1 parent 6793ef0 commit 8ea33ba

12 files changed

+28
-15
lines changed

.eslintrc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins:
1212
- eslint-plugin-unicorn
1313
- eslint-plugin-import
1414
- eslint-plugin-jquery
15+
- eslint-plugin-no-jquery
1516
- eslint-plugin-sonarjs
1617
- eslint-plugin-custom-elements
1718

@@ -192,6 +193,7 @@ rules:
192193
jquery/no-val: [0]
193194
jquery/no-when: [2]
194195
jquery/no-wrap: [2]
196+
no-jquery/no-event-shorthand: [2]
195197
key-spacing: [2]
196198
keyword-spacing: [2]
197199
line-comment-position: [0]

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"eslint-plugin-custom-elements": "0.0.8",
6565
"eslint-plugin-import": "2.27.5",
6666
"eslint-plugin-jquery": "1.5.1",
67+
"eslint-plugin-no-jquery": "2.7.0",
6768
"eslint-plugin-sonarjs": "0.19.0",
6869
"eslint-plugin-unicorn": "46.0.0",
6970
"eslint-plugin-vue": "9.11.0",

web_src/js/features/admin/common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function initAdminCommon() {
2121
$('#login_name').removeAttr('required');
2222
hideElem($('.non-local'));
2323
showElem($('.local'));
24-
$('#user_name').focus();
24+
$('#user_name').trigger('focus');
2525

2626
if ($(this).data('password') === 'required') {
2727
$('#password').attr('required', 'required');
@@ -33,7 +33,7 @@ export function initAdminCommon() {
3333
$('#login_name').attr('required', 'required');
3434
showElem($('.non-local'));
3535
hideElem($('.local'));
36-
$('#login_name').focus();
36+
$('#login_name').trigger('focus');
3737

3838
$('#password').removeAttr('required');
3939
}

web_src/js/features/admin/users.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ export function initAdminUserListSearchForm() {
1616
}
1717
}
1818

19-
$form.find(`input[type=radio]`).click(() => {
20-
$form.submit();
19+
$form.find(`input[type=radio]`).on('click', () => {
20+
$form.trigger('submit');
2121
return false;
2222
});
2323

24-
$form.find('.j-reset-status-filter').click(() => {
24+
$form.find('.j-reset-status-filter').on('click', () => {
2525
$form.find(`input[type=radio]`).each((_, e) => {
2626
const $e = $(e);
2727
if ($e.attr('name').startsWith('status_filter[')) {
2828
$e.prop('checked', false);
2929
}
3030
});
31-
$form.submit();
31+
$form.trigger('submit');
3232
return false;
3333
});
3434
}

web_src/js/features/citation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function initCitationFileCopyContent() {
5151
});
5252

5353
$inputContent.on('click', () => {
54-
$inputContent.select();
54+
$inputContent.trigger('select');
5555
});
5656

5757
$('#cite-repo-button').on('click', () => {

web_src/js/features/common-global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function initGlobalButtonClickOnEnter() {
6868
export function initGlobalCommon() {
6969
// Undo Safari emoji glitch fix at high enough zoom levels
7070
if (navigator.userAgent.match('Safari')) {
71-
$(window).resize(() => {
71+
$(window).on('resize', () => {
7272
const px = mqBinarySearch('width', 0, 4096, 1, 'px');
7373
const em = mqBinarySearch('width', 0, 1024, 0.01, 'em');
7474
if (em * 16 * 1.25 - px <= -1) {

web_src/js/features/repo-common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function initRepoCloneLink() {
6969
});
7070

7171
$inputLink.on('focus', () => {
72-
$inputLink.select();
72+
$inputLink.trigger('select');
7373
});
7474
}
7575

web_src/js/features/repo-issue.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export function initRepoIssueWipTitle() {
313313
e.preventDefault();
314314

315315
const $issueTitle = $('#issue_title');
316-
$issueTitle.focus();
316+
$issueTitle.trigger('focus');
317317
const value = $issueTitle.val().trim().toUpperCase();
318318

319319
const wipPrefixes = $('.title_wip_desc').data('wip-prefixes');
@@ -573,7 +573,7 @@ export function initRepoIssueTitleEdit() {
573573
toggleElem($('#pull-desc-edit'));
574574
toggleElem($('.in-edit'));
575575
$('#issue-title-wrapper').toggleClass('edit-active');
576-
$editInput.focus();
576+
$editInput.trigger('focus');
577577
return false;
578578
};
579579

web_src/js/features/repo-legacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function initRepoCommentForm() {
5757
const $selectBranch = $('.ui.select-branch');
5858
const $branchMenu = $selectBranch.find('.reference-list-menu');
5959
const $isNewIssue = $branchMenu.hasClass('new-issue');
60-
$branchMenu.find('.item:not(.no-select)').click(function () {
60+
$branchMenu.find('.item:not(.no-select)').on('click', function () {
6161
const selectedValue = $(this).data('id');
6262
const editMode = $('#editing_mode').val();
6363
$($(this).data('id-selector')).val(selectedValue);

web_src/js/features/repo-projects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function initRepoProject() {
153153
});
154154

155155
$('.delete-project-board').each(function () {
156-
$(this).click(function (e) {
156+
$(this).on('click', function (e) {
157157
e.preventDefault();
158158

159159
$.ajax({
@@ -169,7 +169,7 @@ export function initRepoProject() {
169169
});
170170
});
171171

172-
$('#new_board_submit').click(function (e) {
172+
$('#new_board_submit').on('click', function (e) {
173173
e.preventDefault();
174174

175175
const boardTitle = $('#new_board');

web_src/js/features/user-auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function initUserAuthOauth2() {
55
const $oauth2LoginNav = $('#oauth2-login-navigator');
66
if ($oauth2LoginNav.length === 0) return;
77

8-
$oauth2LoginNav.find('.oauth-login-image').click(() => {
8+
$oauth2LoginNav.find('.oauth-login-image').on('click', () => {
99
const oauthLoader = $('#oauth2-login-loader');
1010
const oauthNav = $('#oauth2-login-navigator');
1111

0 commit comments

Comments
 (0)