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

+2
View File
@@ -121,6 +121,8 @@ const config = react({
// FIXME A bug with eslint-parser
// 'template-curly-spacing': 'off',
'e18e/prefer-array-at': 'off',
'style/indent': ['warn', 2, {
ArrayExpression: 1,
CallExpression: {
+3
View File
@@ -58,9 +58,12 @@ const base = (option, ...args) => antfu(
'default-param-last': 'off',
'dot-notation': 0,
'e18e/prefer-array-fill': 'off',
'e18e/prefer-array-from-map': 'off',
'e18e/prefer-array-some': 'off',
'e18e/prefer-array-to-sorted': 'off',
'e18e/prefer-static-regex': 'off',
'e18e/prefer-timer-args': 'off',
'eslint-comments/no-unlimited-disable': 'off',
'func-names': 0,
'function-call-argument-newline': 0,
+2 -2
View File
@@ -287,7 +287,7 @@ export default class VJ4 implements Session {
ver = fs.readFileSync(path.join(filePath, 'version')).toString();
} catch (e) { /* ignore */ }
if (version === ver) {
fs.writeFileSync(path.join(filePath, 'lastUsage'), new Date().getTime().toString());
fs.writeFileSync(path.join(filePath, 'lastUsage'), Date.now().toString());
return filePath;
}
fs.removeSync(filePath);
@@ -295,7 +295,7 @@ export default class VJ4 implements Session {
fs.ensureDirSync(domainDir);
await this.problemData(domainId, pid, filePath, 3, next);
fs.writeFileSync(path.join(filePath, 'version'), version);
fs.writeFileSync(path.join(filePath, 'lastUsage'), new Date().getTime().toString());
fs.writeFileSync(path.join(filePath, 'lastUsage'), Date.now().toString());
return filePath;
}
+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;
},
});
+1 -1
View File
@@ -59,7 +59,7 @@ function fixFileName(fileName: string) {
const dotAt = fileName.lastIndexOf('.');
const name = fileName.slice(0, dotAt);
const suffix = fileName.slice(dotAt + 1);
if (!name.match(/[0-9]/)) {
if (!/[0-9]/.test(name)) {
fileName = `${name}0.${suffix}`;
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ function fixFileName(fileName: string) {
const dotAt = fileName.lastIndexOf('.');
const name = fileName.slice(0, dotAt);
const suffix = fileName.slice(dotAt + 1);
if (!name.match(/[0-9]/)) {
if (!/[0-9]/.test(name)) {
fileName = `${name}0.${suffix}`;
}
}
@@ -66,12 +66,12 @@ const invisibles = {
function addInvisibles(grammar) {
if (!grammar || grammar.tab) return;
for (const name in invisibles) {
if (Object.prototype.hasOwnProperty.call(invisibles, name)) {
if (Object.hasOwn(invisibles, name)) {
grammar[name] = invisibles[name];
}
}
for (const name in grammar) {
if (Object.prototype.hasOwnProperty.call(grammar, name) && !invisibles[name]) {
if (Object.hasOwn(grammar, name) && !invisibles[name]) {
if (name === 'rest') addInvisibles(grammar.rest);
else handlerInvisiblesToken(grammar, name); // eslint-disable-line ts/no-use-before-define
}
+1 -1
View File
@@ -58,7 +58,7 @@ class AccountService {
if (langConfig.validAs?.[this.account.type]) task.lang = langConfig.validAs[this.account.type];
const comment = langConfig.comment;
if (comment && !this.Provider.noComment) {
const msg = `Hydro submission #${task.rid}@${new Date().getTime()}`;
const msg = `Hydro submission #${task.rid}@${Date.now()}`;
if (typeof comment === 'string') task.code = `${comment} ${msg}\n${task.code}`;
else if (comment instanceof Array) task.code = `${comment[0]} ${msg} ${comment[1]}\n${task.code}`;
}