[sandbox] Add eslint

This commit is contained in:
orosmatthew 2024-02-17 15:49:30 -05:00
parent 722ff8c199
commit 11b5106f12
8 changed files with 1659 additions and 18 deletions

13
sandbox/.eslintignore Normal file
View File

@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

25
sandbox/.eslintrc.cjs Normal file
View File

@ -0,0 +1,25 @@
module.exports = {
env: {
es2021: true,
node: true
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [
{
env: {
node: true
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script'
}
}
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {}
};

1602
sandbox/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@
"scripts": {
"build": "tsc",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"start": "node build"
},
"author": "",
@ -14,6 +15,9 @@
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.2",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
"prettier": "^3.2.2",
"typescript": "^5.3.3"
},

View File

@ -111,7 +111,7 @@ async function cloneAndRun(submissionData: SubmissionGetData) {
try {
if (submissionData.submission.teamLanguage === 'Java') {
let res = await runJava({
const res = await runJava({
srcDir: repoDir,
mainFile: join(repoDir, problemName, problemName + '.java'),
mainClass: problemName,
@ -123,7 +123,7 @@ async function cloneAndRun(submissionData: SubmissionGetData) {
runResult = res.runResult;
}
} else if (submissionData.submission.teamLanguage === 'CSharp') {
let res = await runCSharp({
const res = await runCSharp({
srcDir: join(repoDir, problemName),
input: submissionData.submission.problem.realInput
});
@ -133,7 +133,7 @@ async function cloneAndRun(submissionData: SubmissionGetData) {
runResult = res.runResult;
}
} else if (submissionData.submission.teamLanguage === 'CPP') {
let res = await runCpp({
const res = await runCpp({
srcDir: repoDir,
input: submissionData.submission.problem.realInput,
cppPlatform: 'GCC',
@ -213,7 +213,6 @@ if (!validateEnv()) {
const adminUrl = process.env.ADMIN_URL as string;
const repoUrl = process.env.REPO_URL as string;
const javaBinPath = process.env.JAVA_PATH as string;
const submissionApiUrl = urlJoin(adminUrl, 'api/submission');
@ -279,6 +278,7 @@ async function run() {
let iterationsSinceProcessedSubmission = 0;
let anySubmissionsProcessed = false;
// eslint-disable-next-line no-constant-condition
while (true) {
switch (await processNextSubmission()) {
case SubmissionProcessingResult.SubmissionProcessed:

View File

@ -75,7 +75,7 @@ export const runCpp: IRunner<IRunnerParamsCpp> = async function (
outputBuffer += data.toString();
});
let runStartTime = performance.now();
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
@ -84,11 +84,11 @@ export const runCpp: IRunner<IRunnerParamsCpp> = async function (
return {
success: true,
runResult: new Promise<RunResult>(async (resolve) => {
runResult: new Promise<RunResult>((resolve) => {
child.on('close', () => {
completedNormally = !timeLimitExceeded;
let runEndTime = performance.now();
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
@ -109,7 +109,7 @@ export const runCpp: IRunner<IRunnerParamsCpp> = async function (
}
});
let timeoutHandle = setTimeout(() => {
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}

View File

@ -1,6 +1,3 @@
import * as fs from 'fs-extra';
import { join } from 'path';
import os = require('os');
import { spawn } from 'child_process';
import kill from 'tree-kill';
import { RunResult, timeoutSeconds } from '../index.js';
@ -27,7 +24,7 @@ export const runCSharp: IRunner = async function (params: {
params.outputCallback?.(data.toString());
});
let runStartTime = performance.now();
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
@ -40,7 +37,7 @@ export const runCSharp: IRunner = async function (params: {
child.on('close', () => {
completedNormally = !timeLimitExceeded;
let runEndTime = performance.now();
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
@ -61,7 +58,7 @@ export const runCSharp: IRunner = async function (params: {
}
});
let timeoutHandle = setTimeout(() => {
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}

View File

@ -47,7 +47,7 @@ export const runJava: IRunner<IRunnerParamsJava> = async function (
outputBuffer += data.toString();
});
let runStartTime = performance.now();
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
@ -56,11 +56,11 @@ export const runJava: IRunner<IRunnerParamsJava> = async function (
return {
success: true,
runResult: new Promise<RunResult>(async (resolve) => {
runResult: new Promise<RunResult>((resolve) => {
child.on('close', () => {
completedNormally = !timeLimitExceeded;
let runEndTime = performance.now();
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
@ -81,7 +81,7 @@ export const runJava: IRunner<IRunnerParamsJava> = async function (
}
});
let timeoutHandle = setTimeout(() => {
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}