workspace: update eslint config

pull/56/head
undefined 4 years ago
parent 4e4f6688bc
commit 3a3983d38d

@ -2,4 +2,5 @@ dist
*.d.ts
*.js
test
tests
tests
node_modules

@ -1,59 +0,0 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'airbnb-base',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
BigInt: true,
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-unused-vars': 'error',
camelcase: 'off',
'global-require': 'off',
'guard-for-in': 'off',
'implicit-arrow-linebreak': 'off',
'import/extensions': 'off',
'import/no-cycle': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/prefer-default-export': 'off',
indent: ['warn', 4],
'lines-between-class-members': ['error', 'always', { 'exceptAfterSingleLine': true }],
'max-classes-per-file': 'off',
'max-len': ['warn', 150],
'no-bitwise': 'off',
'no-console': 'off',
'no-continue': 'off',
'no-dupe-class-members': 'off',
'no-extend-native': 'off',
'no-inner-declarations': 'off',
'no-multi-assign': 'off',
'no-nested-ternary': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-restricted-syntax': 'off',
'no-return-await': 'off',
'no-underscore-dangle': 'off',
'no-unused-vars': 'off',
'prefer-destructuring': 'off',
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
},
};

@ -0,0 +1,55 @@
root: true
extends:
- airbnb-typescript/base
globals:
Atomics: readonly
SharedArrayBuffer: readonly
BigInt: readonly
parser: '@typescript-eslint/parser'
plugins:
- '@typescript-eslint'
rules:
'@typescript-eslint/dot-notation': off
'@typescript-eslint/no-implied-eval': off
'@typescript-eslint/no-throw-literal': off
'@typescript-eslint/indent':
- warn
- 4
'@typescript-eslint/lines-between-class-members':
- error
- always
- exceptAfterSingleLine: true
'@typescript-eslint/naming-convention': off
'@typescript-eslint/no-redeclare': off
global-require: off
guard-for-in: off
implicit-arrow-linebreak: off
import/no-cycle: off
import/no-extraneous-dependencies: off
import/no-named-as-default: off
import/prefer-default-export: off
max-classes-per-file: off
max-len:
- warn
- 150
no-bitwise: off
no-console: off
no-continue: off
no-extend-native: off
no-multi-assign: off
no-nested-ternary: off
no-param-reassign: off
no-plusplus: off
no-restricted-syntax: off
no-return-await: off
no-underscore-dangle: off
prefer-destructuring: off
settings:
import/parsers:
'@typescript-eslint/parser':
- .ts
import/resolver:
typescript:
alwaysTryTypes: true

@ -23,11 +23,11 @@
"@types/jest": "^26.0.20",
"@types/node": "^14.14.22",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"cross-spawn": "^7.0.3",
"eslint": "^7.18.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint": "^7.19.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-plugin-import": "^2.22.1",
"globby": "^11.0.2",
@ -35,7 +35,7 @@
"latest-version": "^5.1.0",
"ora": "^5.3.0",
"semver": "^7.3.4",
"ts-jest": "^26.4.4",
"ts-jest": "^26.5.0",
"typescript": "4.1.3"
},
"dependencies": {

@ -7,13 +7,13 @@
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0-only",
"dependencies": {
"adm-zip": "^0.5.1",
"adm-zip": "^0.5.2",
"decode-html": "^2.0.0",
"fs-extra": "^9.1.0",
"xml2js": "^0.4.23"
},
"devDependencies": {
"@types/xml2js": "^0.4.7",
"@types/xml2js": "^0.4.8",
"bson": "^4.2.2"
},
"peerDependencies": {

@ -1,12 +1,12 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.3.2",
"version": "2.3.3",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
"dependencies": {
"adm-zip": "^0.5.1",
"adm-zip": "^0.5.2",
"axios": "^0.21.1",
"bson": "^4.2.2",
"fs-extra": "^9.1.0",
@ -14,7 +14,7 @@
"lodash": "^4.17.20",
"p-queue": "^6.6.1",
"shell-quote": "^1.7.2",
"systeminformation": "^4.34.9",
"systeminformation": "^5.0.8",
"yargs": "^16.2.0"
},
"peerDependencies": {

@ -36,4 +36,4 @@ export = async function compile(
};
}
throw new SystemError('Unknown language type.');
}
};

