forked from forgejo/forgejo
Add new JS linter rules (#17699)
* Add new JS linter rules Adds a few useful rules from eslint-plugin-github. Notable changes: - Forbid dataset usage, its camel-casing behaviour makes it hard to grep for attributes. - Forbid .then() and .catch(), we should generally prefer await for new code. For rare cases where they are useful, a eslint-disable-line directive can be set. - Add docs js to linting * also enable github/array-foreach * small tweak Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
7743f13bed
commit
a159c3175f
23 changed files with 844 additions and 108 deletions
|
@ -6,57 +6,54 @@ async function initRepoProjectSortable() {
|
|||
|
||||
const {Sortable} = await import(/* webpackChunkName: "sortable" */'sortablejs');
|
||||
const boardColumns = document.getElementsByClassName('board-column');
|
||||
new Sortable(
|
||||
els[0],
|
||||
{
|
||||
group: 'board-column',
|
||||
draggable: '.board-column',
|
||||
animation: 150,
|
||||
ghostClass: 'card-ghost',
|
||||
onSort: () => {
|
||||
const board = document.getElementsByClassName('board')[0];
|
||||
const boardColumns = board.getElementsByClassName('board-column');
|
||||
|
||||
boardColumns.forEach((column, i) => {
|
||||
if (parseInt($(column).data('sorting')) !== i) {
|
||||
$.ajax({
|
||||
url: $(column).data('url'),
|
||||
data: JSON.stringify({sorting: i, color: rgbToHex($(column).css('backgroundColor'))}),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
method: 'PUT',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
new Sortable(els[0], {
|
||||
group: 'board-column',
|
||||
draggable: '.board-column',
|
||||
animation: 150,
|
||||
ghostClass: 'card-ghost',
|
||||
onSort: () => {
|
||||
const board = document.getElementsByClassName('board')[0];
|
||||
const boardColumns = board.getElementsByClassName('board-column');
|
||||
|
||||
for (const column of boardColumns) {
|
||||
new Sortable(
|
||||
column.getElementsByClassName('board')[0],
|
||||
{
|
||||
group: 'shared',
|
||||
animation: 150,
|
||||
ghostClass: 'card-ghost',
|
||||
onAdd: (e) => {
|
||||
$.ajax(`${e.to.dataset.url}/${e.item.dataset.issue}`, {
|
||||
for (const [i, column] of boardColumns.entries()) {
|
||||
if (parseInt($(column).data('sorting')) !== i) {
|
||||
$.ajax({
|
||||
url: $(column).data('url'),
|
||||
data: JSON.stringify({sorting: i, color: rgbToHex($(column).css('backgroundColor'))}),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
error: () => {
|
||||
e.from.insertBefore(e.item, e.from.children[e.oldIndex]);
|
||||
},
|
||||
method: 'PUT',
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
for (const column of boardColumns) {
|
||||
new Sortable(column.getElementsByClassName('board')[0], {
|
||||
group: 'shared',
|
||||
animation: 150,
|
||||
ghostClass: 'card-ghost',
|
||||
onAdd: ({item, from, to, oldIndex}) => {
|
||||
const url = to.getAttribute('data-url');
|
||||
const issue = item.getAttribute('data-issue');
|
||||
$.ajax(`${url}/${issue}`, {
|
||||
headers: {
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
error: () => {
|
||||
from.insertBefore(item, from.children[oldIndex]);
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue