diff --git a/.eslintrc.yaml b/.eslintrc.yaml index a7712d72..0cab092f 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -11,6 +11,7 @@ parser: '@typescript-eslint/parser' plugins: - '@typescript-eslint' - simple-import-sort + - eslint-plugin-import ignorePatterns: - public/ - '*.spec.ts' @@ -56,6 +57,14 @@ rules: match: false format: [camelCase, PascalCase] leadingUnderscore: allowSingleOrDouble + - selector: [objectLiteralProperty] + filter: + regex: '^[\d]+$' + match: true + format: null + - selector: [typeProperty, objectLiteralProperty] + modifiers: [requiresQuotes] + format: null - selector: enum format: [PascalCase] - selector: [class, interface, typeAlias, enumMember] @@ -64,6 +73,7 @@ rules: format: [camelCase, PascalCase, UPPER_CASE] '@typescript-eslint/no-redeclare': 0 + '@typescript-eslint/default-param-last': 0 class-methods-use-this: 0 global-require: 0 @@ -95,6 +105,7 @@ rules: no-return-await: 0 no-underscore-dangle: 0 prefer-destructuring: 0 + function-paren-newline: 0 simple-import-sort/imports: - warn - groups: diff --git a/package.json b/package.json index 51420a00..0f2b1a2a 100644 --- a/package.json +++ b/package.json @@ -27,16 +27,16 @@ "license": "AGPL-3.0-only", "devDependencies": { "@types/cross-spawn": "^6.0.2", - "@types/node": "^16.11.26", + "@types/node": "^17.0.21", "@types/semver": "^7.3.9", - "@typescript-eslint/eslint-plugin": "5.12.0", - "@typescript-eslint/parser": "5.12.0", + "@typescript-eslint/eslint-plugin": "5.14.0", + "@typescript-eslint/parser": "5.14.0", "cac": "^6.7.12", "cross-env": "^7.0.3", "cross-spawn": "^7.0.3", "esbuild": "0.14.3", - "eslint": "^8.10.0", - "eslint-config-airbnb-typescript": "12.3.1", + "eslint": "^8.11.0", + "eslint-config-airbnb-typescript": "16.1.1", "eslint-import-resolver-typescript": "2.5.0", "eslint-plugin-import": "2.25.4", "eslint-plugin-simple-import-sort": "7.0.0", @@ -46,7 +46,7 @@ "mongodb": "^3.7.3", "ora": "5.4.1", "semver": "^7.3.5", - "typedoc": "^0.22.12", - "typescript": "4.4.3" + "typedoc": "^0.22.13", + "typescript": "4.6.2" } } diff --git a/packages/center/package.json b/packages/center/package.json index af33ba97..21ad7af1 100644 --- a/packages/center/package.json +++ b/packages/center/package.json @@ -8,7 +8,7 @@ "preferUnplugged": true, "dependencies": { "js-yaml": "^4.1.0", - "superagent": "^6.1.0" + "superagent": "^7.1.1" }, "devDependencies": { "@types/js-yaml": "^4.0.5" diff --git a/packages/fps-importer/package.json b/packages/fps-importer/package.json index 8192714c..c6cd48c0 100644 --- a/packages/fps-importer/package.json +++ b/packages/fps-importer/package.json @@ -10,7 +10,7 @@ "dependencies": { "adm-zip": "0.5.5", "decode-html": "^2.0.0", - "fs-extra": "^10.0.0", + "fs-extra": "^10.0.1", "mongodb": "^3.7.3", "xml2js": "^0.4.23" }, diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index c54c1000..3c921b64 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -7,7 +7,7 @@ "repository": "https://github.com/hydro-dev/Hydro.git", "dependencies": { "@hydrooj/utils": "workspace:*", - "axios": "^0.25.0", + "axios": "^0.26.1", "cac": "^6.7.12", "esbuild": "0.14.3", "fs-extra": "^10.0.1", @@ -25,7 +25,7 @@ "@types/js-yaml": "^4.0.5", "@types/lodash": "^4.14.179", "@types/shell-quote": "^1.7.1", - "@types/ws": "^8.5.2" + "@types/ws": "^8.5.3" }, "peerDependencies": { "hydrooj": "*" diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index d4116a05..d5e9f97e 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.8.7", + "version": "3.9.0", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", @@ -20,12 +20,12 @@ "cac": "^6.7.12", "cookies": "^0.8.0", "detect-browser": "^5.3.0", - "emoji-regex": "^10.0.0", + "emoji-regex": "^10.0.1", "emojis-list": "2.1.0", "esbuild": "0.14.3", "fs-extra": "^10.0.1", "graphql": "^16.3.0", - "graphql-scalars": "1.14.1", + "graphql-scalars": "1.15.0", "js-yaml": "^4.1.0", "koa": "^2.13.4", "koa-body": "^4.2.0", @@ -34,7 +34,7 @@ "koa-router": "^10.1.1", "koa-static-cache": "^5.1.4", "lodash": "^4.17.21", - "lru-cache": "6.0.0", + "lru-cache": "7.4.4", "mime-types": "^2.1.34", "minio": "7.0.25", "moment-timezone": "^0.5.34", @@ -49,7 +49,7 @@ "serialize-javascript": "^6.0.0", "sockjs": "^0.3.24", "source-map-support": "^0.5.21", - "superagent": "^6.1.0", + "superagent": "^7.1.1", "thirty-two": "^1.0.2", "tx2": "^1.0.5" }, @@ -62,7 +62,7 @@ "@types/koa-router": "^7.4.4", "@types/koa-static-cache": "^5.1.1", "@types/lodash": "^4.14.179", - "@types/lru-cache": "^5.1.1", + "@types/lru-cache": "^7.4.0", "@types/mime-types": "^2.1.1", "@types/minio": "^7.0.12", "@types/mongodb": "^3.6.20", diff --git a/packages/hydrooj/src/lib/difficulty.ts b/packages/hydrooj/src/lib/difficulty.ts index d2f06652..c168f47c 100644 --- a/packages/hydrooj/src/lib/difficulty.ts +++ b/packages/hydrooj/src/lib/difficulty.ts @@ -5,7 +5,7 @@ const _CACHE_INFO = { }; function _LOGP(x: number) { - const sqrtPi = 2.506628274631000502415765284811; // Sqrt[Pi] + const sqrtPi = 2.506628274631; // Sqrt[Pi] return (2 * Math.exp(-1.0 * (Math.log(x) ** 2) * 2)) / x / sqrtPi; } diff --git a/packages/hydrooj/src/model/domain.ts b/packages/hydrooj/src/model/domain.ts index 739e1a28..d79376f3 100644 --- a/packages/hydrooj/src/model/domain.ts +++ b/packages/hydrooj/src/model/domain.ts @@ -91,9 +91,7 @@ class DomainModel { static async inc(domainId: string, field: NumberKeys, n: number): Promise { const res = await coll.findOneAndUpdate( { _id: domainId }, - // FIXME - // @ts-expect-error - { $inc: { [field]: n } }, + { $inc: { [field]: n } as any }, { returnDocument: 'after' }, ); return res.value?.[field]; diff --git a/packages/hydrooj/src/model/system.ts b/packages/hydrooj/src/model/system.ts index f4e348cf..70a8b818 100644 --- a/packages/hydrooj/src/model/system.ts +++ b/packages/hydrooj/src/model/system.ts @@ -52,9 +52,7 @@ export async function set(_id: string, value: any, broadcast = true) { export async function inc>(_id: K) { const res = await coll.findOneAndUpdate( { _id }, - // FIXME NumberKeys<> - // @ts-ignore - { $inc: { value: 1 } }, + { $inc: { value: 1 } as any }, { upsert: true, returnDocument: 'after' }, ); cache[_id] = res.value.value; diff --git a/packages/hydrooj/src/model/user.ts b/packages/hydrooj/src/model/user.ts index d1073bb9..15b8323c 100644 --- a/packages/hydrooj/src/model/user.ts +++ b/packages/hydrooj/src/model/user.ts @@ -35,12 +35,12 @@ export function deleteUserCache(udoc: User | Udoc | string | undefined | null, r } if (typeof udoc === 'string') { // is domainId - for (const key of cache.keys().filter((i) => i.endsWith(`/${udoc}`))) cache.del(key); + for (const key of [...cache.keys()].filter((i) => i.endsWith(`/${udoc}`))) cache.delete(key); return; } const id = [`id/${udoc._id.toString()}`, `name/${udoc.uname.toLowerCase()}`, `mail/${udoc.mail.toLowerCase()}`]; - for (const key of cache.keys().filter((k) => id.includes(`${k.split('/')[0]}/${k.split('/')[1]}`))) { - cache.del(key); + for (const key of [...cache.keys()].filter((k) => id.includes(`${k.split('/')[0]}/${k.split('/')[1]}`))) { + cache.delete(key); } } bus.on('user/delcache', (content) => deleteUserCache(JSON.parse(content), true)); diff --git a/packages/hydrooj/src/service/bus.ts b/packages/hydrooj/src/service/bus.ts index 7f20779c..a7413592 100644 --- a/packages/hydrooj/src/service/bus.ts +++ b/packages/hydrooj/src/service/bus.ts @@ -25,6 +25,7 @@ function isBailed(value: any) { export type Disposable = () => void; export type VoidReturn = Promise | any; +/* eslint-disable @typescript-eslint/naming-convention */ export interface EventMap extends Record { 'app/started': () => void 'app/load/lib': () => VoidReturn @@ -100,6 +101,7 @@ export interface EventMap extends Record { 'record/change': (rdoc: RecordDoc, $set?: any, $push?: any) => void 'record/judge': (rdoc: RecordDoc, updated: boolean) => VoidReturn } +/* eslint-enable @typescript-eslint/naming-convention */ function getHooks(name: K) { const hooks = _hooks[name] || (_hooks[name] = []); diff --git a/packages/import-qduoj/package.json b/packages/import-qduoj/package.json index 65218006..cd260cd9 100644 --- a/packages/import-qduoj/package.json +++ b/packages/import-qduoj/package.json @@ -10,6 +10,6 @@ "dependencies": { "adm-zip": "0.5.5", "decode-html": "^2.0.0", - "fs-extra": "^10.0.0" + "fs-extra": "^10.0.1" } } diff --git a/packages/login-with-github/package.json b/packages/login-with-github/package.json index 2f43aa27..342bae52 100644 --- a/packages/login-with-github/package.json +++ b/packages/login-with-github/package.json @@ -13,6 +13,6 @@ "hydrooj": "*" }, "dependencies": { - "superagent": "^6.1.0" + "superagent": "^7.1.1" } } diff --git a/packages/login-with-google/package.json b/packages/login-with-google/package.json index 5c39dc01..e9678fa5 100644 --- a/packages/login-with-google/package.json +++ b/packages/login-with-google/package.json @@ -13,6 +13,6 @@ "hydrooj": "*" }, "dependencies": { - "superagent": "^6.1.0" + "superagent": "^7.1.1" } } diff --git a/packages/login-with-osu/package.json b/packages/login-with-osu/package.json index 89e40222..28e9ec70 100644 --- a/packages/login-with-osu/package.json +++ b/packages/login-with-osu/package.json @@ -13,6 +13,6 @@ "hydrooj": "*" }, "dependencies": { - "superagent": "^6.1.0" + "superagent": "^7.1.1" } } diff --git a/packages/login-with-qq/package.json b/packages/login-with-qq/package.json index e2023fdc..8ea1722b 100644 --- a/packages/login-with-qq/package.json +++ b/packages/login-with-qq/package.json @@ -10,6 +10,6 @@ "ws": "^8.5.0" }, "devDependencies": { - "@types/ws": "^8.2.2" + "@types/ws": "^8.5.3" } } diff --git a/packages/migrate-vijos/script.ts b/packages/migrate-vijos/script.ts index a868aceb..0aa6ffea 100644 --- a/packages/migrate-vijos/script.ts +++ b/packages/migrate-vijos/script.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable no-await-in-loop */ import mongodb, { Cursor, Db } from 'mongodb'; import { diff --git a/packages/recaptcha/package.json b/packages/recaptcha/package.json index 38f2624d..7d6a30b3 100644 --- a/packages/recaptcha/package.json +++ b/packages/recaptcha/package.json @@ -8,6 +8,6 @@ "license": "AGPL-3.0-or-later", "preferUnplugged": true, "dependencies": { - "superagent": "^6.1.0" + "superagent": "^7.1.1" } } diff --git a/packages/ui-default/.eslintrc.js b/packages/ui-default/.eslintrc.js index 78e8468d..9faaeb33 100644 --- a/packages/ui-default/.eslintrc.js +++ b/packages/ui-default/.eslintrc.js @@ -87,6 +87,8 @@ module.exports = { 'class-methods-use-this': 'off', 'consistent-return': 'warn', 'func-names': 'off', + 'function-paren-newline': 'off', + 'default-param-last': 'off', 'import/first': 'off', 'import/extensions': 'off', 'import/no-extraneous-dependencies': 'off', diff --git a/packages/ui-default/backendlib/markdown-it-xss.ts b/packages/ui-default/backendlib/markdown-it-xss.ts index a89dca66..185ce0ee 100644 --- a/packages/ui-default/backendlib/markdown-it-xss.ts +++ b/packages/ui-default/backendlib/markdown-it-xss.ts @@ -32,7 +32,7 @@ const tagCheck = new Xss.FilterXSS({ }, }); -const xss = new Xss.FilterXSS({ +export const xss = new Xss.FilterXSS({ whiteList: { a: ['target', 'href', 'title'], abbr: ['title'], @@ -107,13 +107,13 @@ const xss = new Xss.FilterXSS({ }, }); -function ensureTag(html: string) { +export function ensureTag(html: string) { stack.length = 0; const res = tagCheck.process(html); return res + stack.map((i) => ``).join(''); } -function xssProtector(md) { +export function xssProtector(md) { function protector(state) { for (let i = 0; i < state.tokens.length; i++) { const cur = state.tokens[i]; @@ -133,5 +133,3 @@ function xssProtector(md) { md.core.ruler.after('linkify', 'xss', protector); } - -module.exports = { xss, ensureTag, xssProtector }; diff --git a/packages/ui-default/build/index.js b/packages/ui-default/build/index.js index b364940c..544c9bce 100644 --- a/packages/ui-default/build/index.js +++ b/packages/ui-default/build/index.js @@ -23,7 +23,7 @@ function transform(filename) { return result.outputFiles[0].text; } require.extensions['.js'] = function loader(module, filename) { - if (!filename.includes('node_modules') && !filename.includes('postcss.config.js')) { + if (filename.includes('chalk') || (!filename.includes('node_modules') && !filename.includes('postcss.config.js'))) { return module._compile(transform(filename), filename); } const content = fs.readFileSync(filename, 'utf-8'); diff --git a/packages/ui-default/components/DOMAttachedObject.ts b/packages/ui-default/components/DOMAttachedObject.ts index b0d095df..ba50e241 100644 --- a/packages/ui-default/components/DOMAttachedObject.ts +++ b/packages/ui-default/components/DOMAttachedObject.ts @@ -119,6 +119,7 @@ export default class DOMAttachedObject { } constructor($dom: JQuery, monitorDetach = false) { + // eslint-disable-next-line no-constructor-return if ($dom == null) return null; this.$dom = $dom; this.id = ++DOMAttachedObject.uniqueIdCounter; diff --git a/packages/ui-default/components/marker/Marker.js b/packages/ui-default/components/marker/Marker.js index 85f7a48b..dffd8460 100644 --- a/packages/ui-default/components/marker/Marker.js +++ b/packages/ui-default/components/marker/Marker.js @@ -23,9 +23,8 @@ class Marker { } constructor() { - if (Marker.exists()) { - return markerInstance; - } + // eslint-disable-next-line no-constructor-return + if (Marker.exists()) return markerInstance; if (markerInstance) { markerInstance.destroy(); } diff --git a/packages/ui-default/components/monaco/index.ts b/packages/ui-default/components/monaco/index.ts index 7b771075..d0f0ad7f 100644 --- a/packages/ui-default/components/monaco/index.ts +++ b/packages/ui-default/components/monaco/index.ts @@ -109,7 +109,7 @@ function handlePasteEvent(editor: monaco.editor.IStandaloneCodeEditor) { }); } let progress = 0; - request.postFile(isProblemEdit ? './file' : '/file', data, { + request.postFile(isProblemEdit ? './files' : '/file', data, { xhr() { const xhr = new XMLHttpRequest(); xhr.upload.addEventListener('loadstart', () => updateText(i18n('Uploading...'))); diff --git a/packages/ui-default/entry.js b/packages/ui-default/entry.js index 8d0eb979..8cc02a54 100644 --- a/packages/ui-default/entry.js +++ b/packages/ui-default/entry.js @@ -11,7 +11,8 @@ console.log( '%c%s%c%s', 'color:red;font-size:24px;', ' Welcome to\n', - 'color:blue;font-weight:bold;', `\ + 'color:blue;font-weight:bold;', + `\ __ __ __ / / / /_ ______/ /________ / /_/ / / / / __ / ___/ __ \\ diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index a93a525e..b45c1e83 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.33.8", + "version": "4.34.0", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", @@ -11,14 +11,14 @@ }, "devDependencies": { "@blueprintjs/core": "^3.53.0", - "@fontsource/dm-mono": "^4.5.3", + "@fontsource/dm-mono": "^4.5.4", "@fontsource/fira-code": "^4.5.5", "@fontsource/inconsolata": "^4.5.2", "@fontsource/jetbrains-mono": "^4.5.3", - "@fontsource/pt-mono": "^4.5.2", + "@fontsource/pt-mono": "^4.5.3", "@fontsource/roboto-mono": "^4.5.3", "@fontsource/source-code-pro": "^4.5.4", - "@fontsource/ubuntu-mono": "^4.5.3", + "@fontsource/ubuntu-mono": "^4.5.4", "@hydrooj/utils": "workspace:*", "@types/gulp-if": "^0.0.34", "@types/jquery": "^3.5.14", @@ -30,27 +30,27 @@ "@undefined-moe/monaco-yaml": "^2.5.1", "ansi_up": "^5.1.0", "autoprefixer": "^9.8.8", - "chalk": "^4.1.2", + "chalk": "^5.0.1", "classnames": "^2.3.1", "clean-webpack-plugin": "^4.0.0", "clipboard": "^2.0.10", "copy-webpack-plugin": "^6.4.1", "css-loader": "^4.3.0", "diff-dom": "^4.2.3", - "echarts": "^5.3.0", + "echarts": "^5.3.1", "emojis-keywords": "2.0.0", "emojis-list": "2.1.0", "esbuild-loader": "^2.18.0", - "eslint": "^8.10.0", - "eslint-config-airbnb": "^18.2.1", + "eslint": "^8.11.0", + "eslint-config-airbnb": "^19.0.4", "eslint-import-resolver-webpack": "^0.13.2", "eslint-plugin-import": "^2.25.4", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.29.2", - "fancy-log": "^1.3.3", + "eslint-plugin-react": "^7.29.3", + "fancy-log": "^2.0.0", "file-loader": "^6.2.0", "friendly-errors-webpack-plugin": "^1.7.0", - "graphiql": "^1.6.0", + "graphiql": "^1.7.1", "gulp": "^4.0.2", "gulp-cli": "^2.3.0", "gulp-iconfont": "^11.0.1", @@ -101,7 +101,7 @@ "through2": "^4.0.2", "timeago-react": "^3.0.4", "timeago.js": "^4.0.2", - "vditor": "^3.8.11", + "vditor": "^3.8.12", "vinyl-buffer": "^1.0.1", "web-streams-polyfill": "^3.2.0", "webpack": "^4.46.0", @@ -127,6 +127,6 @@ "nunjucks": "^3.2.3", "react-query": "^3.34.16", "streamsaver": "^2.0.6", - "xss": "^1.0.10" + "xss": "^1.0.11" } } diff --git a/packages/ui-default/pages/api.page.tsx b/packages/ui-default/pages/api.page.tsx index 23e7874b..e2fcef10 100644 --- a/packages/ui-default/pages/api.page.tsx +++ b/packages/ui-default/pages/api.page.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/function-component-definition */ import { NamedPage } from 'vj/misc/Page'; import request from 'vj/utils/request'; import React from 'react'; diff --git a/packages/utils/package.json b/packages/utils/package.json index 99851bbd..df7d8d8a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -12,7 +12,7 @@ "js-yaml": "^4.1.0", "moment": "^2.29.1", "mongodb": "^3.7.3", - "systeminformation": "^5.11.5" + "systeminformation": "^5.11.8" }, "devDependencies": { "@types/fs-extra": "^9.0.13", diff --git a/packages/vjudge/package.json b/packages/vjudge/package.json index f8e38034..889eb82b 100644 --- a/packages/vjudge/package.json +++ b/packages/vjudge/package.json @@ -12,17 +12,17 @@ "chrome-finder": "^1.0.7", "jsdom": "^19.0.0", "lodash": "^4.17.21", - "puppeteer-core": "^13.2.0", + "puppeteer-core": "^13.5.1", "puppeteer-extra": "^3.2.3", "puppeteer-extra-plugin-portal": "^3.0.1", "puppeteer-extra-plugin-stealth": "^2.9.0", - "superagent": "^6.1.0", - "superagent-proxy": "^2.1.0" + "superagent": "^7.1.1", + "superagent-proxy": "^3.0.0" }, "devDependencies": { "@types/jsdom": "^16.2.14", - "@types/lodash": "^4.14.178", + "@types/lodash": "^4.14.179", "@types/superagent": "^4.1.15", - "@types/superagent-proxy": "^2.0.1" + "@types/superagent-proxy": "^3.0.0" } }