mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: fix eslint version
This commit is contained in:
1 parent
bd7cb2e959
commit
402a58cd47
25 files changed
+79
-60
No files matched your search
+1
-1
@@ -37,7 +37,7 @@
|
||||
"cross-spawn": "^7.0.3",
|
||||
"esbuild": "^0.12.26",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-airbnb-typescript": "^14.0.0",
|
||||
"eslint-config-airbnb-typescript": "12.3.1",
|
||||
"eslint-import-resolver-typescript": "^2.4.0",
|
||||
"eslint-plugin-import": "^2.24.2",
|
||||
"eslint-plugin-simple-import-sort": "^7.0.0",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/no-duplicates */
|
||||
/* eslint-disable no-constant-condition */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
/* ..
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/no-dynamic-require */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import cac from 'cac';
|
||||
import { ObjectID } from 'mongodb';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/no-dynamic-require */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -10,8 +10,8 @@ import * as oplog from '../model/oplog';
|
||||
import * as system from '../model/system';
|
||||
import user from '../model/user';
|
||||
import {
|
||||
Handler, param,
|
||||
Route, Types } from '../service/server';
|
||||
Handler, param, Route, Types,
|
||||
} from '../service/server';
|
||||
|
||||
export const typeMapper = {
|
||||
problem: document.TYPE_PROBLEM,
|
||||
|
||||
@@ -37,7 +37,7 @@ class HomeHandler extends Handler {
|
||||
uids.forEach((uid) => this.uids.add(uid));
|
||||
}
|
||||
|
||||
async getHomework(domainId: string, limit: number = 5) {
|
||||
async getHomework(domainId: string, limit = 5) {
|
||||
if (this.user.hasPerm(PERM.PERM_VIEW_HOMEWORK)) {
|
||||
const tdocs = await contest.getMulti(domainId, {}, document.TYPE_HOMEWORK)
|
||||
.limit(limit).toArray();
|
||||
@@ -50,7 +50,7 @@ class HomeHandler extends Handler {
|
||||
return ['homework', [], {}];
|
||||
}
|
||||
|
||||
async getContest(domainId: string, limit: number = 10) {
|
||||
async getContest(domainId: string, limit = 10) {
|
||||
if (this.user.hasPerm(PERM.PERM_VIEW_CONTEST)) {
|
||||
const tdocs = await contest.getMulti(domainId)
|
||||
.limit(limit).toArray();
|
||||
@@ -62,7 +62,7 @@ class HomeHandler extends Handler {
|
||||
return ['contest', [], {}];
|
||||
}
|
||||
|
||||
async getTraining(domainId: string, limit: number = 10) {
|
||||
async getTraining(domainId: string, limit = 10) {
|
||||
if (this.user.hasPerm(PERM.PERM_VIEW_TRAINING)) {
|
||||
const tdocs = await training.getMulti(domainId)
|
||||
.sort('_id', 1).limit(limit).toArray();
|
||||
@@ -74,7 +74,7 @@ class HomeHandler extends Handler {
|
||||
return ['training', [], {}];
|
||||
}
|
||||
|
||||
async getDiscussion(domainId: string, limit: number = 20) {
|
||||
async getDiscussion(domainId: string, limit = 20) {
|
||||
if (this.user.hasPerm(PERM.PERM_VIEW_DISCUSSION)) {
|
||||
const ddocs = await discussion.getMulti(domainId).limit(limit).toArray();
|
||||
const vndict = await discussion.getListVnodes(
|
||||
@@ -86,7 +86,7 @@ class HomeHandler extends Handler {
|
||||
return ['discussion', [], {}];
|
||||
}
|
||||
|
||||
async getRanking(domainId: string, limit: number = 50) {
|
||||
async getRanking(domainId: string, limit = 50) {
|
||||
if (this.user.hasPerm(PERM.PERM_VIEW_RANKING)) {
|
||||
const dudocs = await domain.getMultiUserInDomain(domainId, { uid: { $gt: 1 } })
|
||||
.sort({ rp: -1 }).project({ uid: 1 }).limit(limit).toArray();
|
||||
|
||||
@@ -6,12 +6,12 @@ import moment from 'moment-timezone';
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { Time } from '@hydrooj/utils/lib/utils';
|
||||
import {
|
||||
BadRequestError,
|
||||
HomeworkNotAttendedError, HomeworkNotLiveError, ProblemNotFoundError,
|
||||
ValidationError } from '../error';
|
||||
BadRequestError, HomeworkNotAttendedError, HomeworkNotLiveError,
|
||||
ProblemNotFoundError, ValidationError,
|
||||
} from '../error';
|
||||
import {
|
||||
DomainDoc,
|
||||
PenaltyRules, ProblemDoc, Tdoc, User } from '../interface';
|
||||
DomainDoc, PenaltyRules, ProblemDoc, Tdoc, User,
|
||||
} from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import { PERM, PRIV, STATUS } from '../model/builtin';
|
||||
import * as contest from '../model/contest';
|
||||
@@ -25,8 +25,8 @@ import * as system from '../model/system';
|
||||
import user from '../model/user';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
Handler, param,
|
||||
Route, Types } from '../service/server';
|
||||
Handler, param, Route, Types,
|
||||
} from '../service/server';
|
||||
|
||||
const validatePenaltyRules = (input: string) => yaml.load(input);
|
||||
const convertPenaltyRules = validatePenaltyRules;
|
||||
|
||||
@@ -20,8 +20,8 @@ import { PERM, PRIV } from '../model/builtin';
|
||||
import problem, { ProblemDoc } from '../model/problem';
|
||||
import TaskModel from '../model/task';
|
||||
import {
|
||||
Handler, post,
|
||||
Route, Types } from '../service/server';
|
||||
Handler, post, Route, Types,
|
||||
} from '../service/server';
|
||||
|
||||
const RE_SYZOJ = /(https?):\/\/([^/]+)\/(problem|p)\/([0-9]+)\/?/i;
|
||||
const logger = new Logger('import.syzoj');
|
||||
|
||||
@@ -14,7 +14,7 @@ import task from '../model/task';
|
||||
import * as bus from '../service/bus';
|
||||
import { updateJudge } from '../service/monitor';
|
||||
import {
|
||||
Connection, ConnectionHandler, Handler, post, Route, Types,
|
||||
Connection, ConnectionHandler, Handler, post, Route, Types,
|
||||
} from '../service/server';
|
||||
import { sleep } from '../utils';
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import * as yaml from 'js-yaml';
|
||||
import * as check from '../check';
|
||||
import { ValidationError } from '../error';
|
||||
import {
|
||||
isEmail, isPassword,
|
||||
isUname, validate } from '../lib/validator';
|
||||
isEmail, isPassword, isUname, validate,
|
||||
} from '../lib/validator';
|
||||
import { Logger } from '../logger';
|
||||
import { PRIV, STATUS } from '../model/builtin';
|
||||
import domain from '../model/domain';
|
||||
@@ -14,7 +14,8 @@ import * as system from '../model/system';
|
||||
import user from '../model/user';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
Connection, ConnectionHandler, Handler, param, Route, Types,
|
||||
Connection, ConnectionHandler, Handler,
|
||||
param, Route, Types,
|
||||
} from '../service/server';
|
||||
import * as judge from './judge';
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import storage from '../model/storage';
|
||||
import * as system from '../model/system';
|
||||
import user from '../model/user';
|
||||
import {
|
||||
Handler, param, post,
|
||||
Route, Types } from '../service/server';
|
||||
Handler, param, post, Route, Types,
|
||||
} from '../service/server';
|
||||
import { sortFiles } from '../utils';
|
||||
|
||||
class CheckInHandler extends Handler {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* eslint-disable class-methods-use-this */
|
||||
import { NotFoundError } from '../error';
|
||||
import {
|
||||
Handler, param, Route, Types,
|
||||
Handler, param, Route, Types,
|
||||
} from '../service/server';
|
||||
|
||||
class NotFoundHandler extends Handler {
|
||||
|
||||
@@ -4,13 +4,13 @@ import { lookup } from 'mime-types';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import { sortFiles } from '@hydrooj/utils/lib/utils';
|
||||
import {
|
||||
BadRequestError,
|
||||
ForbiddenError,
|
||||
NoProblemError, PermissionError, ProblemNotFoundError, SolutionNotFoundError, ValidationError,
|
||||
BadRequestError, ForbiddenError, NoProblemError,
|
||||
PermissionError, ProblemNotFoundError, SolutionNotFoundError,
|
||||
ValidationError,
|
||||
} from '../error';
|
||||
import {
|
||||
ProblemDoc, ProblemStatusDoc,
|
||||
User } from '../interface';
|
||||
ProblemDoc, ProblemStatusDoc, User,
|
||||
} from '../interface';
|
||||
import difficultyAlgorithm from '../lib/difficulty';
|
||||
import paginate from '../lib/paginate';
|
||||
import { isPid, parsePid as convertPid } from '../lib/validator';
|
||||
@@ -26,8 +26,8 @@ import * as system from '../model/system';
|
||||
import user from '../model/user';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
Handler, param, post, query,
|
||||
Route, route, Types } from '../service/server';
|
||||
Handler, param, post, query, Route, route, Types,
|
||||
} from '../service/server';
|
||||
import { registerResolver, registerValue } from './api';
|
||||
|
||||
export const parseCategory = (value: string) => flatten(value.replace(/,/g, ',').split(',')).map((e) => e.trim());
|
||||
|
||||
@@ -12,8 +12,8 @@ import * as training from '../model/training';
|
||||
import user from '../model/user';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
Handler, param,
|
||||
Route, Types } from '../service/server';
|
||||
Handler, param, Route, Types,
|
||||
} from '../service/server';
|
||||
|
||||
async function _parseDagJson(domainId: string, _dag: string): Promise<Tdoc['dag']> {
|
||||
const parsed = [];
|
||||
|
||||
@@ -18,7 +18,9 @@ import * as system from '../model/system';
|
||||
import task from '../model/task';
|
||||
import token from '../model/token';
|
||||
import user from '../model/user';
|
||||
import { Handler, param, post, Route, Types } from '../service/server';
|
||||
import {
|
||||
Handler, param, post, Route, Types,
|
||||
} from '../service/server';
|
||||
import { registerResolver, registerValue } from './api';
|
||||
|
||||
registerValue('User', [
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import {
|
||||
ContestAlreadyAttendedError,
|
||||
ContestNotAttendedError, ContestNotFoundError, ContestScoreboardHiddenError,
|
||||
ValidationError } from '../error';
|
||||
ContestAlreadyAttendedError, ContestNotAttendedError, ContestNotFoundError,
|
||||
ContestScoreboardHiddenError, ValidationError,
|
||||
} from '../error';
|
||||
import {
|
||||
ContestRule, ContestRules, ProblemDict,
|
||||
ProblemId, ScoreboardNode, ScoreboardRow, Tdoc,
|
||||
Udict,
|
||||
ProblemId, ScoreboardNode, ScoreboardRow,
|
||||
Tdoc, Udict,
|
||||
} from '../interface';
|
||||
import * as misc from '../lib/misc';
|
||||
import ranked from '../lib/rank';
|
||||
|
||||
@@ -306,6 +306,7 @@ const t = Math.exp(-0.15);
|
||||
|
||||
async function updateSort() {
|
||||
const cursor = document.coll.find({ docType: document.TYPE_DISCUSSION });
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const data = await cursor.next();
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import {
|
||||
Dictionary, escapeRegExp, flatten, groupBy, pick,
|
||||
escapeRegExp, flatten, groupBy, pick,
|
||||
} from 'lodash';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import type { Readable } from 'stream';
|
||||
import { streamToBuffer } from '@hydrooj/utils/lib/utils';
|
||||
import { ProblemNotFoundError, ValidationError } from '../error';
|
||||
import type {
|
||||
Document, DomainDoc,
|
||||
ProblemDict, ProblemId, ProblemStatusDoc } from '../interface';
|
||||
Document, DomainDoc, ProblemDict,
|
||||
ProblemId, ProblemStatusDoc,
|
||||
} from '../interface';
|
||||
import { parseConfig } from '../lib/testdataConfig';
|
||||
import * as bus from '../service/bus';
|
||||
import {
|
||||
@@ -309,7 +310,7 @@ export class ProblemModel {
|
||||
const psdocs = await ProblemModel.getMultiStatus(
|
||||
domainId, { uid, docId: { $in: Array.from(new Set(pids)) } },
|
||||
).toArray();
|
||||
const r: Dictionary<ProblemStatusDoc> = {};
|
||||
const r: Record<string, ProblemStatusDoc> = {};
|
||||
for (const psdoc of psdocs) r[psdoc.docId] = psdoc;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -209,6 +209,7 @@ 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 let langs = {};
|
||||
|
||||
bus.once('app/started', async () => {
|
||||
|
||||
@@ -6,10 +6,10 @@ import type {
|
||||
import type { ProblemSolutionHandler } from '../handler/problem';
|
||||
import type { UserRegisterHandler } from '../handler/user';
|
||||
import type {
|
||||
DiscussionDoc,
|
||||
DomainDoc, FileInfo, MessageDoc, ProblemDoc, RecordDoc,
|
||||
Tdoc,
|
||||
TrainingDoc, User } from '../interface';
|
||||
DiscussionDoc, DomainDoc, FileInfo,
|
||||
MessageDoc, ProblemDoc, RecordDoc,
|
||||
Tdoc, TrainingDoc, User,
|
||||
} from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
import type { DocType } from '../model/document';
|
||||
import type { Handler } from './server';
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { Collection, Db, IndexSpecification, MongoClient } from 'mongodb';
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import {
|
||||
Collection, Db, IndexSpecification, MongoClient,
|
||||
} from 'mongodb';
|
||||
import { BaseService, Collections } from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
import * as bus from './bus';
|
||||
@@ -57,9 +60,9 @@ class MongoService implements BaseService {
|
||||
existed = [];
|
||||
}
|
||||
for (const index of args) {
|
||||
let i = existed.find(t => t.name == index.name || JSON.stringify(t.key) == JSON.stringify(index.key));
|
||||
if (!i && Object.keys(index.key).map(k => index.key[k]).includes('text')) {
|
||||
i = existed.find(t => t.textIndexVersion);
|
||||
let i = existed.find((t) => t.name === index.name || JSON.stringify(t.key) === JSON.stringify(index.key));
|
||||
if (!i && Object.keys(index.key).map((k) => index.key[k]).includes('text')) {
|
||||
i = existed.find((t) => t.textIndexVersion);
|
||||
}
|
||||
index.background = true;
|
||||
if (!i) {
|
||||
@@ -67,9 +70,9 @@ class MongoService implements BaseService {
|
||||
await coll.createIndexes([index]);
|
||||
} else if (i.v < 2 || i.name !== index.name || JSON.stringify(i.key) !== JSON.stringify(index.key)) {
|
||||
if (i.textIndexVersion) {
|
||||
const cur = Object.keys(i.key).filter(t => !t.startsWith('_')).map(k => k + ':' + i.key[k]);
|
||||
for (const key of Object.keys(i.weights)) cur.push(key + ':text');
|
||||
const wanted = Object.keys(index.key).map(key => key + ':' + index.key[key]);
|
||||
const cur = Object.keys(i.key).filter((t) => !t.startsWith('_')).map((k) => `${k}:${i.key[k]}`);
|
||||
for (const key of Object.keys(i.weights)) cur.push(`${key}:text`);
|
||||
const wanted = Object.keys(index.key).map((key) => `${key}:${index.key[key]}`);
|
||||
if (cur.sort().join(' ') === wanted.sort().join(' ') && i.name === index.name) continue;
|
||||
}
|
||||
logger.info('Re-Index %s.%s with key %o', coll.collectionName, index.name, index.key);
|
||||
|
||||
@@ -90,8 +90,14 @@ class StorageService {
|
||||
'file.pathStyle', 'file.endPointForUser', 'file.endPointForJudge',
|
||||
]);
|
||||
this.opts = {
|
||||
endPoint, accessKey, secretKey, bucket, region,
|
||||
pathStyle, endPointForUser, endPointForJudge,
|
||||
endPoint,
|
||||
accessKey,
|
||||
secretKey,
|
||||
bucket,
|
||||
region,
|
||||
pathStyle,
|
||||
endPointForUser,
|
||||
endPointForJudge,
|
||||
};
|
||||
this.client = new Client({
|
||||
...parseMainEndpointUrl(this.opts.endPoint),
|
||||
|
||||
@@ -421,7 +421,7 @@ const scripts: UpgradeScript[] = [
|
||||
await iterateAllProblem(['docId', 'domainId', 'config'], async (pdoc) => {
|
||||
logger.info('%s/%s', pdoc.domainId, pdoc.docId);
|
||||
if (typeof pdoc.config !== 'string') return;
|
||||
if (!pdoc.config?.includes('type: subjective')) return;
|
||||
if (!pdoc.config.includes('type: subjective')) return;
|
||||
await problem.addTestdata(
|
||||
pdoc.domainId, pdoc.docId, 'config.yaml',
|
||||
Buffer.from(pdoc.config.replace('type: subjective', 'type: objective')),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import mongodb, { Cursor, Db } from 'mongodb';
|
||||
import {
|
||||
DiscussionTailReplyDoc, MessageDoc, RecordDoc, TestCase, TrainingNode,
|
||||
DiscussionTailReplyDoc, MessageDoc, RecordDoc, TestCase, TrainingNode,
|
||||
} from 'hydrooj';
|
||||
|
||||
const dst = global.Hydro.service.db;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Ingest, PushOptions,
|
||||
QueryOptions, Search, SuggestOptions } from 'sonic-channel';
|
||||
Ingest, PushOptions, QueryOptions,
|
||||
Search, SuggestOptions,
|
||||
} from 'sonic-channel';
|
||||
import { BaseService } from 'hydrooj';
|
||||
import { Logger } from 'hydrooj/src/logger';
|
||||
import * as system from 'hydrooj/src/model/system';
|
||||
|
||||
Reference in new issue
Block a user