workspace: update eslint rule (#1027)

This commit is contained in:
undefined authored and GitHub committed 2025-08-06 18:51:25 +01:00
1 parent 05c3b8f2bd
commit cee3c00ddb
150 files changed
+1069 -1043

No files matched your search

+3 -3
View File
@@ -166,7 +166,7 @@ export function parseTimeMS(str: string | number, throwOnError = true) {
const match = TIME_RE.exec(str);
if (!match && throwOnError) throw new Error(`${str} error parsing time`);
if (!match) return 1000;
return Math.floor(parseFloat(match[1]) * TIME_UNITS[match[2].toLowerCase()]);
return Math.floor(Number.parseFloat(match[1]) * TIME_UNITS[match[2].toLowerCase()]);
}
export function parseMemoryMB(str: string | number, throwOnError = true) {
@@ -174,7 +174,7 @@ export function parseMemoryMB(str: string | number, throwOnError = true) {
const match = MEMORY_RE.exec(str);
if (!match && throwOnError) throw new Error(`${str} error parsing memory`);
if (!match) return 256;
return Math.ceil(parseFloat(match[1]) * MEMORY_UNITS[match[2].toLowerCase()]);
return Math.ceil(Number.parseFloat(match[1]) * MEMORY_UNITS[match[2].toLowerCase()]);
}
function _digit2(number: number) {
@@ -209,7 +209,7 @@ export function randomPick<T>(arr: T[]): T {
export type StringKeys<O> = {
[K in keyof O]: string extends O[K] ? K : never
}[keyof O];
const fSortR = /[^\d]+|\d+/g;
const fSortR = /\D+|\d+/g;
export function sortFiles(files: string[]): string[];
export function sortFiles<T extends { _id: string }>(files: T[], key?: '_id'): T[];
export function sortFiles<T extends Record<string, any>>(files: T[], key: StringKeys<T>): T[];
-1
View File
@@ -3,7 +3,6 @@ import path from 'path';
const PATH = process.env.PATH?.split(':') || [];
/* eslint-disable import/no-dynamic-require */
// @ts-ignore
const pm2: typeof import('pm2') | null = (() => {
for (const dir of PATH) {
+1 -1
View File
@@ -7,7 +7,7 @@ export function stringify(queryObject: SearchParserResult, options: SearchParser
if (!Object.keys(queryObject || {}).length) return '';
prefix ||= '';
const toArray = (val: string | string[]) => (typeof val === 'string' ? [val] : val);
const addQuotes = (s: string) => (s.indexOf(' ') > -1 ? JSON.stringify(s) : s);
const addQuotes = (s: string) => (s.includes(' ') ? JSON.stringify(s) : s);
const addPrefix = (s: string) => prefix + s;
const parts = [];
if (queryObject.text) {
+6 -5
View File
@@ -8,7 +8,8 @@ import fs from 'fs-extra';
import type { Moment } from 'moment';
import { Exporter, Factory, Logger as Reggol } from 'reggol';
import type * as superagent from 'superagent';
export * as yaml from 'js-yaml';
export * from '@hydrooj/utils/lib/common';
export * as fs from 'fs-extra';
Factory.formatters['d'] = (value, exporter) => Reggol.color(exporter, 3, value);
@@ -252,10 +253,10 @@ export function findFileSync(pathname: string, doThrow: boolean | Error = true)
return null;
}
export async function retry(func: Function, ...args: any[]): Promise<any>;
export async function retry(times: number, func: Function, ...args: any[]): Promise<any>;
export async function retry<Arg extends any[], Ret>(func: (...args: Arg) => Ret, ...args: Arg): Promise<Ret>;
export async function retry<Arg extends any[], Ret>(times: number, func: (...args: Arg) => Ret, ...args: Arg): Promise<Ret>;
// eslint-disable-next-line consistent-return
export async function retry(arg0: number | Function, func: any, ...args: any[]) {
export async function retry(arg0: number | ((...args: any[]) => any), func: any, ...args: any[]): Promise<any> {
let res;
if (typeof arg0 !== 'number') {
args = [func, ...args];
@@ -397,4 +398,4 @@ export async function pipeRequest(req: superagent.Request, w: fs.WriteStream, ti
}
}
export * from '@hydrooj/utils/lib/common';
export * as yaml from 'js-yaml';