From 04cd89709c02618f9559e27b8b3d5c0865e9e3bd Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 18 Jun 2024 10:10:30 +0200 Subject: [PATCH 1/2] [PORT] Remove `eslint-plugin-jquery` (gitea#31402) - Remove `eslint-plugin-jquery` as `eslint-plugin-no-jquery` does all it does and is actually the maintained fork of it. Co-authored-by: wxiaoguang --- Modification: Only keep removal of eslint-plugin-jquery (cherry picked from commit 17baf1af10de025a47ade1f16f1e5c51646d7fcf) --- .eslintrc.yaml | 50 ----------------------------------------------- package-lock.json | 11 ----------- package.json | 1 - 3 files changed, 62 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 06437657ae..e591592d97 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -16,7 +16,6 @@ plugins: - eslint-plugin-array-func - eslint-plugin-github - eslint-plugin-i - - eslint-plugin-jquery - eslint-plugin-no-jquery - eslint-plugin-no-use-extend-native - eslint-plugin-regexp @@ -280,55 +279,6 @@ rules: i/prefer-default-export: [0] i/unambiguous: [0] init-declarations: [0] - jquery/no-ajax-events: [2] - jquery/no-ajax: [2] - jquery/no-animate: [2] - jquery/no-attr: [2] - jquery/no-bind: [2] - jquery/no-class: [0] - jquery/no-clone: [2] - jquery/no-closest: [0] - jquery/no-css: [2] - jquery/no-data: [0] - jquery/no-deferred: [2] - jquery/no-delegate: [2] - jquery/no-each: [0] - jquery/no-extend: [2] - jquery/no-fade: [2] - jquery/no-filter: [0] - jquery/no-find: [0] - jquery/no-global-eval: [2] - jquery/no-grep: [2] - jquery/no-has: [2] - jquery/no-hide: [2] - jquery/no-html: [0] - jquery/no-in-array: [2] - jquery/no-is-array: [2] - jquery/no-is-function: [2] - jquery/no-is: [2] - jquery/no-load: [2] - jquery/no-map: [2] - jquery/no-merge: [2] - jquery/no-param: [2] - jquery/no-parent: [0] - jquery/no-parents: [2] - jquery/no-parse-html: [2] - jquery/no-prop: [2] - jquery/no-proxy: [2] - jquery/no-ready: [2] - jquery/no-serialize: [2] - jquery/no-show: [2] - jquery/no-size: [2] - jquery/no-sizzle: [0] - jquery/no-slide: [2] - jquery/no-submit: [2] - jquery/no-text: [0] - jquery/no-toggle: [2] - jquery/no-trigger: [0] - jquery/no-trim: [2] - jquery/no-val: [0] - jquery/no-when: [2] - jquery/no-wrap: [2] line-comment-position: [0] logical-assignment-operators: [0] max-classes-per-file: [0] diff --git a/package-lock.json b/package-lock.json index ba0edd2517..ac7b111d19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,7 +73,6 @@ "eslint-plugin-array-func": "4.0.0", "eslint-plugin-github": "5.0.1", "eslint-plugin-i": "2.29.1", - "eslint-plugin-jquery": "1.5.1", "eslint-plugin-no-jquery": "3.0.2", "eslint-plugin-no-use-extend-native": "0.5.0", "eslint-plugin-playwright": "1.6.2", @@ -8527,16 +8526,6 @@ "semver": "bin/semver.js" } }, - "node_modules/eslint-plugin-jquery": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jquery/-/eslint-plugin-jquery-1.5.1.tgz", - "integrity": "sha512-L7v1eaK5t80C0lvUXPFP9MKnBOqPSKhCOYyzy4LZ0+iK+TJwN8S9gAkzzP1AOhypRIwA88HF6phQ9C7jnOpW8w==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "eslint": ">=5.4.0" - } - }, "node_modules/eslint-plugin-jsx-a11y": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.9.0.tgz", diff --git a/package.json b/package.json index d2627ab44a..fe2b2c46ad 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,6 @@ "eslint-plugin-array-func": "4.0.0", "eslint-plugin-github": "5.0.1", "eslint-plugin-i": "2.29.1", - "eslint-plugin-jquery": "1.5.1", "eslint-plugin-no-jquery": "3.0.2", "eslint-plugin-no-use-extend-native": "0.5.0", "eslint-plugin-playwright": "1.6.2", From 98349a188931106404a9ae4be2a3e6e81ab392b6 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 16 Jul 2024 12:14:27 +0200 Subject: [PATCH 2/2] [PORT] Enable `no-jquery/no-class-state` (gitea#31639) Just 4 validations and I specifically tested this by selecting/unselecting issue labels. Co-authored-by: Giteabot --- Clean port. Fixed two additional warnings (cherry picked from commit 3a7454df7a518f810fbeb34b9d784e7c29d173ff) --- .eslintrc.yaml | 2 +- web_src/js/features/repo-legacy.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index e591592d97..6600ae189b 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -354,7 +354,7 @@ rules: no-jquery/no-box-model: [2] no-jquery/no-browser: [2] no-jquery/no-camel-case: [2] - no-jquery/no-class-state: [0] + no-jquery/no-class-state: [2] no-jquery/no-class: [0] no-jquery/no-clone: [2] no-jquery/no-closest: [0] diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js index d3566fb121..d9aa881127 100644 --- a/web_src/js/features/repo-legacy.js +++ b/web_src/js/features/repo-legacy.js @@ -64,7 +64,7 @@ export function initRepoCommentForm() { function initBranchSelector() { const $selectBranch = $('.ui.select-branch'); const $branchMenu = $selectBranch.find('.reference-list-menu'); - const $isNewIssue = $branchMenu.hasClass('new-issue'); + const $isNewIssue = $branchMenu[0]?.classList.contains('new-issue'); $branchMenu.find('.item:not(.no-select)').on('click', async function () { const selectedValue = $(this).data('id'); const editMode = $('#editing_mode').val(); @@ -132,7 +132,7 @@ export function initRepoCommentForm() { $listMenu.find('.item:not(.no-select)').on('click', function (e) { e.preventDefault(); - if ($(this).hasClass('ban-change')) { + if (this.classList.contains('ban-change')) { return false; } @@ -147,7 +147,7 @@ export function initRepoCommentForm() { if (this.getAttribute('data-scope') !== scope) { return true; } - if (this !== clickedItem && !$(this).hasClass('checked')) { + if (this !== clickedItem && !this.classList.contains('checked')) { return true; } } else if (this !== clickedItem) { @@ -155,7 +155,7 @@ export function initRepoCommentForm() { return true; } - if ($(this).hasClass('checked')) { + if (this.classList.contains('checked')) { $(this).removeClass('checked'); $(this).find('.octicon-check').addClass('tw-invisible'); if (hasUpdateAction) { @@ -194,7 +194,7 @@ export function initRepoCommentForm() { const listIds = []; $(this).parent().find('.item').each(function () { - if ($(this).hasClass('checked')) { + if (this.classList.contains('checked')) { listIds.push($(this).data('id')); $($(this).data('id-selector')).removeClass('tw-hidden'); } else { @@ -605,7 +605,7 @@ function initRepoIssueCommentEdit() { const quote = $(`#${target}`).text().replace(/\n/g, '\n> '); const content = `> ${quote}\n\n`; let editor; - if ($(this).hasClass('quote-reply-diff')) { + if (this.classList.contains('quote-reply-diff')) { const $replyBtn = $(this).closest('.comment-code-cloud').find('button.comment-form-reply'); editor = await handleReply($replyBtn); } else {