mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
workspace: update eslint rule (#1027)
This commit is contained in:
1 parent
05c3b8f2bd
commit
cee3c00ddb
150 files changed
+1069
-1043
No files matched your search
@@ -8,8 +8,8 @@ proxy(superagent);
|
||||
|
||||
interface FetchOptions {
|
||||
headers?: { [key: string]: string };
|
||||
post?: Omit<FetchOptions, 'get' | 'post'>
|
||||
get?: Omit<FetchOptions, 'get' | 'post'>
|
||||
post?: Omit<FetchOptions, 'get' | 'post'>;
|
||||
get?: Omit<FetchOptions, 'get' | 'post'>;
|
||||
}
|
||||
|
||||
const defaultUA = `Hydro/${global.Hydro.version.hydrooj} VJudge/${global.Hydro.version.vjudge}`;
|
||||
|
||||
@@ -262,8 +262,8 @@ class VJudgeService extends Service {
|
||||
}
|
||||
|
||||
export { BasicFetcher } from './fetch';
|
||||
export { VERDICT } from './verdict';
|
||||
export * from './interface';
|
||||
export { VERDICT } from './verdict';
|
||||
|
||||
export const name = 'vjudge';
|
||||
export async function apply(ctx: Context) {
|
||||
|
||||
@@ -27,8 +27,8 @@ declare module 'hydrooj' {
|
||||
}
|
||||
type NextFunction = (body: Partial<JudgeResultBody>) => void;
|
||||
export interface IBasicProvider {
|
||||
ensureLogin(): Promise<boolean | string>;
|
||||
getProblem(id: string, meta: Record<string, any>): Promise<{
|
||||
ensureLogin: () => Promise<boolean | string>;
|
||||
getProblem: (id: string, meta: Record<string, any>) => Promise<{
|
||||
title: string;
|
||||
data: Record<string, any>;
|
||||
files: Record<string, any>;
|
||||
@@ -37,9 +37,9 @@ export interface IBasicProvider {
|
||||
difficulty?: number;
|
||||
}>;
|
||||
entryProblemLists?: string[];
|
||||
listProblem(page: number, resync: boolean, listId: string): Promise<string[]>;
|
||||
submitProblem(id: string, lang: string, code: string, info: any, next: NextFunction, end: NextFunction): Promise<string | void>;
|
||||
waitForSubmission(id: string, next: NextFunction, end: NextFunction): Promise<void>;
|
||||
listProblem: (page: number, resync: boolean, listId: string) => Promise<string[]>;
|
||||
submitProblem: (id: string, lang: string, code: string, info: any, next: NextFunction, end: NextFunction) => Promise<string | void>;
|
||||
waitForSubmission: (id: string, next: NextFunction, end: NextFunction) => Promise<void>;
|
||||
checkStatus?: (onCheckFunc: boolean) => Promise<void>;
|
||||
stop?: () => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -191,8 +191,8 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr
|
||||
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);
|
||||
const time = Number.parseInt(document.querySelector('.time-limit').innerHTML.substr(53, 2), 10);
|
||||
const memory = Number.parseInt(document.querySelector('.memory-limit').innerHTML.substr(55, 4), 10);
|
||||
document.body.firstChild.remove();
|
||||
document.querySelector('.input-specification')?.firstChild.remove();
|
||||
document.querySelector('.output-specification')?.firstChild.remove();
|
||||
|
||||
@@ -146,7 +146,7 @@ export default class HDUOJProvider extends BasicFetcher implements IBasicProvide
|
||||
return res;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
// eslint-disable-next-line ts/no-unused-vars
|
||||
async submitProblem(id: string, lang: string, code: string, info) {
|
||||
await this.ensureLogin();
|
||||
const language = lang.includes('hduoj.') ? lang.split('hduoj.')[1] : '0';
|
||||
@@ -163,7 +163,7 @@ export default class HDUOJProvider extends BasicFetcher implements IBasicProvide
|
||||
throw new Error(text.split('<li>')[1].split('</li>')[0]);
|
||||
}
|
||||
// eslint-disable-next-line max-len
|
||||
const { text: status } = await this.get(`/status.php?first=&pid=${id}&user=${this.account.handle}&lang=${parseInt(language, 10) + 1}&status=0`);
|
||||
const { text: status } = await this.get(`/status.php?first=&pid=${id}&user=${this.account.handle}&lang=${Number.parseInt(language, 10) + 1}&status=0`);
|
||||
const $dom = new JSDOM(status);
|
||||
const res = $dom.window.document.querySelector('.table_text>tbody');
|
||||
return res.children[2].children[0].innerHTML;
|
||||
|
||||
@@ -47,7 +47,7 @@ interface HustOJRemoteConfig {
|
||||
endpoint?: string;
|
||||
matcher?: RegExp;
|
||||
selector?: string;
|
||||
},
|
||||
};
|
||||
server?: string;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ const defaultConfig: HustOJRemoteConfig = {
|
||||
// },
|
||||
ceInfo: {
|
||||
endpoint: '/ceinfo.php?sid={rid}',
|
||||
matcher: /<pre class=".*?" id='errtxt' >(.*?)<\/pre>/gmi,
|
||||
matcher: /<pre class=".*?" id='errtxt' >(.*?)<\/pre>/gi,
|
||||
},
|
||||
monit: {
|
||||
endpoint: '/status.php?pid={pid}&user_id={uid}',
|
||||
@@ -87,7 +87,7 @@ const defaultConfig: HustOJRemoteConfig = {
|
||||
codeField: 'source',
|
||||
extra: {},
|
||||
tooFrequent: 'UNKNOWN',
|
||||
rid: /<tbody>\n<tr class="evenrow"><td>([0-9]+)<\/td>/gmi,
|
||||
rid: /<tbody>\n<tr class="evenrow"><td>([0-9]+)<\/td>/gi,
|
||||
},
|
||||
server: 'https://acm.hust.edu.cn',
|
||||
};
|
||||
@@ -188,7 +188,7 @@ export class HUSTOJ extends BasicFetcher implements IBasicProvider {
|
||||
async waitForSubmission(rid, next, end) {
|
||||
let url = this.config.monit.endpoint.replace('{uid}', this.state.username).replace('{pid}', this.state.pid);
|
||||
// eslint-disable-next-line max-len
|
||||
const RE = new RegExp(`<tr.*?class="evenrow".*?><td>${rid}</td>.*?</td><td>.*?</td><td><font color=".*?">(.*?)</font></td><td>(.*?)<font color="red">kb</font></td><td>(.*?)<font color="red">ms`, 'gmi');
|
||||
const RE = new RegExp(`<tr.*?class="evenrow".*?><td>${rid}</td>.*?</td><td>.*?</td><td><font color=".*?">(.*?)</font></td><td>(.*?)<font color="red">kb</font></td><td>(.*?)<font color="red">ms`, 'gim');
|
||||
const res = await this.get(url);
|
||||
let [, status, time, memory] = RE.exec(res.text);
|
||||
while (isProcessing(status)) {
|
||||
@@ -249,14 +249,15 @@ export class XJOI extends HUSTOJ {
|
||||
codeField: 'source',
|
||||
tooFrequent: '请稍后再提交',
|
||||
extra: {},
|
||||
rid: /<tr class="table-bordered"><td class="status-table-text"> <a href="\/detail\/([0-9]+)"/igm,
|
||||
rid: /<tr class="table-bordered"><td class="status-table-text"> <a href="\/detail\/([0-9]+)"/gi,
|
||||
};
|
||||
}
|
||||
|
||||
async waitForSubmission(rid, next, end) {
|
||||
const SUPERMONIT = [
|
||||
/<textarea .*?>([\s\S]*?)<\/textarea>/igm,
|
||||
/time: ([0-9]+)ms, memory: ([0-9]+)kb, points: ([0-9]+), status: (.*?)/gmi,
|
||||
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
||||
/<textarea .*?>([\s\S]*?)<\/textarea>/gi,
|
||||
/time: ([0-9]+)ms, memory: ([0-9]+)kb, points: ([0-9]+), status: (.*?)/gi,
|
||||
];
|
||||
const url = `/detail${rid}`;
|
||||
let res = await this.get(url);
|
||||
|
||||
@@ -32,9 +32,9 @@ export default class UOJProvider extends BasicFetcher implements IBasicProvider
|
||||
async getCsrfToken(url: string) {
|
||||
const { text: html, header } = await this.get(url);
|
||||
if (header['set-cookie']) await this.setCookie(header['set-cookie'], true);
|
||||
let value = /_token *: *"(.+?)"/g.exec(html);
|
||||
let value = /_token *: *"(.+?)"/.exec(html);
|
||||
if (value) return value[1];
|
||||
value = /_token" value="(.+?)"/g.exec(html);
|
||||
value = /_token" value="(.+?)"/.exec(html);
|
||||
return value?.[1];
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ export default class UOJProvider extends BasicFetcher implements IBasicProvider
|
||||
}
|
||||
}
|
||||
if (document.querySelector('tbody').innerHTML.includes('Judging')) continue;
|
||||
// eslint-disable-next-line no-unsafe-optional-chaining
|
||||
|
||||
const score = +summary.children[3]?.children[0]?.innerHTML || 0;
|
||||
const status = score === 100 ? STATUS.STATUS_ACCEPTED : STATUS.STATUS_WRONG_ANSWER;
|
||||
return await end({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
declare module 'superagent' {
|
||||
interface Request {
|
||||
proxy(url: string): this;
|
||||
proxy: (url: string) => this;
|
||||
}
|
||||
}
|
||||
export default {};
|
||||
Reference in new issue
Block a user