From 0e7f5fe63575a8021e302b431488dd1e85f35a09 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 21 Mar 2025 09:48:17 +0800 Subject: [PATCH] workspace: apply eslint edits --- framework/framework/error.ts | 3 --- framework/framework/server.ts | 1 - packages/hydrojudge/src/cases.ts | 1 - packages/hydrojudge/src/checkers.ts | 1 - packages/hydrojudge/src/daemon.ts | 2 -- packages/hydrojudge/src/hosts/hydro.ts | 1 - packages/hydrojudge/src/hosts/vj4.ts | 2 +- packages/hydrojudge/src/judge/hack.ts | 1 - packages/hydrooj/src/commands/install.ts | 1 - packages/hydrooj/src/entry/cli.ts | 2 -- packages/hydrooj/src/entry/common.ts | 1 - packages/hydrooj/src/entry/setup.ts | 1 - packages/hydrooj/src/entry/worker.ts | 2 -- packages/hydrooj/src/handler/contest.ts | 1 - packages/hydrooj/src/handler/misc.ts | 1 - packages/hydrooj/src/handler/problem.ts | 1 - packages/hydrooj/src/interface.ts | 1 - packages/hydrooj/src/loader.ts | 3 --- packages/hydrooj/src/model/contest.ts | 10 ++++------ packages/hydrooj/src/model/document.ts | 14 ++++++-------- packages/hydrooj/src/model/domain.ts | 6 +++++- packages/hydrooj/src/model/problem.ts | 1 - packages/hydrooj/src/model/setting.ts | 2 -- packages/hydrooj/src/model/task.ts | 1 - packages/hydrooj/src/model/user.ts | 2 +- packages/hydrooj/src/plugin-api.ts | 2 +- packages/hydrooj/src/script/problemStat.ts | 1 - packages/hydrooj/src/script/storageUsage.ts | 1 - packages/hydrooj/src/service/bus.ts | 1 - packages/hydrooj/src/service/db.ts | 2 +- packages/hydrooj/src/ui.ts | 1 - packages/onlyoffice/frontend/office.page.ts | 1 - packages/onsite-toolkit/frontend/resolver.page.tsx | 5 ++--- packages/ui-default/api.ts | 1 - packages/ui-default/backendlib/builder.ts | 10 +++++----- .../ui-default/backendlib/markdown-it-imsize.ts | 2 +- .../ui-default/backendlib/markdown-it-media.ts | 1 - packages/ui-default/backendlib/misc.ts | 2 +- packages/ui-default/backendlib/template.ts | 4 ++-- packages/ui-default/build/config/webpack.ts | 5 ++--- packages/ui-default/build/main.ts | 2 +- .../autocomplete/components/AutoComplete.tsx | 6 ++---- .../components/UserSelectAutoComplete.tsx | 1 - packages/ui-default/components/calendar/index.js | 3 ++- packages/ui-default/components/message/worker.ts | 2 +- .../problemconfig/ProblemConfigEditor.tsx | 2 +- .../components/problemconfig/ProblemConfigTree.tsx | 4 ++-- .../components/problemconfig/reducer/config.ts | 2 +- .../components/problemconfig/tree/AddTestcase.tsx | 2 +- .../problemconfig/tree/SubtaskSettings.tsx | 2 +- .../components/problemconfig/tree/Testcase.tsx | 2 +- .../components/scratchpad/DataInputComponent.jsx | 1 - .../scratchpad/ScratchpadToolbarContainer.jsx | 1 - packages/ui-default/index.ts | 1 - packages/ui-next/src/App.tsx | 2 +- packages/utils/lib/locate-pm2.ts | 2 +- packages/utils/lib/utils.ts | 1 - packages/vjudge/src/providers/codeforces.ts | 1 - packages/vjudge/src/providers/hduoj.ts | 1 - packages/vjudge/src/providers/poj.ts | 1 - packages/vjudge/src/providers/spoj.ts | 1 - packages/vjudge/src/providers/uoj.ts | 1 - packages/vjudge/src/providers/yacs.ts | 1 - 63 files changed, 47 insertions(+), 96 deletions(-) diff --git a/framework/framework/error.ts b/framework/framework/error.ts index 2f430b87e..65483a9b0 100644 --- a/framework/framework/error.ts +++ b/framework/framework/error.ts @@ -1,6 +1,3 @@ -/* eslint-disable max-len */ -/* eslint-disable func-names */ - interface IHydroError { new(...args: any[]): HydroError } diff --git a/framework/framework/server.ts b/framework/framework/server.ts index 7a4a630be..03493f161 100644 --- a/framework/framework/server.ts +++ b/framework/framework/server.ts @@ -619,7 +619,6 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`); if (args.shorty) h.resetCompression(); if (h._prepare) await h._prepare(args); if (h.prepare) await h.prepare(args); - // eslint-disable-next-line @typescript-eslint/no-shadow for (const { name, target } of h.__subscribe || []) disposables.push(this.ctx.on(name, target.bind(h))); if (layer) { let lastHeartbeat = Date.now(); diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index 712aee279..8c7e225a9 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-await-in-loop */ import path from 'path'; import { convertIniConfig, LangConfig, normalizeSubtasks, ProblemConfigFile, readSubtasksFromFiles, diff --git a/packages/hydrojudge/src/checkers.ts b/packages/hydrojudge/src/checkers.ts index a255c862f..e9982fbaa 100644 --- a/packages/hydrojudge/src/checkers.ts +++ b/packages/hydrojudge/src/checkers.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-template-curly-in-string */ import { STATUS } from '@hydrooj/common'; import { FormatError, SystemError } from './error'; import { CopyInFile, runQueued } from './sandbox'; diff --git a/packages/hydrojudge/src/daemon.ts b/packages/hydrojudge/src/daemon.ts index e4e071c23..222178246 100644 --- a/packages/hydrojudge/src/daemon.ts +++ b/packages/hydrojudge/src/daemon.ts @@ -1,5 +1,3 @@ -/* eslint-disable import/no-duplicates */ -/* eslint-disable no-constant-condition */ /* eslint-disable no-await-in-loop */ /* .. .' @`._ diff --git a/packages/hydrojudge/src/hosts/hydro.ts b/packages/hydrojudge/src/hosts/hydro.ts index 2485ad4c3..192a6a77f 100644 --- a/packages/hydrojudge/src/hosts/hydro.ts +++ b/packages/hydrojudge/src/hosts/hydro.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-await-in-loop */ import path from 'path'; import PQueue from 'p-queue'; import superagent from 'superagent'; diff --git a/packages/hydrojudge/src/hosts/vj4.ts b/packages/hydrojudge/src/hosts/vj4.ts index 9649ce147..0a8b06133 100644 --- a/packages/hydrojudge/src/hosts/vj4.ts +++ b/packages/hydrojudge/src/hosts/vj4.ts @@ -249,7 +249,7 @@ export default class VJ4 implements Session { } } - async processData(folder: string) { // eslint-disable-line class-methods-use-this + async processData(folder: string) { let files = await fs.readdir(folder); if (files.length <= 2) { if (files.length === 2) files.splice(files.indexOf('version'), 1); diff --git a/packages/hydrojudge/src/judge/hack.ts b/packages/hydrojudge/src/judge/hack.ts index 49f04895f..0cfe99826 100644 --- a/packages/hydrojudge/src/judge/hack.ts +++ b/packages/hydrojudge/src/judge/hack.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-sequences */ import { STATUS } from '@hydrooj/common'; import { fs, parseMemoryMB, parseTimeMS } from '@hydrooj/utils'; import checkers from '../checkers'; diff --git a/packages/hydrooj/src/commands/install.ts b/packages/hydrooj/src/commands/install.ts index 4256c83c7..93b578773 100644 --- a/packages/hydrooj/src/commands/install.ts +++ b/packages/hydrooj/src/commands/install.ts @@ -13,7 +13,6 @@ import { hydroPath } from '../options'; const logger = new Logger('install'); let yarnVersion = 0; try { - // eslint-disable-next-line no-unsafe-optional-chaining yarnVersion = +child.execSync('yarn --version', { cwd: os.tmpdir() }).toString().split('v').pop()!.split('.')[0]; } catch (e) { // yarn 2 does not support global dir diff --git a/packages/hydrooj/src/entry/cli.ts b/packages/hydrooj/src/entry/cli.ts index 70299d062..b68313825 100644 --- a/packages/hydrooj/src/entry/cli.ts +++ b/packages/hydrooj/src/entry/cli.ts @@ -1,5 +1,3 @@ -/* eslint-disable import/no-dynamic-require */ -/* eslint-disable no-await-in-loop */ import os from 'os'; import path from 'path'; import cac from 'cac'; diff --git a/packages/hydrooj/src/entry/common.ts b/packages/hydrooj/src/entry/common.ts index a04eea77f..8acdf995f 100644 --- a/packages/hydrooj/src/entry/common.ts +++ b/packages/hydrooj/src/entry/common.ts @@ -1,6 +1,5 @@ /* eslint-disable import/no-dynamic-require */ /* eslint-disable no-await-in-loop */ -/* eslint-disable no-eval */ import '../lib/index'; import os from 'os'; diff --git a/packages/hydrooj/src/entry/setup.ts b/packages/hydrooj/src/entry/setup.ts index 9f6e20fea..7fc1b1e2d 100644 --- a/packages/hydrooj/src/entry/setup.ts +++ b/packages/hydrooj/src/entry/setup.ts @@ -13,7 +13,6 @@ export async function load() { console.error('{"url":"mongodb://localhost:27017/hydro"}'); process.exit(1); } - // eslint-disable-next-line no-constant-condition while (true) { console.error('Please type your MongoDB connection string below:'); console.error('Example: mongodb://localhost:27017/hydro'); diff --git a/packages/hydrooj/src/entry/worker.ts b/packages/hydrooj/src/entry/worker.ts index 3a6d949cd..0010c5c86 100644 --- a/packages/hydrooj/src/entry/worker.ts +++ b/packages/hydrooj/src/entry/worker.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/no-dynamic-require */ /* eslint-disable no-await-in-loop */ import os from 'os'; import path from 'path'; @@ -92,7 +91,6 @@ export async function apply(ctx: Context) { } for (const f of Object.values(global.addons)) { const dir = path.join(f, 'public'); - // eslint-disable-next-line no-await-in-loop if (await fs.pathExists(dir)) await fs.copy(dir, path.join(os.homedir(), '.hydro/static')); } ctx.inject(['server'], async ({ server }) => { diff --git a/packages/hydrooj/src/handler/contest.ts b/packages/hydrooj/src/handler/contest.ts index fa2c13220..4e90c5511 100644 --- a/packages/hydrooj/src/handler/contest.ts +++ b/packages/hydrooj/src/handler/contest.ts @@ -324,7 +324,6 @@ export class ContestEditHandler extends Handler { await ScheduleModel.deleteMany(task); const operation = []; if (Date.now() <= endAt.getTime() && autoHide) { - // eslint-disable-next-line no-await-in-loop await Promise.all(pids.map((pid) => problem.edit(domainId, pid, { hidden: true }))); operation.push('unhide'); } diff --git a/packages/hydrooj/src/handler/misc.ts b/packages/hydrooj/src/handler/misc.ts index 7781f3f2a..b437b0acd 100644 --- a/packages/hydrooj/src/handler/misc.ts +++ b/packages/hydrooj/src/handler/misc.ts @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ import { pick } from 'lodash'; import { lookup } from 'mime-types'; import { Context } from '../context'; diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 568d76298..23778f9f5 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -142,7 +142,6 @@ export class ProblemMainHandler extends Handler { } const sort = this.queryContext.sort; await this.ctx.parallel('problem/list', query, this, sort); - // eslint-disable-next-line prefer-const let [pdocs, ppcount, pcount] = this.queryContext.fail ? [[], 0, 0] : await this.paginate( diff --git a/packages/hydrooj/src/interface.ts b/packages/hydrooj/src/interface.ts index 08d31abaf..8f346cba7 100644 --- a/packages/hydrooj/src/interface.ts +++ b/packages/hydrooj/src/interface.ts @@ -172,7 +172,6 @@ export interface Document { } declare module './model/problem' { - // eslint-disable-next-line @typescript-eslint/no-shadow interface ProblemDoc { docType: document['TYPE_PROBLEM']; docId: number; diff --git a/packages/hydrooj/src/loader.ts b/packages/hydrooj/src/loader.ts index 0fe62a640..752627e46 100644 --- a/packages/hydrooj/src/loader.ts +++ b/packages/hydrooj/src/loader.ts @@ -1,8 +1,6 @@ /* eslint-disable import/no-dynamic-require */ /* eslint-disable consistent-return */ /* eslint-disable simple-import-sort/imports */ -/* eslint-disable no-await-in-loop */ -/* eslint-disable no-eval */ import './init'; import './interface'; import path from 'path'; @@ -156,7 +154,6 @@ async function preload() { try { // Is a npm package const packagejson = require.resolve(`${a}/package.json`); - // eslint-disable-next-line import/no-dynamic-require const payload = require(packagejson); const name = payload.name.startsWith('@hydrooj/') ? payload.name.split('@hydrooj/')[1] : payload.name; global.Hydro.version[name] = payload.version; diff --git a/packages/hydrooj/src/model/contest.ts b/packages/hydrooj/src/model/contest.ts index 90008adb0..ba085cfa7 100644 --- a/packages/hydrooj/src/model/contest.ts +++ b/packages/hydrooj/src/model/contest.ts @@ -91,7 +91,6 @@ const acm = buildContestRule({ submitAfterAccept: false, showScoreboard: (tdoc, now) => now > tdoc.beginAt, showSelfRecord: () => true, - // eslint-disable-next-line @typescript-eslint/no-use-before-define showRecord: (tdoc, now) => now > tdoc.endAt && !isLocked(tdoc), stat(tdoc, journal: AcmJournal[]) { const naccept = Counter(); @@ -100,7 +99,6 @@ const acm = buildContestRule({ const detail: Record = {}; let accept = 0; let time = 0; - // eslint-disable-next-line @typescript-eslint/no-use-before-define const lockAt = isLocked(tdoc) ? tdoc.lockAt : null; for (const j of journal) { if (!tdoc.pids.includes(j.pid)) continue; @@ -281,7 +279,7 @@ const oi = buildContestRule({ const detail = {}; const display = {}; let score = 0; - // eslint-disable-next-line @typescript-eslint/no-use-before-define + const lockAt = isLocked(tdoc) ? tdoc.lockAt : null; for (const j of journal.filter((i) => tdoc.pids.includes(i.pid))) { if (lockAt && j.rid.getTimestamp() > lockAt) { @@ -362,7 +360,7 @@ const oi = buildContestRule({ const tsddict = ((config.lockAt && isLocked(tdoc, new Date())) ? tsdoc.display : tsdoc.detail) || {}; for (const pid of tdoc.pids) { const index = `${tsdoc.uid}/${tdoc.domainId}/${pid}`; - // eslint-disable-next-line @typescript-eslint/no-use-before-define + const node: ScoreboardNode = (!config.isExport && !config.lockAt && isDone(tdoc) && meta?.psdict?.[index]?.rid && tsddict[pid]?.rid?.toHexString() !== meta?.psdict?.[index]?.rid?.toHexString() @@ -408,7 +406,7 @@ const oi = buildContestRule({ if (!first[pid] || first[pid] > time) first[pid] = time; } } - // eslint-disable-next-line @typescript-eslint/no-use-before-define + if (isDone(tdoc)) { const psdocs = await Promise.all( tdoc.pids.map((pid) => problem.getMultiStatus(tdoc.domainId, { docId: pid, uid: { $in: uids } }).toArray()), @@ -450,7 +448,7 @@ const oi = buildContestRule({ const ioi = buildContestRule({ TEXT: 'IOI', submitAfterAccept: false, - // eslint-disable-next-line @typescript-eslint/no-use-before-define + showRecord: (tdoc, now) => now > tdoc.endAt && !isLocked(tdoc), showSelfRecord: () => true, showScoreboard: (tdoc, now) => now > tdoc.beginAt, diff --git a/packages/hydrooj/src/model/document.ts b/packages/hydrooj/src/model/document.ts index 83f47e6ab..c8c43d922 100644 --- a/packages/hydrooj/src/model/document.ts +++ b/packages/hydrooj/src/model/document.ts @@ -382,14 +382,12 @@ export async function revPushStatus( { $set: { [`${key}.$`]: value }, $inc: { rev: 1 } }, { returnDocument: 'after' }, ); - if (!res) { - res = await collStatus.findOneAndUpdate( - { domainId, docType, docId, uid }, - // @ts-ignore - { $push: { [key]: value }, $inc: { rev: 1 } }, - { upsert: true, returnDocument: 'after' }, - ); - } + res ||= await collStatus.findOneAndUpdate( + { domainId, docType, docId, uid }, + // @ts-ignore + { $push: { [key]: value }, $inc: { rev: 1 } }, + { upsert: true, returnDocument: 'after' }, + ); return res; } diff --git a/packages/hydrooj/src/model/domain.ts b/packages/hydrooj/src/model/domain.ts index bca9fa9e3..c40c60b78 100644 --- a/packages/hydrooj/src/model/domain.ts +++ b/packages/hydrooj/src/model/domain.ts @@ -136,7 +136,11 @@ class DomainModel { static async setUserRole(domainId: string, uid: MaybeArray, role: string, autojoin = false) { const update = { $set: { role, ...(autojoin ? { join: true } : {}) } }; if (!(uid instanceof Array)) { - const res = await collUser.findOneAndUpdate({ domainId, uid }, update, { upsert: true, returnDocument: 'after', includeResultMetadata: true }); + const res = await collUser.findOneAndUpdate( + { domainId, uid }, + update, + { upsert: true, returnDocument: 'after', includeResultMetadata: true }, + ); const udoc = await UserModel.getById(domainId, uid); deleteUserCache(udoc); return res; diff --git a/packages/hydrooj/src/model/problem.ts b/packages/hydrooj/src/model/problem.ts index ff58db2c7..9235f63dc 100644 --- a/packages/hydrooj/src/model/problem.ts +++ b/packages/hydrooj/src/model/problem.ts @@ -385,7 +385,6 @@ export class ProblemModel { } for (const pdoc of pdocs) { try { - // eslint-disable-next-line no-await-in-loop pdoc.config = await parseConfig(pdoc.config as string); } catch (e) { pdoc.config = `Cannot parse: ${e.message}`; diff --git a/packages/hydrooj/src/model/setting.ts b/packages/hydrooj/src/model/setting.ts index 420d2718d..5077ce305 100644 --- a/packages/hydrooj/src/model/setting.ts +++ b/packages/hydrooj/src/model/setting.ts @@ -45,7 +45,6 @@ export const DOMAIN_USER_SETTINGS_BY_KEY: SettingDict = {}; export const DOMAIN_SETTINGS_BY_KEY: SettingDict = {}; export const SYSTEM_SETTINGS_BY_KEY: SettingDict = {}; -// eslint-disable-next-line max-len export type SettingType = 'text' | 'yaml' | 'number' | 'float' | 'markdown' | 'password' | 'boolean' | 'textarea' | [string, string][] | Record | 'json'; export const Setting = ( @@ -355,7 +354,6 @@ SystemSetting( Setting('setting_storage', 'installid', String.random(64), 'text', 'installid', 'Installation ID', FLAG_HIDDEN | FLAG_DISABLED), ); -// eslint-disable-next-line import/no-mutable-exports export const langs: Record = {}; declare module '@cordisjs/core' { diff --git a/packages/hydrooj/src/model/task.ts b/packages/hydrooj/src/model/task.ts index 57df43213..879aa5747 100644 --- a/packages/hydrooj/src/model/task.ts +++ b/packages/hydrooj/src/model/task.ts @@ -169,7 +169,6 @@ export async function apply(ctx: Context) { stream.on('error', async () => { // The $changeStream stage is only supported on replica sets logger.info('No replica set found.'); - // eslint-disable-next-line no-constant-condition while (true) { let res; try { diff --git a/packages/hydrooj/src/model/user.ts b/packages/hydrooj/src/model/user.ts index 6f39bc238..fb2a0f048 100644 --- a/packages/hydrooj/src/model/user.ts +++ b/packages/hydrooj/src/model/user.ts @@ -316,7 +316,7 @@ class UserModel { autoAlloc = true; } const salt = String.random(); - while (true) { // eslint-disable-line no-constant-condition + while (true) { try { // eslint-disable-next-line no-await-in-loop await coll.insertOne({ diff --git a/packages/hydrooj/src/plugin-api.ts b/packages/hydrooj/src/plugin-api.ts index 9d791b5de..775d3ed51 100644 --- a/packages/hydrooj/src/plugin-api.ts +++ b/packages/hydrooj/src/plugin-api.ts @@ -58,4 +58,4 @@ export { EventMap } from './service/bus'; export { db, pwsh }; // to load ctx.scoreboard -export { } from './handler/contest'; // eslint-disable-line @typescript-eslint/no-useless-empty-export +export { } from './handler/contest'; diff --git a/packages/hydrooj/src/script/problemStat.ts b/packages/hydrooj/src/script/problemStat.ts index 94c81313e..26ad4559b 100644 --- a/packages/hydrooj/src/script/problemStat.ts +++ b/packages/hydrooj/src/script/problemStat.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-await-in-loop */ import Schema from 'schemastery'; import { STATUS } from '../model/builtin'; import * as document from '../model/document'; diff --git a/packages/hydrooj/src/script/storageUsage.ts b/packages/hydrooj/src/script/storageUsage.ts index 16a7902e6..058a42b97 100644 --- a/packages/hydrooj/src/script/storageUsage.ts +++ b/packages/hydrooj/src/script/storageUsage.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-await-in-loop */ import Schema from 'schemastery'; import { STATUS } from '../model/builtin'; import storage from '../model/storage'; diff --git a/packages/hydrooj/src/service/bus.ts b/packages/hydrooj/src/service/bus.ts index d679ac8fc..259f08817 100644 --- a/packages/hydrooj/src/service/bus.ts +++ b/packages/hydrooj/src/service/bus.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-await-in-loop */ import { BSON, Db, Filter, ObjectId, OnlyFieldsOfType, } from 'mongodb'; diff --git a/packages/hydrooj/src/service/db.ts b/packages/hydrooj/src/service/db.ts index 9455f1e78..0a621c03a 100644 --- a/packages/hydrooj/src/service/db.ts +++ b/packages/hydrooj/src/service/db.ts @@ -59,7 +59,7 @@ export class MongoService extends Service { const mongourl = await MongoService.getUrl(); const url = mongoUri.parse(mongourl); this.client = await MongoClient.connect(mongourl); - yield () => { this.client.close(); } + yield () => { this.client.close(); }; this.db = this.client.db(url.database || 'hydro'); await bus.parallel('database/connect', this.db); this.ctx.setInterval(() => this.fixExpireAfter(), Time.hour); diff --git a/packages/hydrooj/src/ui.ts b/packages/hydrooj/src/ui.ts index ffd0e3a53..64ad00441 100644 --- a/packages/hydrooj/src/ui.ts +++ b/packages/hydrooj/src/ui.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-shadow */ import { Logger } from './logger'; import bus from './service/bus'; diff --git a/packages/onlyoffice/frontend/office.page.ts b/packages/onlyoffice/frontend/office.page.ts index 8b9e63ee6..42a5eecf0 100644 --- a/packages/onlyoffice/frontend/office.page.ts +++ b/packages/onlyoffice/frontend/office.page.ts @@ -1,4 +1,3 @@ -/* eslint-disable github/array-foreach */ import { $, addPage, AutoloadPage, i18n, Notification, request, } from '@hydrooj/ui-default'; diff --git a/packages/onsite-toolkit/frontend/resolver.page.tsx b/packages/onsite-toolkit/frontend/resolver.page.tsx index ae5e017aa..91d595e62 100644 --- a/packages/onsite-toolkit/frontend/resolver.page.tsx +++ b/packages/onsite-toolkit/frontend/resolver.page.tsx @@ -1,9 +1,8 @@ -/* eslint-disable no-await-in-loop */ -import { animated, easings, useSprings } from '@react-spring/web'; -import useKey from 'react-use/lib/useKey'; import { addPage, NamedPage, React, ReactDOM, } from '@hydrooj/ui-default'; +import { animated, easings, useSprings } from '@react-spring/web'; +import useKey from 'react-use/lib/useKey'; import { ResolverInput } from '../interface'; async function scrollTo(offset) { diff --git a/packages/ui-default/api.ts b/packages/ui-default/api.ts index f07b133ca..98b5bcda5 100644 --- a/packages/ui-default/api.ts +++ b/packages/ui-default/api.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/order */ /* eslint-disable import/first */ export * from './utils'; export { default as Notification } from './components/notification'; diff --git a/packages/ui-default/backendlib/builder.ts b/packages/ui-default/backendlib/builder.ts index 9533366a9..94fb2ca1f 100644 --- a/packages/ui-default/backendlib/builder.ts +++ b/packages/ui-default/backendlib/builder.ts @@ -1,12 +1,12 @@ -import esbuild from 'esbuild'; -import { - Context, fs, Handler, Logger, NotFoundError, param, SettingModel, sha1, - size, SystemModel, Types, UiContextBase, -} from 'hydrooj'; import { tmpdir } from 'os'; import { basename, join, relative, resolve, } from 'path'; +import { + Context, fs, Handler, Logger, NotFoundError, param, SettingModel, sha1, + size, SystemModel, Types, UiContextBase, +} from 'hydrooj'; +import esbuild from 'esbuild'; declare module 'hydrooj' { interface UI { diff --git a/packages/ui-default/backendlib/markdown-it-imsize.ts b/packages/ui-default/backendlib/markdown-it-imsize.ts index 5a43ab588..4ada0d7be 100644 --- a/packages/ui-default/backendlib/markdown-it-imsize.ts +++ b/packages/ui-default/backendlib/markdown-it-imsize.ts @@ -232,4 +232,4 @@ export default function plugin(md) { state.posMax = max; return true; }); -}; +} diff --git a/packages/ui-default/backendlib/markdown-it-media.ts b/packages/ui-default/backendlib/markdown-it-media.ts index b6684467d..9a192e2e2 100644 --- a/packages/ui-default/backendlib/markdown-it-media.ts +++ b/packages/ui-default/backendlib/markdown-it-media.ts @@ -1,5 +1,4 @@ /* eslint-disable max-len */ -/* eslint-disable prefer-destructuring */ import type MarkdownIt from 'markdown-it'; import { v4 as uuid } from 'uuid'; diff --git a/packages/ui-default/backendlib/misc.ts b/packages/ui-default/backendlib/misc.ts index 238696e6c..ec6eeba64 100644 --- a/packages/ui-default/backendlib/misc.ts +++ b/packages/ui-default/backendlib/misc.ts @@ -1,5 +1,5 @@ -import { AnsiUp } from 'ansi_up'; import { moment, ObjectId } from 'hydrooj'; +import { AnsiUp } from 'ansi_up'; export { size, formatSeconds } from 'hydrooj'; diff --git a/packages/ui-default/backendlib/template.ts b/packages/ui-default/backendlib/template.ts index 473f43f52..6813830de 100644 --- a/packages/ui-default/backendlib/template.ts +++ b/packages/ui-default/backendlib/template.ts @@ -1,12 +1,12 @@ +import path from 'path'; import * as status from '@hydrooj/common/status'; import { findFileSync } from '@hydrooj/utils/lib/utils'; -import { convert } from 'html-to-text'; import { avatar, Context, difficultyAlgorithm, fs, PERM, PRIV, Service, STATUS, yaml, } from 'hydrooj'; +import { convert } from 'html-to-text'; import jsesc from 'jsesc'; import nunjucks from 'nunjucks'; -import path from 'path'; import markdown from './markdown'; import { ensureTag, xss } from './markdown-it-xss'; import * as misc from './misc'; diff --git a/packages/ui-default/build/config/webpack.ts b/packages/ui-default/build/config/webpack.ts index 3bfb91bf8..9f59d917a 100644 --- a/packages/ui-default/build/config/webpack.ts +++ b/packages/ui-default/build/config/webpack.ts @@ -1,16 +1,15 @@ -/* eslint-disable global-require */ +import fs from 'fs'; +import { dirname } from 'path'; import { sentryWebpackPlugin } from '@sentry/webpack-plugin'; import { CleanWebpackPlugin } from 'clean-webpack-plugin'; import CopyWebpackPlugin from 'copy-webpack-plugin'; import { version as coreJsVersion } from 'core-js/package.json'; import compat from 'core-js-compat'; import { EsbuildPlugin } from 'esbuild-loader'; -import fs from 'fs'; import { DuplicatesPlugin } from 'inspectpack/plugin'; import ExtractCssPlugin from 'mini-css-extract-plugin'; import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin'; import packageJson from 'package-json'; -import { dirname } from 'path'; import { gt } from 'semver'; import webpack from 'webpack'; import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; diff --git a/packages/ui-default/build/main.ts b/packages/ui-default/build/main.ts index e3eef497e..8fbbed1c7 100644 --- a/packages/ui-default/build/main.ts +++ b/packages/ui-default/build/main.ts @@ -1,10 +1,10 @@ /* eslint-disable import/no-import-module-exports */ +import path from 'path'; import { size } from '@hydrooj/utils/lib/utils'; import cac from 'cac'; import chalk from 'chalk'; import fs from 'fs-extra'; import { globbySync } from 'globby'; -import path from 'path'; import webpack, { Stats } from 'webpack'; import WebpackDevServer from 'webpack-dev-server'; import pkg from '../package.json'; diff --git a/packages/ui-default/components/autocomplete/components/AutoComplete.tsx b/packages/ui-default/components/autocomplete/components/AutoComplete.tsx index 614bf9d4d..885b8334a 100644 --- a/packages/ui-default/components/autocomplete/components/AutoComplete.tsx +++ b/packages/ui-default/components/autocomplete/components/AutoComplete.tsx @@ -1,5 +1,3 @@ -/* eslint-disable jsx-a11y/role-supports-aria-props */ -/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */ import { debounce, uniqueId } from 'lodash'; import React, { forwardRef, useEffect, @@ -83,7 +81,7 @@ function DraggableSelection({ const AutoComplete = forwardRef(function Impl(props: AutoCompleteProps, ref: React.Ref>) { const { multi = false, width = '100%', height = 'auto', - freeSolo = false, allowEmptyQuery = false, listStyle = {}, + freeSolo = false, allowEmptyQuery = false, listStyle = {}, // eslint-disable-line @eslint-react/no-unstable-default-props disabled = false, disabledHint = '', draggable = multi, } = props; const queryItems = props.queryItems ?? (() => []); @@ -333,7 +331,7 @@ const AutoComplete = forwardRef(function Impl(props: AutoCompleteProps, re key={itemKey(item)} onClick={() => toggleItem(item)} onMouseMove={() => setCurrentItem(idx)} - aria-selected={selectedKeys.includes(itemKey(item))} + data-selected={selectedKeys.includes(itemKey(item))} data-focus={idx === currentItem} >
{renderItem(item)}
diff --git a/packages/ui-default/components/autocomplete/components/UserSelectAutoComplete.tsx b/packages/ui-default/components/autocomplete/components/UserSelectAutoComplete.tsx index 63dc39dfb..8d437f72a 100644 --- a/packages/ui-default/components/autocomplete/components/UserSelectAutoComplete.tsx +++ b/packages/ui-default/components/autocomplete/components/UserSelectAutoComplete.tsx @@ -4,7 +4,6 @@ import React, { forwardRef } from 'react'; import { api, gql } from 'vj/utils'; import AutoComplete, { AutoCompleteHandle, AutoCompleteProps } from './AutoComplete'; -// eslint-disable-next-line prefer-arrow-callback const UserSelectAutoComplete = forwardRef, AutoCompleteProps>((props, ref) => ( ref={ref as any} diff --git a/packages/ui-default/components/calendar/index.js b/packages/ui-default/components/calendar/index.js index 0b00ee95e..7ab0bea02 100644 --- a/packages/ui-default/components/calendar/index.js +++ b/packages/ui-default/components/calendar/index.js @@ -1,3 +1,4 @@ +/* eslint-disable no-lone-blocks */ import $ from 'jquery'; import _ from 'lodash'; import moment from 'moment'; @@ -208,7 +209,7 @@ export default class Calendar { const now = moment(); days.forEach((day) => { - day.current = day.date.isSame(now, 'day'); // eslint-disable-line no-param-reassign + day.current = day.date.isSame(now, 'day'); }); const daysByWeek = _.chunk(days, 7); diff --git a/packages/ui-default/components/message/worker.ts b/packages/ui-default/components/message/worker.ts index 463438260..ff7bc27b6 100644 --- a/packages/ui-default/components/message/worker.ts +++ b/packages/ui-default/components/message/worker.ts @@ -80,7 +80,7 @@ function initConn(path: string, port: MessagePort, cookie: any) { }; } -self.onconnect = function (e) { // eslint-disable-line no-undef +self.onconnect = function (e) { const port = e.ports[0]; port.addEventListener('message', (msg: { data: RequestPayload }) => { diff --git a/packages/ui-default/components/problemconfig/ProblemConfigEditor.tsx b/packages/ui-default/components/problemconfig/ProblemConfigEditor.tsx index 7b3ce231e..1d4561f5e 100644 --- a/packages/ui-default/components/problemconfig/ProblemConfigEditor.tsx +++ b/packages/ui-default/components/problemconfig/ProblemConfigEditor.tsx @@ -1,6 +1,6 @@ /* eslint-disable react-refresh/only-export-components */ -import { diffLines } from 'diff'; import type { ProblemConfigFile, TestCaseConfig } from 'hydrooj/src/interface'; +import { diffLines } from 'diff'; import $ from 'jquery'; import yaml from 'js-yaml'; import { isEqual } from 'lodash'; diff --git a/packages/ui-default/components/problemconfig/ProblemConfigTree.tsx b/packages/ui-default/components/problemconfig/ProblemConfigTree.tsx index f4a0d76dd..31fd461f8 100644 --- a/packages/ui-default/components/problemconfig/ProblemConfigTree.tsx +++ b/packages/ui-default/components/problemconfig/ProblemConfigTree.tsx @@ -1,8 +1,8 @@ +import { normalizeSubtasks, readSubtasksFromFiles } from '@hydrooj/common'; +import { TestCaseConfig } from 'hydrooj'; import { Button, Classes, Icon, Popover, TreeNode, } from '@blueprintjs/core'; -import { normalizeSubtasks, readSubtasksFromFiles } from '@hydrooj/common'; -import { TestCaseConfig } from 'hydrooj'; import { isEqual } from 'lodash'; import React from 'react'; import { DndProvider, useDrop } from 'react-dnd'; diff --git a/packages/ui-default/components/problemconfig/reducer/config.ts b/packages/ui-default/components/problemconfig/reducer/config.ts index 111154155..b054ea561 100644 --- a/packages/ui-default/components/problemconfig/reducer/config.ts +++ b/packages/ui-default/components/problemconfig/reducer/config.ts @@ -1,6 +1,6 @@ import { parseMemoryMB, parseTimeMS, sortFiles } from '@hydrooj/utils/lib/common'; -import Ajv from 'ajv'; import type { ProblemConfigFile, TestCaseConfig } from 'hydrooj/src/interface'; +import Ajv from 'ajv'; import yaml from 'js-yaml'; import { cloneDeep } from 'lodash'; import schema from '../../monaco/schema/problemconfig'; diff --git a/packages/ui-default/components/problemconfig/tree/AddTestcase.tsx b/packages/ui-default/components/problemconfig/tree/AddTestcase.tsx index 26347c2bb..351a7a063 100644 --- a/packages/ui-default/components/problemconfig/tree/AddTestcase.tsx +++ b/packages/ui-default/components/problemconfig/tree/AddTestcase.tsx @@ -1,7 +1,7 @@ +import { readSubtasksFromFiles } from '@hydrooj/common'; import { Button, Classes, Dialog, DialogBody, DialogFooter, Icon, } from '@blueprintjs/core'; -import { readSubtasksFromFiles } from '@hydrooj/common'; import React, { useEffect, useRef } from 'react'; import { useSelector, useStore } from 'react-redux'; import { i18n } from 'vj/utils'; diff --git a/packages/ui-default/components/problemconfig/tree/SubtaskSettings.tsx b/packages/ui-default/components/problemconfig/tree/SubtaskSettings.tsx index 6ad8275d6..bcfce9104 100644 --- a/packages/ui-default/components/problemconfig/tree/SubtaskSettings.tsx +++ b/packages/ui-default/components/problemconfig/tree/SubtaskSettings.tsx @@ -1,9 +1,9 @@ +import { parseMemoryMB, parseTimeMS } from '@hydrooj/utils/lib/common'; import { Button, ControlGroup, Dialog, DialogBody, DialogFooter, Icon, InputGroup, Tag, } from '@blueprintjs/core'; -import { parseMemoryMB, parseTimeMS } from '@hydrooj/utils/lib/common'; import { isEqual } from 'lodash'; import React, { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; diff --git a/packages/ui-default/components/problemconfig/tree/Testcase.tsx b/packages/ui-default/components/problemconfig/tree/Testcase.tsx index a570014a5..909cefd79 100644 --- a/packages/ui-default/components/problemconfig/tree/Testcase.tsx +++ b/packages/ui-default/components/problemconfig/tree/Testcase.tsx @@ -1,7 +1,7 @@ +import { TestCaseConfig } from 'hydrooj'; import { ContextMenu, Menu, MenuItem, TreeNode, } from '@blueprintjs/core'; -import { TestCaseConfig } from 'hydrooj'; import { omit } from 'lodash'; import React from 'react'; import { useDrag } from 'react-dnd'; diff --git a/packages/ui-default/components/scratchpad/DataInputComponent.jsx b/packages/ui-default/components/scratchpad/DataInputComponent.jsx index 8fef6b7da..ead914119 100644 --- a/packages/ui-default/components/scratchpad/DataInputComponent.jsx +++ b/packages/ui-default/components/scratchpad/DataInputComponent.jsx @@ -18,7 +18,6 @@ export default function DataInputComponent(props) { wrap="off" spellCheck="false" > - {/* eslint-disable-next-line react/no-danger */}
         
       ) : (
diff --git a/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx b/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx
index 5935a0766..d659f9809 100644
--- a/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx
+++ b/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx
@@ -1,4 +1,3 @@
-/* eslint-disable react/static-property-placement */
 import _ from 'lodash';
 import PropTypes from 'prop-types';
 import React from 'react';
diff --git a/packages/ui-default/index.ts b/packages/ui-default/index.ts
index aea578f8e..36859c0bd 100644
--- a/packages/ui-default/index.ts
+++ b/packages/ui-default/index.ts
@@ -1,4 +1,3 @@
-/* eslint-disable global-require */
 import {
   ContestModel, Context, Handler, ObjectId, param, PERM, PRIV, ProblemModel, Schema,
   SettingModel, SystemModel, Types, UserModel,
diff --git a/packages/ui-next/src/App.tsx b/packages/ui-next/src/App.tsx
index a453bf114..6f74d94b5 100644
--- a/packages/ui-next/src/App.tsx
+++ b/packages/ui-next/src/App.tsx
@@ -1,5 +1,5 @@
 function App() {
-    return 
; + return
; } export default App; diff --git a/packages/utils/lib/locate-pm2.ts b/packages/utils/lib/locate-pm2.ts index 402c7a238..1d36692ad 100644 --- a/packages/utils/lib/locate-pm2.ts +++ b/packages/utils/lib/locate-pm2.ts @@ -12,7 +12,7 @@ const pm2: typeof import('pm2') | null = (() => { const p = path.resolve(dir, info); if (p.startsWith('/nix')) return require(`${p.split('/bin')[0]}/lib/node_modules/pm2`); // installed by yarn - return require(`${p.split('.bin')[0]}pm2`); // eslint-disable-line import/no-dynamic-require + return require(`${p.split('.bin')[0]}pm2`); } catch (e) { } } return null; diff --git a/packages/utils/lib/utils.ts b/packages/utils/lib/utils.ts index 01a5b2c03..27cec8446 100644 --- a/packages/utils/lib/utils.ts +++ b/packages/utils/lib/utils.ts @@ -39,7 +39,6 @@ export const sha1 = (content: string) => encrypt('sha1', content); export const md5 = (content: string) => encrypt('md5', content); export function folderSize(folderPath: string) { - // eslint-disable-next-line @typescript-eslint/no-shadow let size = 0; const _next = function a(p: string) { if (p) { diff --git a/packages/vjudge/src/providers/codeforces.ts b/packages/vjudge/src/providers/codeforces.ts index 4d8034a52..ae6a42446 100644 --- a/packages/vjudge/src/providers/codeforces.ts +++ b/packages/vjudge/src/providers/codeforces.ts @@ -318,7 +318,6 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr async waitForSubmission(id: string, next, end) { let i = 1; const start = Date.now(); - // eslint-disable-next-line no-constant-condition while (true) { await sleep(3000); const contestId = id.includes('#') ? id.split('#')[0] : null; diff --git a/packages/vjudge/src/providers/hduoj.ts b/packages/vjudge/src/providers/hduoj.ts index 73012a570..735fca6c2 100644 --- a/packages/vjudge/src/providers/hduoj.ts +++ b/packages/vjudge/src/providers/hduoj.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-constant-condition */ /* eslint-disable no-await-in-loop */ import { PassThrough } from 'stream'; import { JSDOM } from 'jsdom'; diff --git a/packages/vjudge/src/providers/poj.ts b/packages/vjudge/src/providers/poj.ts index 4b98b6932..33fca66f3 100644 --- a/packages/vjudge/src/providers/poj.ts +++ b/packages/vjudge/src/providers/poj.ts @@ -190,7 +190,6 @@ export default class POJProvider extends BasicFetcher implements IBasicProvider // eslint-disable-next-line consistent-return async waitForSubmission(id: string, next, end) { let count = 0; - // eslint-disable-next-line no-constant-condition while (count < 60) { count++; await sleep(3000); diff --git a/packages/vjudge/src/providers/spoj.ts b/packages/vjudge/src/providers/spoj.ts index 1b3473096..cf184de90 100644 --- a/packages/vjudge/src/providers/spoj.ts +++ b/packages/vjudge/src/providers/spoj.ts @@ -108,7 +108,6 @@ langs: ${JSON.stringify(langs)}`), async waitForSubmission(id: string, next, end) { logger.debug('Waiting for %s', id); - // eslint-disable-next-line no-constant-condition while (true) { await sleep(3000); const { text } = await this.get(`/status/ns=${id}`); diff --git a/packages/vjudge/src/providers/uoj.ts b/packages/vjudge/src/providers/uoj.ts index aad18638f..908f015b5 100644 --- a/packages/vjudge/src/providers/uoj.ts +++ b/packages/vjudge/src/providers/uoj.ts @@ -161,7 +161,6 @@ export default class UOJProvider extends BasicFetcher implements IBasicProvider async waitForSubmission(id: string, next, end) { let i = 1; let count = 0; - // eslint-disable-next-line no-constant-condition while (count < 120) { count++; await sleep(3000); diff --git a/packages/vjudge/src/providers/yacs.ts b/packages/vjudge/src/providers/yacs.ts index 61e9552c2..5768fdbf4 100644 --- a/packages/vjudge/src/providers/yacs.ts +++ b/packages/vjudge/src/providers/yacs.ts @@ -109,7 +109,6 @@ export default class YACSProvider extends BasicFetcher implements IBasicProvider async waitForSubmission(id: string, next, end) { const done = {}; - // eslint-disable-next-line no-constant-condition while (true) { await sleep(3000); const { submission } = await this.getData(`/submission/${id}`);