Fix all 93 ESLint issues (3 errors, 90 warnings) (#666)

This commit is contained in:
Thomas Durieux
2026-04-15 09:04:22 +02:00
committed by GitHub
parent 1d97c76e7e
commit f4209110c7
28 changed files with 77 additions and 69 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ export async function connect() {
return database;
}
export async function getRepository(repoId: string, opts: {} = {}) {
export async function getRepository(repoId: string, _opts: {} = {}) {
if (!repoId || repoId == "undefined") {
throw new AnonymousError("repo_not_found", {
object: repoId,
+6 -6
View File
@@ -89,20 +89,20 @@ export default async function start() {
sendCommand: (...args: string[]) => redisClient.sendCommand(args),
}),
windowMs: 15 * 60 * 1000, // 15 minutes
skip: async (request: express.Request, response: express.Response) => {
skip: async (request: express.Request, _response: express.Response) => {
try {
const user = await getUser(request);
if (user && user.isAdmin) return true;
} catch (_) {
} catch {
// ignore: user not connected
}
return false;
},
max: async (request: express.Request, response: express.Response) => {
max: async (request: express.Request, _response: express.Response) => {
try {
const user = await getUser(request);
if (user) return config.RATE_LIMIT;
} catch (_) {
} catch {
// ignore: user not connected
}
// if not logged in, limit to half the rate
@@ -111,7 +111,7 @@ export default async function start() {
keyGenerator,
standardHeaders: true,
legacyHeaders: false,
message: (request: express.Request, response: express.Response) => {
message: (_request: express.Request, _response: express.Response) => {
return `You can only make ${config.RATE_LIMIT} requests every 15min. Please try again later.`;
},
});
@@ -167,7 +167,7 @@ export default async function start() {
res.sendStatus(404);
});
let stat: any = {};
let stat: Record<string, unknown> = {};
setInterval(() => {
stat = {};
+5 -2
View File
@@ -51,14 +51,14 @@ router.post("/queue/:name/:repo_id", async (req, res) => {
await job.retry();
res.send("ok");
} catch (error) {
} catch {
try {
if (job) {
await job.remove();
queue.add(job.name, job.data, job.opts);
}
res.send("ok");
} catch (error) {
} catch {
res.status(500).send("error_retrying_job");
}
}
@@ -121,6 +121,7 @@ router.get("/repos", async (req, res) => {
const remove = req.query.removed == "true";
const expired = req.query.expired == "true";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let sort: any = { _id: 1 };
if (req.query.sort) {
sort = {};
@@ -190,6 +191,7 @@ router.get("/users", async (req, res) => {
const limit = parseInt(req.query.limit as string) || 10;
const skipIndex = (page - 1) * limit;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let sort: any = { _id: 1 };
if (req.query.sort) {
sort = {};
@@ -260,6 +262,7 @@ router.get("/conferences", async (req, res) => {
const limit = parseInt(req.query.limit as string) || 10;
const skipIndex = (page - 1) * limit;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let sort: any = { _id: 1 };
if (req.query.sort) {
sort = {};
+3 -1
View File
@@ -67,6 +67,7 @@ router.get("/", async (req: express.Request, res: express.Response) => {
}
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateConferenceForm(conf: any) {
if (!conf.name)
throw new AnonymousError("conf_name_missing", {
@@ -237,12 +238,13 @@ router.get(
const conference = new Conference(data);
try {
isOwnerOrAdmin(conference.ownerIDs, user);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const o: any = conference.toJSON();
o.repositories = (await conference.repositories()).map((r) =>
r.toJSON()
);
res.json(o);
} catch (error) {
} catch {
return res.json({
conferenceID: conference.conferenceID,
name: conference.name,
+1 -1
View File
@@ -29,7 +29,7 @@ const verify = async (
profile: Profile,
done: OAuth2Strategy.VerifyCallback
): Promise<void> => {
let user: IUserDocument | null = null;
let user: IUserDocument | null;
try {
user = await UserModel.findOne({ "externalIDs.github": profile.id });
if (user) {
+2
View File
@@ -98,6 +98,7 @@ router.get(
}
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateNewPullRequest(pullRequestUpdate: any): void {
const validCharacters = /^[0-9a-zA-Z\-_]+$/;
if (
@@ -146,6 +147,7 @@ function validateNewPullRequest(pullRequestUpdate: any): void {
function updatePullRequestModel(
model: IAnonymizedPullRequestDocument,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
pullRequestUpdate: any
) {
model.options = {
+4
View File
@@ -39,6 +39,7 @@ async function getTokenForAdmin(user: User, req: express.Request) {
path: "owner",
model: UserModel,
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const user: IUserDocument = existingRepo?.owner as any;
if (user instanceof UserModel) {
const check = await checkToken(user.accessTokens.github);
@@ -280,6 +281,7 @@ router.get("/:repoId/", async (req: express.Request, res: express.Response) => {
}
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateNewRepo(repoUpdate: any): void {
const validCharacters = /^[0-9a-zA-Z\-_]+$/;
if (
@@ -325,6 +327,7 @@ function validateNewRepo(repoUpdate: any): void {
function updateRepoModel(
model: IAnonymizedRepositoryDocument,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
repoUpdate: any
) {
if (repoUpdate.source.type) {
@@ -485,6 +488,7 @@ router.post("/", async (req: express.Request, res: express.Response) => {
httpStatus: 400,
object: repoUpdate,
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (error.message == "repo_not_found") {
// the repository does not exist yet
+2 -2
View File
@@ -31,7 +31,7 @@ router.get(
let user: User | undefined = undefined;
try {
user = await getUser(req);
} catch (_) {}
} catch { /* not logged in */ }
let download = false;
if (
@@ -187,7 +187,7 @@ router.get(
let user: User | undefined = undefined;
try {
user = await getUser(req);
} catch (_) {}
} catch { /* not logged in */ }
res.json({
url: redirectURL,
download: download || user?.isAdmin === true,
+5 -4
View File
@@ -13,8 +13,7 @@ export async function getPullRequest(
) {
try {
const pullRequest = await db.getPullRequest(req.params.pullRequestId);
if (opt?.nocheck == true) {
} else {
if (opt?.nocheck !== true) {
// redirect if the repository is expired
if (
pullRequest.status == "expired" &&
@@ -44,8 +43,7 @@ export async function getRepo(
) {
try {
const repo = await db.getRepository(req.params.repoId);
if (opt.nocheck == true) {
} else {
if (opt.nocheck !== true) {
// redirect if the repository is expired
if (
repo.status == RepositoryStatus.EXPIRED &&
@@ -73,6 +71,7 @@ export function isOwnerOrAdmin(authorizedUsers: string[], user: User) {
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function printError(error: any, req?: express.Request) {
if (error instanceof AnonymousError) {
let message = `[ERROR] ${error.toString()} ${error.stack
@@ -97,6 +96,7 @@ function printError(error: any, req?: express.Request) {
}
export function handleError(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any,
res?: express.Response,
req?: express.Request
@@ -139,6 +139,7 @@ export async function getUser(req: express.Request) {
if (!req.user) {
notConnected();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const user = (req.user as any).user;
if (!user) {
notConnected();
+1 -1
View File
@@ -88,7 +88,7 @@ async function webView(req: express.Request, res: express.Response) {
let info: IFile | null = null;
try {
info = await f.getFileInfo();
} catch (error) {}
} catch { /* ignored */ }
if (
req.headers.accept?.includes("text/html") &&
(filePath == "" || (info && info.size == null))
+3 -3
View File
@@ -6,7 +6,7 @@ import Repository from "../core/Repository";
export function conferenceStatusCheck() {
// check every 6 hours the status of the conferences
const job = schedule.scheduleJob("0 */6 * * *", async () => {
schedule.scheduleJob("0 */6 * * *", async () => {
(await ConferenceModel.find({ status: { $eq: "ready" } })).forEach(
async (data) => {
const conference = new Conference(data);
@@ -24,7 +24,7 @@ export function conferenceStatusCheck() {
export function repositoryStatusCheck() {
// check every 6 hours the status of the repositories
const job = schedule.scheduleJob("0 */6 * * *", async () => {
schedule.scheduleJob("0 */6 * * *", async () => {
console.log("[schedule] Check repository status and unused repositories");
(
await AnonymizedRepositoryModel.find({
@@ -35,7 +35,7 @@ export function repositoryStatusCheck() {
const repo = new Repository(data);
try {
repo.check();
} catch (error) {
} catch {
console.log(`Repository ${repo.repoId} is expired`);
}
const fourMonthAgo = new Date();