Skip to content

Commit

Permalink
[build] Fix build errors after update to '@typescript-eslint/*' v.8.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Rubezhny <[email protected]>
  • Loading branch information
vrubezhny committed Aug 1, 2024
1 parent 80e756f commit 27d16ca
Show file tree
Hide file tree
Showing 74 changed files with 288 additions and 262 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"@typescript-eslint/no-unsafe-assignment": 1,
"@typescript-eslint/no-var-requires": 1,
"@typescript-eslint/no-unsafe-argument": 1,
"@typescript-eslint/no-unused-expressions": 0,
"no-var": 2,
"object-shorthand": ["error", "properties"],
"prefer-const": ["error", { "destructuring": "all" }],
Expand Down
6 changes: 3 additions & 3 deletions build/install-vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import * as testElectron from '@vscode/test-electron';
import { platform } from 'os';

import cp = require('child_process');
import path = require('path');
import * as cp from 'child_process';
import * as path from 'path';
import * as packageJson from '../package.json';

void testElectron.downloadAndUnzipVSCode().then((executable: string) => {
// Install extensions that openshift-toolkit depends on
const packageJson = require('../package.json');
const extensionsToInstall = packageJson.extensionDependencies;

if (extensionsToInstall) {
Expand Down
4 changes: 2 additions & 2 deletions build/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import * as path from 'path';
import * as etest from '@vscode/test-electron';
import * as path from 'path';

/**
* Run mocha tests from project's tests folder.
Expand All @@ -27,7 +27,7 @@ async function main(): Promise<void> {
'--disable-workspace-trust',
],
});
} catch (error) {
} catch {
// eslint-disable-next-line no-console
console.error('Failed to run tests');
process.exit(1);
Expand Down
16 changes: 8 additions & 8 deletions build/verify-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable @typescript-eslint/no-misused-promises */

import * as cp from 'child_process';
import * as fs from 'fs-extra';
import * as hasha from 'hasha';
import * as mkdirp from 'mkdirp';
import * as os from 'os';
import * as path from 'path';
import { exit } from 'shelljs';
import { DownloadUtil } from '../src/downloadUtil/download';
import hasha = require('hasha');
import mkdirp = require('mkdirp');
import fs = require('fs-extra');
import path = require('path');
import cp = require('child_process');
import os = require('os');
import configData = require('../src/tools.json');
import * as configData from '../src/tools.json';

/**
* Download reqURL to targetFolder and save it to fileName. Verify the downloaded file sha256 is matching sha256sum
Expand Down Expand Up @@ -71,7 +71,7 @@ cp.exec('git diff --name-only origin/master -- .', async (error, stdout) => {
console.log('tools.json is changed, starting download verification');
try {
await verifyTools();
} catch (err) {
} catch {
exit(1);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/base/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export class CommandText {
}
}

// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function verbose(_: unknown, key: string, descriptor: TypedPropertyDescriptor<Function>): void {
let fnKey: string | undefined;
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
let fn: Function | undefined;

if (typeof descriptor.value === 'function') {
Expand Down
6 changes: 3 additions & 3 deletions src/cloudProvider/redhatCloudProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import * as k8s from 'vscode-kubernetes-tools-api';
import * as path from 'path';
import * as vscode from 'vscode';
import { vsCommand } from '../vscommand';
import * as k8s from 'vscode-kubernetes-tools-api';
import { createSandboxAPI, SBSignupResponse } from '../openshift/sandbox';
import { vsCommand } from '../vscommand';
import ClusterViewLoader from '../webview/cluster/clusterViewLoader';
import path = require('path');

const sandboxAPI = createSandboxAPI();

Expand Down
18 changes: 9 additions & 9 deletions src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
*-----------------------------------------------------------------------------------------------*/

import {
TreeDataProvider,
TreeItem,
debug,
DebugSession,
Disposable,
Event,
ProviderResult,
EventEmitter,
Disposable,
ProviderResult,
TreeDataProvider,
TreeItem,
TreeItemCollapsibleState,
TreeView,
window,
TreeItemCollapsibleState,
debug,
DebugSession,
} from 'vscode';
import { ComponentsTreeDataProvider } from './componentsView';

Expand Down Expand Up @@ -48,13 +48,13 @@ export class DebugSessionsView implements TreeDataProvider<string>, Disposable {
this.refresh();
});
}
}),
});
debug.onDidTerminateDebugSession((session) => {
if (session.configuration?.contextPath) {
DebugSessionsView.sessions.delete(session.configuration.contextPath);
this.refresh();
}
})
});
}

