diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..b1bffa0 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh + +npm install +npm run lint diff --git a/package.json b/package.json index 51a932d..f0dd8df 100644 --- a/package.json +++ b/package.json @@ -156,7 +156,7 @@ } }, "scripts": { - "preinstall": "./scripts/download-humctl.sh", + "preinstall": "./scripts/download-humctl.sh && ./scripts/set-githooks.sh", "vscode:prepublish": "npm run compile", "compile": "tsc -p ./", "watch": "tsc -watch -p ./", diff --git a/scripts/download-humctl.sh b/scripts/download-humctl.sh index 25ccd9e..96bb347 100755 --- a/scripts/download-humctl.sh +++ b/scripts/download-humctl.sh @@ -1,3 +1,5 @@ +#!/bin/sh + CLI_VERSION=0.24.0 mkdir -p ./humctl diff --git a/scripts/set-githooks.sh b/scripts/set-githooks.sh new file mode 100755 index 0000000..79a16f1 --- /dev/null +++ b/scripts/set-githooks.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +git config --local core.hooksPath .githooks/ diff --git a/src/adapters/humctl/HumctlAdapter.ts b/src/adapters/humctl/HumctlAdapter.ts index a3b387b..c74f5e2 100644 --- a/src/adapters/humctl/HumctlAdapter.ts +++ b/src/adapters/humctl/HumctlAdapter.ts @@ -61,6 +61,7 @@ export class HumctlAdapter implements IHumctlAdapter { result = await exec(humctlFilePath, command, { env: await this.prepareEnvVars(), }); + /* eslint-disable @typescript-eslint/no-explicit-any */ } catch (error: any) { statusCode = error.code; result.stderr = error.stderr; diff --git a/src/controllers/ValidateScoreFileController.ts b/src/controllers/ValidateScoreFileController.ts index bb6a8fd..e3173b5 100644 --- a/src/controllers/ValidateScoreFileController.ts +++ b/src/controllers/ValidateScoreFileController.ts @@ -139,6 +139,7 @@ export class ValidateScoreFileController { private isScoreFile(textDocument: TextDocument): boolean { try { + /* eslint-disable @typescript-eslint/no-explicit-any */ const loadedYamlDocument: any = yaml.load(textDocument.getText()); if (!(loadedYamlDocument instanceof Object)) { return false; diff --git a/src/errors/IHumanitecExtensionError.ts b/src/errors/IHumanitecExtensionError.ts index 0b9208b..b78f695 100644 --- a/src/errors/IHumanitecExtensionError.ts +++ b/src/errors/IHumanitecExtensionError.ts @@ -4,6 +4,7 @@ export interface IHumanitecExtensionError { } export function isHumanitecExtensionError( + /* eslint-disable @typescript-eslint/no-explicit-any */ error: any ): error is IHumanitecExtensionError { const isObject = error !== null && typeof error === 'object'; diff --git a/src/errors/UnexpectedEmptyOutputError.ts b/src/errors/UnexpectedEmptyOutputError.ts index d8dcebf..ec9ae07 100644 --- a/src/errors/UnexpectedEmptyOutputError.ts +++ b/src/errors/UnexpectedEmptyOutputError.ts @@ -4,6 +4,7 @@ export class UnexpectedEmptyOutputError implements IHumanitecExtensionError { constructor( private binaryPath: string, private command: string[], + /* eslint-disable @typescript-eslint/no-explicit-any */ private options: any ) {} diff --git a/src/repos/ApplicationRepository.ts b/src/repos/ApplicationRepository.ts index 0370d6c..7f7511a 100644 --- a/src/repos/ApplicationRepository.ts +++ b/src/repos/ApplicationRepository.ts @@ -18,6 +18,7 @@ export class ApplicationRepository implements IApplicationRepository { const applications: Application[] = []; const rawApplications = JSON.parse(result.stdout); + /* eslint-disable @typescript-eslint/no-explicit-any */ rawApplications.forEach((rawApplication: any) => { const application = new Application( rawApplication['metadata']['id'], diff --git a/src/repos/EnvironmentRepository.ts b/src/repos/EnvironmentRepository.ts index b6a1a58..fec0ae6 100644 --- a/src/repos/EnvironmentRepository.ts +++ b/src/repos/EnvironmentRepository.ts @@ -26,6 +26,7 @@ export class EnvironmentRepository implements IEnvironmentRepository { const environments: Environment[] = []; const rawEnvironments = JSON.parse(result.stdout); + /* eslint-disable @typescript-eslint/no-explicit-any */ rawEnvironments.forEach((rawEnvironment: any) => { const environment = new Environment( rawEnvironment['metadata']['id'], diff --git a/src/repos/OrganizationRepository.ts b/src/repos/OrganizationRepository.ts index d551bd4..4ec8635 100644 --- a/src/repos/OrganizationRepository.ts +++ b/src/repos/OrganizationRepository.ts @@ -13,6 +13,7 @@ export class OrganizationRepository implements IOrganizationRepository { const organizations: Organization[] = []; const rawOrganizations = JSON.parse(result.stdout); + /* eslint-disable @typescript-eslint/no-explicit-any */ rawOrganizations.forEach((rawOrganization: any) => { const organization = new Organization( rawOrganization['metadata']['id'], diff --git a/src/repos/ResourceTypeRepository.ts b/src/repos/ResourceTypeRepository.ts index aff6f16..d7c1fc1 100644 --- a/src/repos/ResourceTypeRepository.ts +++ b/src/repos/ResourceTypeRepository.ts @@ -18,6 +18,7 @@ export class ResourceTypeRepository implements IResourceTypeRepository { const rawResourceTypes = JSON.parse(result.stdout); const rawResourceType = rawResourceTypes.find( + /* eslint-disable @typescript-eslint/no-explicit-any */ (rawResourceType: any) => rawResourceType['Type'] === type ); if (!rawResourceType) { @@ -40,6 +41,7 @@ export class ResourceTypeRepository implements IResourceTypeRepository { const resourceTypes: ResourceType[] = []; const rawResourceTypes = JSON.parse(result.stdout); + /* eslint-disable @typescript-eslint/no-explicit-any */ rawResourceTypes.forEach((rawResourceType: any) => { const resourceType = new ResourceType( rawResourceType['Category'], @@ -54,6 +56,7 @@ export class ResourceTypeRepository implements IResourceTypeRepository { } private resolveVariables( + /* eslint-disable @typescript-eslint/no-explicit-any */ rawVariables: any ): Map { const result = new Map(); diff --git a/src/repos/SecretRepository.ts b/src/repos/SecretRepository.ts index 9da98f0..1e9a490 100644 --- a/src/repos/SecretRepository.ts +++ b/src/repos/SecretRepository.ts @@ -22,6 +22,7 @@ export class SecretRepository implements ISecretRepository { let configFile: Buffer = Buffer.from([]); try { configFile = readFileSync(configPath); + /* eslint-disable @typescript-eslint/no-explicit-any */ } catch (error: any) { if (error.code && error.code === 'ENOENT') { console.log(error); @@ -51,6 +52,7 @@ export class SecretRepository implements ISecretRepository { value = ''; } return value; + /* eslint-disable @typescript-eslint/no-explicit-any */ } catch (error: any) { if (error.code && error.code === 'ENOENT') { return ''; diff --git a/src/services/LoginService.ts b/src/services/LoginService.ts index 70abab7..68cc355 100644 --- a/src/services/LoginService.ts +++ b/src/services/LoginService.ts @@ -22,6 +22,7 @@ export class LoginService implements ILoginService { if (response.status !== 200) { throw new AuthorizationError(await response.text()); } + /* eslint-disable @typescript-eslint/no-explicit-any */ const body: any = await response.json(); if (!body.security_code || !body.verification_url) { throw new AuthorizationError(await response.text()); @@ -47,6 +48,7 @@ export class LoginService implements ILoginService { } ); if (response.status === 200) { + /* eslint-disable @typescript-eslint/no-explicit-any */ const body: any = await response.json(); if (!body.accepted) { throw new AuthorizationError(await response.text()); diff --git a/src/services/ScoreValidationService.ts b/src/services/ScoreValidationService.ts index e6439b4..21bc3f4 100644 --- a/src/services/ScoreValidationService.ts +++ b/src/services/ScoreValidationService.ts @@ -28,6 +28,7 @@ export class ScoreValidationService implements IScoreValidationService { return validationErrors; } const validationRawErrors = JSON.parse(result.stdout); + /* eslint-disable @typescript-eslint/no-explicit-any */ validationRawErrors.forEach((validationRawError: any) => { validationErrors.push( new ValidationError(