Skip to content
Snippets Groups Projects
Commit da22aba9 authored by michael.minelli's avatar michael.minelli
Browse files

Lint => Update eslint

parent 08cdfea0
Branches
No related tags found
No related merge requests found
Pipeline #30906 passed
Showing
with 74 additions and 60 deletions
dist
node_modules
.gitlab-ci
\ No newline at end of file
{
"root" : true,
"parser" : "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
]
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="EslintConfiguration"> <component name="EslintConfiguration">
<custom-configuration-file used="false" path="./eslint.config.js" />
<option name="fix-on-save" value="true" /> <option name="fix-on-save" value="true" />
</component> </component>
</project> </project>
\ No newline at end of file
// @ts-check
// @formatter:off
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config({
ignores: [ 'dist/*', 'node_modules/*', '.gitlab-ci.yml', 'eslint.config.js' ]
}, eslint.configs.recommended, ...tseslint.configs.recommendedTypeChecked, {
languageOptions: {
parserOptions: {
project: true, tsconfigRootDir: import.meta.dirname
}
}
}, {
plugins: {
'@typescript-eslint': tseslint.plugin
}, rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
}
});
\ No newline at end of file
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"pkg": "^5.8.1", "pkg": "^5.8.1",
"tiny-typed-emitter": "^2.1.0", "tiny-typed-emitter": "^2.1.0",
"tsx": "^4.7.1", "tsx": "^4.7.1",
"typescript": "^5.4.2", "typescript": "^5.4.3",
"typescript-eslint": "^7.4.0" "typescript-eslint": "^7.4.0"
} }
}, },
......
...@@ -34,14 +34,14 @@ ...@@ -34,14 +34,14 @@
"test" : "echo \"Error: no test specified\" && exit 1" "test" : "echo \"Error: no test specified\" && exit 1"
}, },
"dependencies" : { "dependencies" : {
"@gitbeaker/rest" : "^40.0.1", "@gitbeaker/rest" : "^40.0.2",
"@gitbeaker/core" : "^40.0.1", "@gitbeaker/core" : "^40.0.2",
"@gitbeaker/requester-utils": "^40.0.1", "@gitbeaker/requester-utils": "^40.0.2",
"appdata-path" : "^1.0.0", "appdata-path" : "^1.0.0",
"axios" : "^1.6.5", "axios" : "^1.6.8",
"boxen" : "^5.1.2", "boxen" : "^5.1.2",
"chalk" : "^4.1.2", "chalk" : "^4.1.2",
"commander" : "^11.1.0", "commander" : "^12.0.0",
"dotenv" : "^16.3.1", "dotenv" : "^16.3.1",
"dotenv-expand" : "^10.0.0", "dotenv-expand" : "^10.0.0",
"form-data" : "^4.0.0", "form-data" : "^4.0.0",
...@@ -52,28 +52,28 @@ ...@@ -52,28 +52,28 @@
"jsonwebtoken" : "^8.5.1", "jsonwebtoken" : "^8.5.1",
"open" : "^8.4.2", "open" : "^8.4.2",
"ora" : "^5.4.1", "ora" : "^5.4.1",
"semver" : "^7.5.4", "semver" : "^7.6.0",
"tar-stream" : "^3.1.6", "tar-stream" : "^3.1.7",
"winston" : "^3.11.0", "winston" : "^3.13.0",
"winston-transport" : "^4.7.0", "winston-transport" : "^4.7.0",
"yaml" : "^2.3.4", "yaml" : "^2.4.1",
"zod" : "^3.22.4", "zod" : "^3.22.4",
"zod-validation-error" : "^3.0.0" "zod-validation-error" : "^3.0.3"
}, },
"devDependencies": { "devDependencies": {
"@types/fs-extra" : "^11.0.4", "@types/fs-extra" : "^11.0.4",
"@types/inquirer" : "^8.2.10", "@types/inquirer" : "^8.2.10",
"@types/jsonwebtoken": "^8.5.9", "@types/jsonwebtoken": "^8.5.9",
"@types/node" : "^18.19.2", "@types/node" : "^18.19.26",
"@types/semver" : "^7.5.6", "@types/semver" : "^7.5.8",
"@types/tar-stream" : "^3.1.3", "@types/tar-stream" : "^3.1.3",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser" : "^6.18.1",
"dotenv-vault" : "^1.25.0", "dotenv-vault" : "^1.25.0",
"eslint" : "^8.57.0",
"genversion" : "^3.2.0", "genversion" : "^3.2.0",
"pkg" : "^5.8.1", "pkg" : "^5.8.1",
"tiny-typed-emitter" : "^2.1.0",
"tsx" : "^4.7.1", "tsx" : "^4.7.1",
"typescript" : "^5.4.2", "typescript" : "^5.4.3",
"typescript" : "^5.3.3" "typescript-eslint" : "^7.4.0"
} }
} }
...@@ -96,7 +96,7 @@ ${ TextStyle.CODE(' dojo upgrade ') }`, { ...@@ -96,7 +96,7 @@ ${ TextStyle.CODE(' dojo upgrade ') }`, {
if ( SharedConfig.production ) { if ( SharedConfig.production ) {
const latestDojoCliVersion = stateConfigFile.getParam('latestDojoCliVersion') as string | null || '0.0.0'; const latestDojoCliVersion = stateConfigFile.getParam('latestDojoCliVersion') as string | null || '0.0.0';
const latestDojoCliVersionNotification = stateConfigFile.getParam('latestDojoCliVersionNotification') as number | null || 0; const latestDojoCliVersionNotification = stateConfigFile.getParam('latestDojoCliVersionNotification') as number | null || 0;
if ( semver.lt(version, latestDojoCliVersion) && (new Date()).getTime() - latestDojoCliVersionNotification >= Config.versionUpdateInformationPeriodHours * 60 * 60 * 1000 ) { if ( semver.lt(version as string, latestDojoCliVersion) && (new Date()).getTime() - latestDojoCliVersionNotification >= Config.versionUpdateInformationPeriodHours * 60 * 60 * 1000 ) {
console.log(boxen(`The ${ latestDojoCliVersion } version of the DojoCLI is available. console.log(boxen(`The ${ latestDojoCliVersion } version of the DojoCLI is available.
You can upgrade the DojoCLI by executing this command: You can upgrade the DojoCLI by executing this command:
${ TextStyle.CODE(' dojo upgrade ') }`, { ${ TextStyle.CODE(' dojo upgrade ') }`, {
......
...@@ -68,7 +68,7 @@ class ExerciseCorrectionCommand extends CommanderCommand { ...@@ -68,7 +68,7 @@ class ExerciseCorrectionCommand extends CommanderCommand {
console.log(TextStyle.URL(correctionUrl)); console.log(TextStyle.URL(correctionUrl));
open(correctionUrl).then(); await open(correctionUrl);
} }
} }
......
...@@ -32,7 +32,7 @@ class LocalConfigFile { ...@@ -32,7 +32,7 @@ class LocalConfigFile {
} }
} }
getParam(key: string): unknown | null { getParam(key: string): unknown {
const value = key in this._config ? this._config[key] : null; const value = key in this._config ? this._config[key] : null;
if ( value === null ) { if ( value === null ) {
return null; return null;
......
...@@ -27,7 +27,7 @@ async function askConfirmation(msg: string): Promise<boolean> { ...@@ -27,7 +27,7 @@ async function askConfirmation(msg: string): Promise<boolean> {
message: msg, message: msg,
type : 'confirm', type : 'confirm',
default: false default: false
})).confirm; })).confirm as boolean;
} }
// Returns false, when the renaming is interrupted // Returns false, when the renaming is interrupted
......
...@@ -256,7 +256,7 @@ class ExerciseRunHelper { ...@@ -256,7 +256,7 @@ class ExerciseRunHelper {
}); });
this.exerciseResultsValidation.events.on('finished', (success: boolean, exitCode: number) => { this.exerciseResultsValidation.events.on('finished', (success: boolean, exitCode: number) => {
success || exitCode === ExerciseCheckerError.EXERCISE_RESULTS_FOLDER_TOO_BIG ? resolve() : reject(); success || exitCode === ExerciseCheckerError.EXERCISE_RESULTS_FOLDER_TOO_BIG.valueOf() ? resolve() : reject();
}); });
this.exerciseResultsValidation.run(); this.exerciseResultsValidation.run();
...@@ -271,7 +271,7 @@ class ExerciseRunHelper { ...@@ -271,7 +271,7 @@ class ExerciseRunHelper {
* Step 4: Display results + Volume location * Step 4: Display results + Volume location
* @private * @private
*/ */
private async displayResults() { private displayResults() {
const info = chalk.magenta.bold.italic; const info = chalk.magenta.bold.italic;
ClientsSharedExerciseHelper.displayExecutionResults(this.exerciseResultsValidation.exerciseResults, this.exerciseDockerCompose.exitCode, { ClientsSharedExerciseHelper.displayExecutionResults(this.exerciseResultsValidation.exerciseResults, this.exerciseDockerCompose.exitCode, {
INFO : info, INFO : info,
...@@ -285,7 +285,7 @@ class ExerciseRunHelper { ...@@ -285,7 +285,7 @@ class ExerciseRunHelper {
await this.checkRequirements(); await this.checkRequirements();
await this.runDockerCompose(); await this.runDockerCompose();
await this.getResults(); await this.getResults();
await this.displayResults(); this.displayResults();
} catch ( error ) { } catch ( error ) {
return; return;
} }
......
...@@ -25,7 +25,7 @@ class DojoBackendManager { ...@@ -25,7 +25,7 @@ class DojoBackendManager {
spinner.fail(`No pipeline found for this assignment.`); spinner.fail(`No pipeline found for this assignment.`);
break; break;
case DojoStatusCode.ASSIGNMENT_PUBLISH_PIPELINE_FAILED: case DojoStatusCode.ASSIGNMENT_PUBLISH_PIPELINE_FAILED:
spinner.fail(error.response?.data?.message ?? `Last pipeline status is not "${ GitlabPipelineStatus.SUCCESS }".`); spinner.fail((error.response?.data?.message as string | undefined) ?? `Last pipeline status is not "${ GitlabPipelineStatus.SUCCESS }".`);
break; break;
case DojoStatusCode.EXERCISE_CORRECTION_ALREADY_EXIST: case DojoStatusCode.EXERCISE_CORRECTION_ALREADY_EXIST:
spinner.fail(`This exercise is already labelled as a correction. If you want to update it, please use the update command.`); spinner.fail(`This exercise is already labelled as a correction. If you want to update it, please use the update command.`);
...@@ -199,7 +199,7 @@ class DojoBackendManager { ...@@ -199,7 +199,7 @@ class DojoBackendManager {
} }
try { try {
const axiosFunction = isUpdate ? axios.patch : axios.post; const axiosFunction = isUpdate ? axios.patch.bind(axios) : axios.post.bind(axios);
const route = isUpdate ? ApiRoute.ASSIGNMENT_CORRECTION_UPDATE : ApiRoute.ASSIGNMENT_CORRECTION_LINK; const route = isUpdate ? ApiRoute.ASSIGNMENT_CORRECTION_UPDATE : ApiRoute.ASSIGNMENT_CORRECTION_LINK;
await axiosFunction(DojoBackendHelper.getApiUrl(route, { await axiosFunction(DojoBackendHelper.getApiUrl(route, {
......
...@@ -26,9 +26,11 @@ class HttpManager { ...@@ -26,9 +26,11 @@ class HttpManager {
} }
if ( config.url && (config.url.indexOf(ClientsSharedConfig.apiURL) !== -1) ) { if ( config.url && (config.url.indexOf(ClientsSharedConfig.apiURL) !== -1) ) {
config.headers['Accept-Encoding'] = 'gzip'; config.headers['Accept-Encoding'] = 'gzip';
if ( config.data && Object.keys(config.data).length > 0 ) { if ( config.data && Object.keys(config.data as { [key: string]: unknown }).length > 0 ) {
config.headers['Content-Type'] = 'multipart/form-data'; config.headers['Content-Type'] = 'multipart/form-data';
} }
...@@ -62,10 +64,10 @@ class HttpManager { ...@@ -62,10 +64,10 @@ class HttpManager {
const data: DojoBackendResponse<void> = error.response.data as DojoBackendResponse<void>; const data: DojoBackendResponse<void> = error.response.data as DojoBackendResponse<void>;
switch ( data.code ) { switch ( data.code ) {
case DojoStatusCode.CLIENT_NOT_SUPPORTED: case DojoStatusCode.CLIENT_NOT_SUPPORTED.valueOf():
this.requestError('Client not recognized by the server. Please contact the administrator.'); this.requestError('Client not recognized by the server. Please contact the administrator.');
break; break;
case DojoStatusCode.CLIENT_VERSION_NOT_SUPPORTED: case DojoStatusCode.CLIENT_VERSION_NOT_SUPPORTED.valueOf():
this.requestError(`CLI version not anymore supported by the server. Please update the CLI by executing this command:\n${ TextStyle.CODE(' dojo upgrade ') }`); this.requestError(`CLI version not anymore supported by the server. Please update the CLI by executing this command:\n${ TextStyle.CODE(' dojo upgrade ') }`);
break; break;
default: default:
...@@ -80,10 +82,10 @@ class HttpManager { ...@@ -80,10 +82,10 @@ class HttpManager {
if ( errorCustomCode === error.response.status ) { if ( errorCustomCode === error.response.status ) {
switch ( error.response.status ) { switch ( error.response.status ) {
case StatusCodes.UNAUTHORIZED: case StatusCodes.UNAUTHORIZED.valueOf():
this.requestError('Session expired or does not exist. Please login again.'); this.requestError('Session expired or does not exist. Please login again.');
break; break;
case StatusCodes.FORBIDDEN: case StatusCodes.FORBIDDEN.valueOf():
this.requestError('Forbidden access.'); this.requestError('Forbidden access.');
break; break;
default: default:
...@@ -114,8 +116,8 @@ class HttpManager { ...@@ -114,8 +116,8 @@ class HttpManager {
return response; return response;
}, async error => { }, async error => {
if ( error.response ) { if ( error instanceof AxiosError && error.response ) {
const isFromApi = error.response.config.url && error.response.config.url.indexOf(ClientsSharedConfig.apiURL) !== -1; const isFromApi = error.response.config.url !== undefined && error.response.config.url.indexOf(ClientsSharedConfig.apiURL) !== -1;
this.apiMethodNotAllowed(error, isFromApi); this.apiMethodNotAllowed(error, isFromApi);
this.apiAuthorizationError(error, isFromApi); this.apiAuthorizationError(error, isFromApi);
......
...@@ -134,7 +134,7 @@ class SessionManager { ...@@ -134,7 +134,7 @@ class SessionManager {
message: `${ chalk.green('?') } Please paste the Gitlab code here`, message: `${ chalk.green('?') } Please paste the Gitlab code here`,
mask : '*', mask : '*',
prefix : ' ' prefix : ' '
})).code; })).code as string;
} }
private getGitlabCodeFromGraphicEnvironment(): Promise<string> { private getGitlabCodeFromGraphicEnvironment(): Promise<string> {
...@@ -156,7 +156,7 @@ class SessionManager { ...@@ -156,7 +156,7 @@ class SessionManager {
text : `Waiting for user to authorize the application in his web browser. If the browser does not open automatically, please go to : ${ Config.login.gitlab.url.code }`, text : `Waiting for user to authorize the application in his web browser. If the browser does not open automatically, please go to : ${ Config.login.gitlab.url.code }`,
indent: 4 indent: 4
}).start(); }).start();
open(Config.login.gitlab.url.code).then(); void open(Config.login.gitlab.url.code).then();
}); });
loginServer.events.on('error', (error: string) => { loginServer.events.on('error', (error: string) => {
currentSpinner.fail(`Login server error: ${ error }`); currentSpinner.fail(`Login server error: ${ error }`);
......
Subproject commit 77badeab872fc6ce5873c1182b428e9410525f95 Subproject commit 021300d29473dee2ad229384d22a521c0e5c14aa
Subproject commit acba6304b6fea92d473ceba1a66adacd06ca00c5 Subproject commit 8514d5ef589a8aa34e4d2260c618781d81368c22
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment