Add eslint-plugin-github and fix issues (#29201)

This plugin has a few useful rules. The only thing I dislike about it is
that it pulls in a rather big number of dependencies for react-related
rules we don't use, but it can't really be avoided.

Rule docs:
https://github.com/github/eslint-plugin-github?tab=readme-ov-file#rules

(cherry picked from commit 26b17537e651fe93ef9b64f961633cb4c0b8c2c3)
This commit is contained in:
silverwind 2024-02-16 22:41:23 +01:00 committed by Earl Warren
parent 4b69d9e46d
commit 59ab49a7eb
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
9 changed files with 1026 additions and 38 deletions

View file

@ -194,7 +194,7 @@ export function initRepoCodeView() {
const blob = await $.get(`${url}?${query}&anchor=${anchor}`);
currentTarget.closest('tr').outerHTML = blob;
});
$(document).on('click', '.copy-line-permalink', async (e) => {
await clippie(toAbsoluteUrl(e.currentTarget.getAttribute('data-url')));
$(document).on('click', '.copy-line-permalink', async ({currentTarget}) => {
await clippie(toAbsoluteUrl(currentTarget.getAttribute('data-url')));
});
}

View file

@ -69,16 +69,12 @@ function initRepoIssueListCheckboxes() {
}
}
updateIssuesMeta(
url,
action,
issueIDs,
elementId,
).then(() => {
try {
await updateIssuesMeta(url, action, issueIDs, elementId);
window.location.reload();
}).catch((reason) => {
showErrorToast(reason.responseJSON.error);
});
} catch (err) {
showErrorToast(err.responseJSON?.error ?? err.message);
}
});
}

View file

@ -344,19 +344,15 @@ export async function updateIssuesMeta(url, action, issueIds, elementId) {
export function initRepoIssueComments() {
if ($('.repository.view.issue .timeline').length === 0) return;
$('.re-request-review').on('click', function (e) {
$('.re-request-review').on('click', async function (e) {
e.preventDefault();
const url = $(this).data('update-url');
const issueId = $(this).data('issue-id');
const id = $(this).data('id');
const isChecked = $(this).hasClass('checked');
updateIssuesMeta(
url,
isChecked ? 'detach' : 'attach',
issueId,
id,
).then(() => window.location.reload());
await updateIssuesMeta(url, isChecked ? 'detach' : 'attach', issueId, id);
window.location.reload();
});
$(document).on('click', (event) => {

View file

@ -205,12 +205,15 @@ export function initRepoCommentForm() {
$listMenu.find('.no-select.item').on('click', function (e) {
e.preventDefault();
if (hasUpdateAction) {
updateIssuesMeta(
$listMenu.data('update-url'),
'clear',
$listMenu.data('issue-id'),
'',
).then(reloadConfirmDraftComment);
(async () => {
await updateIssuesMeta(
$listMenu.data('update-url'),
'clear',
$listMenu.data('issue-id'),
'',
);
reloadConfirmDraftComment();
})();
}
$(this).parent().find('.item').each(function () {
@ -248,12 +251,15 @@ export function initRepoCommentForm() {
$(this).addClass('selected active');
if (hasUpdateAction) {
updateIssuesMeta(
$menu.data('update-url'),
'',
$menu.data('issue-id'),
$(this).data('id'),
).then(reloadConfirmDraftComment);
(async () => {
await updateIssuesMeta(
$menu.data('update-url'),
'',
$menu.data('issue-id'),
$(this).data('id'),
);
reloadConfirmDraftComment();
})();
}
let icon = '';
@ -281,12 +287,15 @@ export function initRepoCommentForm() {
});
if (hasUpdateAction) {
updateIssuesMeta(
$menu.data('update-url'),
'',
$menu.data('issue-id'),
$(this).data('id'),
).then(reloadConfirmDraftComment);
(async () => {
await updateIssuesMeta(
$menu.data('update-url'),
'',
$menu.data('issue-id'),
$(this).data('id'),
);
reloadConfirmDraftComment();
})();
}
$list.find('.selected').html('');