Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-22 01:44:24 +01:00

Introduce eslint-plugin-no-jquery/no-event-shorthand (#24198)

https://github.com/go-gitea/gitea/pull/24098#issuecomment-1514010690

---------

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
yp05327 2023-04-20 18:28:27 +09:00 committed by GitHub
parent 6793ef0069
commit 8ea33baa1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 15 deletions

View file

@ -12,6 +12,7 @@ plugins:
- eslint-plugin-unicorn - eslint-plugin-unicorn
- eslint-plugin-import - eslint-plugin-import
- eslint-plugin-jquery - eslint-plugin-jquery
- eslint-plugin-no-jquery
- eslint-plugin-sonarjs - eslint-plugin-sonarjs
- eslint-plugin-custom-elements - eslint-plugin-custom-elements
@ -192,6 +193,7 @@ rules:
jquery/no-val: [0] jquery/no-val: [0]
jquery/no-when: [2] jquery/no-when: [2]
jquery/no-wrap: [2] jquery/no-wrap: [2]
no-jquery/no-event-shorthand: [2]
key-spacing: [2] key-spacing: [2]
keyword-spacing: [2] keyword-spacing: [2]
line-comment-position: [0] line-comment-position: [0]

10
package-lock.json generated
View file

@ -64,6 +64,7 @@
"eslint-plugin-custom-elements": "0.0.8", "eslint-plugin-custom-elements": "0.0.8",
"eslint-plugin-import": "2.27.5", "eslint-plugin-import": "2.27.5",
"eslint-plugin-jquery": "1.5.1", "eslint-plugin-jquery": "1.5.1",
"eslint-plugin-no-jquery": "2.7.0",
"eslint-plugin-sonarjs": "0.19.0", "eslint-plugin-sonarjs": "0.19.0",
"eslint-plugin-unicorn": "46.0.0", "eslint-plugin-unicorn": "46.0.0",
"eslint-plugin-vue": "9.11.0", "eslint-plugin-vue": "9.11.0",
@ -4550,6 +4551,15 @@
"eslint": ">=5.4.0" "eslint": ">=5.4.0"
} }
}, },
"node_modules/eslint-plugin-no-jquery": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-no-jquery/-/eslint-plugin-no-jquery-2.7.0.tgz",
"integrity": "sha512-Aeg7dA6GTH1AcWLlBtWNzOU9efK5KpNi7b0EhBO0o0M+awyzguUUo8gF6hXGjQ9n5h8/uRtYv9zOqQkeC5CG0w==",
"dev": true,
"peerDependencies": {
"eslint": ">=2.3.0"
}
},
"node_modules/eslint-plugin-sonarjs": { "node_modules/eslint-plugin-sonarjs": {
"version": "0.19.0", "version": "0.19.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.19.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.19.0.tgz",

View file

@ -64,6 +64,7 @@
"eslint-plugin-custom-elements": "0.0.8", "eslint-plugin-custom-elements": "0.0.8",
"eslint-plugin-import": "2.27.5", "eslint-plugin-import": "2.27.5",
"eslint-plugin-jquery": "1.5.1", "eslint-plugin-jquery": "1.5.1",
"eslint-plugin-no-jquery": "2.7.0",
"eslint-plugin-sonarjs": "0.19.0", "eslint-plugin-sonarjs": "0.19.0",
"eslint-plugin-unicorn": "46.0.0", "eslint-plugin-unicorn": "46.0.0",
"eslint-plugin-vue": "9.11.0", "eslint-plugin-vue": "9.11.0",

View file

@ -21,7 +21,7 @@ export function initAdminCommon() {
$('#login_name').removeAttr('required'); $('#login_name').removeAttr('required');
hideElem($('.non-local')); hideElem($('.non-local'));
showElem($('.local')); showElem($('.local'));
$('#user_name').focus(); $('#user_name').trigger('focus');
if ($(this).data('password') === 'required') { if ($(this).data('password') === 'required') {
$('#password').attr('required', 'required'); $('#password').attr('required', 'required');
@ -33,7 +33,7 @@ export function initAdminCommon() {
$('#login_name').attr('required', 'required'); $('#login_name').attr('required', 'required');
showElem($('.non-local')); showElem($('.non-local'));
hideElem($('.local')); hideElem($('.local'));
$('#login_name').focus(); $('#login_name').trigger('focus');
$('#password').removeAttr('required'); $('#password').removeAttr('required');
} }

View file

@ -16,19 +16,19 @@ export function initAdminUserListSearchForm() {
} }
} }
$form.find(`input[type=radio]`).click(() => { $form.find(`input[type=radio]`).on('click', () => {
$form.submit(); $form.trigger('submit');
return false; return false;
}); });
$form.find('.j-reset-status-filter').click(() => { $form.find('.j-reset-status-filter').on('click', () => {
$form.find(`input[type=radio]`).each((_, e) => { $form.find(`input[type=radio]`).each((_, e) => {
const $e = $(e); const $e = $(e);
if ($e.attr('name').startsWith('status_filter[')) { if ($e.attr('name').startsWith('status_filter[')) {
$e.prop('checked', false); $e.prop('checked', false);
} }
}); });
$form.submit(); $form.trigger('submit');
return false; return false;
}); });
} }

