mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: disable github/array-foreach rule
This commit is contained in:
4 files changed
+21
-20
No files matched your search
@@ -59,6 +59,7 @@ module.exports = {
|
||||
2,
|
||||
{ SwitchCase: 1 },
|
||||
],
|
||||
'github/array-foreach': 'off',
|
||||
'function-paren-newline': 'off',
|
||||
'no-mixed-operators': 'off',
|
||||
'no-await-in-loop': 'off',
|
||||
|
||||
@@ -22,7 +22,7 @@ function setDomSelected($dom, selected) {
|
||||
}
|
||||
|
||||
async function updateSelection() {
|
||||
dirtyCategories.forEach(({ type, category, subcategory }) => {
|
||||
for (const { type, category, subcategory } of dirtyCategories) {
|
||||
let item = categories[category];
|
||||
const isSelected = item.select || _.some(item.children, (c) => c.select);
|
||||
setDomSelected(item.$tag, isSelected);
|
||||
@@ -35,7 +35,7 @@ async function updateSelection() {
|
||||
if (item.select) selections.push(selectionName);
|
||||
else _.pull(selections, selectionName);
|
||||
}
|
||||
});
|
||||
}
|
||||
const requestCategoryTags = _.uniq(selections
|
||||
.filter((s) => s.indexOf(',') !== -1)
|
||||
.map((s) => s.split(',')[0]));
|
||||
@@ -59,7 +59,7 @@ function findCategory(name) {
|
||||
function parseCategorySelection() {
|
||||
const $txt = $('[name="tag"]');
|
||||
tags.length = 0;
|
||||
$txt.val().split(',').map((name) => name.trim()).forEach((name) => {
|
||||
for (const name of $txt.val().split(',').map((i) => i.trim())) {
|
||||
if (!name) return;
|
||||
const [category, subcategory] = findCategory(name);
|
||||
if (!category) tags.push(name);
|
||||
@@ -70,7 +70,7 @@ function parseCategorySelection() {
|
||||
categories[category].children[subcategory].select = true;
|
||||
dirtyCategories.push({ type: 'subcategory', subcategory, category });
|
||||
}
|
||||
});
|
||||
}
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ function buildCategoryFilter() {
|
||||
const $container = $('[data-widget-cf-container]');
|
||||
if (!$container) return;
|
||||
$container.attr('class', 'widget--category-filter row small-up-3 medium-up-2');
|
||||
$container.children('li').get().forEach((category) => {
|
||||
for (const category of $container.children('li').get()) {
|
||||
const $category = $(category)
|
||||
.attr('class', 'widget--category-filter__category column');
|
||||
const $categoryTag = $category
|
||||
@@ -104,16 +104,16 @@ function buildCategoryFilter() {
|
||||
.find('a')
|
||||
.attr('class', 'widget--category-filter__tag')
|
||||
.attr('data-category', categoryText);
|
||||
$subCategoryTags.get().forEach((subCategoryTag) => {
|
||||
for (const subCategoryTag of $subCategoryTags.get()) {
|
||||
const $tag = $(subCategoryTag);
|
||||
treeItem.children[$tag.text()] = { select: false, $tag };
|
||||
});
|
||||
}
|
||||
Dropdown.getOrConstruct($categoryTag, {
|
||||
target: $drop[0],
|
||||
position: 'left center',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).on('click', '.widget--category-filter__tag', (ev) => {
|
||||
if (ev.shiftKey || ev.metaKey || ev.ctrlKey) return;
|
||||
const tag = $(ev.currentTarget).text();
|
||||
|
||||
@@ -108,7 +108,7 @@ function buildLegacyCategoryFilter() {
|
||||
const $container = $('[data-widget-cf-container]');
|
||||
if (!$container) return;
|
||||
$container.attr('class', 'widget--category-filter row small-up-3 medium-up-2');
|
||||
$container.children('li').get().forEach((category) => {
|
||||
for (const category of $container.children('li').get()) {
|
||||
const $category = $(category)
|
||||
.attr('class', 'widget--category-filter__category column');
|
||||
const $categoryTag = $category
|
||||
@@ -139,18 +139,18 @@ function buildLegacyCategoryFilter() {
|
||||
.find('a')
|
||||
.attr('class', 'widget--category-filter__tag')
|
||||
.attr('data-category', categoryText);
|
||||
$subCategoryTags.get().forEach((subCategoryTag) => {
|
||||
for (const subCategoryTag of $subCategoryTags.get()) {
|
||||
const $tag = $(subCategoryTag);
|
||||
selections.category[categoryText].children[$tag.text()] = {
|
||||
$tag,
|
||||
};
|
||||
});
|
||||
}
|
||||
Dropdown.getOrConstruct($categoryTag, {
|
||||
target: $drop[0],
|
||||
position: 'left center',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
list.push(...Object.keys(selections.category));
|
||||
list.push(..._.flatMap(Object.values(selections.category), (c: any) => Object.keys(c.children)));
|
||||
$(document).on('click', '.widget--category-filter__tag', (ev) => handleTagSelected(ev));
|
||||
@@ -228,9 +228,9 @@ async function handleOperation(operation) {
|
||||
}
|
||||
|
||||
function hideTags(target) {
|
||||
$(target).find('.problem__tag').get()
|
||||
.filter((i) => list.includes(i.children[0].innerHTML))
|
||||
.forEach((i) => $(i).addClass('notag--hide'));
|
||||
for (const i of $(target).find('.problem__tag').get()) {
|
||||
if (list.includes(i.children[0].innerHTML)) $(i).addClass('notag--hide');
|
||||
}
|
||||
}
|
||||
|
||||
const categoryDialog: any = new Dialog({
|
||||
@@ -265,7 +265,7 @@ function buildSearchContainer() {
|
||||
});
|
||||
|
||||
categoryDialog.$dom.find('.subcategory__all .search-tag__item').each((_index, _element) => {
|
||||
const [,subcategory] = $(_element).attr('data-selection').split(':');
|
||||
const [, subcategory] = $(_element).attr('data-selection').split(':');
|
||||
selections.category[subcategory] = {
|
||||
$tag: $(_element),
|
||||
children: {},
|
||||
@@ -314,9 +314,9 @@ const page = new NamedPage(['problem_main'], () => {
|
||||
$(document).on('click', '[name="enter-edit-mode"]', () => {
|
||||
$body.removeClass('display-mode').addClass('edit-mode');
|
||||
});
|
||||
['delete', 'hide', 'unhide', 'copy'].forEach((op) => {
|
||||
for (const op of ['delete', 'hide', 'unhide', 'copy']) {
|
||||
$(document).on('click', `[name="${op}_selected_problems"]`, () => handleOperation(op));
|
||||
});
|
||||
}
|
||||
$(document).on('click', '[name="download_selected_problems"]', handleDownload);
|
||||
|
||||
$(document).on('click', '.toggle-tag', () => {
|
||||
|
||||
@@ -90,7 +90,7 @@ pjax.request = async (opt) => {
|
||||
window.history.replaceState(currentState, null, meta.url);
|
||||
}
|
||||
if (meta.title) document.title = meta.title;
|
||||
data.fragments.forEach((fragment) => {
|
||||
for (const fragment of data.fragments) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (fragment.html === undefined) {
|
||||
throw new Error("Fragement should contain 'html'");
|
||||
@@ -117,7 +117,7 @@ pjax.request = async (opt) => {
|
||||
$target.trigger('vjContentRemove');
|
||||
$target.replaceWith($el);
|
||||
$el.trigger('vjContentNew');
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
if (!err.aborted) {
|
||||
Notification.error(err.message);
|
||||
|
||||
Reference in new issue
Block a user