Set up CI with ESLint linter and Mocha test runner (#661)

This commit is contained in:
Thomas Durieux
2026-04-15 04:34:03 +02:00
committed by GitHub
parent 812f8b6314
commit f3641c8ce3
14 changed files with 1991 additions and 38 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ const config: Config = {
S3_REGION: null,
};
for (let conf in process.env) {
for (const conf in process.env) {
if ((config as any)[conf] !== undefined) {
(config as any)[conf] = process.env[conf];
}
+1
View File
@@ -281,6 +281,7 @@ export default class AnonymizedFile {
.startActiveSpan("AnonymizedFile.send", async (span) => {
span.setAttribute("repoId", this.repository.repoId);
span.setAttribute("anonymizedPath", this.anonymizedPath);
// eslint-disable-next-line no-async-promise-executor
return new Promise<void>(async (resolve, reject) => {
try {
if (config.STREAMER_ENTRYPOINT) {
+2 -2
View File
@@ -135,7 +135,7 @@ export default class User {
}).exec()
).map((d) => new Repository(d));
const promises = [];
for (let repo of repositories) {
for (const repo of repositories) {
if (
repo.status == "ready" &&
repo.options.expirationMode != "never" &&
@@ -163,7 +163,7 @@ export default class User {
}).exec()
).map((d) => new PullRequest(d));
const promises = [];
for (let repo of pullRequests) {
for (const repo of pullRequests) {
if (
repo.status == "ready" &&
repo.options.expirationMode != "never" &&
+1 -1
View File
@@ -96,7 +96,7 @@ export class ContentAnonimizer {
}
// remove image in markdown
return content.replace(
/!\[[^\]]*\]\((?<filename>.*?)(?=\"|\))(?<optionalpart>\".*\")?\)/g,
/!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalpart>".*")?\)/g,
() => {
this.wasAnonymized = true;
return config.ANONYMIZATION_MASK;
+1 -1
View File
@@ -106,7 +106,7 @@ export default class GitHubStream extends GitHubBase {
span.setAttribute("file", file.anonymizedPath);
try {
try {
file.filePath;
void file.filePath;
} catch (_) {
// compute the original path if ambiguous
await file.originalPath();
+3 -3
View File
@@ -145,10 +145,10 @@ export default class FileSystem extends StorageBase {
.startActiveSpan("fs.listFiles", async (span) => {
span.setAttribute("path", dir);
const fullPath = join(config.FOLDER, this.repoPath(repoId), dir);
let files = await fs.promises.readdir(fullPath);
const files = await fs.promises.readdir(fullPath);
const output2: IFile[] = [];
for (let file of files) {
let filePath = join(fullPath, file);
for (const file of files) {
const filePath = join(fullPath, file);
try {
const stats = await fs.promises.stat(filePath);
if (stats.isDirectory()) {
+1 -1
View File
@@ -126,7 +126,7 @@ router.get("/repos", async (req, res) => {
sort = {};
sort[req.query.sort as string] = -1;
}
let query = [];
const query = [];
if (req.query.search) {
query.push({ repoId: { $regex: req.query.search } });
}
+1 -1
View File
@@ -99,7 +99,7 @@ router.get(
);
function validateNewPullRequest(pullRequestUpdate: any): void {
const validCharacters = /^[0-9a-zA-Z\-\_]+$/;
const validCharacters = /^[0-9a-zA-Z\-_]+$/;
if (
!pullRequestUpdate.pullRequestId.match(validCharacters) ||
pullRequestUpdate.pullRequestId.length < 3
+1 -1
View File
@@ -281,7 +281,7 @@ router.get("/:repoId/", async (req: express.Request, res: express.Response) => {
});
function validateNewRepo(repoUpdate: any): void {
const validCharacters = /^[0-9a-zA-Z\-\_]+$/;
const validCharacters = /^[0-9a-zA-Z\-_]+$/;
if (
!repoUpdate.repoId.match(validCharacters) ||
repoUpdate.repoId.length < 3
+1 -1
View File
@@ -85,7 +85,7 @@ function printError(error: any, req?: express.Request) {
}
console.error(message);
} else if (error instanceof HTTPError) {
let message = `[ERROR] HTTP.${
const message = `[ERROR] HTTP.${
error.code
} ${error.message.toString()} ${error.stack?.split("\n")[1].trim()}`;
console.error(message);