[sandbox] Add eslint
This commit is contained in:
parent
722ff8c199
commit
11b5106f12
13
sandbox/.eslintignore
Normal file
13
sandbox/.eslintignore
Normal 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
25
sandbox/.eslintrc.cjs
Normal 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
1602
sandbox/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
|
"lint": "prettier --check . && eslint .",
|
||||||
"start": "node build"
|
"start": "node build"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
@ -14,6 +15,9 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^20.11.2",
|
"@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",
|
"prettier": "^3.2.2",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
|
@ -111,7 +111,7 @@ async function cloneAndRun(submissionData: SubmissionGetData) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (submissionData.submission.teamLanguage === 'Java') {
|
if (submissionData.submission.teamLanguage === 'Java') {
|
||||||
let res = await runJava({
|
const res = await runJava({
|
||||||
srcDir: repoDir,
|
srcDir: repoDir,
|
||||||
mainFile: join(repoDir, problemName, problemName + '.java'),
|
mainFile: join(repoDir, problemName, problemName + '.java'),
|
||||||
mainClass: problemName,
|
mainClass: problemName,
|
||||||
@ -123,7 +123,7 @@ async function cloneAndRun(submissionData: SubmissionGetData) {
|
|||||||
runResult = res.runResult;
|
runResult = res.runResult;
|
||||||
}
|
}
|
||||||
} else if (submissionData.submission.teamLanguage === 'CSharp') {
|
} else if (submissionData.submission.teamLanguage === 'CSharp') {
|
||||||
let res = await runCSharp({
|
const res = await runCSharp({
|
||||||
srcDir: join(repoDir, problemName),
|
srcDir: join(repoDir, problemName),
|
||||||
input: submissionData.submission.problem.realInput
|
input: submissionData.submission.problem.realInput
|
||||||
});
|
});
|
||||||
@ -133,7 +133,7 @@ async function cloneAndRun(submissionData: SubmissionGetData) {
|
|||||||
runResult = res.runResult;
|
runResult = res.runResult;
|
||||||
}
|
}
|
||||||
} else if (submissionData.submission.teamLanguage === 'CPP') {
|
} else if (submissionData.submission.teamLanguage === 'CPP') {
|
||||||
let res = await runCpp({
|
const res = await runCpp({
|
||||||
srcDir: repoDir,
|
srcDir: repoDir,
|
||||||
input: submissionData.submission.problem.realInput,
|
input: submissionData.submission.problem.realInput,
|
||||||
cppPlatform: 'GCC',
|
cppPlatform: 'GCC',
|
||||||
@ -213,7 +213,6 @@ if (!validateEnv()) {
|
|||||||
|
|
||||||
const adminUrl = process.env.ADMIN_URL as string;
|
const adminUrl = process.env.ADMIN_URL as string;
|
||||||
const repoUrl = process.env.REPO_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');
|
const submissionApiUrl = urlJoin(adminUrl, 'api/submission');
|
||||||
|
|
||||||
@ -279,6 +278,7 @@ async function run() {
|
|||||||
|
|
||||||
let iterationsSinceProcessedSubmission = 0;
|
let iterationsSinceProcessedSubmission = 0;
|
||||||
let anySubmissionsProcessed = false;
|
let anySubmissionsProcessed = false;
|
||||||
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (await processNextSubmission()) {
|
switch (await processNextSubmission()) {
|
||||||
case SubmissionProcessingResult.SubmissionProcessed:
|
case SubmissionProcessingResult.SubmissionProcessed:
|
||||||
|
@ -75,7 +75,7 @@ export const runCpp: IRunner<IRunnerParamsCpp> = async function (
|
|||||||
outputBuffer += data.toString();
|
outputBuffer += data.toString();
|
||||||
});
|
});
|
||||||
|
|
||||||
let runStartTime = performance.now();
|
const runStartTime = performance.now();
|
||||||
child.stdin.write(params.input);
|
child.stdin.write(params.input);
|
||||||
child.stdin.end();
|
child.stdin.end();
|
||||||
|
|
||||||
@ -84,11 +84,11 @@ export const runCpp: IRunner<IRunnerParamsCpp> = async function (
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
runResult: new Promise<RunResult>(async (resolve) => {
|
runResult: new Promise<RunResult>((resolve) => {
|
||||||
child.on('close', () => {
|
child.on('close', () => {
|
||||||
completedNormally = !timeLimitExceeded;
|
completedNormally = !timeLimitExceeded;
|
||||||
|
|
||||||
let runEndTime = performance.now();
|
const runEndTime = performance.now();
|
||||||
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
|
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
|
||||||
|
|
||||||
if (completedNormally) {
|
if (completedNormally) {
|
||||||
@ -109,7 +109,7 @@ export const runCpp: IRunner<IRunnerParamsCpp> = async function (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let timeoutHandle = setTimeout(() => {
|
const timeoutHandle = setTimeout(() => {
|
||||||
if (completedNormally) {
|
if (completedNormally) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import * as fs from 'fs-extra';
|
|
||||||
import { join } from 'path';
|
|
||||||
import os = require('os');
|
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import kill from 'tree-kill';
|
import kill from 'tree-kill';
|
||||||
import { RunResult, timeoutSeconds } from '../index.js';
|
import { RunResult, timeoutSeconds } from '../index.js';
|
||||||
@ -27,7 +24,7 @@ export const runCSharp: IRunner = async function (params: {
|
|||||||
params.outputCallback?.(data.toString());
|
params.outputCallback?.(data.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
let runStartTime = performance.now();
|
const runStartTime = performance.now();
|
||||||
child.stdin.write(params.input);
|
child.stdin.write(params.input);
|
||||||
child.stdin.end();
|
child.stdin.end();
|
||||||
|
|
||||||
@ -40,7 +37,7 @@ export const runCSharp: IRunner = async function (params: {
|
|||||||
child.on('close', () => {
|
child.on('close', () => {
|
||||||
completedNormally = !timeLimitExceeded;
|
completedNormally = !timeLimitExceeded;
|
||||||
|
|
||||||
let runEndTime = performance.now();
|
const runEndTime = performance.now();
|
||||||
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
|
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
|
||||||
|
|
||||||
if (completedNormally) {
|
if (completedNormally) {
|
||||||
@ -61,7 +58,7 @@ export const runCSharp: IRunner = async function (params: {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let timeoutHandle = setTimeout(() => {
|
const timeoutHandle = setTimeout(() => {
|
||||||
if (completedNormally) {
|
if (completedNormally) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ export const runJava: IRunner<IRunnerParamsJava> = async function (
|
|||||||
outputBuffer += data.toString();
|
outputBuffer += data.toString();
|
||||||
});
|
});
|
||||||
|
|
||||||
let runStartTime = performance.now();
|
const runStartTime = performance.now();
|
||||||
child.stdin.write(params.input);
|
child.stdin.write(params.input);
|
||||||
child.stdin.end();
|
child.stdin.end();
|
||||||
|
|
||||||
@ -56,11 +56,11 @@ export const runJava: IRunner<IRunnerParamsJava> = async function (
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
runResult: new Promise<RunResult>(async (resolve) => {
|
runResult: new Promise<RunResult>((resolve) => {
|
||||||
child.on('close', () => {
|
child.on('close', () => {
|
||||||
completedNormally = !timeLimitExceeded;
|
completedNormally = !timeLimitExceeded;
|
||||||
|
|
||||||
let runEndTime = performance.now();
|
const runEndTime = performance.now();
|
||||||
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
|
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
|
||||||
|
|
||||||
if (completedNormally) {
|
if (completedNormally) {
|
||||||
@ -81,7 +81,7 @@ export const runJava: IRunner<IRunnerParamsJava> = async function (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let timeoutHandle = setTimeout(() => {
|
const timeoutHandle = setTimeout(() => {
|
||||||
if (completedNormally) {
|
if (completedNormally) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user