[extension] Add eslint

This commit is contained in:
orosmatthew 2023-10-16 13:51:50 -04:00
parent 45646318c0
commit 697dfb968d
10 changed files with 197 additions and 43 deletions

View File

@ -0,0 +1,2 @@
node_modules
out

View File

@ -0,0 +1,37 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
es2017: true,
node: true
},
overrides: [
{ files: ['*.ts', '*.svelte'], rules: { 'no-undef': 'off' } },
{
files: ['*.ts'],
rules: {
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'never' }]
},
parserOptions: { project: ['./tsconfig.json', './webviews/tsconfig.json'] }
},
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};

View File

@ -1,2 +1,2 @@
node_modules
compiled
out

View File

@ -13,7 +13,8 @@
"fs-extra": "^11.1.1",
"isomorphic-git": "^1.24.5",
"tree-kill": "^1.2.2",
"url-join": "^5.0.0"
"url-join": "^5.0.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
@ -32,6 +33,8 @@
"concurrently": "^8.2.1",
"esbuild": "^0.19.4",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.34.0",
"glob": "^10.3.10",
"mocha": "^10.2.0",
"postcss": "^8.4.31",
@ -2686,19 +2689,53 @@
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint-visitor-keys": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
"integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
"node_modules/eslint-config-prettier": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz",
"integrity": "sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
"bin": {
"eslint-config-prettier": "bin/cli.js"
},
"funding": {
"url": "https://opencollective.com/eslint"
"peerDependencies": {
"eslint": ">=7.0.0"
}
},
"node_modules/eslint/node_modules/eslint-scope": {
"node_modules/eslint-plugin-svelte": {
"version": "2.34.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-svelte/-/eslint-plugin-svelte-2.34.0.tgz",
"integrity": "sha512-4RYUgNai7wr0v+T/kljMiYSjC/oqwgq5i+cPppawryAayj4C7WK1ixFlWCGmNmBppnoKCl4iA4ZPzPtlHcb4CA==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@jridgewell/sourcemap-codec": "^1.4.14",
"debug": "^4.3.1",
"esutils": "^2.0.3",
"known-css-properties": "^0.28.0",
"postcss": "^8.4.5",
"postcss-load-config": "^3.1.4",
"postcss-safe-parser": "^6.0.0",
"postcss-selector-parser": "^6.0.11",
"semver": "^7.5.3",
"svelte-eslint-parser": ">=0.33.0 <1.0.0"
},
"engines": {
"node": "^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ota-meshi"
},
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0-0",
"svelte": "^3.37.0 || ^4.0.0"
},
"peerDependenciesMeta": {
"svelte": {
"optional": true
}
}
},
"node_modules/eslint-scope": {
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
"integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==",
@ -2714,13 +2751,16 @@
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint/node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"node_modules/eslint-visitor-keys": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
"integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
"dev": true,
"engines": {
"node": ">=4.0"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/espree": {
@ -2752,15 +2792,6 @@
"node": ">=0.10"
}
},
"node_modules/esquery/node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"dev": true,
"engines": {
"node": ">=4.0"
}
},
"node_modules/esrecurse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
@ -2773,7 +2804,7 @@
"node": ">=4.0"
}
},
"node_modules/esrecurse/node_modules/estraverse": {
"node_modules/estraverse": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
@ -3725,6 +3756,12 @@
"prebuild-install": "^7.0.1"
}
},
"node_modules/known-css-properties": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.28.0.tgz",
"integrity": "sha512-9pSL5XB4J+ifHP0e0jmmC98OGC1nL8/JjS+fi6mnTlIf//yt/MfVLtKg7S6nCtj/8KTcWX7nRlY0XywoYY1ISQ==",
"dev": true
},
"node_modules/leven": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz",
@ -5065,6 +5102,48 @@
"postcss": "^8.2.15"
}
},
"node_modules/postcss-safe-parser": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/postcss-safe-parser/-/postcss-safe-parser-6.0.0.tgz",
"integrity": "sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==",
"dev": true,
"engines": {
"node": ">=12.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
"peerDependencies": {
"postcss": "^8.3.3"
}
},
"node_modules/postcss-scss": {
"version": "4.0.9",
"resolved": "https://registry.npmjs.org/postcss-scss/-/postcss-scss-4.0.9.tgz",
"integrity": "sha512-AjKOeiwAitL/MXxQW2DliT28EKukvvbEWx3LBmJIRN8KfBGZbRTxNYW0kSqi1COiTZ57nZ9NW06S6ux//N1c9A==",
"dev": true,
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss-scss"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"engines": {
"node": ">=12.0"
},
"peerDependencies": {
"postcss": "^8.4.29"
}
},
"node_modules/postcss-selector-parser": {
"version": "6.0.12",
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.12.tgz",
@ -6037,6 +6116,33 @@
"svelte": "^3.55.0 || ^4.0.0-next.0 || ^4.0.0"
}
},
"node_modules/svelte-eslint-parser": {
"version": "0.33.1",
"resolved": "https://registry.npmjs.org/svelte-eslint-parser/-/svelte-eslint-parser-0.33.1.tgz",
"integrity": "sha512-vo7xPGTlKBGdLH8T5L64FipvTrqv3OQRx9d2z5X05KKZDlF4rQk8KViZO4flKERY+5BiVdOh7zZ7JGJWo5P0uA==",
"dev": true,
"dependencies": {
"eslint-scope": "^7.0.0",
"eslint-visitor-keys": "^3.0.0",
"espree": "^9.0.0",
"postcss": "^8.4.29",
"postcss-scss": "^4.0.8"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ota-meshi"
},
"peerDependencies": {
"svelte": "^3.37.0 || ^4.0.0"
},
"peerDependenciesMeta": {
"svelte": {
"optional": true
}
}
},
"node_modules/svelte-preprocess": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.0.4.tgz",
@ -6606,6 +6712,14 @@
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/zod": {
"version": "3.22.4",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
"integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
}
}
}