@ -6,4 +6,4 @@ import * as hack from './hack';
export = {
default: def, interactive, run, submit_answer, hack,
}
};

@ -31,39 +31,39 @@ const colors = [
];
const instances: Record<string, Logger> = {};
type LogFunction = (format: any, ...param: any[]) => void
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug'
type LogFunction = (format: any, ...param: any[]) => void;
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug';
export interface Logger extends Record<LogType, LogFunction> { }
export class Logger {
static readonly SUCCESS = 1
static readonly ERROR = 1
static readonly INFO = 2
static readonly WARN = 2
static readonly DEBUG = 3
static baseLevel = argv.debug ? 3 : 2
static showDiff = false
static levels: Record<string, number> = {}
static lastTime = 0
static readonly SUCCESS = 1;
static readonly ERROR = 1;
static readonly INFO = 2;
static readonly WARN = 2;
static readonly DEBUG = 3;
static baseLevel = argv.debug ? 3 : 2;
static showDiff = false;
static levels: Record<string, number> = {};
static lastTime = 0;
static options: InspectOptions = {
colors: process.stderr.isTTY,
}
};
static formatters: Record<string, (this: Logger, value: any) => string> = {
c: Logger.prototype.color,
C: (value) => Logger.color(15, value, ';1'),
o: (value) => inspect(value, Logger.options).replace(/\s*\n\s*/g, ' '),
}
};
static color(code: number, value: any, decoration = '') {
if (!Logger.options.colors) return `${value}`;
return `\u001B[3${code < 8 ? code : `8;5;${code}`}${decoration}m${value}\u001B[0m`;
}
private code: number
private displayName: string
public stream: NodeJS.WritableStream = process.stderr
private code: number;
private displayName: string;
public stream: NodeJS.WritableStream = process.stderr;
constructor(public name: string, private showDiff = false) {
if (name in instances) return instances[name];
@ -97,7 +97,7 @@ export class Logger {
return Logger.levels[this.name] ?? Logger.baseLevel;
}
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff)
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff);
format: (format: any, ...param: any[]) => string = (...args) => {
if (args[0] instanceof Error) args[0] = args[0].stack || args[0].message;
@ -122,7 +122,7 @@ export class Logger {
Logger.lastTime = now;
}
return format(...args);
}
};
}
export default new Logger('judge');

