workspace: apply eslint edits

This commit is contained in:
undefined committed 2025-03-21 09:48:17 +08:00
1 parent 040f7d8863
commit 0e7f5fe635
63 files changed
+47 -96

No files matched your search

+4 -6
View File
@@ -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<number>();
@@ -100,7 +99,6 @@ const acm = buildContestRule({
const detail: Record<number, AcmDetail> = {};
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,
+6 -8
View File
@@ -382,14 +382,12 @@ export async function revPushStatus<T extends keyof DocStatusType>(
{ $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;
}
+5 -1
View File
@@ -136,7 +136,11 @@ class DomainModel {
static async setUserRole(domainId: string, uid: MaybeArray<number>, 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;
-1
View File
@@ -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}`;
-2
View File
@@ -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<string, string> | '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<string, LangConfig> = {};
declare module '@cordisjs/core' {
-1
View File
@@ -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 {
+1 -1
View File
@@ -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({