mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
eslint-config: add de-morgan
This commit is contained in:
10 files changed
+19
-19
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
extends:
|
extends:
|
||||||
- airbnb-base
|
- airbnb-base
|
||||||
- ./typescript
|
- ./typescript
|
||||||
|
- plugin:de-morgan/recommended-legacy
|
||||||
env:
|
env:
|
||||||
es6: true
|
es6: true
|
||||||
globals:
|
globals:
|
||||||
@@ -14,6 +15,7 @@ plugins:
|
|||||||
- eslint-plugin-import
|
- eslint-plugin-import
|
||||||
- eslint-plugin-github
|
- eslint-plugin-github
|
||||||
- '@stylistic'
|
- '@stylistic'
|
||||||
|
- eslint-plugin-de-morgan
|
||||||
rules:
|
rules:
|
||||||
'@typescript-eslint/no-shadow': 1
|
'@typescript-eslint/no-shadow': 1
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "react.yaml",
|
"main": "react.yaml",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@stylistic/eslint-plugin": "^3.0.1",
|
"@stylistic/eslint-plugin": "^3.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.23.0",
|
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
||||||
"@typescript-eslint/parser": "^8.23.0",
|
"@typescript-eslint/parser": "^8.24.0",
|
||||||
"eslint-config-airbnb": "^19.0.4",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
|
"eslint-plugin-de-morgan": "^1.0.1",
|
||||||
"eslint-plugin-github": "^5.1.8",
|
"eslint-plugin-github": "^5.1.8",
|
||||||
"eslint-plugin-import": "2.31.0",
|
"eslint-plugin-import": "2.31.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ export async function versionCheck(reportWarn: (str: string) => void, reportErro
|
|||||||
const { osinfo } = await sysinfo.get();
|
const { osinfo } = await sysinfo.get();
|
||||||
if (sandboxCgroup === 2) {
|
if (sandboxCgroup === 2) {
|
||||||
const kernelVersion = osinfo.kernel.split('-')[0];
|
const kernelVersion = osinfo.kernel.split('-')[0];
|
||||||
if (!(gte(kernelVersion, '5.19.0') && gte(sandboxVersion, '1.6.10'))) {
|
if (!gte(kernelVersion, '5.19.0') || !gte(sandboxVersion, '1.6.10')) {
|
||||||
reportWarn('You are using cgroup v2 without kernel 5.19+. This could result in inaccurate memory usage measurements.');
|
reportWarn('You are using cgroup v2 without kernel 5.19+. This could result in inaccurate memory usage measurements.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,8 +275,7 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
|||||||
@param('drid', Types.ObjectId)
|
@param('drid', Types.ObjectId)
|
||||||
async postDeleteReply(domainId: string, drid: ObjectId) {
|
async postDeleteReply(domainId: string, drid: ObjectId) {
|
||||||
const deleteBy = this.user.own(this.drdoc) ? 'self' : this.user.own(this.ddoc) ? 'DiscussionOwner' : 'Admin';
|
const deleteBy = this.user.own(this.drdoc) ? 'self' : this.user.own(this.ddoc) ? 'DiscussionOwner' : 'Admin';
|
||||||
if (!(this.user.own(this.ddoc)
|
if (!this.user.own(this.ddoc) || !this.user.hasPerm(PERM.PERM_DELETE_DISCUSSION_REPLY_SELF_DISCUSSION)) {
|
||||||
&& this.user.hasPerm(PERM.PERM_DELETE_DISCUSSION_REPLY_SELF_DISCUSSION))) {
|
|
||||||
if (!this.user.own(this.drdoc)) {
|
if (!this.user.own(this.drdoc)) {
|
||||||
this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY);
|
this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY);
|
||||||
} else this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY_SELF);
|
} else this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY_SELF);
|
||||||
@@ -316,8 +315,7 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
|||||||
@param('drrid', Types.ObjectId)
|
@param('drrid', Types.ObjectId)
|
||||||
async postDeleteTailReply(domainId: string, drid: ObjectId, drrid: ObjectId) {
|
async postDeleteTailReply(domainId: string, drid: ObjectId, drrid: ObjectId) {
|
||||||
const deleteBy = this.user.own(this.drrdoc) ? 'self' : 'Admin';
|
const deleteBy = this.user.own(this.drrdoc) ? 'self' : 'Admin';
|
||||||
if (!(this.user.own(this.drrdoc)
|
if (!this.user.own(this.drrdoc) || !this.user.hasPerm(PERM.PERM_DELETE_DISCUSSION_REPLY_SELF)) {
|
||||||
&& this.user.hasPerm(PERM.PERM_DELETE_DISCUSSION_REPLY_SELF))) {
|
|
||||||
this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY);
|
this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY);
|
||||||
}
|
}
|
||||||
const msg = JSON.stringify({
|
const msg = JSON.stringify({
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ class RecordDetailConnectionHandler extends ConnectionHandler {
|
|||||||
rdoc.compilerTexts = [];
|
rdoc.compilerTexts = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rdoc.contest && this.user._id === rdoc.uid)) {
|
if (!rdoc.contest || this.user._id !== rdoc.uid) {
|
||||||
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,15 +275,15 @@ export function flushNodes(domainId: string) {
|
|||||||
export async function getVnode(domainId: string, type: number, id: string, uid?: number) {
|
export async function getVnode(domainId: string, type: number, id: string, uid?: number) {
|
||||||
if (type === document.TYPE_PROBLEM) {
|
if (type === document.TYPE_PROBLEM) {
|
||||||
const pdoc = await problem.get(domainId, Number.isSafeInteger(+id) ? +id : id, problem.PROJECTION_LIST);
|
const pdoc = await problem.get(domainId, Number.isSafeInteger(+id) ? +id : id, problem.PROJECTION_LIST);
|
||||||
if (!pdoc) throw new DiscussionNodeNotFoundError(id);
|
if (!pdoc) throw new DiscussionNodeNotFoundError(`problem/${id}`);
|
||||||
return { ...pdoc, type, id: pdoc.docId };
|
return { ...pdoc, type, id: pdoc.docId };
|
||||||
}
|
}
|
||||||
if ([document.TYPE_CONTEST, document.TYPE_TRAINING].includes(type as any)) {
|
if ([document.TYPE_CONTEST, document.TYPE_TRAINING].includes(type as any)) {
|
||||||
const model = type === document.TYPE_TRAINING ? training : contest;
|
const model = type === document.TYPE_TRAINING ? training : contest;
|
||||||
if (!ObjectId.isValid(id)) throw new DiscussionNodeNotFoundError(id);
|
if (!ObjectId.isValid(id)) throw new DiscussionNodeNotFoundError(`contest/${id}`);
|
||||||
const _id = new ObjectId(id);
|
const _id = new ObjectId(id);
|
||||||
const tdoc = await model.get(domainId, _id);
|
const tdoc = await model.get(domainId, _id);
|
||||||
if (!tdoc) throw new DiscussionNodeNotFoundError(id);
|
if (!tdoc) throw new DiscussionNodeNotFoundError(`contest/${id}`);
|
||||||
if (uid) {
|
if (uid) {
|
||||||
const tsdoc = await model.getStatus(domainId, _id, uid);
|
const tsdoc = await model.getStatus(domainId, _id, uid);
|
||||||
tdoc.attend = tsdoc?.attend || tsdoc?.enroll;
|
tdoc.attend = tsdoc?.attend || tsdoc?.enroll;
|
||||||
@@ -320,7 +320,7 @@ export async function getListVnodes(domainId: string, ddocs: any, getHidden = fa
|
|||||||
|
|
||||||
export function checkVNodeVisibility(type: number, vnode: any, user: User) {
|
export function checkVNodeVisibility(type: number, vnode: any, user: User) {
|
||||||
if (type === document.TYPE_PROBLEM) {
|
if (type === document.TYPE_PROBLEM) {
|
||||||
if (vnode.hidden && !(user.own(vnode) || user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN))) return false;
|
if (vnode.hidden && !user.own(vnode) && !user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) return false;
|
||||||
}
|
}
|
||||||
if ([document.TYPE_CONTEST, document.TYPE_TRAINING].includes(type as any)) {
|
if ([document.TYPE_CONTEST, document.TYPE_TRAINING].includes(type as any)) {
|
||||||
if (!user.own(vnode) && vnode.assign?.length && !Set.intersection(vnode.assign, user.group).size) return false;
|
if (!user.own(vnode) && vnode.assign?.length && !Set.intersection(vnode.assign, user.group).size) return false;
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ export class ProblemModel {
|
|||||||
// TODO enhance
|
// TODO enhance
|
||||||
if (pdocs.length !== pids.length) {
|
if (pdocs.length !== pids.length) {
|
||||||
for (const pid of pids) {
|
for (const pid of pids) {
|
||||||
if (!(r[pid] || l[pid])) {
|
if (!r[pid] && !l[pid]) {
|
||||||
if (doThrow) throw new ProblemNotFoundError(domainId, pid);
|
if (doThrow) throw new ProblemNotFoundError(domainId, pid);
|
||||||
if (!indexByDocIdOnly) r[pid] = { ...ProblemModel.default, domainId, pid: pid.toString() };
|
if (!indexByDocIdOnly) r[pid] = { ...ProblemModel.default, domainId, pid: pid.toString() };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,8 +123,7 @@ export class ConnectionHandler extends ConnectionHandlerOriginal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onerror(err: HydroError) {
|
onerror(err: HydroError) {
|
||||||
if (!(err instanceof NotFoundError)
|
if (![NotFoundError, PrivilegeError, PermissionError].some((i) => err instanceof i) || this.user?._id !== 0) {
|
||||||
&& !((err instanceof PrivilegeError || err instanceof PermissionError) && this.user?._id === 0)) {
|
|
||||||
logger.error(`Path:${this.request.path}, User:${this.user?._id}(${this.user?.uname})`);
|
logger.error(`Path:${this.request.path}, User:${this.user?._id}(${this.user?.uname})`);
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,11 +154,11 @@ export default class Watcher extends Service {
|
|||||||
for (const filename in require.cache) {
|
for (const filename in require.cache) {
|
||||||
const module = require.cache[filename];
|
const module = require.cache[filename];
|
||||||
const plugin = unwrapExports(module.exports);
|
const plugin = unwrapExports(module.exports);
|
||||||
if (!(typeof plugin === 'object' && plugin && 'apply' in plugin)) continue;
|
if (typeof plugin !== 'object' || !plugin || !('apply' in plugin)) continue;
|
||||||
const runtime = this.ctx.registry.get(plugin);
|
const runtime = this.ctx.registry.get(plugin);
|
||||||
if (!runtime || this.declined.has(filename)) continue;
|
if (!runtime || this.declined.has(filename)) continue;
|
||||||
pending.set(filename, runtime);
|
pending.set(filename, runtime);
|
||||||
if (!(plugin && 'sideEffect' in plugin && plugin['sideEffect'])) this.declined.add(filename);
|
if (!plugin || !('sideEffect' in plugin) || !plugin['sideEffect']) this.declined.add(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [filename, runtime] of pending) {
|
for (const [filename, runtime] of pending) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function parseProblemId(id: string) {
|
|||||||
|
|
||||||
export function getDifficulty(tags: string[]) {
|
export function getDifficulty(tags: string[]) {
|
||||||
const d = tags.find((i) => /^\*\d+$/.test(i))?.split('*')[1];
|
const d = tags.find((i) => /^\*\d+$/.test(i))?.split('*')[1];
|
||||||
if (!(d && +d)) return null;
|
if (!Number.isSafeInteger(+d)) return null;
|
||||||
const map = [
|
const map = [
|
||||||
[500, 1],
|
[500, 1],
|
||||||
[800, 2],
|
[800, 2],
|
||||||
|
|||||||
Reference in new issue
Block a user