fix lint errors

This commit is contained in:
syuilo
2021-11-12 10:52:10 +09:00
parent 84df0714d8
commit b9eaf906e7
22 changed files with 55 additions and 49 deletions

View File

@ -20,7 +20,7 @@ type SimpleUserInfo = {
};
type Params<T extends IEndpointMeta> = {
[P in keyof T['params']]: NonNullable<T['params']>[P]['transform'] extends Function
[P in keyof T['params']]: NonNullable<T['params']>[P]['transform'] extends () => any
? ReturnType<NonNullable<T['params']>[P]['transform']>
: NonNullable<T['params']>[P]['default'] extends null | number | string
? NonOptional<ReturnType<NonNullable<T['params']>[P]['validator']['get']>[0]>
@ -30,7 +30,7 @@ type Params<T extends IEndpointMeta> = {
export type Response = Record<string, any> | void;
type executor<T extends IEndpointMeta> =
(params: Params<T>, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: Function) =>
(params: Params<T>, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: () => any) =>
Promise<T['res'] extends undefined ? Response : SchemaType<NonNullable<T['res']>>>;
export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>)
@ -74,7 +74,7 @@ function getParams<T extends IEndpointMeta>(defs: T, params: any): [Params<T>, A
});
return true;
} else {
if (v === undefined && def.hasOwnProperty('default')) {
if (v === undefined && Object.prototype.hasOwnProperty.call(def, 'default')) {
x[k] = def.default;
} else {
x[k] = v;

View File

@ -69,7 +69,7 @@ export default define(meta, async (ps, me) => {
throw new ApiError(meta.errors.accessDenied);
}
// tslint:disable-next-line:no-unnecessary-initializer
// eslint:disable-next-line:no-unnecessary-initializer
let banner = undefined;
if (ps.bannerId != null) {
banner = await DriveFiles.findOne({

View File

@ -75,7 +75,7 @@ export default define(meta, async (ps, user) => {
const flags = attestation.authData[32];
// tslint:disable-next-line:no-bitwise
// eslint:disable-next-line:no-bitwise
if (!(flags & 1)) {
throw new Error('user not present');
}

View File

@ -10,16 +10,16 @@ const logger = new Logger('limiter');
export default (endpoint: IEndpoint, user: User) => new Promise<void>((ok, reject) => {
const limitation = endpoint.meta.limit!;
const key = limitation.hasOwnProperty('key')
const key = Object.prototype.hasOwnProperty.call(limitation, 'key')
? limitation.key
: endpoint.name;
const hasShortTermLimit =
limitation.hasOwnProperty('minInterval');
Object.prototype.hasOwnProperty.call(limitation, 'minInterval');
const hasLongTermLimit =
limitation.hasOwnProperty('duration') &&
limitation.hasOwnProperty('max');
Object.prototype.hasOwnProperty.call(limitation, 'duration') &&
Object.prototype.hasOwnProperty.call(limitation, 'max');
if (hasShortTermLimit) {
min();

View File

@ -19,7 +19,7 @@ export default class extends Channel {
@autobind
public async onMessage(type: string, body: any) {
switch (type) {
case 'ping':
case 'ping': {
if (body.id == null) return;
const matching = await ReversiMatchings.findOne({
parentId: this.user!.id,
@ -28,6 +28,7 @@ export default class extends Channel {
if (matching == null) return;
publishMainStream(matching.childId, 'reversiInvited', await ReversiMatchings.pack(matching, { id: matching.childId }));
break;
}
}
}
}

View File

@ -31,7 +31,7 @@ export interface BroadcastTypes {
}
export interface UserStreamTypes {
terminate: {};
terminate: Record<string, unknown>;
followChannel: Channel;
unfollowChannel: Channel;
updateUserProfile: UserProfile;