View file

@ -51,7 +51,7 @@ export function initCitationFileCopyContent() {
}); });
$inputContent.on('click', () => { $inputContent.on('click', () => {
$inputContent.select(); $inputContent.trigger('select');
}); });
$('#cite-repo-button').on('click', () => { $('#cite-repo-button').on('click', () => {

View file

@ -68,7 +68,7 @@ export function initGlobalButtonClickOnEnter() {
export function initGlobalCommon() { export function initGlobalCommon() {
// Undo Safari emoji glitch fix at high enough zoom levels // Undo Safari emoji glitch fix at high enough zoom levels
if (navigator.userAgent.match('Safari')) { if (navigator.userAgent.match('Safari')) {
$(window).resize(() => { $(window).on('resize', () => {
const px = mqBinarySearch('width', 0, 4096, 1, 'px'); const px = mqBinarySearch('width', 0, 4096, 1, 'px');
const em = mqBinarySearch('width', 0, 1024, 0.01, 'em'); const em = mqBinarySearch('width', 0, 1024, 0.01, 'em');
if (em * 16 * 1.25 - px <= -1) { if (em * 16 * 1.25 - px <= -1) {

View file

@ -69,7 +69,7 @@ export function initRepoCloneLink() {
}); });
$inputLink.on('focus', () => { $inputLink.on('focus', () => {
$inputLink.select(); $inputLink.trigger('select');
}); });
} }

View file

@ -313,7 +313,7 @@ export function initRepoIssueWipTitle() {
e.preventDefault(); e.preventDefault();
const $issueTitle = $('#issue_title'); const $issueTitle = $('#issue_title');
$issueTitle.focus(); $issueTitle.trigger('focus');
const value = $issueTitle.val().trim().toUpperCase(); const value = $issueTitle.val().trim().toUpperCase();
const wipPrefixes = $('.title_wip_desc').data('wip-prefixes'); const wipPrefixes = $('.title_wip_desc').data('wip-prefixes');
@ -573,7 +573,7 @@ export function initRepoIssueTitleEdit() {
toggleElem($('#pull-desc-edit')); toggleElem($('#pull-desc-edit'));
toggleElem($('.in-edit')); toggleElem($('.in-edit'));
$('#issue-title-wrapper').toggleClass('edit-active'); $('#issue-title-wrapper').toggleClass('edit-active');
$editInput.focus(); $editInput.trigger('focus');
return false; return false;
}; };

View file

@ -57,7 +57,7 @@ export function initRepoCommentForm() {
const $selectBranch = $('.ui.select-branch'); const $selectBranch = $('.ui.select-branch');
const $branchMenu = $selectBranch.find('.reference-list-menu'); const $branchMenu = $selectBranch.find('.reference-list-menu');
const $isNewIssue = $branchMenu.hasClass('new-issue'); const $isNewIssue = $branchMenu.hasClass('new-issue');
$branchMenu.find('.item:not(.no-select)').click(function () { $branchMenu.find('.item:not(.no-select)').on('click', function () {
const selectedValue = $(this).data('id'); const selectedValue = $(this).data('id');
const editMode = $('#editing_mode').val(); const editMode = $('#editing_mode').val();
$($(this).data('id-selector')).val(selectedValue); $($(this).data('id-selector')).val(selectedValue);

View file

@ -153,7 +153,7 @@ export function initRepoProject() {
}); });
$('.delete-project-board').each(function () { $('.delete-project-board').each(function () {
$(this).click(function (e) { $(this).on('click', function (e) {
e.preventDefault(); e.preventDefault();
$.ajax({ $.ajax({
@ -169,7 +169,7 @@ export function initRepoProject() {
}); });
}); });
$('#new_board_submit').click(function (e) { $('#new_board_submit').on('click', function (e) {
e.preventDefault(); e.preventDefault();
const boardTitle = $('#new_board'); const boardTitle = $('#new_board');

View file

@ -5,7 +5,7 @@ export function initUserAuthOauth2() {
const $oauth2LoginNav = $('#oauth2-login-navigator'); const $oauth2LoginNav = $('#oauth2-login-navigator');
if ($oauth2LoginNav.length === 0) return; if ($oauth2LoginNav.length === 0) return;
$oauth2LoginNav.find('.oauth-login-image').click(() => { $oauth2LoginNav.find('.oauth-login-image').on('click', () => {
const oauthLoader = $('#oauth2-login-loader'); const oauthLoader = $('#oauth2-login-loader');
const oauthNav = $('#oauth2-login-navigator'); const oauthNav = $('#oauth2-login-navigator');