mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
eslint: add github/array-foreach rule
This commit is contained in:
21 files changed
+59
-51
No files matched your search
@@ -59,7 +59,7 @@ class AccountService {
|
||||
await next({ status: STATUS.STATUS_JUDGING, message: `ID = ${rid}` });
|
||||
const nextFunction = (data) => {
|
||||
if (data.case) delete data.case.message;
|
||||
if (data.cases) data.cases.forEach((x) => delete x.message);
|
||||
if (data.cases) for (const x of data.cases) delete x.message;
|
||||
return next(data);
|
||||
};
|
||||
await this.api.waitForSubmission(rid, task.config?.detail === false ? nextFunction : next, end);
|
||||
|
||||
@@ -177,15 +177,15 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr
|
||||
const text = $dom.window.document.querySelector('.problem-statement').innerHTML;
|
||||
const { window: { document } } = new JSDOM(text);
|
||||
const files = {};
|
||||
document.querySelectorAll('img[src]').forEach((ele) => {
|
||||
for (const ele of document.querySelectorAll('img[src]')) {
|
||||
const src = ele.getAttribute('src');
|
||||
if (!src.startsWith('http')) return;
|
||||
if (!src.startsWith('http')) continue;
|
||||
const file = new PassThrough();
|
||||
this.get(src).pipe(file);
|
||||
const fid = String.random(8);
|
||||
files[`${fid}.png`] = file;
|
||||
ele.setAttribute('src', `file://${fid}.png`);
|
||||
});
|
||||
}
|
||||
const title = document.querySelector('.title').innerHTML.trim().split('. ')[1];
|
||||
const time = parseInt(document.querySelector('.time-limit').innerHTML.substr(53, 2), 10);
|
||||
const memory = parseInt(document.querySelector('.memory-limit').innerHTML.substr(55, 4), 10);
|
||||
@@ -200,11 +200,11 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr
|
||||
const note = document.querySelector('.note')?.innerHTML.trim();
|
||||
document.querySelector('.note')?.remove();
|
||||
document.querySelector('.sample-tests')?.remove();
|
||||
document.querySelectorAll('.section-title').forEach((ele) => {
|
||||
for (const ele of document.querySelectorAll('.section-title')) {
|
||||
const e = document.createElement('h2');
|
||||
e.innerHTML = ele.innerHTML;
|
||||
ele.replaceWith(e);
|
||||
});
|
||||
}
|
||||
const description = document.body.innerHTML.trim();
|
||||
return {
|
||||
title: id.startsWith('P921') ? title.replace('1', id.split('P921')[1]) : title,
|
||||
|
||||
@@ -93,12 +93,12 @@ export default class CSGOJProvider extends BasicFetcher implements IBasicProvide
|
||||
const pDescription = document.querySelector('div[name="Description"]');
|
||||
const files = {};
|
||||
const images = {};
|
||||
pDescription.querySelectorAll('img[src]').forEach((ele) => {
|
||||
for (const ele of pDescription.querySelectorAll('img[src]')) {
|
||||
let src = ele.getAttribute('src').replace('.svg', '.png');
|
||||
src = new URL(src, 'https://cpc.csgrandeur.cn').toString();
|
||||
if (images[src]) {
|
||||
ele.setAttribute('src', `file://${images[src]}.png`);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
const file = new PassThrough();
|
||||
this.get(src).pipe(file);
|
||||
@@ -106,7 +106,7 @@ export default class CSGOJProvider extends BasicFetcher implements IBasicProvide
|
||||
images[src] = fid;
|
||||
files[`${fid}.png`] = file;
|
||||
ele.setAttribute('src', `file://${fid}.png`);
|
||||
});
|
||||
}
|
||||
const description = [...pDescription.children].map((i) => i.outerHTML).join('');
|
||||
const input = [...document.querySelector('div[name="Input"]').children].map((i) => i.outerHTML).join('');
|
||||
const output = [...document.querySelector('div[name="Output"]').children].map((i) => i.outerHTML).join('');
|
||||
|
||||
@@ -113,11 +113,11 @@ export default class POJProvider extends BasicFetcher implements IBasicProvider
|
||||
content.children[0].remove();
|
||||
content.children[0].remove();
|
||||
content.children[0].remove();
|
||||
content.querySelectorAll('img[src]').forEach((ele) => {
|
||||
for (const ele of content.querySelectorAll('img[src]')) {
|
||||
const src = ele.getAttribute('src');
|
||||
if (images[src]) {
|
||||
ele.setAttribute('src', `file://${images[src]}.png`);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
const file = new PassThrough();
|
||||
this.get(src).pipe(file);
|
||||
@@ -125,7 +125,7 @@ export default class POJProvider extends BasicFetcher implements IBasicProvider
|
||||
images[src] = fid;
|
||||
files[`${fid}.png`] = file;
|
||||
ele.setAttribute('src', `file://${fid}.png`);
|
||||
});
|
||||
}
|
||||
let lastId = 0;
|
||||
let markNext = '';
|
||||
let html = '';
|
||||
|
||||
@@ -52,15 +52,15 @@ export default class SPOJProvider extends BasicFetcher implements IBasicProvider
|
||||
logger.info(id);
|
||||
const { document } = await this.html(`/problems/${id}/`);
|
||||
const files = {};
|
||||
document.querySelector('#problem-body').querySelectorAll('img[src]').forEach((ele) => {
|
||||
for (const ele of document.querySelector('#problem-body').querySelectorAll('img[src]')) {
|
||||
const src = ele.getAttribute('src');
|
||||
if (!src.startsWith('http')) return;
|
||||
if (!src.startsWith('http')) continue;
|
||||
const file = new PassThrough();
|
||||
this.get(src).pipe(file);
|
||||
const fid = String.random(8);
|
||||
files[`${fid}.png`] = file;
|
||||
ele.setAttribute('src', `file://${fid}.png`);
|
||||
});
|
||||
}
|
||||
const meta = document.querySelector('#problem-meta').children[1];
|
||||
const window = await this.html(`/submit/${id}/`);
|
||||
const langs = Array.from(window.document.querySelector('#lang').querySelectorAll('option'))
|
||||
|
||||
@@ -71,15 +71,15 @@ export default class UOJProvider extends BasicFetcher implements IBasicProvider
|
||||
const res = await this.get(`/problem/${id.split('P')[1]}`);
|
||||
const { window: { document } } = new JSDOM(res.text);
|
||||
const files = {};
|
||||
document.querySelectorAll('article>img[src]').forEach((ele) => {
|
||||
for (const ele of document.querySelectorAll('article>img[src]')) {
|
||||
const src = ele.getAttribute('src');
|
||||
if (!src.startsWith('http')) return;
|
||||
if (!src.startsWith('http')) continue;
|
||||
const file = new PassThrough();
|
||||
this.get(src).pipe(file);
|
||||
const fid = String.random(8);
|
||||
files[`${fid}.png`] = file;
|
||||
ele.setAttribute('src', `file://${fid}.png`);
|
||||
});
|
||||
}
|
||||
const contentNode = document.querySelector('article');
|
||||
const titles = contentNode.querySelectorAll('h3');
|
||||
for (const title of titles) {
|
||||
|
||||
Reference in new issue
Block a user