Remove jQuery .map() and enable eslint rules for it (#29272)

- Use case in `repo-commit` was tested until the point where the POST
request was sent with the same payload.
- Use case in `repo-legacy` was tested completely with comment editing.
- `jquery/no-fade` was disabled as well to stay in sync with
`no-jquery/no-fade`, had no violations.
This commit is contained in:
silverwind 2024-02-21 01:05:17 +01:00 committed by GitHub
parent 3f73eabb66
commit a5c570c1e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 19 deletions

View File

@ -296,7 +296,7 @@ rules:
jquery/no-delegate: [2] jquery/no-delegate: [2]
jquery/no-each: [0] jquery/no-each: [0]
jquery/no-extend: [2] jquery/no-extend: [2]
jquery/no-fade: [0] jquery/no-fade: [2]
jquery/no-filter: [0] jquery/no-filter: [0]
jquery/no-find: [0] jquery/no-find: [0]
jquery/no-global-eval: [2] jquery/no-global-eval: [2]
@ -309,7 +309,7 @@ rules:
jquery/no-is-function: [2] jquery/no-is-function: [2]
jquery/no-is: [0] jquery/no-is: [0]
jquery/no-load: [2] jquery/no-load: [2]
jquery/no-map: [0] jquery/no-map: [2]
jquery/no-merge: [2] jquery/no-merge: [2]
jquery/no-param: [2] jquery/no-param: [2]
jquery/no-parent: [0] jquery/no-parent: [0]
@ -451,7 +451,7 @@ rules:
no-jquery/no-load: [2] no-jquery/no-load: [2]
no-jquery/no-map-collection: [0] no-jquery/no-map-collection: [0]
no-jquery/no-map-util: [2] no-jquery/no-map-util: [2]
no-jquery/no-map: [0] no-jquery/no-map: [2]
no-jquery/no-merge: [2] no-jquery/no-merge: [2]
no-jquery/no-node-name: [2] no-jquery/no-node-name: [2]
no-jquery/no-noop: [2] no-jquery/no-noop: [2]

View File

@ -14,17 +14,15 @@ export function initRepoEllipsisButton() {
} }
export function initRepoCommitLastCommitLoader() { export function initRepoCommitLastCommitLoader() {
const notReadyEls = document.querySelectorAll('table#repo-files-table tr.notready');
if (!notReadyEls.length) return;
const entryMap = {}; const entryMap = {};
const entries = [];
const entries = $('table#repo-files-table tr.notready') for (const el of notReadyEls) {
.map((_, v) => { const entryname = el.getAttribute('data-entryname');
entryMap[$(v).attr('data-entryname')] = $(v); entryMap[entryname] = $(el);
return $(v).attr('data-entryname'); entries.push(entryname);
})
.get();
if (entries.length === 0) {
return;
} }
const lastCommitLoaderURL = $('table#repo-files-table').data('lastCommitLoaderUrl'); const lastCommitLoaderURL = $('table#repo-files-table').data('lastCommitLoaderUrl');

View File

@ -398,17 +398,14 @@ async function onEditContent(event) {
} }
}; };
const saveAndRefresh = (dz, $dropzone) => { const saveAndRefresh = (dz) => {
showElem($renderContent); showElem($renderContent);
hideElem($editContentZone); hideElem($editContentZone);
const $attachments = $dropzone.find('.files').find('[name=files]').map(function () {
return $(this).val();
}).get();
$.post($editContentZone.attr('data-update-url'), { $.post($editContentZone.attr('data-update-url'), {
_csrf: csrfToken, _csrf: csrfToken,
content: comboMarkdownEditor.value(), content: comboMarkdownEditor.value(),
context: $editContentZone.attr('data-context'), context: $editContentZone.attr('data-context'),
files: $attachments, files: dz.files.map((file) => file.uuid),
}, (data) => { }, (data) => {
if (!data.content) { if (!data.content) {
$renderContent.html($('#no-content').html()); $renderContent.html($('#no-content').html());
@ -452,7 +449,7 @@ async function onEditContent(event) {
}); });
$editContentZone.find('.save.button').on('click', (e) => { $editContentZone.find('.save.button').on('click', (e) => {
e.preventDefault(); e.preventDefault();
saveAndRefresh(dz, $dropzone); saveAndRefresh(dz);
}); });
} else { } else {
comboMarkdownEditor = getComboMarkdownEditor($editContentZone.find('.combo-markdown-editor')); comboMarkdownEditor = getComboMarkdownEditor($editContentZone.find('.combo-markdown-editor'));