From 3a7454df7a518f810fbeb34b9d784e7c29d173ff Mon Sep 17 00:00:00 2001
From: silverwind <me@silverwind.io>
Date: Tue, 16 Jul 2024 12:14:27 +0200
Subject: [PATCH] Enable `no-jquery/no-class-state` (#31639)

Just 4 validations and I specifically tested this by
selecting/unselecting issue labels.

Co-authored-by: Giteabot <teabot@gitea.io>
---
 .eslintrc.yaml                     | 2 +-
 web_src/js/features/repo-legacy.ts | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/.eslintrc.yaml b/.eslintrc.yaml
index 47f4eaa2d2..65c897c913 100644
--- a/.eslintrc.yaml
+++ b/.eslintrc.yaml
@@ -512,7 +512,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.ts b/web_src/js/features/repo-legacy.ts
index b26803c76d..75b485cc98 100644
--- a/web_src/js/features/repo-legacy.ts
+++ b/web_src/js/features/repo-legacy.ts
@@ -125,7 +125,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;
       }
 
@@ -140,7 +140,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) {
@@ -148,7 +148,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) {
@@ -187,7 +187,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 {