Skip to content

Commit 8aac1f2

Browse files
committed
patch eslint rules
1 parent 403a762 commit 8aac1f2

14 files changed

Lines changed: 23 additions & 18 deletions

File tree

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ const config = react({
121121
// FIXME A bug with eslint-parser
122122
// 'template-curly-spacing': 'off',
123123

124+
'e18e/prefer-array-at': 'off',
125+
124126
'style/indent': ['warn', 2, {
125127
ArrayExpression: 1,
126128
CallExpression: {

framework/eslint-config/base.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ const base = (option, ...args) => antfu(
5858
'default-param-last': 'off',
5959
'dot-notation': 0,
6060

61+
'e18e/prefer-array-fill': 'off',
62+
'e18e/prefer-array-from-map': 'off',
6163
'e18e/prefer-array-some': 'off',
6264
'e18e/prefer-array-to-sorted': 'off',
6365
'e18e/prefer-static-regex': 'off',
66+
'e18e/prefer-timer-args': 'off',
6467
'eslint-comments/no-unlimited-disable': 'off',
6568
'func-names': 0,
6669
'function-call-argument-newline': 0,

packages/hydrojudge/src/hosts/vj4.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,15 @@ export default class VJ4 implements Session {
287287
ver = fs.readFileSync(path.join(filePath, 'version')).toString();
288288
} catch (e) { /* ignore */ }
289289
if (version === ver) {
290-
fs.writeFileSync(path.join(filePath, 'lastUsage'), new Date().getTime().toString());
290+
fs.writeFileSync(path.join(filePath, 'lastUsage'), Date.now().toString());
291291
return filePath;
292292
}
293293
fs.removeSync(filePath);
294294
}
295295
fs.ensureDirSync(domainDir);
296296
await this.problemData(domainId, pid, filePath, 3, next);
297297
fs.writeFileSync(path.join(filePath, 'version'), version);
298-
fs.writeFileSync(path.join(filePath, 'lastUsage'), new Date().getTime().toString());
298+
fs.writeFileSync(path.join(filePath, 'lastUsage'), Date.now().toString());
299299
return filePath;
300300
}
301301

packages/hydrooj/src/entry/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async function cli() {
7777
return console.error(parameters.join(', '));
7878
}
7979
for (let i = 0; i < args.length; i++) {
80-
if ("'\"".includes(args[i][0]) && "'\"".includes(args[i][args[i].length - 1])) {
80+
if ("'\"".includes(args[i][0]) && "'\"".includes(args[i].at(-1))) {
8181
args[i] = args[i].substr(1, args[i].length - 2);
8282
} else if (args[i].length === 24 && ObjectId.isValid(args[i])) {
8383
args[i] = new ObjectId(args[i]);

packages/hydrooj/src/handler/judge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export async function apply(ctx: Context) {
363363
assert(Array.isArray(config.subtasks));
364364
const file = await storage.get(`submission/${rdoc.files.hack.split('#')[0]}`);
365365
assert(file);
366-
const hackSubtask = config.subtasks[config.subtasks.length - 1];
366+
const hackSubtask = config.subtasks.at(-1);
367367
hackSubtask.cases ||= [];
368368
const input = `hack-${rdoc._id}-${hackSubtask.cases.length + 1}.in`;
369369
hackSubtask.cases.push({ input, output: '/dev/null' });

packages/hydrooj/src/handler/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async function getStatus() {
1010
const stats = await coll.find().sort({ type: 1, updateAt: -1 }).toArray();
1111
for (const stat of stats) {
1212
let desc = '';
13-
const online = new Date(stat.updateAt).getTime() > new Date().getTime() - 300000;
13+
const online = new Date(stat.updateAt).getTime() > Date.now() - 300000;
1414
if (!online) desc = 'Offline';
1515
desc ||= 'Online';
1616
stat.isOnline = online;

packages/hydrooj/src/model/blacklist.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import moment from 'moment-timezone';
22
import { Context } from '../context';
33
import db from '../service/db';
4-
import { ArgMethod } from '../utils';
4+
import { ArgMethod, Time } from '../utils';
55

66
let coll = db.collection('blacklist');
77

@@ -12,7 +12,7 @@ class BlackListModel {
1212
if (expire === 0) expireAt = moment().add(1000, 'months').toDate();
1313
else if (typeof expire === 'number') expireAt = moment().add(expire, 'months').toDate();
1414
else if (expire instanceof Date) expireAt = expire;
15-
else expireAt = new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000);
15+
else expireAt = new Date(Date.now() + 365 * Time.day);
1616
return await coll.findOneAndUpdate(
1717
{ _id: id },
1818
{ $set: { expireAt } },

packages/hydrooj/src/model/contest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function isLocked(tdoc: Tdoc, time = new Date()) {
7878
}
7979

8080
export function isExtended(tdoc: Tdoc) {
81-
const now = new Date().getTime();
81+
const now = Date.now();
8282
return tdoc.penaltySince.getTime() <= now && now < tdoc.endAt.getTime();
8383
}
8484

packages/hydrooj/src/model/opcount.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import db from '../service/db';
44
const coll = db.collection('opcount');
55

66
export async function inc(op: string, ident: string, periodSecs: number, maxOperations: number) {
7-
const now = new Date().getTime();
7+
const now = Date.now();
88
const expireAt = new Date(now - (now % (periodSecs * 1000)) + periodSecs * 1000);
99
try {
1010
const res = await coll.findOneAndUpdate({

packages/hydrooj/src/script/rating.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ export async function run({ domainId }, report: Report) {
166166
const domains = await domain.getMulti().toArray();
167167
await report({ message: `Found ${domains.length} domains` });
168168
for (const i in domains) {
169-
const start = new Date().getTime();
169+
const start = Date.now();
170170
await runInDomain(domains[i]._id, report);
171171
await report({
172172
case: {
173173
status: STATUS.STATUS_ACCEPTED,
174174
message: `Domain ${domains[i]._id} finished`,
175-
time: new Date().getTime() - start,
175+
time: Date.now() - start,
176176
memory: 0,
177177
score: 0,
178178
},

0 commit comments

Comments
 (0)