@ -78,11 +78,11 @@ export async function get() {
const cpu = `${Cpu.manufacturer} ${Cpu.brand}`;
const memory = `${size(Memory.active)}/${size(Memory.total)}`;
const osinfo = `${OsInfo.distro} ${OsInfo.release} ${OsInfo.codename} ${OsInfo.kernel} ${OsInfo.arch}`;
const load = `${CurrentLoad.avgload}`;
const load = `${CurrentLoad.avgLoad}`;
const flags = CpuFlags;
let battery;
if (!Battery.hasbattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.ischarging ? ' Charging' : ''}`;
if (!Battery.hasBattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.isCharging ? ' Charging' : ''}`;
const mid = OsInfo.serial;
cache.cpu = cpu;
cache.osinfo = osinfo;
@ -114,10 +114,10 @@ export async function update() {
mid, cpu, osinfo, flags, stack,
} = cache;
const memory = `${size(Memory.active)}/${size(Memory.total)}`;
const load = `${CurrentLoad.avgload}`;
const load = `${CurrentLoad.avgLoad}`;
let battery;
if (!Battery.hasbattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.ischarging ? ' Charging' : ''}`;
if (!Battery.hasBattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.isCharging ? ' Charging' : ''}`;
const reqCount = global.reqCount;
global.reqCount = 0;
return [

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.17.6",
"version": "2.17.7",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
@ -11,8 +11,8 @@
"node": ">=10.10"
},
"dependencies": {
"adm-zip": "^0.5.1",
"ansi_up": "^4.0.4",
"adm-zip": "^0.5.2",
"ansi_up": "^5.0.0",
"cookies": "^0.8.0",
"detect-browser": "^5.1.1",
"fs-extra": "^9.1.0",
@ -32,27 +32,28 @@
"serialize-javascript": "^5.0.1",
"sockjs": "^0.3.20",
"superagent": "^6.1.0",
"systeminformation": "^4.34.9",
"terminal-kit": "^1.45.8",
"systeminformation": "^5.0.8",
"terminal-kit": "^1.45.9",
"yargs": "^16.2.0"
},
"devDependencies": {
"@types/adm-zip": "^0.4.33",
"@types/fs-extra": "^9.0.6",
"@types/js-yaml": "^4.0.0",
"@types/koa": "^2.11.4",
"@types/koa": "^2.11.7",
"@types/koa-router": "^7.4.1",
"@types/koa-static-cache": "^5.1.0",
"@types/lodash": "^4.14.168",
"@types/lru-cache": "^5.1.0",
"@types/minio": "^7.0.7",
"@types/mongodb": "^3.5.33",
"@types/mongodb": "^3.6.3",
"@types/nodemailer": "^6.4.0",
"@types/serialize-javascript": "^5.0.0",
"@types/sockjs": "^0.3.32",
"@types/superagent": "^4.1.8",
"@types/terminal-kit": "^1.28.2",
"@types/yargs": "^15.0.12"
"@types/yargs": "^16.0.0",
"formidable": "^1.2.2"
},
"scripts": {
"build": "tsc",

@ -10,7 +10,6 @@ import { argv } from 'yargs';
import { Logger } from '../logger';
const logger = new Logger('setup');
const listenPort = argv.port || 8888;
async function get(ctx: Context) {
@ -81,7 +80,6 @@ async function get(ctx: Context) {
async function post(ctx: Context) {
const {
host, port, name, username, password,
// @ts-ignore
} = ctx.request.body;
let mongourl = 'mongodb://';
if (username) mongourl += `${username}:${password}@`;

@ -2,6 +2,7 @@ import type { Readable, Writable } from 'stream';
import type { ObjectID } from 'mongodb';
import type fs from 'fs';
import type { Dictionary, NumericDictionary } from 'lodash';
import type * as Koa from 'koa';
import type { Pdoc } from './model/problem';
type document = typeof import('./model/document');
@ -159,7 +160,7 @@ export interface SampleContentNode {
payload: [string, string],
}
export type ContentNode = PlainContentNode | TextContentNode | SampleContentNode;
export type Content = string | ContentNode[] | Record<string, ContentNode[]>
export type Content = string | ContentNode[] | Record<string, ContentNode[]>;
declare module './model/problem' {
interface Pdoc {
@ -589,3 +590,10 @@ declare global {
}
}
}
declare module 'koa' {
interface Request extends Koa.BaseRequest {
body?: any;
files?: import('formidable').Files;
}
}

@ -11,7 +11,7 @@ async function _download(url: string, path: string, retry: number) {
return path;
}
function download(url: string): SuperAgentRequest
function download(url: string): SuperAgentRequest;
function download(url: string, path?: string, retry = 3) {
if (path) return _download(url, path, retry);
return superagent.get(url).retry(retry);

@ -18,11 +18,11 @@ export async function get() {
const cpu = `${Cpu.manufacturer} ${Cpu.brand}`;
const memory = `${size(Memory.active)}/${size(Memory.total)}`;
const osinfo = `${OsInfo.distro} ${OsInfo.release} ${OsInfo.codename} ${OsInfo.kernel} ${OsInfo.arch}`;
const load = `${CurrentLoad.avgload}`;
const load = `${CurrentLoad.avgLoad}`;
const flags = CpuFlags;
let battery;
if (!Battery.hasbattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.ischarging ? ' Charging' : ''}`;
if (!Battery.hasBattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.isCharging ? ' Charging' : ''}`;
const mid = OsInfo.serial;
cache.cpu = cpu;
cache.osinfo = osinfo;
@ -44,10 +44,10 @@ export async function update(): Promise<[string, any, any]> {
mid, cpu, osinfo, flags,
} = cache;
const memory = `${size(Memory.active)}/${size(Memory.total)}`;
const load = `${CurrentLoad.avgload}`;
const load = `${CurrentLoad.avgLoad}`;
let battery;
if (!Battery.hasbattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.ischarging ? ' Charging' : ''}`;
if (!Battery.hasBattery) battery = 'No battery';
else battery = `${Battery.type} ${Battery.model} ${Battery.percent}%${Battery.isCharging ? ' Charging' : ''}`;
return [
mid,
{

@ -3,22 +3,22 @@ import { argv } from 'yargs';
import { Time } from './utils';
const instances: Record<string, Logger> = {};
type LogFunction = (format: any, ...param: any[]) => void
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug'
type LogFunction = (format: any, ...param: any[]) => void;
type LogType = 'success' | 'error' | 'info' | 'warn' | 'debug';
export interface Logger extends Record<LogType, LogFunction> { }
export class Logger {
static readonly SUCCESS = 1
static readonly ERROR = 1
static readonly INFO = 2
static readonly WARN = 2
static readonly DEBUG = 3
static baseLevel = argv.debug ? 3 : 2
static showDiff = false
static levels: Record<string, number> = {}
static lastTime = 0
static readonly SUCCESS = 1;
static readonly ERROR = 1;
static readonly INFO = 2;
static readonly WARN = 2;
static readonly DEBUG = 3;
static baseLevel = argv.debug ? 3 : 2;
static showDiff = false;
static levels: Record<string, number> = {};
static lastTime = 0;
static formatters: Record<string, (this: Logger, value: any) => string> = {
o: (value) => inspect(value).replace(/\s*\n\s*/g, ' '),
}
};
constructor(public name: string, private showDiff = false) {
if (name in instances) return instances[name];
@ -48,7 +48,7 @@ export class Logger {
return Logger.levels[this.name] ?? Logger.baseLevel;
}
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff)
extend = (namespace: string, showDiff = this.showDiff) => new Logger(`${this.name}:${namespace}`, showDiff);
format: (format: any, ...param: any[]) => string = (...args) => {
if (args[0] instanceof Error) args[0] = args[0].stack || args[0].message;
@ -71,7 +71,7 @@ export class Logger {
Logger.lastTime = now;
}
return format(...args);
}
};
}
global.Hydro.Logger = Logger;

@ -49,13 +49,13 @@ export async function add<T extends keyof DocType, K extends DocType[T]['docId']
docType: T, docId: K,
parentType?: DocType[T]['parentType'], parentId?: DocType[T]['parentId'],
args?: Partial<DocType[T]>,
): Promise<K>
): Promise<K>;
export async function add<T extends keyof DocType>(
domainId: string, content: Content, owner: number,
docType: T, docId: null,
parentType?: DocType[T]['parentType'], parentId?: DocType[T]['parentId'],
args?: Partial<DocType[T]>,
): Promise<ObjectID>
): Promise<ObjectID>;
export async function add(
domainId: string, content: Content, owner: number,
docType: number, docId: DocID = null,
@ -164,14 +164,14 @@ export function count<K extends keyof DocType>(
return coll.find({ ...query, docType, domainId }).count();
}
export async function push<K extends keyof DocType, T extends keyof DocType[K]>(
export async function push<K extends keyof DocType>(
domainId: string, docType: K, docId: DocType[K]['docId'],
key: ArrayKeys<DocType[K]>, value: DocType[K][0],
): Promise<[DocType[K], ObjectID]>
): Promise<[DocType[K], ObjectID]>;
export async function push<K extends keyof DocType, T extends keyof DocType[K]>(
domainId: string, docType: K, docId: DocType[K]['docId'],
key: keyof DocType[K], content: string, owner: number, args?: DocType[K][T][0],
): Promise<[DocType[K], ObjectID]>
): Promise<[DocType[K], ObjectID]>;
export async function push(
domainId: string, docType: number, docId: DocID, key: string,
arg0: any, arg1?: any, arg2?: any,

@ -95,8 +95,8 @@ export function setUserRole(domainId: string, uid: number, role: string) {
return collUser.updateOne({ uid, domainId }, { $set: { role } }, { upsert: true });
}
export async function getRoles(domainId: string): Promise<any[]>
export async function getRoles(domain: DomainDoc): Promise<any[]>
export async function getRoles(domainId: string): Promise<any[]>;
export async function getRoles(domain: DomainDoc): Promise<any[]>;
export async function getRoles(arg: string | DomainDoc) {
let ddoc: DomainDoc;
if (typeof arg === 'string') ddoc = await get(arg);

@ -17,7 +17,7 @@ export interface Pdoc {
export namespace Pdoc {
export type Field = keyof Pdoc;
export const fields: Field[] = [];
type Getter = (docId?: number, pid?: string) => Partial<Pdoc>
type Getter = (docId?: number, pid?: string) => Partial<Pdoc>;
const getters: Getter[] = [];
export function extend(getter: Getter) {
getters.push(getter);

@ -7,37 +7,37 @@ import * as bus from '../service/bus';
const coll = db.collection('system');
const cache: Record<string, any> = {};
export function get<K extends keyof SystemKeys>(key: K): SystemKeys[K]
export function get(key: string): any
export function get<K extends keyof SystemKeys>(key: K): SystemKeys[K];
export function get(key: string): any;
export function get(key: string): any {
return cache[key];
}
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys,
>(keys: [A, B]): [SystemKeys[A], SystemKeys[B]]
>(keys: [A, B]): [SystemKeys[A], SystemKeys[B]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
>(keys: [A, B, C]): [SystemKeys[A], SystemKeys[B], SystemKeys[C]]
>(keys: [A, B, C]): [SystemKeys[A], SystemKeys[B], SystemKeys[C]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys,
>(keys: [A, B, C, D]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D]]
>(keys: [A, B, C, D]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys, E extends keyof SystemKeys,
>(keys: [A, B, C, D, E]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E]]
>(keys: [A, B, C, D, E]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys, E extends keyof SystemKeys, F extends keyof SystemKeys,
>(keys: [A, B, C, D, E, F]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E], SystemKeys[F]]
export function getMany(keys: (keyof SystemKeys)[]): any[]
>(keys: [A, B, C, D, E, F]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E], SystemKeys[F]];
export function getMany(keys: (keyof SystemKeys)[]): any[];
export function getMany(keys: string[]): any[] {
return keys.map((key) => cache[key]);
}
export async function set<K extends keyof SystemKeys>(_id: K, value: SystemKeys[K], boardcast?: boolean): Promise<SystemKeys[K]>
export async function set<K>(_id: string, value: K, boardcast?: boolean): Promise<K>
export async function set<K extends keyof SystemKeys>(_id: K, value: SystemKeys[K], boardcast?: boolean): Promise<SystemKeys[K]>;
export async function set<K>(_id: string, value: K, boardcast?: boolean): Promise<K>;
export async function set(_id: string, value: any, boardcast = true) {
if (boardcast) bus.boardcast('system/setting', { [_id]: value });
const res = await coll.findOneAndUpdate(

@ -28,4 +28,4 @@ export = function load() {
result = {};
}
return result;
}
};

@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import { ObjectID } from 'mongodb';
import * as document from '../model/document';
import * as discussion from '../model/discussion';
@ -62,7 +62,7 @@ async function _user(
}
export async function run({
// eslint-disable-next-line no-shadow
// eslint-disable-next-line @typescript-eslint/no-shadow
address = null, discuss = null, user = null, dryrun = true,
}, report) {
if (address) await _address(address, new Set(), new Set(), new Set(), dryrun, report);

@ -12,10 +12,10 @@ import paginate from '../lib/paginate';
export const description = 'Calculate rp of a domain, or all domains';
type ND = NumericDictionary<number>
type ND = NumericDictionary<number>;
async function runProblem(pdoc: Pdoc, udict: ND): Promise<void>
async function runProblem(domainId: string, pid: number, udict: ND): Promise<void>
async function runProblem(pdoc: Pdoc, udict: ND): Promise<void>;
async function runProblem(domainId: string, pid: number, udict: ND): Promise<void>;
async function runProblem(...arg: any[]) {
const pdoc: Pdoc = (typeof arg[0] === 'string')
? await problem.get(arg[0], arg[1], -1)
@ -50,10 +50,10 @@ async function runProblem(...arg: any[]) {
}
}
async function runContest(tdoc: Tdoc, udict: ND, report: Function): Promise<void>
async function runContest(tdoc: Tdoc, udict: ND, report: Function): Promise<void>;
async function runContest(
domainId: string, tid: ObjectID, udict: ND, report: Function
): Promise<void>
): Promise<void>;
async function runContest(...arg: any[]) {
const start = new Date().getTime();
const tdoc: Tdoc = (typeof arg[0] === 'string')

@ -16,8 +16,8 @@ function isBailed(value: any) {
return value !== null && value !== false && value !== undefined;
}
export type Disposable = () => void
export type VoidReturn = Promise<any> | any
export type Disposable = () => void;
export type VoidReturn = Promise<any> | any;
export interface EventMap {
'app/started': () => void
@ -53,7 +53,7 @@ export interface EventMap {
'document/add': (doc: any) => VoidReturn
'document/set': <T extends keyof DocType>
(domainId: string, docType: T, docId: DocType[T], $set: any, $unset: OnlyFieldsOfType<DocType[T], any, true | '' | 1>) => VoidReturn
(domainId: string, docType: T, docId: DocType[T], $set: any, $unset: OnlyFieldsOfType<DocType[T], any, true | '' | 1>) => VoidReturn
'problem/edit': (doc: Pdoc) => VoidReturn
'problem/list': (query: FilterQuery<Pdoc>, handler: any) => VoidReturn

@ -1,4 +1,3 @@
/* eslint-disable prefer-destructuring */
import assert from 'assert';
import { PassThrough } from 'stream';
import { resolve } from 'path';
@ -199,7 +198,7 @@ type DescriptorBuilder =
& ((name: string, type: Type, validate: null, convert: Converter) => MethodDecorator)
& ((name: string, type: Type, validate?: Validator, convert?: Converter) => MethodDecorator)
& ((name: string, type?: Type, isOptional?: boolean, validate?: Validator, convert?: Converter) => MethodDecorator)
& ((name: string, ...args: Array<Type | boolean | Validator | Converter>) => MethodDecorator)
& ((name: string, ...args: Array<Type | boolean | Validator | Converter>) => MethodDecorator);
export const get: DescriptorBuilder = (name, ...args) => _descriptor(_buildParam(name, 'get', ...args));
export const post: DescriptorBuilder = (name, ...args) => _descriptor(_buildParam(name, 'post', ...args));
@ -663,7 +662,7 @@ export class ConnectionHandler extends HandlerCommon {
params: Record<string, any>;
headers: Record<string, string>;
ip: string;
}
};
constructor(conn: sockjs.Connection) {
super();

@ -4,10 +4,10 @@ export type NumberKeys<O> = {
export type ArrayKeys<O, P = any> = {
[K in keyof O]: P[] extends O[K] ? K : never
}[keyof O]
}[keyof O];
export type Value<O, V = ''> = {
[K in keyof O]: V
}
};
export type Projection<O> = (string & keyof O)[]
export type Projection<O> = (string & keyof O)[];

@ -1,4 +1,4 @@
/* eslint-disable no-shadow */
/* eslint-disable @typescript-eslint/no-shadow */
// @ts-nocheck
import cluster from 'cluster';
import {

@ -7,7 +7,7 @@
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0-only",
"dependencies": {
"adm-zip": "^0.5.1",
"adm-zip": "^0.5.2",
"decode-html": "^2.0.0",
"fs-extra": "^9.1.0"
},

@ -11,7 +11,7 @@
},
"devDependencies": {
"@types/js-yaml": "^4.0.0",
"@types/mongodb": "^3.5.33"
"@types/mongodb": "^3.6.3"
},
"peerDependencies": {
"hydrooj": "2.14.x"

Loading…
Cancel
Save