View File

@ -65,7 +65,8 @@
"esbuild": "npm run esbuild-base -- --sourcemap",
"compile": "rollup -c && npm run esbuild-base -- --minify",
"format": "prettier --plugin prettier-plugin-svelte --write .",
"watch": "concurrently \"rollup -c -w\" \"npm run esbuild-base -- --sourcemap --watch\""
"watch": "concurrently \"rollup -c -w\" \"npm run esbuild-base -- --sourcemap --watch\"",
"lint": "prettier --plugin prettier-plugin-svelte --check . && eslint ."
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
@ -84,6 +85,8 @@
"concurrently": "^8.2.1",
"esbuild": "^0.19.4",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.34.0",
"glob": "^10.3.10",
"mocha": "^10.2.0",
"postcss": "^8.4.31",
@ -103,6 +106,7 @@
"fs-extra": "^11.1.1",
"isomorphic-git": "^1.24.5",
"tree-kill": "^1.2.2",
"url-join": "^5.0.0"
"url-join": "^5.0.0",
"zod": "^3.22.4"
}
}

View File

@ -47,7 +47,7 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
}
case 'onStartup': {
const token: string | undefined = this.context.globalState.get('token');
const teamData = this.context.globalState.get('teamData') as TeamData | undefined;
const teamData: TeamData | undefined = this.context.globalState.get('teamData');
if (token && teamData !== undefined) {
webviewPostMessage({
msg: 'onLogin',
@ -69,21 +69,21 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
password: m.data.password
})
});
const thing = await res.json();
if (thing.success !== true) {
return;
const resData = await res.json();
if (resData.success !== true) {
throw new Error(resData.error.message);
}
const sessionToken = thing.token;
const sessionToken = resData.token;
this.context.globalState.update('token', sessionToken);
const res1 = await fetch(urlJoin(this.webUrl, `api/team/${sessionToken}`), {
const teamRes = await fetch(urlJoin(this.webUrl, `api/team/${sessionToken}`), {
method: 'GET'
});
const data2 = await res1.json();
const data2 = await teamRes.json();
if (!data2.success) {
return;
}
this.context.globalState.update('teamData', data2.data);
webviewPostMessage({ msg: 'onLogout' });
webviewPostMessage({ msg: 'onLogin', data: data2.data });
break;
}
case 'onLogout': {

View File

@ -50,7 +50,7 @@ export async function cloneAndOpenRepo(contestId: number, teamId: number) {
`${teamId.toString()}.git`
);
const repoName = repoUrl.split('/').pop()?.replace('.git', '')!;
const repoName = teamId.toString();
if (!fs.existsSync(`${currentSettings.repoClonePath}/BWContest`)) {
fs.mkdirSync(`${currentSettings.repoClonePath}/BWContest`);

View File

@ -1,9 +1,5 @@
import * as vscode from 'vscode';
import { getNonce } from './getNonce';
import { runJava } from './run/java';
import { extensionSettings } from './extension';
import { join } from 'path';
import { submitProblem } from './submit';
import urlJoin from 'url-join';
export type ProblemData = {
@ -24,7 +20,7 @@ export class BWPanel {
public static currentPanel: BWPanel | undefined;
private running: boolean = false;
private kill: Function | null = null;
// private kill: () => void | null = null;
private constructor(
private readonly context: vscode.ExtensionContext,

View File

@ -14,7 +14,7 @@ export async function runJava(
mainFile: string,
mainClass: string,
input: string
): Promise<{ output: Promise<string>; kill: Function | null }> {
): Promise<{ output: Promise<string>; kill: () => void | null }> {
const javaPath = extensionSettings().javaPath;
if (javaPath == '') {
throw error('Java path not set');

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/// <reference types="svelte" />
type VSCode = {