patch eslint rules

This commit is contained in:
undefined committed 2026-03-30 20:02:19 +08:00
1 parent 403a762da1
commit 642662f505
15 files changed
+24 -19

No files matched your search

+1 -1
View File
@@ -77,7 +77,7 @@ async function cli() {
return console.error(parameters.join(', '));
}
for (let i = 0; i < args.length; i++) {
if ("'\"".includes(args[i][0]) && "'\"".includes(args[i][args[i].length - 1])) {
if ("'\"".includes(args[i][0]) && "'\"".includes(args[i].at(-1))) {
args[i] = args[i].substr(1, args[i].length - 2);
} else if (args[i].length === 24 && ObjectId.isValid(args[i])) {
args[i] = new ObjectId(args[i]);
+1 -1
View File
@@ -363,7 +363,7 @@ export async function apply(ctx: Context) {
assert(Array.isArray(config.subtasks));
const file = await storage.get(`submission/${rdoc.files.hack.split('#')[0]}`);
assert(file);
const hackSubtask = config.subtasks[config.subtasks.length - 1];
const hackSubtask = config.subtasks.at(-1);
hackSubtask.cases ||= [];
const input = `hack-${rdoc._id}-${hackSubtask.cases.length + 1}.in`;
hackSubtask.cases.push({ input, output: '/dev/null' });
+1 -1
View File
@@ -10,7 +10,7 @@ async function getStatus() {
const stats = await coll.find().sort({ type: 1, updateAt: -1 }).toArray();
for (const stat of stats) {
let desc = '';
const online = new Date(stat.updateAt).getTime() > new Date().getTime() - 300000;
const online = new Date(stat.updateAt).getTime() > Date.now() - 300000;
if (!online) desc = 'Offline';
desc ||= 'Online';
stat.isOnline = online;
+2 -2
View File
@@ -1,7 +1,7 @@
import moment from 'moment-timezone';
import { Context } from '../context';
import db from '../service/db';
import { ArgMethod } from '../utils';
import { ArgMethod, Time } from '../utils';
let coll = db.collection('blacklist');
@@ -12,7 +12,7 @@ class BlackListModel {
if (expire === 0) expireAt = moment().add(1000, 'months').toDate();
else if (typeof expire === 'number') expireAt = moment().add(expire, 'months').toDate();
else if (expire instanceof Date) expireAt = expire;
else expireAt = new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000);
else expireAt = new Date(Date.now() + 365 * Time.day);
return await coll.findOneAndUpdate(
{ _id: id },
{ $set: { expireAt } },
+1 -1
View File
@@ -78,7 +78,7 @@ export function isLocked(tdoc: Tdoc, time = new Date()) {
}
export function isExtended(tdoc: Tdoc) {
const now = new Date().getTime();
const now = Date.now();
return tdoc.penaltySince.getTime() <= now && now < tdoc.endAt.getTime();
}
+1 -1
View File
@@ -4,7 +4,7 @@ import db from '../service/db';
const coll = db.collection('opcount');
export async function inc(op: string, ident: string, periodSecs: number, maxOperations: number) {
const now = new Date().getTime();
const now = Date.now();
const expireAt = new Date(now - (now % (periodSecs * 1000)) + periodSecs * 1000);
try {
const res = await coll.findOneAndUpdate({
+2 -2
View File
@@ -166,13 +166,13 @@ export async function run({ domainId }, report: Report) {
const domains = await domain.getMulti().toArray();
await report({ message: `Found ${domains.length} domains` });
for (const i in domains) {
const start = new Date().getTime();
const start = Date.now();
await runInDomain(domains[i]._id, report);
await report({
case: {
status: STATUS.STATUS_ACCEPTED,
message: `Domain ${domains[i]._id} finished`,
time: new Date().getTime() - start,
time: Date.now() - start,
memory: 0,
score: 0,
},
+3 -3
View File
@@ -103,7 +103,7 @@ export class SettingService extends Service {
async _actualMigrate(schema: Schema<any>) {
const processNode = async (path: string[], node: Schema<any, any>) => {
for (const item of node.list || []) await processNode(path, item); // eslint-disable-line no-await-in-loop
for (const key in node.dict || {}) await processNode(path.concat(key), node.dict[key]); // eslint-disable-line no-await-in-loop
for (const key in node.dict || {}) await processNode([...path, ...key], node.dict[key]); // eslint-disable-line no-await-in-loop
if (['string', 'number', 'boolean'].includes(node.type)) {
const value = this.initialValues[path.join('.')];
const migrated = this.initialValues[`${path.join('.')}__migrated`];
@@ -181,10 +181,10 @@ export class SettingService extends Service {
if (path.some((p) => typeof p === 'symbol')) return currentValue;
return new Proxy(currentValue, {
get(self, key: string) {
return getAccess(path.concat(key));
return getAccess([...path, ...key]);
},
set(self, p: string | symbol, newValue: any) {
that.setConfig(path.concat(p).join(','), newValue);
that.setConfig([...path, p].join(','), newValue);
return true;
},
});