createTreeView(id: string): TreeView<string> {
Expand Down
4 changes: 2 additions & 2 deletions src/downloadUtil/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { throttleTime } from 'rxjs/operators';
import { promisify } from 'util';

// need to use `require`, since we replace these imports in the unit tests
import got = require('got');
import stream = require('stream');
import * as got from 'got';
import * as stream from 'stream';

export class DownloadUtil {
static async downloadFile(
Expand Down
2 changes: 1 addition & 1 deletion src/downloadUtil/downloadBinaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* eslint-disable no-console */

import * as fs from 'fs-extra';
import * as hasha from 'hasha';
import * as mkdirp from 'mkdirp';
import * as path from 'path';
import { Archive } from './archive';
import { DownloadUtil } from './download';
import hasha = require('hasha');

export interface PlatformData {
url: string;
Expand Down
41 changes: 21 additions & 20 deletions src/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
try {
this.kubeConfig = new KubeConfigUtils();
this.kubeContext = this.kubeConfig.getContextObject(this.kubeConfig.currentContext);
} catch (err) {
} catch {
// ignore config loading error and let odo report it on first call
}
try {
const kubeconfigFiles = getKubeConfigFiles();
this.kubeConfigWatchers = kubeconfigFiles.map(kubeconfigFile => WatchUtil.watchFileForContextChange(path.dirname(kubeconfigFile), path.basename(kubeconfigFile)));
} catch (err) {
} catch {
void window.showWarningMessage('Couldn\'t install watcher for Kubernetes configuration file. OpenShift Application Explorer view won\'t be updated automatically.');
}
for (const fsw of this.kubeConfigWatchers) {
Expand Down Expand Up @@ -318,21 +318,22 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos

// Search for Pod continers' errors
pods.forEach((pod) => {
pod.status?.containerStatuses &&
pod.status.containerStatuses.forEach((cs) => {
if (cs.state?.waiting) {
const reason = cs.state.waiting.reason;
const message = cs.state.waiting.message;

inCrashLoopBackOff = inCrashLoopBackOff || reason === 'CrashLoopBackOff';

const msg = `${reason}: ${message ? message.trim(): 'No valuable message'}`;
// Skip duplicated messages
if (messages.length < 3 && !(messages.find((m) => m.startsWith(`${reason}:`)))) {
messages.push(msg);
if (pod.status?.containerStatuses) {
pod.status.containerStatuses.forEach((cs) => {
if (cs.state?.waiting) {
const reason = cs.state.waiting.reason;
const message = cs.state.waiting.message;

inCrashLoopBackOff = inCrashLoopBackOff || reason === 'CrashLoopBackOff';

const msg = `${reason}: ${message ? message.trim(): 'No valuable message'}`;
// Skip duplicated messages
if (messages.length < 3 && !(messages.find((m) => m.startsWith(`${reason}:`)))) {
messages.push(msg);
}
}
}
});
});
}
});

return {
Expand Down Expand Up @@ -443,7 +444,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
result.unshift({ label: process.env.KUBECONFIG ? 'Custom KubeConfig' : 'Default KubeConfig', description: config.join(':') })
}
}
} catch (err) {
} catch {
// ignore because ether server is not accessible or user is logged out
}
OpenShiftExplorer.getInstance().onDidChangeContextEmitter.fire(new KubeConfigUtils().currentContext);
Expand Down Expand Up @@ -484,7 +485,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
if (await Oc.Instance.canGetKubernetesObjects('csv', this.executionContext)) {
serviceKinds = await getServiceKindStubs(this.executionContext);
}
} catch (_) {
} catch {
// operator framework is not installed on cluster; do nothing
}
void commands.executeCommand('setContext', 'showCreateService', serviceKinds.length > 0);
Expand All @@ -494,7 +495,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
try {
services = await getServices(this.executionContext);
}
catch (_) {
catch {
// operator framework is not installed on cluster; do nothing
}
void commands.executeCommand('setContext', 'showCreateRoute', services.length > 0);
Expand Down Expand Up @@ -647,7 +648,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
if (await Oc.Instance.canGetKubernetesObjects('csv', this.executionContext)) {
serviceKinds = await getServiceKindStubs(this.executionContext);
}
} catch (_) {
} catch {
// operator framework is not installed on cluster; do nothing
}

Expand Down
2 changes: 1 addition & 1 deletion src/helm/manageRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class ManageRepository {
if (repositories?.find((registry) => registry.url !== repoURL && new URL(registry.url).hostname === new URL(value).hostname)) {
return `Repository with entered URL '${value}' already exists`;
}
} catch (Error) {
} catch {
return 'Entered URL is invalid';
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/installToolsInRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*-----------------------------------------------------------------------------------------------*/
/* eslint-disable no-console */

import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import * as shell from 'shelljs';
import { downloadFileAndCreateSha256 } from './downloadUtil/downloadBinaries';
import configData = require('./tools.json');
import fs = require('fs-extra');
import * as configData from './tools.json';

async function installBinary(tool): Promise<void> {
const openShiftToolsFolder = path.join(os.homedir(), '.local', 'state', 'vs-openshift-tools');
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/clusterExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import * as path from 'path';
import * as vscode from 'vscode';
import * as k8s from 'vscode-kubernetes-tools-api';
import { CommandText } from '../base/command';
Expand All @@ -11,7 +12,6 @@ import { isOpenShiftCluster } from '../util/kubeUtils';
import { Build } from './build';
import { ClusterServiceVersion } from './csv';
import { DeploymentConfig } from './deploymentConfig';
import path = require('path');

let clusterExplorer: k8s.ClusterExplorerV1 | undefined;

Expand Down
2 changes: 1 addition & 1 deletion src/k8s/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getChildrenNode(command: CommandText, kind: string, abbrev
.filter((value) => value !== '')
.map<Node>((item: string) => new Node(item.split(',')[0], item.split(',')[1], Number.parseInt(item.split(',')[2], 10), kind, abbreviation));
return builds;
} catch (error) {
} catch {
return [];
}
}
4 changes: 2 additions & 2 deletions src/k8s/vfs/json-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import * as parse from 'json-to-ast';
import * as vscode from 'vscode';
import { MappingItem, Node, NodeProvider } from './locator-util';
import * as parse from 'json-to-ast';

export interface ASTPosition {
readonly line: number;
Expand Down Expand Up @@ -234,7 +234,7 @@ export class JsonLocator {
const ast = parse(textDocument.getText(), {loc: true});
this.cache[key].jsonDocs = [new JsonDocument([ast], [])];
this.cache[key].version = textDocument.version;
} catch (err) {
} catch {
delete this.cache[key];
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/k8s/vfs/kuberesources.virtualfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

import * as vscode from 'vscode';

import { Uri, FileSystemProvider, FileType, FileStat, FileChangeEvent, Event, EventEmitter, Disposable } from 'vscode';
import * as path from 'path';
import * as fs from 'fs';
import * as path from 'path';
import * as querystring from 'querystring';
import { Disposable, Event, EventEmitter, FileChangeEvent, FileStat, FileSystemProvider, FileType, Uri } from 'vscode';

import { Errorable } from './errorable';
import { CommandText } from '../../base/command';
import { CliChannel } from '../../cli';
import { CliExitData } from '../../util/childProcessUtil';
import { helmSyntaxVersion, HelmSyntaxVersion } from '../../helm/helm';
import { CliExitData } from '../../util/childProcessUtil';
import { Progress } from '../../util/progress';
import { Errorable } from './errorable';

export const K8S_RESOURCE_SCHEME = 'osmsx'; // Changed from 'k8smsx' to 'osmsx' to not make a conflict with k8s extension
export const K8S_RESOURCE_SCHEME_READONLY = 'osmsxro'; // Changed from 'k8smsxro' to 'osmsxro' to not make a conflict with k8s extension
Expand Down Expand Up @@ -125,14 +125,14 @@ export class KubernetesResourceVirtualFileSystemProvider implements FileSystemPr
const eer = await this.execLoadResource(resourceAuthority, ns, value, revision, outputFormat);
if (Errorable.failed(eer)) {
void vscode.window.showErrorMessage(eer.error[0]);
throw eer.error[0];
throw new Error(eer.error[0]);
}

const er = eer.result;
if (CliExitData.failed(er)) {
const message = `Get command failed: ${CliExitData.getErrorMessage(er)}`;
void vscode.window.showErrorMessage(message);
throw message;
throw new Error(message);
}

return er.stdout;
Expand Down
6 changes: 3 additions & 3 deletions src/k8s/vfs/yaml-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import * as vscode from 'vscode';

import {MappingItem, Node, NodeProvider} from './locator-util';
import { parse, findNodeAtPosition } from 'node-yaml-parser';
import * as YAML from 'js-yaml';
import { findNodeAtPosition, parse } from 'node-yaml-parser';
import { MappingItem, Node, NodeProvider } from './locator-util';

export function isMapping(node: YamlNode): node is YamlMap {
return node.kind === 'MAPPING';
Expand Down Expand Up @@ -117,7 +117,7 @@ export class YamlLocator {
this.cache[key].yamlDocs = documents;
this.cache[key].lineLengths = lineLengths;
this.cache[key].version = textDocument.version;
} catch (err) {
} catch {
delete this.cache[key];
}
}
Expand Down
Loading

0 comments on commit 27d16ca

Please sign in to comment.