loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: enable several no-jquery rules (#7408)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7408
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>

Gusted c497ef9e da62c2ca

+50 -47
+6 -4
eslint.config.mjs
··· 318 318 'no-jquery/no-data': [0], 319 319 'no-jquery/no-deferred': [2], 320 320 'no-jquery/no-delegate': [2], 321 + 'no-jquery/no-done-fail': [2], 321 322 'no-jquery/no-each-collection': [0], 322 - 'no-jquery/no-each-util': [0], 323 + 'no-jquery/no-each-util': [2], 323 324 'no-jquery/no-each': [0], 324 325 'no-jquery/no-error-shorthand': [2], 325 326 'no-jquery/no-error': [2], ··· 331 332 'no-jquery/no-find-collection': [0], 332 333 'no-jquery/no-find-util': [2], 333 334 'no-jquery/no-find': [0], 335 + 'no-jquery/no-fx': [2], 334 336 'no-jquery/no-fx-interval': [2], 335 337 'no-jquery/no-global-eval': [2], 336 338 'no-jquery/no-global-selector': [0], ··· 350 352 'no-jquery/no-live': [2], 351 353 'no-jquery/no-load-shorthand': [2], 352 354 'no-jquery/no-load': [2], 353 - 'no-jquery/no-map-collection': [0], 355 + 'no-jquery/no-map-collection': [2], 354 356 'no-jquery/no-map-util': [2], 355 357 'no-jquery/no-map': [2], 356 358 'no-jquery/no-merge': [2], ··· 374 376 'no-jquery/no-selector-prop': [2], 375 377 'no-jquery/no-serialize': [2], 376 378 'no-jquery/no-size': [2], 377 - 'no-jquery/no-sizzle': [0], 379 + 'no-jquery/no-sizzle': [2], 378 380 'no-jquery/no-slide': [2], 379 381 'no-jquery/no-sub': [2], 380 382 'no-jquery/no-support': [2], 381 383 'no-jquery/no-text': [0], 382 - 'no-jquery/no-trigger': [0], 384 + 'no-jquery/no-trigger': [2], 383 385 'no-jquery/no-trim': [2], 384 386 'no-jquery/no-type': [2], 385 387 'no-jquery/no-unique': [2],
+2 -2
web_src/js/components/RepoBranchTagSelector.vue
··· 98 98 $(`#${this.branchForm} input[name="refType"]`).val('branch'); 99 99 } 100 100 if (this.submitForm) { 101 - $(`#${this.branchForm}`).trigger('submit'); 101 + document.getElementById(this.branchForm).requestSubmit(); 102 102 } 103 103 this.menuVisible = false; 104 104 } 105 105 }, 106 106 createNewBranch() { 107 107 if (!this.showCreateNewBranch) return; 108 - $(this.$refs.newBranchForm).trigger('submit'); 108 + this.$refs.newBranchForm.requestSubmit(); 109 109 }, 110 110 focusSearchField() { 111 111 nextTick(() => {
+6 -4
web_src/js/features/admin/common.js
··· 175 175 onUsePagedSearchChange(); 176 176 } 177 177 }); 178 - $('#auth_type').trigger('change'); 178 + document.getElementById('auth_type').dispatchEvent(new Event('change')); 179 179 document.getElementById('security_protocol')?.addEventListener('change', onSecurityProtocolChange); 180 180 document.getElementById('use_paged_search')?.addEventListener('change', onUsePagedSearchChange); 181 181 document.getElementById('oauth2_provider')?.addEventListener('change', () => onOAuth2Change(true)); ··· 200 200 } 201 201 202 202 if (document.querySelector('.admin.authentication')) { 203 - $('#auth_name').on('input', function () { 203 + const authNameEl = document.getElementById('auth_name'); 204 + authNameEl.addEventListener('input', (el) => { 204 205 // appSubUrl is either empty or is a path that starts with `/` and doesn't have a trailing slash. 205 - document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(this.value)}/callback`; 206 - }).trigger('input'); 206 + document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(el.target.value)}/callback`; 207 + }); 208 + authNameEl.dispatchEvent(new Event('input')); 207 209 } 208 210 209 211 // Notice
+2 -2
web_src/js/features/common-global.js
··· 57 57 export function initGlobalButtonClickOnEnter() { 58 58 $(document).on('keypress', 'div.ui.button,span.ui.button', (e) => { 59 59 if (e.code === ' ' || e.code === 'Enter') { 60 - $(e.target).trigger('click'); 60 + e.target.click(); 61 61 e.preventDefault(); 62 62 } 63 63 }); ··· 314 314 closable: false, 315 315 onApprove: async () => { 316 316 if ($this.data('type') === 'form') { 317 - $($this.data('form')).trigger('submit'); 317 + document.querySelector($this.data('form')).requestSubmit(); 318 318 return; 319 319 } 320 320 if ($this[0].getAttribute('hx-confirm')) {
+2 -2
web_src/js/features/comp/LabelEdit.js
··· 38 38 form.reportValidity(); 39 39 return false; 40 40 } 41 - $('.new-label.form').trigger('submit'); 41 + document.querySelector('.new-label.form').requestSubmit(); 42 42 }, 43 43 }).modal('show'); 44 44 return false; ··· 75 75 form.reportValidity(); 76 76 return false; 77 77 } 78 - $('.edit-label.form').trigger('submit'); 78 + document.querySelector('.edit-label.form').requestSubmit(); 79 79 }, 80 80 }).modal('show'); 81 81 return false;
+1 -1
web_src/js/features/comp/ReactionSelector.js
··· 23 23 $react.remove(); 24 24 } 25 25 if (!data.empty) { 26 - const $attachments = $content.find('.segment.bottom:first'); 26 + const $attachments = $content.find('.segment.bottom').first(); 27 27 $react = $(data.html); 28 28 if ($attachments.length > 0) { 29 29 $react.insertBefore($attachments);
+2 -3
web_src/js/features/org-team.js
··· 10 10 url: `${appSubUrl}/repo/search?q={query}&uid=${$searchRepoBox.data('uid')}`, 11 11 onResponse(response) { 12 12 const items = []; 13 - $.each(response.data, (_i, item) => { 13 + for (const item of response.data) { 14 14 items.push({ 15 15 title: item.repository.full_name.split('/')[1], 16 16 description: item.repository.full_name, 17 17 }); 18 - }); 19 - 18 + } 20 19 return {results: items}; 21 20 }, 22 21 },
+2 -1
web_src/js/features/repo-code.js
··· 184 184 $('html, body').scrollTop($first.offset().top - 200); 185 185 } 186 186 } 187 - }).trigger('hashchange'); 187 + }); 188 + window.dispatchEvent(new Event('hashchange')); 188 189 } 189 190 $(document).on('click', '.fold-file', ({currentTarget}) => { 190 191 invertFileFolding(currentTarget.closest('.file-content'), currentTarget);
+8 -8
web_src/js/features/repo-common.js
··· 33 33 } 34 34 35 35 export function initRepoCloneLink() { 36 - const $repoCloneSsh = $('#repo-clone-ssh'); 37 - const $repoCloneHttps = $('#repo-clone-https'); 38 - const $inputLink = $('#repo-clone-url'); 36 + const repoCloneSSH = document.getElementById('repo-clone-ssh'); 37 + const repoCloneHTTPS = document.getElementById('repo-clone-https'); 38 + const inputLink = document.getElementById('repo-clone-url'); 39 39 40 - if ((!$repoCloneSsh.length && !$repoCloneHttps.length) || !$inputLink.length) { 40 + if ((!repoCloneSSH && !repoCloneHTTPS) || !inputLink) { 41 41 return; 42 42 } 43 43 44 - $repoCloneSsh.on('click', () => { 44 + repoCloneSSH.addEventListener('click', () => { 45 45 localStorage.setItem('repo-clone-protocol', 'ssh'); 46 46 window.updateCloneStates(); 47 47 }); 48 - $repoCloneHttps.on('click', () => { 48 + repoCloneHTTPS.addEventListener('click', () => { 49 49 localStorage.setItem('repo-clone-protocol', 'https'); 50 50 window.updateCloneStates(); 51 51 }); 52 52 53 - $inputLink.on('focus', () => { 54 - $inputLink.trigger('select'); 53 + inputLink.addEventListener('focus', () => { 54 + inputLink.select(); 55 55 }); 56 56 } 57 57
+1 -1
web_src/js/features/repo-editor.js
··· 185 185 $('#edit-empty-content-modal') 186 186 .modal({ 187 187 onApprove() { 188 - $('.edit.form').trigger('submit'); 188 + document.querySelector('.edit.form').requestSubmit(); 189 189 }, 190 190 }) 191 191 .modal('show');
+14 -14
web_src/js/features/repo-issue.js
··· 37 37 $('.issue-start-time-modal').modal({ 38 38 duration: 200, 39 39 onApprove() { 40 - $('#add_time_manual_form').trigger('submit'); 40 + document.getElementById('add_time_manual_form').requestSubmit(); 41 41 }, 42 42 }).modal('show'); 43 43 $('.issue-start-time-modal input').on('keydown', (e) => { 44 44 if ((e.keyCode || e.key) === 13) { 45 - $('#add_time_manual_form').trigger('submit'); 45 + document.getElementById('add_time_manual_form').requestSubmit(); 46 46 } 47 47 }); 48 48 }); 49 49 $(document).on('click', '.issue-start-time, .issue-stop-time', () => { 50 - $('#toggle_stopwatch_form').trigger('submit'); 50 + document.getElementById('toggle_stopwatch_form').requestSubmit(); 51 51 }); 52 52 $(document).on('click', '.issue-cancel-time', () => { 53 - $('#cancel_stopwatch_form').trigger('submit'); 53 + document.getElementById('cancel_stopwatch_form').requestSubmit(); 54 54 }); 55 55 $(document).on('click', 'button.issue-delete-time', function () { 56 56 const sel = `.issue-delete-time-modal[data-id="${$(this).data('id')}"]`; 57 57 $(sel).modal({ 58 58 duration: 200, 59 59 onApprove() { 60 - $(`${sel} form`).trigger('submit'); 60 + document.getElementById(`${sel} form`).requestSubmit(); 61 61 }, 62 62 }).modal('show'); 63 63 }); ··· 139 139 const filteredResponse = {success: true, results: []}; 140 140 const currIssueId = $('#new-dependency-drop-list').data('issue-id'); 141 141 // Parse the response from the api to work with our dropdown 142 - $.each(response, (_i, issue) => { 142 + for (const [_, issue] of Object.entries(response)) { 143 143 // Don't list current issue in the dependency list. 144 144 if (issue.id === currIssueId) { 145 145 return; ··· 149 149 }<div class="text small tw-break-anywhere">${htmlEscape(issue.repository.full_name)}</div>`, 150 150 value: issue.id, 151 151 }); 152 - }); 152 + } 153 153 return filteredResponse; 154 154 }, 155 155 cache: false, ··· 247 247 onApprove: () => { 248 248 $('#removeDependencyID').val(id); 249 249 $('#dependencyType').val(type); 250 - $('#removeDependencyForm').trigger('submit'); 250 + document.getElementById('removeDependencyForm').requestSubmit(); 251 251 }, 252 252 }).modal('show'); 253 253 }); ··· 345 345 url: `${appSubUrl}/repo/search?q={query}&limit=20`, 346 346 onResponse(response) { 347 347 const filteredResponse = {success: true, results: []}; 348 - $.each(response.data, (_r, repo) => { 348 + for (const repo of response.data) { 349 349 filteredResponse.results.push({ 350 350 name: htmlEscape(repo.repository.full_name), 351 351 value: repo.repository.full_name, 352 352 }); 353 - }); 353 + } 354 354 return filteredResponse; 355 355 }, 356 356 cache: false, ··· 369 369 $('.title_wip_desc > a').on('click', (e) => { 370 370 e.preventDefault(); 371 371 372 - const $issueTitle = $('#issue_title'); 373 - $issueTitle.trigger('focus'); 374 - const value = $issueTitle.val().trim().toUpperCase(); 372 + const issueTitleEl = document.getElementById('issue_title'); 373 + issueTitleEl.focus(); 374 + const value = issueTitleEl.value.trim().toUpperCase(); 375 375 376 376 const wipPrefixes = $('.title_wip_desc').data('wip-prefixes'); 377 377 for (const prefix of wipPrefixes) { ··· 380 380 } 381 381 } 382 382 383 - $issueTitle.val(`${wipPrefixes[0]} ${$issueTitle.val()}`); 383 + issueTitleEl.value = `${wipPrefixes[0]} ${issueTitleEl.value}`; 384 384 }); 385 385 } 386 386
+2 -3
web_src/js/features/repo-settings.js
··· 55 55 headers: {'X-Csrf-Token': csrfToken}, 56 56 onResponse(response) { 57 57 const items = []; 58 - $.each(response.data, (_i, item) => { 58 + for (const item of response.data) { 59 59 items.push({ 60 60 title: item.name, 61 61 description: `${item.permission} access`, // TODO: translate this string 62 62 }); 63 - }); 64 - 63 + } 65 64 return {results: items}; 66 65 }, 67 66 },
+2 -2
web_src/js/features/repo-template.js
··· 32 32 value: '', 33 33 }); 34 34 // Parse the response from the api to work with our dropdown 35 - $.each(response.data, (_r, repo) => { 35 + for (const repo of response.data) { 36 36 filteredResponse.results.push({ 37 37 name: htmlEscape(repo.repository.full_name), 38 38 value: repo.repository.id, 39 39 }); 40 - }); 40 + } 41 41 return filteredResponse; 42 42 }, 43 43 cache: false,