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
@@ -246,7 +246,7 @@ export default class AnonymizedFile {
anonymizerOptions: anonymizer.opt,
},
})
.on("error", (err) => {
.on("error", (_err) => {
handleError(
new AnonymousError("file_not_found", {
object: this,
+2 -2
View File
@@ -9,7 +9,7 @@ import User from "./User";
* Custom error message
*/
export default class AnonymousError extends CustomError {
value?: any;
value?: unknown;
httpStatus?: number;
cause?: Error;
@@ -18,7 +18,7 @@ export default class AnonymousError extends CustomError {
opt?: {
httpStatus?: number;
cause?: Error;
object?: any;
object?: unknown;
}
) {
super(message);
+2 -2
View File
@@ -16,7 +16,7 @@ export default class Conference {
* @param status the new status
* @param errorMessage a potential error message to display
*/
async updateStatus(status: ConferenceStatus, errorMessage?: string) {
async updateStatus(status: ConferenceStatus, _errorMessage?: string) {
this._data.status = status;
await this._data.save();
return;
@@ -104,7 +104,7 @@ export default class Conference {
return this._data.options;
}
toJSON(opt?: { billing: boolean }): any {
toJSON(_opt?: { billing: boolean }): Record<string, unknown> {
const pricePerHourPerRepo = this._data.plan.pricePerRepository / 30;
let price = 0;
const today =
+1 -2
View File
@@ -3,7 +3,6 @@ import { Octokit } from "@octokit/rest";
import Repository from "./Repository";
import UserModel from "./model/users/users.model";
import config from "../config";
import { RepositoryStatus } from "./types";
export function octokit(token: string) {
return new Octokit({
@@ -19,7 +18,7 @@ export async function checkToken(token: string) {
try {
await oct.users.getAuthenticated();
return true;
} catch (error) {
} catch {
return false;
}
}
+3 -3
View File
@@ -37,7 +37,7 @@ export default class PullRequest {
if (this._model.source.accessToken) {
try {
return this._model.source.accessToken;
} catch (error) {
} catch {
console.debug(
"[ERROR] Token is invalid",
this._model.source.pullRequestId
@@ -240,7 +240,7 @@ export default class PullRequest {
}
content() {
const output: any = {
const output: Record<string, unknown> = {
anonymizeDate: this._model.anonymizeDate,
merged: this._model.pullRequest.merged,
mergedDate: this._model.pullRequest.mergedDate,
@@ -259,7 +259,7 @@ export default class PullRequest {
}
if (this.options.comments) {
output.comments = this._model.pullRequest.comments?.map((comment) => {
const o: any = {};
const o: Record<string, unknown> = {};
if (this.options.body) o.body = anonymizer.anonymize(comment.body);
if (this.options.username)
o.author = anonymizer.anonymize(comment.author);
-1
View File
@@ -1,5 +1,4 @@
import { model } from "mongoose";
import { join } from "path";
import { IFileDocument, IFileModel } from "./files.types";
import FileSchema from "./files.schema";
+1 -1
View File
@@ -31,7 +31,7 @@ export default class GitHubDownload extends GitHubBase {
response = await this.getZipUrl();
} catch (error) {
throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status || 404,
httpStatus: (error as { status?: number }).status || 404,
object: this.data,
cause: error as Error,
});
+3 -3
View File
@@ -99,7 +99,7 @@ export class GitHubRepository {
}
} catch (error) {
throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status,
httpStatus: (error as { status?: number }).status,
cause: error as Error,
object: this,
});
@@ -212,7 +212,7 @@ export async function getRepositoryFromGitHub(opt: {
if (opt.repo.indexOf(".git") > -1) {
opt.repo = opt.repo.replace(".git", "");
}
let dbModel = null;
let dbModel;
if (opt.repositoryID) {
dbModel = isConnected
? await RepositoryModel.findById(opt.repositoryID)
@@ -255,7 +255,7 @@ export async function getRepositoryFromGitHub(opt: {
});
}
throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status,
httpStatus: (error as { status?: number }).status,
object: {
owner: opt.owner,
repo: opt.repo,
+5 -5
View File
@@ -70,7 +70,7 @@ export default class GitHubStream extends GitHubBase {
content.on("error", (error) => {
error = new AnonymousError("file_not_found", {
httpStatus: (error as any).status || (error as any).httpStatus,
httpStatus: (error as { status?: number; httpStatus?: number }).status || (error as { httpStatus?: number }).httpStatus,
cause: error as Error,
object: filePath,
});
@@ -85,7 +85,7 @@ export default class GitHubStream extends GitHubBase {
async getFileContent(file: AnonymizedFile): Promise<stream.Readable> {
try {
void file.filePath;
} catch (_) {
} catch {
// compute the original path if ambiguous
await file.originalPath();
}
@@ -139,7 +139,7 @@ export default class GitHubStream extends GitHubBase {
file: 0,
};
const output: IFile[] = [];
let data = null;
let data;
try {
data = await this.getGHTree(sha, count, {
recursive: false,
@@ -152,12 +152,12 @@ export default class GitHubStream extends GitHubBase {
output.push(...this.tree2Tree(data.tree, parentPath));
} catch (error) {
console.log(error);
if ((error as any).status == 409 || (error as any).status == 404) {
if ((error as { status?: number }).status == 409 || (error as { status?: number }).status == 404) {
// empty repo
data = { tree: [] };
} else {
throw new AnonymousError("repo_not_found", {
httpStatus: (error as any).status || 404,
httpStatus: (error as { status?: number }).status || 404,
object: this.data,
cause: error as Error,
});
+2 -1
View File
@@ -8,6 +8,7 @@ export default class Zip implements SourceBase {
type = "Zip";
url?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(data: any, readonly repoId: string) {
this.url = data.url;
}
@@ -28,7 +29,7 @@ export default class Zip implements SourceBase {
return storage.read(file.repository.repoId, file.filePath);
}
toJSON(): any {
toJSON(): { type: string } {
return {
type: this.type,
};
+7 -7
View File
@@ -25,7 +25,7 @@ export default class FileSystem extends StorageBase {
const stat = await fs.promises.stat(fullPath);
if (stat.isDirectory()) return FILE_TYPE.FOLDER;
if (stat.isFile()) return FILE_TYPE.FILE;
} catch (_) {
} catch {
// ignore file not found or not downloaded
}
return FILE_TYPE.NOT_FOUND;
@@ -65,13 +65,13 @@ export default class FileSystem extends StorageBase {
try {
await this.mk(repoId, dirname(p));
if (data instanceof Readable) {
data.on("error", (err) => {
data.on("error", (_err) => {
this.rm(repoId, p);
});
}
return await fs.promises.writeFile(fullPath, data, "utf-8");
} catch (err: any) {
// throw err;
} catch {
// write error ignored
}
}
@@ -91,8 +91,8 @@ export default class FileSystem extends StorageBase {
await fs.promises.mkdir(fullPath, {
recursive: true,
});
} catch (err: any) {
if (err.code !== "EEXIST") {
} catch (err: unknown) {
if (err instanceof Error && (err as NodeJS.ErrnoException).code !== "EEXIST") {
throw err;
}
}
@@ -135,7 +135,7 @@ export default class FileSystem extends StorageBase {
})
);
}
} catch (error) {
} catch {
// ignore stat errors for individual files
}
}
+3 -3
View File
@@ -55,7 +55,7 @@ export default class S3Storage extends StorageBase {
// if we can get the file info, it is a file
await this.fileInfo(repoId, path);
return FILE_TYPE.FILE;
} catch (err) {
} catch {
// check if it is a directory
const data = await this.client().listObjectsV2({
Bucket: config.S3_BUCKET,
@@ -69,7 +69,7 @@ export default class S3Storage extends StorageBase {
}
/** @override */
async mk(repoId: string, dir: string = ""): Promise<void> {
async mk(repoId: string, _dir: string = ""): Promise<void> {
// no need to create folder on S3
}
@@ -125,7 +125,7 @@ export default class S3Storage extends StorageBase {
} else {
res.end();
}
} catch (error) {
} catch {
try {
res.status(500);
} catch (err) {