New linter settings + mountain of linter error fixes (#2836)

This commit is contained in:
Brandon Waterloo [MSFT] 2021-04-12 10:23:46 -04:00 коммит произвёл GitHub
Родитель eca11bb1ef
Коммит 1aa4d60500
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
134 изменённых файлов: 506 добавлений и 3682 удалений

Просмотреть файл

@ -1,3 +1,2 @@
test/
gulpfile.ts
.eslintrc.js

Просмотреть файл

@ -1,272 +0,0 @@
module.exports = {
"env": {
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"import",
"unicorn"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/indent": [
"error",
4,
{
"CallExpression": {
"arguments": "first"
},
"FunctionDeclaration": {
"parameters": "first"
},
"FunctionExpression": {
"parameters": "first"
},
"SwitchCase": 1
}
],
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": [
"off",
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-param-reassign": "off",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-use-before-declare": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/quotes": [
"off",
"single"
],
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/semi": [
"off",
"always"
],
"@typescript-eslint/strict-boolean-expressions": [
"off",
{
"allowNullable": true
}
],
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "off",
"@typescript-eslint/unified-signatures": "error",
"arrow-parens": [
"off",
"as-needed"
],
"camelcase": "error",
"capitalized-comments": "off",
"comma-dangle": "off",
"complexity": "error",
"constructor-super": "error",
"curly": "error",
"default-case": "error",
"dot-notation": "error",
"eol-last": "off",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": [
"error",
"any",
"number",
"string",
"Boolean",
"boolean",
],
"id-match": "error",
"import/no-default-export": "off",
"import/no-deprecated": "off",
"import/no-extraneous-dependencies": "error",
"import/no-internal-modules": "off",
"import/no-unassigned-import": "error",
"import/order": "off",
"linebreak-style": "off",
"max-classes-per-file": [
"off",
3
],
"max-len": [
"off",
{
"code": 140
}
],
"max-lines": "off",
"new-parens": "error",
"newline-per-chained-call": "off",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": [
"off",
{
"allow": [
"dirxml",
"warn",
"error",
"dir",
"timeLog",
"assert",
"clear",
"count",
"countReset",
"group",
"groupCollapsed",
"groupEnd",
"table",
"Console",
"markTimeline",
"profile",
"profileEnd",
"timeline",
"timelineEnd",
"timeStamp",
"context"
]
}
],
"no-constant-condition": "error",
"no-control-regex": "error",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "off",
"no-empty": "off",
"no-eval": "error",
"no-extra-bind": "error",
"no-extra-semi": "error",
"no-fallthrough": "off",
"no-invalid-regexp": "error",
"no-invalid-this": "error",
"no-irregular-whitespace": "error",
"no-magic-numbers": "off",
"no-multi-str": "off",
"no-multiple-empty-lines": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-null/no-null": "off",
"no-octal": "error",
"no-octal-escape": "error",
"no-redeclare": "error",
"no-regex-spaces": "error",
"no-restricted-syntax": [
"error",
"ForInStatement"
],
"no-return-await": "off",
"no-sequences": "error",
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "off",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-var": "error",
"no-void": "off",
"object-shorthand": "off",
"one-var": [
"off",
"never"
],
"padding-line-between-statements": [
"off",
"error",
{
"blankLine": "always",
"prev": "*",
"next": "return"
}
],
"prefer-arrow/prefer-arrow-functions": "off",
"prefer-const": "off",
"prefer-object-spread": "error",
"prefer-readonly": "off",
"prefer-template": "off",
"quote-props": [
"off",
"as-needed"
],
"radix": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"never"
],
"spaced-comment": [
"error",
"always",
{
"exceptions": ["-"]
}
],
"unicorn/filename-case": [
"error",
{
cases: {
"camelCase": true,
// CONSIDER: Enforce a single case (e.g. camelCase).
"pascalCase": true
}
}
],
"use-isnan": "error",
"valid-typeof": "off",
"yoda": "off"
}
};

65
.eslintrc.json Normal file
Просмотреть файл

@ -0,0 +1,65 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"project": "tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/naming-convention": [ // Naming is enforced with some exceptions below
"warn",
{ // Names should be either camelCase or PascalCase, both are extensively used throughout this project
"selector": "default",
"format": [
"camelCase",
"PascalCase"
]
},
{ // const variables can also have UPPER_CASE
"selector": "variable",
"modifiers": [
"const"
],
"format": [
"camelCase",
"PascalCase",
"UPPER_CASE"
]
},
{ // private class properties can also have leading _underscores
"selector": "classProperty",
"modifiers": [
"private"
],
"format": [
"camelCase",
"PascalCase"
],
"leadingUnderscore": "allow"
}
],
"@typescript-eslint/no-floating-promises": "warn", // Floating promises are bad, should do `void thePromise()`
"@typescript-eslint/no-inferrable-types": "off", // This gets upset about e.g. `const foo: string = 'bar'` because it's obvious that it's a string; it doesn't matter enough to enforce
"@typescript-eslint/no-unused-vars": [ // Unused variables aren't allowed, with an exception (below)
"warn",
{ // As a function parameter, unused parameters are allowed
"args": "none"
}
],
"@typescript-eslint/semi": "warn", // Elevate this to warning, we like semicolons
"curly": "warn", // May have been a mistake to include a `{curly}` inside a template string, you might mean `${curly}`
"eqeqeq": "warn", // Should use `===`, not `==`, nearly 100% of the time
"no-extra-boolean-cast": "off", // We !!flatten a lot of things into booleans this way
"no-throw-literal": "warn", // Elevate this from suggestion to warning
"semi": "off" // Covered by @typescript-eslint/semi
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
}

2986
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -2729,12 +2729,9 @@
"@types/vscode": "1.55.0",
"@types/xml2js": "^0.4.8",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/eslint-plugin-tslint": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"copy-webpack-plugin": "^8.1.1",
"eslint": "^7.24.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-unicorn": "^29.0.0",
"gulp": "^4.0.2",
"gulp-eslint": "^6.0.0",
"gulp-sourcemaps": "^3.0.0",

Просмотреть файл

@ -25,7 +25,7 @@ export async function confirmAllAffectedContainers(context: IActionContext, node
});
const groupsList = Array.from(groupsSet);
const groupsConfirm = groupsList.map(g => `\'${g}\'`).join(', ');
const groupsConfirm = groupsList.map(g => `'${g}'`).join(', ');
const confirm = localize('vscode-docker.commands.containers.aciContainerActionWarning.confirm', 'ACI containers can only be started or stopped in a group. This action will apply to all containers in {0}. Do you want to proceed?', groupsConfirm);

Просмотреть файл

@ -76,7 +76,7 @@ export async function downloadContainerFile(context: IActionContext, node?: File
location: vscode.ProgressLocation.Notification,
title: localize('vscode-docker.commands.containers.files.downloadContainerFile.opening', 'Downloading File(s)...')
},
async (_, token) => {
async (task, token) => {
for (const file of files) {
if (token.isCancellationRequested) {
throw new UserCancelledError();

Просмотреть файл

@ -20,7 +20,7 @@ export async function pruneContainers(context: IActionContext): Promise<void> {
const result = await ext.dockerClient.pruneContainers(context);
const mbReclaimed = convertToMB(result.SpaceReclaimed);
let message = localize('vscode-docker.commands.containers.prune.removed', 'Removed {0} container(s) and reclaimed {1} MB of space.', result.ObjectsDeleted, mbReclaimed);
const message = localize('vscode-docker.commands.containers.prune.removed', 'Removed {0} container(s) and reclaimed {1} MB of space.', result.ObjectsDeleted, mbReclaimed);
// don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showInformationMessage(message);

Просмотреть файл

@ -29,7 +29,7 @@ export async function removeContainer(context: IActionContext, node?: ContainerT
// no need to check result - cancel will throw a UserCancelledError
await ext.ui.showWarningMessage(confirmRemove, { modal: true }, { title: localize('vscode-docker.commands.containers.remove.remove', 'Remove') });
let removing: string = localize('vscode-docker.commands.containers.remove.removing', 'Removing container(s)...');
const removing: string = localize('vscode-docker.commands.containers.remove.removing', 'Removing container(s)...');
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: removing }, async () => {
await Promise.all(nodes.map(async n => await n.deleteTreeItem(context)));
});

Просмотреть файл

@ -9,13 +9,10 @@ import { localize } from '../../localize';
import { ContainerTreeItem } from '../../tree/containers/ContainerTreeItem';
export async function selectContainer(context: IActionContext): Promise<string> {
let node: ContainerTreeItem;
// Expecting running containers to change often as this is a debugging scenario.
await ext.containersTree.refresh(context);
node = await ext.containersTree.showTreeItemPicker(ContainerTreeItem.runningContainerRegExp, {
const node: ContainerTreeItem = await ext.containersTree.showTreeItemPicker(ContainerTreeItem.runningContainerRegExp, {
...context,
noItemFoundErrorMessage: localize('vscode-docker.commands.containers.select.noContainers', 'No running containers are available')
});

Просмотреть файл

@ -11,7 +11,6 @@ export async function configureDockerContextsExplorer(context: IActionContext):
await ext.contextsRoot.configureExplorer(context);
}
export async function dockerContextsHelp(_context: IActionContext): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/helpicon_dockercontext'));
export async function dockerContextsHelp(context: IActionContext): Promise<void> {
void vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/helpicon_dockercontext'));
}

Просмотреть файл

@ -57,7 +57,7 @@ export abstract class DockerInstallerBase {
let proceedInstall = true;
if (await dockerInstallStatusProvider.isDockerInstalledRealTimeCheck()) {
const reinstallMessage = localize('vscode-docker.commands.DockerInstallerBase.reInstall', 'Docker Desktop is already installed. Would you like to reinstall?');
const install = localize('vscode-docker.commands.DockerInstallerBase.reinstall', 'Reinstall')
const install = localize('vscode-docker.commands.DockerInstallerBase.reinstall', 'Reinstall');
const response = await vscode.window.showInformationMessage(reinstallMessage, ...[install]);
proceedInstall = response !== undefined;
}

Просмотреть файл

@ -16,15 +16,15 @@ interface HelpMenuItem extends vscode.QuickPickItem {
}
export async function help(context: IActionContext): Promise<void> {
let items: HelpMenuItem[] = [
const items: HelpMenuItem[] = [
{ label: localize('vscode-docker.commands.help.getStarted', 'Get started with Docker...'), handler: getStarted, telemetryID: 'getStarted' },
{ label: localize('vscode-docker.commands.help.review', 'Review Docker extension issues...'), handler: reviewIssues, telemetryID: 'reviewIssues' },
{ label: localize('vscode-docker.commands.help.report', 'Report Docker extension issue...'), handler: reportIssue, telemetryID: 'reportIssue' },
{ label: localize('vscode-docker.commands.help.editSettings', 'Edit settings...'), handler: editSettings, telemetryID: 'editSettings' }
];
const options: IAzureQuickPickOptions = { canPickMany: false, suppressPersistence: true }
let selectedItem: HelpMenuItem = await ext.ui.showQuickPick(items, options);
const options: IAzureQuickPickOptions = { canPickMany: false, suppressPersistence: true };
const selectedItem: HelpMenuItem = await ext.ui.showQuickPick(items, options);
context.telemetry.properties.helpItem = selectedItem.telemetryID;
await selectedItem.handler();
}

Просмотреть файл

@ -20,7 +20,7 @@ export async function pruneImages(context: IActionContext): Promise<void> {
const result = await ext.dockerClient.pruneImages(context);
const mbReclaimed = convertToMB(result.SpaceReclaimed);
let message = localize('vscode-docker.commands.images.prune.removed', 'Removed {0} image(s) and reclaimed {1} MB of space.', result.ObjectsDeleted, mbReclaimed);
const message = localize('vscode-docker.commands.images.prune.removed', 'Removed {0} image(s) and reclaimed {1} MB of space.', result.ObjectsDeleted, mbReclaimed);
// don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showInformationMessage(message);

Просмотреть файл

@ -29,7 +29,7 @@ export async function removeImage(context: IActionContext, node?: ImageTreeItem,
// no need to check result - cancel will throw a UserCancelledError
await ext.ui.showWarningMessage(confirmRemove, { modal: true }, { title: 'Remove' });
let removing: string = localize('vscode-docker.commands.images.remove.removing', 'Removing image(s)...');
const removing: string = localize('vscode-docker.commands.images.remove.removing', 'Removing image(s)...');
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: removing }, async () => {
await Promise.all(nodes.map(async n => await n.deleteTreeItem(context)));
});

Просмотреть файл

@ -12,7 +12,7 @@ import { executeAsTask } from '../../utils/executeAsTask';
import { getDockerOSType } from '../../utils/osUtils';
export async function runAzureCliImage(context: IActionContext): Promise<void> {
let osType = await getDockerOSType(context);
const osType = await getDockerOSType(context);
context.telemetry.properties.dockerOSType = osType;
if (osType === "windows") {

Просмотреть файл

@ -28,7 +28,7 @@ export async function tagImage(context: IActionContext, node?: ImageTreeItem, re
}
export async function getTagFromUserInput(fullTag: string, baseImagePath?: string): Promise<string> {
let opt: vscode.InputBoxOptions = {
const opt: vscode.InputBoxOptions = {
ignoreFocusOut: true,
prompt: localize('vscode-docker.commands.images.tag.tagAs', 'Tag image as...'),
};
@ -66,22 +66,22 @@ const KnownRegistries: { type: string, regex: RegExp }[] = [
export function addImageTaggingTelemetry(context: IActionContext, fullImageName: string, propertyPostfix: '.before' | '.after' | ''): void {
try {
let properties: TelemetryProperties = {};
const properties: TelemetryProperties = {};
let [, repository, tag] = /^(.*):(.*)$/.exec(fullImageName) ?? [undefined, fullImageName, ''];
const [, repository, tag] = /^(.*):(.*)$/.exec(fullImageName) ?? [undefined, fullImageName, ''];
if (!!tag.match(/^[0-9.-]*(|alpha|beta|latest|edge|v|version)?[0-9.-]*$/)) {
properties.safeTag = tag
properties.safeTag = tag;
}
properties.hasTag = String(!!tag);
properties.numSlashes = String(numberMatches(repository.match(/\//g)));
let knownRegistry = KnownRegistries.find(kr => !!repository.match(kr.regex));
const knownRegistry = KnownRegistries.find(kr => !!repository.match(kr.regex));
if (knownRegistry) {
properties.registryType = knownRegistry.type;
}
for (let propertyName of Object.keys(properties)) {
for (const propertyName of Object.keys(properties)) {
context.telemetry.properties[propertyName + propertyPostfix] = properties[propertyName];
}
} catch (error) {

Просмотреть файл

@ -18,7 +18,7 @@ export async function pruneNetworks(context: IActionContext): Promise<void> {
async () => {
const result = await ext.dockerClient.pruneNetworks(context);
let message = localize('vscode-docker.commands.networks.prune.removed', 'Removed {0} network(s).', result.ObjectsDeleted);
const message = localize('vscode-docker.commands.networks.prune.removed', 'Removed {0} network(s).', result.ObjectsDeleted);
// don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showInformationMessage(message);

Просмотреть файл

@ -29,7 +29,7 @@ export async function removeNetwork(context: IActionContext, node?: NetworkTreeI
// no need to check result - cancel will throw a UserCancelledError
await ext.ui.showWarningMessage(confirmRemove, { modal: true }, { title: localize('vscode-docker.commands.networks.remove.remove', 'Remove') });
let removing: string = localize('vscode-docker.commands.networks.remove.removing', 'Removing network(s)...');
const removing: string = localize('vscode-docker.commands.networks.remove.removing', 'Removing network(s)...');
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: removing }, async () => {
await Promise.all(nodes.map(async n => await n.deleteTreeItem(context)));
});

Просмотреть файл

@ -23,7 +23,7 @@ export async function pruneSystem(context: IActionContext): Promise<void> {
const volumesResult = await ext.dockerClient.pruneVolumes(context);
const mbReclaimed = convertToMB(containersResult.SpaceReclaimed + imagesResult.SpaceReclaimed + volumesResult.SpaceReclaimed);
let message = localize('vscode-docker.commands.pruneSystem.removed', 'Removed {0} container(s), {1} image(s), {2} network(s), {3} volume(s) and reclaimed {4} MB of space.', containersResult.ObjectsDeleted, imagesResult.ObjectsDeleted, networksResult.ObjectsDeleted, volumesResult.ObjectsDeleted, mbReclaimed);
const message = localize('vscode-docker.commands.pruneSystem.removed', 'Removed {0} container(s), {1} image(s), {2} network(s), {3} volume(s) and reclaimed {4} MB of space.', containersResult.ObjectsDeleted, imagesResult.ObjectsDeleted, networksResult.ObjectsDeleted, volumesResult.ObjectsDeleted, mbReclaimed);
// don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showInformationMessage(message);

Просмотреть файл

@ -63,8 +63,8 @@ async function verifyIsRunningInWorkspace(context: IActionContext): Promise<void
updateExtensionKind('workspace');
context.telemetry.properties.cancelStep = 'requiresReload';
let reloadMessage: string = localize('vscode-docker.commands.registerWorkspaceCommands.reloadRequired', 'This change to the Docker extension requires reloading VS Code to take effect.');
let reload: MessageItem = { title: localize('vscode-docker.commands.registerWorkspaceCommands.reload', 'Reload Now') };
const reloadMessage: string = localize('vscode-docker.commands.registerWorkspaceCommands.reloadRequired', 'This change to the Docker extension requires reloading VS Code to take effect.');
const reload: MessageItem = { title: localize('vscode-docker.commands.registerWorkspaceCommands.reload', 'Reload Now') };
await ext.ui.showWarningMessage(reloadMessage, reload);
// Add a one-off event here before reloading the window otherwise we'll lose telemetry for this code path

Просмотреть файл

@ -32,8 +32,8 @@ export class DockerWebhookCreateStep extends AzureWizardExecuteStep<IAppServiceW
const vscAzureAppService = await import('vscode-azureappservice');
vscAzureAppService.registerAppServiceExtensionVariables(ext);
const site: WebSiteManagementModels.Site = nonNullProp(context, 'site');
let siteClient = new vscAzureAppService.SiteClient(site, context);
let appUri: string = (await siteClient.getWebAppPublishCredential()).scmUri;
const siteClient = new vscAzureAppService.SiteClient(site, context);
const appUri: string = (await siteClient.getWebAppPublishCredential()).scmUri;
if (this._treeItem.parent instanceof AzureRepositoryTreeItem) {
const creatingNewWebhook: string = localize('vscode-docker.commands.registries.azure.dockerWebhook.creatingWebhook', 'Creating webhook for web app "{0}"...', context.newSiteName);
ext.outputChannel.appendLine(creatingNewWebhook);
@ -83,7 +83,7 @@ export class DockerWebhookCreateStep extends AzureWizardExecuteStep<IAppServiceW
const registryTreeItem: AzureRegistryTreeItem = (<AzureRepositoryTreeItem>node.parent).parent;
const armContainerRegistry = await import('@azure/arm-containerregistry');
const crmClient = createAzureClient(registryTreeItem.parent.root, armContainerRegistry.ContainerRegistryManagementClient);
let webhookCreateParameters: AcrModels.WebhookCreateParameters = {
const webhookCreateParameters: AcrModels.WebhookCreateParameters = {
location: registryTreeItem.registryLocation,
serviceUri: appUri,
scope: `${node.parent.repoName}:${node.tag}`,

Просмотреть файл

@ -73,7 +73,9 @@ async function getImagePorts(fullTag: string): Promise<number[]> {
const portParts = portAndProtocol.split('/');
result.push(Number.parseInt(portParts[0], 10));
}
} catch { } // Best effort
} catch {
// Best effort
}
return result;
} catch (err) {

Просмотреть файл

@ -83,11 +83,11 @@ export async function deployImageToAzure(context: IActionContext, node?: RemoteT
}
async function getNewSiteConfig(node: RemoteTagTreeItem): Promise<WebSiteManagementModels.SiteConfig> {
let registryTI: RegistryTreeItemBase = node.parent.parent;
const registryTI: RegistryTreeItemBase = node.parent.parent;
let username: string | undefined;
let password: string | undefined;
let appSettings: WebSiteManagementModels.NameValuePair[] = [];
const appSettings: WebSiteManagementModels.NameValuePair[] = [];
if (registryTI instanceof AzureRegistryTreeItem) {
appSettings.push({ name: "DOCKER_ENABLE_CI", value: 'true' });
@ -118,7 +118,7 @@ async function getNewSiteConfig(node: RemoteTagTreeItem): Promise<WebSiteManagem
appSettings.push({ name: "DOCKER_REGISTRY_SERVER_PASSWORD", value: password });
}
let linuxFxVersion = `DOCKER|${registryTI.baseImagePath}/${node.repoNameAndTag}`;
const linuxFxVersion = `DOCKER|${registryTI.baseImagePath}/${node.repoNameAndTag}`;
return {
linuxFxVersion,

Просмотреть файл

@ -16,8 +16,8 @@ export async function runAzureTask(context: IActionContext, node?: AzureTaskTree
}
const registryTI = node.parent.parent;
let runRequest: AcrModels.TaskRunRequest = { type: 'TaskRunRequest', taskId: node.id };
let run = await (await registryTI.getClient()).registries.scheduleRun(registryTI.resourceGroup, registryTI.registryName, runRequest);
const runRequest: AcrModels.TaskRunRequest = { type: 'TaskRunRequest', taskId: node.id };
const run = await (await registryTI.getClient()).registries.scheduleRun(registryTI.resourceGroup, registryTI.registryName, runRequest);
await node.parent.refresh(context);
// don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */

Просмотреть файл

@ -22,7 +22,7 @@ import { bufferToString } from "../../../../utils/spawnAsync";
import { addImageTaggingTelemetry, getTagFromUserInput } from '../../../images/tagImage';
const idPrecision = 6;
const vcsIgnoreList = ['.git', '.gitignore', '.bzr', 'bzrignore', '.hg', '.hgignore', '.svn']
const vcsIgnoreList = ['.git', '.gitignore', '.bzr', 'bzrignore', '.hg', '.hgignore', '.svn'];
export async function scheduleRunRequest(context: IActionContext, requestType: 'DockerBuildRequest' | 'FileTaskRunRequest', uri: vscode.Uri | undefined): Promise<void> {
// Acquire information.
@ -69,7 +69,7 @@ export async function scheduleRunRequest(context: IActionContext, requestType: '
taskFilePath: fileItem.relativeFilePath,
sourceLocation: uploadedSourceLocation,
platform: { os: osType }
}
};
}
// Schedule the run and Clean up.
@ -83,9 +83,9 @@ export async function scheduleRunRequest(context: IActionContext, requestType: '
}
async function quickPickImageName(context: IActionContext, rootFolder: vscode.WorkspaceFolder, dockerFileItem: Item | undefined): Promise<string> {
let absFilePath: string = path.join(rootFolder.uri.fsPath, dockerFileItem.relativeFilePath);
let dockerFileKey = `ACR_buildTag_${absFilePath}`;
let prevImageName: string | undefined = ext.context.globalState.get(dockerFileKey);
const absFilePath: string = path.join(rootFolder.uri.fsPath, dockerFileItem.relativeFilePath);
const dockerFileKey = `ACR_buildTag_${absFilePath}`;
const prevImageName: string | undefined = ext.context.globalState.get(dockerFileKey);
let suggestedImageName: string;
if (!prevImageName) {
@ -95,7 +95,7 @@ async function quickPickImageName(context: IActionContext, rootFolder: vscode.Wo
suggestedImageName = path.basename(rootFolder.uri.fsPath).toLowerCase().replace(/\s/g, '');
}
suggestedImageName += ":{{.Run.ID}}"
suggestedImageName += ":{{.Run.ID}}";
} else {
suggestedImageName = prevImageName;
}
@ -113,16 +113,16 @@ async function quickPickImageName(context: IActionContext, rootFolder: vscode.Wo
async function uploadSourceCode(client: ContainerRegistryManagementClient, registryName: string, resourceGroupName: string, rootFolder: vscode.WorkspaceFolder, tarFilePath: string): Promise<string> {
ext.outputChannel.appendLine(localize('vscode-docker.commands.registries.azure.tasks.sendingSource', ' Sending source code to temp file'));
let source: string = rootFolder.uri.fsPath;
const source: string = rootFolder.uri.fsPath;
let items = await fse.readdir(source);
items = items.filter(i => !(i in vcsIgnoreList));
// tslint:disable-next-line:no-unsafe-any
tar.c({ cwd: source }, items).pipe(fse.createWriteStream(tarFilePath));
ext.outputChannel.appendLine(localize('vscode-docker.commands.registries.azure.tasks.gettingBuildSourceUploadUrl', ' Getting build source upload URL'));
let sourceUploadLocation = await client.registries.getBuildSourceUploadUrl(resourceGroupName, registryName);
let uploadUrl: string = sourceUploadLocation.uploadUrl;
let relativePath: string = sourceUploadLocation.relativePath;
const sourceUploadLocation = await client.registries.getBuildSourceUploadUrl(resourceGroupName, registryName);
const uploadUrl: string = sourceUploadLocation.uploadUrl;
const relativePath: string = sourceUploadLocation.relativePath;
const storageBlob = await import('@azure/storage-blob');
const blobClient = new storageBlob.BlockBlobClient(uploadUrl);

Просмотреть файл

@ -18,8 +18,8 @@ export async function logInToDockerCli(context: IActionContext, node?: RegistryT
node = await ext.registriesTree.showTreeItemPicker<RegistryTreeItemBase>(registryExpectedContextValues.all.registry, context);
}
let creds = await node.getDockerCliCredentials();
let auth: { username?: string, password?: string, token?: string } = creds.auth || {};
const creds = await node.getDockerCliCredentials();
const auth: { username?: string, password?: string, token?: string } = creds.auth || {};
let username: string | undefined;
let password: string | undefined;
if (auth.token) {

Просмотреть файл

@ -14,6 +14,6 @@ export async function logOutOfDockerCli(context: IActionContext, node?: Registry
node = await ext.registriesTree.showTreeItemPicker<RegistryTreeItemBase>(registryExpectedContextValues.all.registry, context);
}
let creds = await node.getDockerCliCredentials();
const creds = await node.getDockerCliCredentials();
await executeAsTask(context, `docker logout ${creds.registryPath}`, 'Docker', { addDockerEnv: true });
}

Просмотреть файл

@ -55,7 +55,7 @@ export async function selectRunCommand(context: IActionContext, fullTag: string,
let portsString: string = '';
if (exposedPorts) {
portsString = Object.keys(exposedPorts).reduce((partialPortsString: string, portAndProtocol: string) => {
return `${partialPortsString} -p ${portAndProtocol.split('/')[0]}:${portAndProtocol}`
return `${partialPortsString} -p ${portAndProtocol.split('/')[0]}:${portAndProtocol}`;
}, portsString);
}
@ -94,7 +94,7 @@ export async function selectComposeCommand(context: IActionContext, folder: vsco
composeCommand === 'up' ? 'composeUp' : 'composeDown',
[folder.name, configurationFile],
folder,
{ 'configurationFile': configurationFile ? `-f \"${configurationFile}\"` : '', 'detached': detached ? '-d' : '', 'build': build ? '--build' : '' }
{ 'configurationFile': configurationFile ? `-f "${configurationFile}"` : '', 'detached': detached ? '-d' : '', 'build': build ? '--build' : '' }
);
}
@ -175,7 +175,7 @@ async function quickPickTemplate(context: IActionContext, templates: CommandTemp
label: template.label,
detail: template.template,
data: template,
}
};
});
const selection = await ext.ui.showQuickPick(items, {

Просмотреть файл

@ -66,7 +66,9 @@ class StartPage {
let showWhatsNew = false;
try {
showWhatsNew = !!(await ext.experimentationService.isLiveFlightEnabled('vscode-docker.whatsNew'));
} catch { } // Best effort
} catch {
// Best effort
}
const startPageContext: StartPageContext = {
cspSource: webview.cspSource,

Просмотреть файл

@ -20,7 +20,7 @@ export async function pruneVolumes(context: IActionContext): Promise<void> {
const result = await ext.dockerClient.pruneVolumes(context);
const mbReclaimed = convertToMB(result.SpaceReclaimed);
let message = localize('vscode-docker.commands.volumes.prune.removed', 'Removed {0} volume(s) and reclaimed {1} MB of space.', result.ObjectsDeleted, mbReclaimed);
const message = localize('vscode-docker.commands.volumes.prune.removed', 'Removed {0} volume(s) and reclaimed {1} MB of space.', result.ObjectsDeleted, mbReclaimed);
// don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showInformationMessage(message);

Просмотреть файл

@ -29,7 +29,7 @@ export async function removeVolume(context: IActionContext, node?: VolumeTreeIte
// no need to check result - cancel will throw a UserCancelledError
await ext.ui.showWarningMessage(confirmRemove, { modal: true }, { title: localize('vscode-docker.commands.volumes.remove.remove', 'Remove') });
let removing: string = localize('vscode-docker.commands.volumes.remove.removing', 'Removing volume(s)...');
const removing: string = localize('vscode-docker.commands.volumes.remove.removing', 'Removing volume(s)...');
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: removing }, async () => {
await Promise.all(nodes.map(async n => await n.deleteTreeItem(context)));
});

Просмотреть файл

@ -11,10 +11,6 @@ export const configPrefix: string = 'docker';
// Consider downloading multiple pages (images, tags, etc)
export const PAGE_SIZE = 100;
export namespace configurationKeys {
export const groupImagesBy = 'groupImagesBy';
}
// Credentials Constants
export const NULL_GUID = '00000000-0000-0000-0000-000000000000'; // Empty GUID is a special username to indicate the login credential is based on JWT token.
@ -22,7 +18,7 @@ export const NULL_GUID = '00000000-0000-0000-0000-000000000000'; // Empty GUID i
export const imageTagRegExp = new RegExp('^[a-zA-Z0-9.-_/]{1,256}:(?![.-])[a-zA-Z0-9.-_]{1,128}$');
// GLOB Patterns
export const FROM_DIRECTIVE_PATTERN = /^\s*FROM\s*([\w-\/:]*)(\s*AS\s*[a-z][a-z0-9-_\\.]*)?$/i;
export const FROM_DIRECTIVE_PATTERN = /^\s*FROM\s*([\w-/:]*)(\s*AS\s*[a-z][a-z0-9-_\\.]*)?$/i;
export const COMPOSE_FILE_GLOB_PATTERN = '**/*[cC][oO][mM][pP][oO][sS][eE]*.{[yY][aA][mM][lL],[yY][mM][lL]}';
export const DOCKERFILE_GLOB_PATTERN = '**/{*.[dD][oO][cC][kK][eE][rR][fF][iI][lL][eE],[dD][oO][cC][kK][eE][rR][fF][iI][lL][eE]}';
export const YAML_GLOB_PATTERN = '**/*.{[yY][aA][mM][lL],[yY][mM][lL]}';

Просмотреть файл

@ -91,7 +91,7 @@ export function inferContainerName(debugConfiguration: DockerDebugConfiguration,
}
export function resolveDockerServerReadyAction(debugConfiguration: DockerDebugConfiguration, defaultDockerSRA: DockerServerReadyAction, createIfUserUndefined: boolean): DockerServerReadyAction | undefined {
let numBrowserOptions = [debugConfiguration.launchBrowser, debugConfiguration.serverReadyAction, debugConfiguration.dockerServerReadyAction].filter(item => item !== undefined).length;
const numBrowserOptions = [debugConfiguration.launchBrowser, debugConfiguration.serverReadyAction, debugConfiguration.dockerServerReadyAction].filter(item => item !== undefined).length;
if (numBrowserOptions > 1) {
// Multiple user-provided options is not valid
@ -101,7 +101,7 @@ export function resolveDockerServerReadyAction(debugConfiguration: DockerDebugCo
return undefined;
} else if (numBrowserOptions === 0 && !createIfUserUndefined) {
// No user-provided option, and not creating if nothing user-defined--return nothing
return undefined
return undefined;
}
// Otherwise create one based on user-defined and default options

Просмотреть файл

@ -142,7 +142,9 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi
!(configuration?.subProcessId)) { // Must not have subProcessId, i.e. not a subprocess debug session (which is how Python does hot reload sessions)
try {
await ext.dockerClient.removeContainer(context, configuration.dockerOptions.containerName);
} catch { } // Best effort
} catch {
// Best effort
}
}
}
@ -171,7 +173,9 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi
ext.outputChannel.appendLine(localize('vscode-docker.debug.configProvider.portMappings', 'The application is listening on the following port(s) (Host => Container):'));
ext.outputChannel.appendLine(portMappings.join('\n'));
}
} catch { } // Best effort
} catch {
// Best effort
}
}
}
}

Просмотреть файл

@ -40,31 +40,27 @@ export class DockerDebugScaffoldingProvider implements IDockerDebugScaffoldingPr
public async initializeNetCoreForDebugging(context: DockerDebugScaffoldContext, options?: NetCoreScaffoldingOptions): Promise<void> {
await this.initializeForDebugging(
context,
/* eslint-disable @typescript-eslint/promise-function-async */
() => netCoreDebugHelper.provideDebugConfigurations(context, options),
() => netCoreTaskHelper.provideDockerBuildTasks(context, options),
() => netCoreTaskHelper.provideDockerRunTasks(context, options));
/* eslint-enable @typescript-eslint/promise-function-async */
() => netCoreTaskHelper.provideDockerRunTasks(context, options)
);
}
public async initializeNodeForDebugging(context: DockerDebugScaffoldContext, options?: NodeScaffoldingOptions): Promise<void> {
await this.initializeForDebugging(
context,
/* eslint-disable @typescript-eslint/promise-function-async */
() => nodeDebugHelper.provideDebugConfigurations(context, options),
() => nodeTaskHelper.provideDockerBuildTasks(context, options),
() => nodeTaskHelper.provideDockerRunTasks(context, options));
/* eslint-enable @typescript-eslint/promise-function-async */
() => nodeTaskHelper.provideDockerRunTasks(context, options)
);
}
public async initializePythonForDebugging(context: DockerDebugScaffoldContext, options?: PythonScaffoldingOptions): Promise<void> {
await this.initializeForDebugging(
context,
/* eslint-disable @typescript-eslint/promise-function-async */
() => pythonDebugHelper.provideDebugConfigurations(context, options),
() => pythonTaskHelper.provideDockerBuildTasks(context),
() => pythonTaskHelper.provideDockerRunTasks(context, options)
/* eslint-enable @typescript-eslint/promise-function-async */
);
}
@ -80,17 +76,17 @@ export class DockerDebugScaffoldingProvider implements IDockerDebugScaffoldingPr
const debugConfigurations = await provideDebugConfigurations();
for (const buildTask of buildTasks) {
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
// eslint-disable-next-line @typescript-eslint/naming-convention
overwrite = await DockerDebugScaffoldingProvider.addObjectWithOverwritePrompt((_overwrite?: boolean) => addTask(buildTask, context.folder, _overwrite), overwrite);
}
for (const runTask of runTasks) {
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
// eslint-disable-next-line @typescript-eslint/naming-convention
overwrite = await DockerDebugScaffoldingProvider.addObjectWithOverwritePrompt((_overwrite?: boolean) => addTask(runTask, context.folder, _overwrite), overwrite);
}
for (const debugConfiguration of debugConfigurations) {
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
// eslint-disable-next-line @typescript-eslint/naming-convention
overwrite = await DockerDebugScaffoldingProvider.addObjectWithOverwritePrompt((_overwrite?: boolean) => addDebugConfiguration(debugConfiguration, context.folder, _overwrite), overwrite);
}
}

Просмотреть файл

@ -14,7 +14,7 @@ interface DockerPlatformConfiguration {
export function getPlatform<T extends DockerPlatformConfiguration>(configuration: T): DockerPlatform | undefined {
if (configuration.platform === 'netCore' || configuration.netCore !== undefined) {
return 'netCore'
return 'netCore';
} else if (configuration.platform === 'node' || configuration.node !== undefined) {
return 'node';
} else if (configuration.platform === 'python' || configuration.python !== undefined) {

Просмотреть файл

@ -65,8 +65,7 @@ class ServerReadyDetector implements DockerServerReadyDetector {
// verify that format does not contain '%s'
if (format.indexOf('%s') >= 0) {
const errMsg = localize('vscode-docker.debug.serverReady.noCapture', 'Format uri (\'{0}\') uses a substitution placeholder but pattern did not capture anything.', format);
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showErrorMessage(errMsg, { modal: true }).then(_ => undefined);
void vscode.window.showErrorMessage(errMsg, { modal: true });
return;
}
captureString = format;
@ -76,8 +75,7 @@ class ServerReadyDetector implements DockerServerReadyDetector {
const s = format.split('%s');
if (s.length !== 2) {
const errMsg = localize('vscode-docker.debug.serverReady.oneSubstitution', 'Format uri (\'{0}\') must contain exactly one substitution placeholder.', format);
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showErrorMessage(errMsg, { modal: true }).then(_ => undefined);
void vscode.window.showErrorMessage(errMsg, { modal: true });
return;
}
@ -95,8 +93,7 @@ class ServerReadyDetector implements DockerServerReadyDetector {
if (containerPort === undefined) {
const errMsg = localize('vscode-docker.debug.serverReady.noCapturedPort', 'Captured string (\'{0}\') must contain a port number.', captureString);
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showErrorMessage(errMsg, { modal: true }).then(_ => undefined);
void vscode.window.showErrorMessage(errMsg, { modal: true });
return;
}
@ -118,8 +115,7 @@ class ServerReadyDetector implements DockerServerReadyDetector {
captureString = util.format(format, containerProtocol, hostPort);
} else {
const errMsg = localize('vscode-docker.debug.serverReady.twoSubstitutions', 'Format uri (\'{0}\') must contain exactly two substitution placeholders.', format);
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showErrorMessage(errMsg, { modal: true }).then(_ => undefined);
void vscode.window.showErrorMessage(errMsg, { modal: true });
return;
}
}
@ -131,7 +127,7 @@ class ServerReadyDetector implements DockerServerReadyDetector {
private getContainerProtocol(containerUrl: string): string {
const httpsRegex = /https:\/\//i; // Matches https://
return httpsRegex.test(containerUrl) ? 'https' : 'http'
return httpsRegex.test(containerUrl) ? 'https' : 'http';
}
private getContainerPort(containerUrl: string): number | undefined {
@ -155,10 +151,8 @@ class ServerReadyDetector implements DockerServerReadyDetector {
vscode.env.openExternal(vscode.Uri.parse(uri));
break;
case 'debugWithChrome':
const remoteName = 'remoteName';
if (vscode.env[remoteName] === 'wsl' || !!vscode.extensions.getExtension('msjsdiag.debugger-for-chrome')) {
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.debug.startDebugging(
if (vscode.env['remoteName'] === 'wsl' || !!vscode.extensions.getExtension('msjsdiag.debugger-for-chrome')) {
void vscode.debug.startDebugging(
session.workspaceFolder,
{
type: 'chrome',
@ -169,8 +163,7 @@ class ServerReadyDetector implements DockerServerReadyDetector {
});
} else {
const errMsg = localize('vscode-docker.debug.serverReady.noChrome', 'The action \'debugWithChrome\' requires the \'Debugger for Chrome\' extension.');
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
vscode.window.showErrorMessage(errMsg, { modal: true }).then(_ => undefined);
void vscode.window.showErrorMessage(errMsg, { modal: true });
}
break;
default:
@ -258,7 +251,7 @@ class DockerDebugAdapterTracker extends vscode.Disposable implements vscode.Debu
class MultiOutputDockerServerReadyManager extends vscode.Disposable implements DockerServerReadyDetector {
private readonly detector: ServerReadyDetector;
private readonly logsTracker: DockerLogsTracker;
private readonly _tracker: DockerDebugAdapterTracker;
public readonly tracker: DockerDebugAdapterTracker;
public constructor(session: vscode.DebugSession) {
super(
@ -267,7 +260,7 @@ class MultiOutputDockerServerReadyManager extends vscode.Disposable implements D
this.logsTracker.dispose();
}
this._tracker.dispose();
this.tracker.dispose();
});
this.detector = new ServerReadyDetector(session);
@ -278,7 +271,7 @@ class MultiOutputDockerServerReadyManager extends vscode.Disposable implements D
this.logsTracker = new DockerLogsTracker(configuration.dockerOptions.dockerServerReadyAction.containerName, this);
}
this._tracker = new DockerDebugAdapterTracker(this);
this.tracker = new DockerDebugAdapterTracker(this);
}
public detectPattern(output: string): void {
@ -286,10 +279,6 @@ class MultiOutputDockerServerReadyManager extends vscode.Disposable implements D
this.dispose();
}
}
public get tracker(): DockerDebugAdapterTracker {
return this._tracker;
}
}
class DockerDebugAdapterTrackerFactory implements vscode.DebugAdapterTrackerFactory {

Просмотреть файл

@ -28,7 +28,7 @@ export async function trustCertificateIfNecessary(): Promise<void> {
if (isWindows()) {
if (!(await isCertificateTrusted())) {
const trust: MessageItem = { title: localize('vscode-docker.debugging.netCore.trust', 'Trust') };
const message = localize('vscode-docker.debugging.netCore.notTrusted', 'The ASP.NET Core HTTPS development certificate is not trusted. To trust the certificate, run \`dotnet dev-certs https --trust\`, or click "Trust" below.');
const message = localize('vscode-docker.debugging.netCore.notTrusted', 'The ASP.NET Core HTTPS development certificate is not trusted. To trust the certificate, run `dotnet dev-certs https --trust`, or click "Trust" below.');
// Don't wait
void ext.ui
@ -42,7 +42,7 @@ export async function trustCertificateIfNecessary(): Promise<void> {
}
} else if (isMac()) {
if (!(await isCertificateTrusted())) {
const message = localize('vscode-docker.debugging.netCore.notTrustedRunManual', 'The ASP.NET Core HTTPS development certificate is not trusted. To trust the certificate, run \`dotnet dev-certs https --trust\`.');
const message = localize('vscode-docker.debugging.netCore.notTrustedRunManual', 'The ASP.NET Core HTTPS development certificate is not trusted. To trust the certificate, run `dotnet dev-certs https --trust`.');
// Don't wait
void ext.ui.showWarningMessage(

Просмотреть файл

@ -194,7 +194,7 @@ export class NetCoreDebugHelper implements DebugHelper {
configureSsl: !!(associatedTask?.netCore?.configureSsl),
containerName: inferContainerName(debugConfiguration, context, context.folder.name),
platformOS: associatedTask?.dockerRun?.os || 'Linux',
}
};
}
private async acquireDebuggers(platformOS: PlatformOS): Promise<void> {
@ -291,7 +291,7 @@ export class NetCoreDebugHelper implements DebugHelper {
.withQuotedArg(containerOS === 'windows' ? `IF EXIST "${debuggerPath}" (echo true) else (echo false)` : `if [ -f ${debuggerPath} ]; then echo true; fi;`)
.build();
const { stdout } = await execAsync(command)
const { stdout } = await execAsync(command);
return /true/ig.test(stdout);
}

Просмотреть файл

@ -45,7 +45,7 @@ export class NodeDebugHelper implements DebugHelper {
if (nodeOptions) {
// localRoot must match the build context
nodeOptions.localRoot = unresolveWorkspaceFolder(path.dirname(options.package), context.folder)
nodeOptions.localRoot = unresolveWorkspaceFolder(path.dirname(options.package), context.folder);
}
return [

Просмотреть файл

@ -78,13 +78,17 @@ export class DockerContextManager implements ContextManager, Disposable {
if (fse.existsSync(dockerConfigFile)) {
this.configFileWatcher = fs.watch(dockerConfigFile, async () => this.refresh());
}
} catch { } // Best effort
} catch {
// Best effort
}
try {
if (fse.existsSync(dockerContextsFolder)) {
this.contextFolderWatcher = fs.watch(dockerContextsFolder, async () => this.refresh());
}
} catch { } // Best effort
} catch {
// Best effort
}
}
public dispose(): void {
@ -256,6 +260,7 @@ export class DockerContextManager implements ContextManager, Disposable {
// Setting the DOCKER_CONTEXT environment variable to whatever is passed along means the CLI will always
// return that specified context as Current = true. This way we don't need extra logic below in parsing.
// TODO: eventually change to `docker context ls --format json`
// eslint-disable-next-line @typescript-eslint/naming-convention
const { stdout } = await execAsync('docker context ls --format="{{json .}}"', { ...ContextCmdExecOptions, env: { ...process.env, DOCKER_CONTEXT: dockerContextEnv } });
try {
@ -283,7 +288,7 @@ export class DockerContextManager implements ContextManager, Disposable {
if (currentContext.Name === 'default') {
actionContext.telemetry.properties.hostSource = 'defaultContextSelected';
} else {
actionContext.telemetry.properties.hostSource = 'customContextSelected'
actionContext.telemetry.properties.hostSource = 'customContextSelected';
}
try {
@ -339,7 +344,9 @@ export class DockerContextManager implements ContextManager, Disposable {
// Set the VSCode context to the result (which may expose commands, etc.)
this.setVsCodeContext('vscode-docker:newCliPresent', result);
return result;
} catch { } // Best effort
} catch {
// Best effort
}
}
private setVsCodeContext(vsCodeContext: VSCodeContext, value: boolean): void {

Просмотреть файл

@ -7,7 +7,7 @@ import { Container } from '@docker/sdk/containers';
import { DockerContainer, InspectionPort } from '../Containers';
// Group 1 is container group name; group 2 is container name
const containerGroupAndName = /(?:([a-z0-9\-]+)_)?([a-z0-9\-]+)/i;
const containerGroupAndName = /(?:([a-z0-9-]+)_)?([a-z0-9-]+)/i;
export function containerToDockerContainer(container: Container.AsObject): DockerContainer | undefined {
if (!container) {

Просмотреть файл

@ -19,10 +19,10 @@ import { DockerContainer, DockerContainerInspection } from '../Containers';
import { ContextChangeCancelClient } from '../ContextChangeCancelClient';
import { DockerContext } from '../Contexts';
import { DockerApiClient, DockerExecCommandProvider, DockerExecOptions } from '../DockerApiClient';
import { DockerImage, DockerImageInspection } from '../Images';
import { DockerImage, DockerImageInspection, ImageInspectionContainers } from '../Images';
import { DockerNetwork, DockerNetworkInspection, DriverType } from '../Networks';
import { DockerVersion } from '../Version';
import { DockerVolume, DockerVolumeInspection } from '../Volumes';
import { DockerVolume, DockerVolumeInspection, VolumeInspectionContainers } from '../Volumes';
import { getContainerName, getFullTagFromDigest, refreshDockerode } from './DockerodeUtils';
// 20 s timeout for all calls (enough time for any call, but short enough to be UX-reasonable)
@ -53,7 +53,7 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
Name: getContainerName(ci),
CreatedTime: ci.Created * 1000,
State: ci.State,
}
};
});
}
@ -84,7 +84,7 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
dockerCommand += `"${ref}" ${commandProvider('windows').join(' ')}`;
// Copy the Docker environment settings in
let newEnv: NodeJS.ProcessEnv = cloneObject(process.env);
const newEnv: NodeJS.ProcessEnv = cloneObject(process.env);
addDockerSettingsToEnv(newEnv, process.env);
const { stdout, stderr } = await execStreamAsync(dockerCommand, { env: newEnv }, token);
@ -105,8 +105,8 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
return new Promise<{ stdout: string, stderr: string }>(
(resolve, reject) => {
const stdoutChunks = [];
const stderrChunks = [];
const stdoutChunks: Buffer[] = [];
const stderrChunks: Buffer[] = [];
const stdout = new stream.PassThrough();
const stderr = new stream.PassThrough();
@ -169,7 +169,7 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
// This is the first entry, so extract its content...
//
const chunks = [];
const chunks: Buffer[] = [];
entryStream.on('data', chunk => {
chunks.push(chunk);
@ -288,7 +288,7 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
// Sorely missing in the inspect result for an image is the containers using it, so we will add that in, in the same-ish shape as networks' inspect result
const containersUsingImage = await this.callWithErrorHandling(context, async () => this.dockerodeClient.listContainers({ filters: { 'ancestor': [result.Id] }, all: true }));
const containersObject = {};
const containersObject: ImageInspectionContainers = {};
for (const container of containersUsingImage) {
containersObject[container.Id] = { Name: getContainerName(container) };
}
@ -329,7 +329,7 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
...ni,
Driver: ni.Driver as DriverType,
CreatedTime: new Date(ni.Created).valueOf(),
}
};
});
}
@ -369,7 +369,7 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
// eslint-disable-next-line @typescript-eslint/no-explicit-any
CreatedTime: new Date((vi as any).CreatedAt).valueOf(),
Id: undefined, // Not defined for volumes
}
};
});
}
@ -380,7 +380,7 @@ export class DockerodeApiClient extends ContextChangeCancelClient implements Doc
// Sorely missing in the inspect result for a volume is the containers using it, so we will add that in, in the same-ish shape as networks' inspect result
const containersUsingVolume = await this.callWithErrorHandling(context, async () => this.dockerodeClient.listContainers({ filters: { 'volume': [ref] } }));
const containersObject = {};
const containersObject: VolumeInspectionContainers = {};
for (const container of containersUsingVolume) {
const destination = container.Mounts?.find(m => m.Name === volume.name)?.Destination;
containersObject[container.Id] = { Name: getContainerName(container), Destination: destination || localize('vscode-docker.utils.dockerode.unknownDestination', '<Unknown>') };

Просмотреть файл

@ -16,7 +16,7 @@ import { DockerContext } from '../Contexts';
export function getFullTagFromDigest(image: Dockerode.ImageInfo): string {
let repo = '<none>';
let tag = '<none>';
const tag = '<none>';
const digest = image.RepoDigests[0];
if (digest) {

Просмотреть файл

@ -10,6 +10,12 @@ export interface DockerImage extends DockerObject {
readonly Size?: number;
}
export interface ImageInspectionContainers {
[containerId: string]: {
readonly Name: string;
};
}
export interface DockerImageInspection extends DockerObject {
readonly Config?: {
readonly ExposedPorts?: { readonly [portAndProtocol: string]: unknown; };
@ -20,9 +26,5 @@ export interface DockerImageInspection extends DockerObject {
readonly Os: string;
readonly Name: undefined; // Not defined for inspection
readonly Containers?: { // Not a real part of image inspection, but we add it because it's desperately needed
[containerId: string]: {
readonly Name: string;
}
};
readonly Containers?: ImageInspectionContainers; // Not a real part of image inspection, but we add it because it's desperately needed
}

Просмотреть файл

@ -14,15 +14,17 @@ export interface DockerVolume extends DockerObject {
readonly Description?: string;
}
export interface VolumeInspectionContainers {
[containerId: string]: {
readonly Name: string;
readonly Destination: string;
}
}
export interface DockerVolumeInspection extends DockerObject {
readonly Driver?: VolumeDriverType;
readonly Id: undefined; // Not defined for volumes
readonly Description?: string;
readonly Containers?: { // Not a real part of volume inspection, but we add it because it's desperately needed
[containerId: string]: {
readonly Name: string;
readonly Destination: string;
}
};
readonly Containers?: VolumeInspectionContainers; // Not a real part of volume inspection, but we add it because it's desperately needed
}

Просмотреть файл

@ -45,7 +45,9 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
public watch(uri: vscode.Uri, options: { recursive: boolean; excludes: string[]; }): vscode.Disposable {
// As we don't actually support watching files, just return a dummy subscription object...
return {
dispose: () => {}
dispose: () => {
// Noop
}
};
}
@ -98,7 +100,7 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
}
public readDirectory(uri: vscode.Uri): [string, vscode.FileType][] | Thenable<[string, vscode.FileType][]> {
const method = async (): Promise <[string, vscode.FileType][]> => {
const method = async (): Promise<[string, vscode.FileType][]> => {
const dockerUri = DockerUri.parse(uri);
const executor: DockerContainerExecutor =
@ -108,7 +110,7 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
return stdout;
};
let containerOS = dockerUri.options?.containerOS ?? await this.getContainerOS(dockerUri.containerId);
const containerOS = dockerUri.options?.containerOS ?? await this.getContainerOS(dockerUri.containerId);
let items: DirectoryItem[];
@ -130,7 +132,7 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
throw new UnrecognizedContainerOSError();
}
return items.map(item => [item.name, item.type === 'directory' ? vscode.FileType.Directory : vscode.FileType.File])
return items.map(item => [item.name, item.type === 'directory' ? vscode.FileType.Directory : vscode.FileType.File]);
};
return method();
@ -216,7 +218,7 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
private async getContainerOS(id: string): Promise<DockerOSType | undefined> {
const result = await this.dockerClientProvider().inspectContainer(/* context */ undefined, id);
return result.Platform
return result.Platform;
}
private async readFileViaCopy(dockerUri: DockerUri): Promise<Uint8Array> {
@ -246,13 +248,13 @@ export class ContainerFilesProvider extends vscode.Disposable implements vscode.
switch (containerOS) {
case 'linux':
command = ['/bin/sh', '-c', `"cat '${dockerUri.path}'"` ];
command = ['/bin/sh', '-c', `"cat '${dockerUri.path}'"`];
break;
case 'windows':
command = ['cmd', '/C', `type "${dockerUri.windowsPath}"` ];
command = ['cmd', '/C', `type "${dockerUri.windowsPath}"`];
break;

Просмотреть файл

@ -324,7 +324,7 @@ async function statWindowsContainerDirectory(executor: DockerContainerExecutor,
mtime: Date.now(),
size: 0,
type: 'directory'
}
};
}
return undefined;
@ -361,7 +361,7 @@ async function statWindowsContainerFile(executor: DockerContainerExecutor, itemP
mtime: Date.now(),
size: 0,
type: 'file'
}
};
}
return undefined;

Просмотреть файл

@ -17,45 +17,45 @@ export class DockerComposeCompletionItemProvider implements CompletionItemProvid
/* eslint-disable-next-line @typescript-eslint/promise-function-async */ // Grandfathered in
public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Promise<CompletionItem[]> {
let yamlSuggestSupport = new helper.SuggestSupportHelper();
const yamlSuggestSupport = new helper.SuggestSupportHelper();
// Determine the schema version of the current compose file,
// based on the existence of a top-level "version" property.
let versionMatch = document.getText().match(/^version:\s*(["'])(\d+(\.\d)?)\1/im);
let version = versionMatch ? versionMatch[2] : "1";
const versionMatch = document.getText().match(/^version:\s*(["'])(\d+(\.\d)?)\1/im);
const version = versionMatch ? versionMatch[2] : "1";
// Get the line where intellisense was invoked on (e.g. 'image: u').
let line = document.lineAt(position.line).text;
const line = document.lineAt(position.line).text;
if (line.length === 0) {
// empty line
return Promise.resolve(this.suggestKeys('', version));
}
let range = document.getWordRangeAtPosition(position);
const range = document.getWordRangeAtPosition(position);
// Get the text where intellisense was invoked on (e.g. 'u').
let word = range && document.getText(range) || '';
const word = range && document.getText(range) || '';
let textBefore = line.substring(0, position.character);
const textBefore = line.substring(0, position.character);
if (/^\s*[\w_]*$/.test(textBefore)) {
// on the first token
return Promise.resolve(this.suggestKeys(word, version));
}
// Matches strings like: 'image: "ubuntu'
let imageTextWithQuoteMatchYaml = textBefore.match(/^\s*image\s*\:\s*"([^"]*)$/);
const imageTextWithQuoteMatchYaml = textBefore.match(/^\s*image\s*:\s*"([^"]*)$/);
if (imageTextWithQuoteMatchYaml) {
let imageText = imageTextWithQuoteMatchYaml[1];
const imageText = imageTextWithQuoteMatchYaml[1];
return yamlSuggestSupport.suggestImages(imageText);
}
// Matches strings like: 'image: ubuntu'
let imageTextWithoutQuoteMatch = textBefore.match(/^\s*image\s*\:\s*([\w\:\/]*)/);
const imageTextWithoutQuoteMatch = textBefore.match(/^\s*image\s*:\s*([\w:/]*)/);
if (imageTextWithoutQuoteMatch) {
let imageText = imageTextWithoutQuoteMatch[1];
const imageText = imageTextWithoutQuoteMatch[1];
return yamlSuggestSupport.suggestImages(imageText);
}
@ -65,10 +65,10 @@ export class DockerComposeCompletionItemProvider implements CompletionItemProvid
private suggestKeys(word: string, version: string): CompletionItem[] {
// Attempt to grab the keys for the requested schema version,
// otherwise, fall back to showing a composition of all possible keys.
const keys = <KeyInfo>composeVersions[`v${version}`] || composeVersions.All;
const keys = <KeyInfo>composeVersions[`v${version}`] || composeVersions.all;
return Object.keys(keys).map(ruleName => {
let completionItem = new CompletionItem(ruleName);
const completionItem = new CompletionItem(ruleName);
completionItem.kind = CompletionItemKind.Keyword;
completionItem.insertText = ruleName + ': ';
completionItem.documentation = keys[ruleName];

Просмотреть файл

@ -11,32 +11,25 @@ import parser = require('../parser');
import suggestHelper = require('../utils/suggestSupportHelper');
export class DockerComposeHoverProvider implements HoverProvider {
public _parser: parser.Parser;
public _keyInfo: KeyInfo;
// Provide the parser you want to use as well as keyinfo dictionary.
public constructor(wordParser: parser.Parser, keyInfo: KeyInfo) {
this._parser = wordParser;
this._keyInfo = keyInfo;
public constructor(public readonly parser: parser.Parser, public readonly keyInfo: KeyInfo) {
}
public provideHover(document: TextDocument, position: Position, token: CancellationToken): Thenable<Hover> {
let line = document.lineAt(position.line);
const line = document.lineAt(position.line);
if (line.text.length === 0) {
return Promise.resolve(null);
}
let tokens = this._parser.parseLine(line);
return this._computeInfoForLineWithTokens(line.text, tokens, position);
const tokens = this.parser.parseLine(line);
return this.computeInfoForLineWithTokens(line.text, tokens, position);
}
/* eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/promise-function-async */ // Grandfathered in
private _computeInfoForLineWithTokens(line: string, tokens: parser.IToken[], position: Position): Promise<Hover> {
let possibleTokens = this._parser.tokensAtColumn(tokens, position.character);
private computeInfoForLineWithTokens(line: string, tokens: parser.IToken[], position: Position): Promise<Hover> {
const possibleTokens = this.parser.tokensAtColumn(tokens, position.character);
/* eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/promise-function-async */ // Grandfathered in
return Promise.all(possibleTokens.map(tokenIndex => this._computeInfoForToken(line, tokens, tokenIndex))).then((results) => {
return Promise.all(possibleTokens.map(tokenIndex => this.computeInfoForToken(line, tokens, tokenIndex))).then((results) => {
return possibleTokens.map((tokenIndex, arrayIndex) => {
return {
startIndex: tokens[tokenIndex].startIndex,
@ -45,27 +38,26 @@ export class DockerComposeHoverProvider implements HoverProvider {
};
});
}).then((results) => {
let filteredResults = results.filter(r => !!r.result);
const filteredResults = results.filter(r => !!r.result);
if (filteredResults.length === 0) {
return;
}
let range = new Range(position.line, filteredResults[0].startIndex, position.line, filteredResults[0].endIndex);
const range = new Range(position.line, filteredResults[0].startIndex, position.line, filteredResults[0].endIndex);
let hover = new Hover(filteredResults[0].result, range);
const hover = new Hover(filteredResults[0].result, range);
return hover;
});
}
/* eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/promise-function-async */ // Grandfathered in
private _computeInfoForToken(line: string, tokens: parser.IToken[], tokenIndex: number): Promise<MarkedString[]> {
private computeInfoForToken(line: string, tokens: parser.IToken[], tokenIndex: number): Promise<MarkedString[]> {
// -------------
// Detect hovering on a key
if (tokens[tokenIndex].type === parser.TokenType.Key) {
let keyName = this._parser.keyNameFromKeyToken(this._parser.tokenValue(line, tokens[tokenIndex])).trim();
let r = this._keyInfo[keyName];
const keyName = this.parser.keyNameFromKeyToken(this.parser.tokenValue(line, tokens[tokenIndex])).trim();
const r = this.keyInfo[keyName];
if (r) {
return Promise.resolve([r]);
}
@ -74,8 +66,8 @@ export class DockerComposeHoverProvider implements HoverProvider {
// -------------
// Detect <<image: [["something"]]>>
// Detect <<image: [[something]]>>
let helper = new suggestHelper.SuggestSupportHelper();
let r2 = helper.getImageNameHover(line, this._parser, tokens, tokenIndex);
const helper = new suggestHelper.SuggestSupportHelper();
const r2 = helper.getImageNameHover(line, this.parser, tokens, tokenIndex);
if (r2) {
return r2;
}

Просмотреть файл

@ -9,15 +9,18 @@ import { localize } from "../localize";
// Define the keys that are shared between all compose file versions,
// regardless of the major/minor version (e.g. v1-v2.1+).
// https://docs.docker.com/compose/yml/
/* eslint-disable @typescript-eslint/naming-convention */
const DOCKER_COMPOSE_SHARED_KEY_INFO: KeyInfo = {
'build': (
localize('vscode-docker.dockerComposeKey.build', 'Path to a directory containing a Dockerfile. When the value supplied is a relative path, it is interpreted as relative to the location of the yml file itself. This directory is also the build context that is sent to the Docker daemon.\n\nCompose will build and tag it with a generated name, and use that image thereafter.')
),
'cap_add': (
localize('vscode-docker.dockerComposeKey.cap_add', 'Add or drop container capabilities. See \`man 7 capabilities\` for a full list.')
localize('vscode-docker.dockerComposeKey.cap_add', 'Add or drop container capabilities. See `man 7 capabilities` for a full list.')
),
'cap_drop': (
localize('vscode-docker.dockerComposeKey.cap_drop', 'Add or drop container capabilities. See \`man 7 capabilities\` for a full list.')
localize('vscode-docker.dockerComposeKey.cap_drop', 'Add or drop container capabilities. See `man 7 capabilities` for a full list.')
),
'cgroup_parent': (
localize('vscode-docker.dockerComposeKey.cgroup_parent', 'Specify an optional parent cgroup for the container.')
@ -38,7 +41,7 @@ const DOCKER_COMPOSE_SHARED_KEY_INFO: KeyInfo = {
localize('vscode-docker.dockerComposeKey.cpuset', 'CPUs in which to allow execution.')
),
'devices': (
localize('vscode-docker.dockerComposeKey.devices', 'List of device mappings. Uses the same format as the \`--device\` docker client create option.')
localize('vscode-docker.dockerComposeKey.devices', 'List of device mappings. Uses the same format as the `--device` docker client create option.')
),
'dns': (
localize('vscode-docker.dockerComposeKey.dns', 'Custom DNS servers. Can be a single value or a list.')
@ -47,7 +50,7 @@ const DOCKER_COMPOSE_SHARED_KEY_INFO: KeyInfo = {
localize('vscode-docker.dockerComposeKey.dns_search', 'Custom DNS search domains. Can be a single value or a list.')
),
'dockerfile': (
localize('vscode-docker.dockerComposeKey.dockerfile', 'Alternate Dockerfile. Compose will use an alternate file to build with. Using \`dockerfile\` together with \`image\` is not allowed. Attempting to do so results in an error.')
localize('vscode-docker.dockerComposeKey.dockerfile', 'Alternate Dockerfile. Compose will use an alternate file to build with. Using `dockerfile` together with `image` is not allowed. Attempting to do so results in an error.')
),
'domainname': (
localize('vscode-docker.dockerComposeKey.domainname', 'Container domain name.')
@ -323,17 +326,18 @@ const DOCKER_COMPOSE_V2_2_KEY_INFO: KeyInfo = {
)
};
/* eslint-enable @typescript-eslint/naming-convention */
// Helper function that merges the specified version-specific keys with the shared
// keys, in order to create a complete schema for a specic version.
function mergeWithSharedKeys(...versions: KeyInfo[]): KeyInfo {
return <KeyInfo>Object.assign({}, DOCKER_COMPOSE_SHARED_KEY_INFO, ...versions);
}
// tslint:disable-next-line: export-name
export default <ComposeVersionKeys>{
v1: mergeWithSharedKeys(DOCKER_COMPOSE_V1_KEY_INFO),
v2: mergeWithSharedKeys(DOCKER_COMPOSE_V2_KEY_INFO),
"v2.1": mergeWithSharedKeys(DOCKER_COMPOSE_V2_KEY_INFO, DOCKER_COMPOSE_V2_1_KEY_INFO),
"v2.2": mergeWithSharedKeys(DOCKER_COMPOSE_V2_KEY_INFO, DOCKER_COMPOSE_V2_1_KEY_INFO, DOCKER_COMPOSE_V2_2_KEY_INFO),
All: mergeWithSharedKeys(DOCKER_COMPOSE_V1_KEY_INFO, DOCKER_COMPOSE_V2_KEY_INFO, DOCKER_COMPOSE_V2_1_KEY_INFO, DOCKER_COMPOSE_V2_2_KEY_INFO)
all: mergeWithSharedKeys(DOCKER_COMPOSE_V1_KEY_INFO, DOCKER_COMPOSE_V2_KEY_INFO, DOCKER_COMPOSE_V2_1_KEY_INFO, DOCKER_COMPOSE_V2_2_KEY_INFO)
};

Просмотреть файл

@ -10,16 +10,16 @@ import { IToken, Parser, TokenType } from '../parser';
export class DockerComposeParser extends Parser {
public constructor() {
let parseRegex = /\:+$/g;
const parseRegex = /:+$/g;
super(parseRegex);
}
public parseLine(textLine: vscode.TextLine): IToken[] {
let r: IToken[] = [];
const r: IToken[] = [];
let lastTokenEndIndex = 0;
let lastPushedToken: IToken | undefined;
let emit = (end: number, type: TokenType) => {
const emit = (end: number, type: TokenType) => {
if (end <= lastTokenEndIndex) {
return;
}
@ -42,11 +42,11 @@ export class DockerComposeParser extends Parser {
};
let inString = false;
let idx = textLine.firstNonWhitespaceCharacterIndex;
let line = textLine.text;
const idx = textLine.firstNonWhitespaceCharacterIndex;
const line = textLine.text;
for (let i = idx, len = line.length; i < len; i++) {
let ch = line.charAt(i);
const ch = line.charAt(i);
if (inString) {
if (ch === '"' && line.charAt(i - 1) !== '\\') {

Просмотреть файл

@ -11,7 +11,7 @@ import { localize } from "./localize";
import { httpRequest } from "./utils/httpRequest";
export function tagsForImage(image: IHubSearchResponseResult): string {
let tags: string[] = [];
const tags: string[] = [];
if (image.is_automated) {
tags.push('Automated');
} else if (image.is_trusted) {
@ -35,7 +35,8 @@ export function searchImageInRegistryHub(imageName: string, cache: boolean): Pro
});
}
let popular = [
/* eslint-disable @typescript-eslint/naming-convention */
const popular = [
{ "is_automated": false, "name": "redis", "is_trusted": false, "is_official": true, "star_count": 1300, "description": localize('vscode-docker.dockerHubSearch.redis', 'Redis is an open source key-value store that functions as a data structure server.') },
{ "is_automated": false, "name": "ubuntu", "is_trusted": false, "is_official": true, "star_count": 2600, "description": localize('vscode-docker.dockerHubSearch.ubuntu', 'Ubuntu is a Debian-based Linux operating system based on free software.') },
{ "is_automated": false, "name": "wordpress", "is_trusted": false, "is_official": true, "star_count": 582, "description": localize('vscode-docker.dockerHubSearch.wordPress', 'The WordPress rich content management system can utilize plugins, widgets, and themes.') },
@ -47,6 +48,7 @@ let popular = [
{ "is_automated": false, "name": "postgres", "is_trusted": false, "is_official": true, "star_count": 1200, "description": localize('vscode-docker.dockerHubSearch.postgres', 'The PostgreSQL object-relational database system provides reliability and data integrity.') },
{ "is_automated": true, "name": "microsoft/aspnet", "is_trusted": true, "is_official": false, "star_count": 277, "description": localize('vscode-docker.dockerHubSearch.aspNet', 'ASP.NET is an open source server-side Web application framework') }
];
/* eslint-enable @typescript-eslint/naming-convention */
/* eslint-disable-next-line @typescript-eslint/promise-function-async */ // Grandfathered in
export function searchImagesInRegistryHub(prefix: string, cache: boolean): Promise<IHubSearchResponseResult[]> {
@ -89,34 +91,33 @@ function invokeHubSearch(imageName: string, count: number, cache: boolean): Prom
return fetchHttpsJson<IHubSearchResponse>(url.toString(), cache);
}
export interface IHubSearchResponse {
/* eslint-disable-next-line camelcase */
// eslint-disable-next-line @typescript-eslint/naming-convention
num_pages: number;
/* eslint-disable-next-line camelcase */
// eslint-disable-next-line @typescript-eslint/naming-convention
num_results: number;
results: [IHubSearchResponseResult];
/* eslint-disable-next-line camelcase */
// eslint-disable-next-line @typescript-eslint/naming-convention
page_size: number;
query: string;
page: number;
}
export interface IHubSearchResponseResult {
/* eslint-disable-next-line camelcase */
// eslint-disable-next-line @typescript-eslint/naming-convention
is_automated: boolean;
name: string;
/* eslint-disable-next-line camelcase */
// eslint-disable-next-line @typescript-eslint/naming-convention
is_trusted: boolean;
/* eslint-disable-next-line camelcase */
// eslint-disable-next-line @typescript-eslint/naming-convention
is_official: boolean;
/* eslint-disable-next-line camelcase */
// eslint-disable-next-line @typescript-eslint/naming-convention
star_count: number;
description: string;
}
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
let JSON_CACHE: { [key: string]: any } = {};
const JSON_CACHE: { [key: string]: unknown } = {};
async function fetchHttpsJson<T>(url: string, cache: boolean): Promise<T> {
let cacheKey = url.toString();
const cacheKey = url.toString();
if (!cache || !JSON_CACHE[cacheKey]) {
JSON_CACHE[cacheKey] = await doFetchHttpsJson(url);
@ -131,7 +132,7 @@ async function doFetchHttpsJson<T>(url: string): Promise<T> {
Accept: 'application/json',
'X-Meta-Source-Client': ociClientId,
}
}
};
const response = await httpRequest<T>(url.toString(), options);
return response.json();

Просмотреть файл

@ -17,11 +17,11 @@ export class DockerfileCompletionItemProvider implements CompletionItemProvider
/* eslint-disable-next-line @typescript-eslint/promise-function-async */ // Grandfathered in
public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Promise<CompletionItem[]> {
let dockerSuggestSupport = new helper.SuggestSupportHelper();
const dockerSuggestSupport = new helper.SuggestSupportHelper();
let textLine = document.lineAt(position.line);
const textLine = document.lineAt(position.line);
let fromTextDocker = textLine.text.match(FROM_DIRECTIVE_PATTERN);
const fromTextDocker = textLine.text.match(FROM_DIRECTIVE_PATTERN);
if (fromTextDocker) {
return dockerSuggestSupport.suggestImages(fromTextDocker[1]);

Просмотреть файл

@ -34,7 +34,7 @@ import { isLinux, isMac, isWindows } from './utils/osUtils';
export type KeyInfo = { [keyName: string]: string };
export interface ComposeVersionKeys {
All: KeyInfo;
all: KeyInfo;
v1: KeyInfo;
v2: KeyInfo;
}
@ -102,9 +102,9 @@ export async function activateInternal(ctx: vscode.ExtensionContext, perfStats:
language: 'dockercompose',
scheme: 'file',
};
let composeHoverProvider = new DockerComposeHoverProvider(
const composeHoverProvider = new DockerComposeHoverProvider(
new DockerComposeParser(),
composeVersionKeys.All
composeVersionKeys.all
);
ctx.subscriptions.push(
vscode.languages.registerHoverProvider(COMPOSE_MODE_ID, composeHoverProvider)
@ -189,7 +189,9 @@ async function getDockerInstallationIDHash(): Promise<string> {
return result;
}
}
} catch { }
} catch {
// Best effort
}
return 'unknown';
}
@ -200,8 +202,8 @@ async function getDockerInstallationIDHash(): Promise<string> {
function validateOldPublisher(activateContext: IActionContext): void {
const extension = vscode.extensions.getExtension('PeterJausovec.vscode-docker');
if (extension) {
let message: string = localize('vscode-docker.extension.pleaseReload', 'Please reload Visual Studio Code to complete updating the Docker extension.');
let reload: vscode.MessageItem = { title: localize('vscode-docker.extension.reloadNow', 'Reload Now') };
const message: string = localize('vscode-docker.extension.pleaseReload', 'Please reload Visual Studio Code to complete updating the Docker extension.');
const reload: vscode.MessageItem = { title: localize('vscode-docker.extension.reloadNow', 'Reload Now') };
// Don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
ext.ui.showWarningMessage(message, reload).then(async result => {
@ -215,10 +217,11 @@ function validateOldPublisher(activateContext: IActionContext): void {
}
}
/* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
namespace Configuration {
export function computeConfiguration(params: ConfigurationParams): vscode.WorkspaceConfiguration[] {
let result: vscode.WorkspaceConfiguration[] = [];
for (let item of params.items) {
const result: vscode.WorkspaceConfiguration[] = [];
for (const item of params.items) {
let config: vscode.WorkspaceConfiguration;
if (item.scopeUri) {
@ -256,13 +259,13 @@ namespace Configuration {
));
}
}
/* eslint-enable @typescript-eslint/no-namespace, no-inner-declarations */
function activateLanguageClient(ctx: vscode.ExtensionContext): void {
// Don't wait
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
callWithTelemetryAndErrorHandling('docker.languageclient.activate', async (context: IActionContext) => {
void callWithTelemetryAndErrorHandling('docker.languageclient.activate', async (context: IActionContext) => {
context.telemetry.properties.isActivationEvent = 'true';
let serverModule = ext.context.asAbsolutePath(
const serverModule = ext.context.asAbsolutePath(
path.join(
ext.ignoreBundle ? "node_modules" : "dist",
"dockerfile-language-server-nodejs",
@ -271,9 +274,9 @@ function activateLanguageClient(ctx: vscode.ExtensionContext): void {
)
);
let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
let serverOptions: ServerOptions = {
const serverOptions: ServerOptions = {
run: {
module: serverModule,
transport: TransportKind.ipc,
@ -286,13 +289,13 @@ function activateLanguageClient(ctx: vscode.ExtensionContext): void {
}
};
let middleware: Middleware = {
const middleware: Middleware = {
workspace: {
configuration: Configuration.computeConfiguration
}
};
let clientOptions: LanguageClientOptions = {
const clientOptions: LanguageClientOptions = {
documentSelector: DOCUMENT_SELECTOR,
synchronize: {
fileEvents: vscode.workspace.createFileSystemWatcher("**/.clientrc")

Просмотреть файл

@ -18,7 +18,7 @@ import { VolumesTreeItem } from './tree/volumes/VolumesTreeItem';
/**
* Namespace for common variables used throughout the extension. They must be initialized in the activate() method of extension.ts
*/
// tslint:disable-next-line: export-name
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace ext {
export let context: ExtensionContext;
export let outputChannel: IAzExtOutputChannel;
@ -59,5 +59,6 @@ export namespace ext {
export let contextsTreeView: TreeView<AzExtTreeItem>;
export let contextsRoot: ContextsTreeItem;
// eslint-disable-next-line prefer-const
export let runningTests: boolean = false;
}

Просмотреть файл

@ -8,14 +8,11 @@
import { TextLine } from 'vscode';
export abstract class Parser {
public _tokenParseRegex: RegExp;
public constructor(parseTokenRegex: RegExp) {
this._tokenParseRegex = parseTokenRegex;
public constructor(public readonly tokenParseRegex: RegExp) {
}
public keyNameFromKeyToken(keyToken: string): string {
return keyToken.replace(this._tokenParseRegex, '');
return keyToken.replace(this.tokenParseRegex, '');
}
public tokenValue(line: string, token: IToken): string {
@ -24,14 +21,14 @@ export abstract class Parser {
public tokensAtColumn(tokens: IToken[], charIndex: number): number[] {
for (let i = 0, len = tokens.length; i < len; i++) {
let token = tokens[i];
const token = tokens[i];
if (token.endIndex < charIndex) {
continue;
}
if (token.endIndex === charIndex && i + 1 < len) {
return [i, i + 1]
return [i, i + 1];
}
return [i];
}

Просмотреть файл

@ -29,7 +29,7 @@ export class ChoosePortsStep extends TelemetryPromptStep<ScaffoldingWizardContex
}
};
wizardContext.ports = splitPorts(await ext.ui.showInputBox(opt))
wizardContext.ports = splitPorts(await ext.ui.showInputBox(opt));
}
public shouldPrompt(wizardContext: ScaffoldingWizardContext): boolean {
@ -49,14 +49,14 @@ function splitPorts(value: string): number[] | undefined {
return [];
}
let elements = value.split(',').map(p => p.trim());
let matches = elements.filter(p => p.match(/^-*\d+$/));
const elements = value.split(',').map(p => p.trim());
const matches = elements.filter(p => p.match(/^-*\d+$/));
if (matches.length < elements.length) {
return undefined;
}
let ports = matches.map(Number);
const ports = matches.map(Number);
// If anything is non-integral or less than 1 or greater than 65535, it's not valid
if (ports.some(p => !Number.isInteger(p) || p < 1 || p > 65535)) {

Просмотреть файл

@ -7,7 +7,7 @@ import * as path from 'path';
import { Progress } from 'vscode';
import { AzureWizardExecuteStep } from 'vscode-azureextensionui';
import { DockerDebugScaffoldContext } from '../../debugging/DebugHelper';
import { dockerDebugScaffoldingProvider, NetCoreScaffoldingOptions, NodeScaffoldingOptions, PythonScaffoldingOptions } from '../../debugging/DockerDebugScaffoldingProvider';
import { dockerDebugScaffoldingProvider } from '../../debugging/DockerDebugScaffoldingProvider';
import { localize } from '../../localize';
import { unresolveWorkspaceFolder } from '../../utils/resolveVariables';
import { NetCoreScaffoldingWizardContext } from './netCore/NetCoreScaffoldingWizardContext';
@ -30,20 +30,24 @@ export class ScaffoldDebuggingStep extends AzureWizardExecuteStep<ScaffoldingWiz
switch (wizardContext.platform) {
case 'Node.js':
scaffoldContext.platform = 'node';
const nodeOptions: NodeScaffoldingOptions = {
package: wizardContext.artifact,
};
await dockerDebugScaffoldingProvider.initializeNodeForDebugging(scaffoldContext, nodeOptions);
await dockerDebugScaffoldingProvider.initializeNodeForDebugging(
scaffoldContext,
{
package: wizardContext.artifact,
}
);
break;
case '.NET: ASP.NET Core':
case '.NET: Core Console':
scaffoldContext.platform = 'netCore';
const netCoreOptions: NetCoreScaffoldingOptions = {
appProject: unresolveWorkspaceFolder(wizardContext.artifact, wizardContext.workspaceFolder),
platformOS: (wizardContext as NetCoreScaffoldingWizardContext).netCorePlatformOS,
};
await dockerDebugScaffoldingProvider.initializeNetCoreForDebugging(scaffoldContext, netCoreOptions);
await dockerDebugScaffoldingProvider.initializeNetCoreForDebugging(
scaffoldContext,
{
appProject: unresolveWorkspaceFolder(wizardContext.artifact, wizardContext.workspaceFolder),
platformOS: (wizardContext as NetCoreScaffoldingWizardContext).netCorePlatformOS,
}
);
break;
case 'Python: Django':
@ -51,11 +55,13 @@ export class ScaffoldDebuggingStep extends AzureWizardExecuteStep<ScaffoldingWiz
case 'Python: Flask':
case 'Python: General':
scaffoldContext.platform = 'python';
const pythonOptions: PythonScaffoldingOptions = {
projectType: (wizardContext as PythonScaffoldingWizardContext).pythonProjectType,
target: (wizardContext as PythonScaffoldingWizardContext).pythonArtifact,
};
await dockerDebugScaffoldingProvider.initializePythonForDebugging(scaffoldContext, pythonOptions);
await dockerDebugScaffoldingProvider.initializePythonForDebugging(
scaffoldContext,
{
projectType: (wizardContext as PythonScaffoldingWizardContext).pythonProjectType,
target: (wizardContext as PythonScaffoldingWizardContext).pythonArtifact,
}
);
break;
default:

Просмотреть файл

@ -21,7 +21,7 @@ export class VerifyDockerfileStep<TWizardContext extends ScaffoldingWizardContex
},
title: localize('vscode-docker.scaffold.verifyDockerfileStep.addDockerfiles', 'Add Docker Files'),
}
]
];
throw new Error(localize('vscode-docker.scaffold.verifyDockerfileStep.noDockerfile', 'No Dockerfile is present in the workspace. Please add Docker files before adding Compose files.'));
}

Просмотреть файл

@ -20,6 +20,8 @@ export class ChooseJavaArtifactStep extends ChooseArtifactStep<ScaffoldingWizard
// Java's behavior is to look for a POM or Gradle file, but if none is present no error is thrown
try {
await super.prompt(wizardContext);
} catch { } // Not a problem
} catch {
// Not a problem
}
}
}

Просмотреть файл

@ -50,7 +50,7 @@ export class JavaGatherInformationStep extends GatherInformationStep<JavaScaffol
if (gradleObject?.jar?.archiveName) {
wizardContext.relativeJavaOutputPath = `build/libs/${gradleObject.jar.archiveName}`;
} else if (gradleObject?.jar?.baseName) {
wizardContext.relativeJavaOutputPath = `build/libs/${gradleObject.jar.baseName}-${wizardContext.version}.jar`
wizardContext.relativeJavaOutputPath = `build/libs/${gradleObject.jar.baseName}-${wizardContext.version}.jar`;
} else if (gradleObject?.archivesBaseName) {
wizardContext.relativeJavaOutputPath = `build/libs/${gradleObject.archivesBaseName}-${wizardContext.version}.jar`;
} else {

Просмотреть файл

@ -48,7 +48,7 @@ export class NetCoreGatherInformationStep extends GatherInformationStep<NetCoreS
if (!wizardContext.netCoreRuntimeBaseImage || !wizardContext.netCoreSdkBaseImage) {
this.targetFramework = projectInfo[1]; // Line 2 is the <TargetFramework> value, or first item from <TargetFrameworks>
const regexMatch = /net(coreapp)?([\d\.]+)/i.exec(this.targetFramework);
const regexMatch = /net(coreapp)?([\d.]+)/i.exec(this.targetFramework);
if (!regexMatch || regexMatch.length < 3) {
throw new Error(localize('vscode-docker.scaffold.netCoreGatherInformationStep.noNetCoreVersion', 'Unable to determine .NET target framework version for \'{0}\'', wizardContext.artifact));

Просмотреть файл

@ -22,10 +22,10 @@ export class NodeGatherInformationStep extends GatherInformationStep<NodeScaffol
const [, main] = /node (.+)/i.exec(nodePackage.scripts.start) ?? [undefined, undefined];
wizardContext.nodeDebugCmdParts = ['node', '--inspect=0.0.0.0:9229', nodePackage.main || main || 'index.js'];
} else if (nodePackage.main) {
wizardContext.nodeCmdParts = ['node', nodePackage.main]
wizardContext.nodeCmdParts = ['node', nodePackage.main];
wizardContext.nodeDebugCmdParts = ['node', '--inspect=0.0.0.0:9229', nodePackage.main];
} else {
wizardContext.nodeCmdParts = ['npm', 'start']
wizardContext.nodeCmdParts = ['npm', 'start'];
wizardContext.nodeDebugCmdParts = ['node', '--inspect=0.0.0.0:9229', 'index.js'];
}

Просмотреть файл

@ -163,6 +163,6 @@ export class PythonGatherInformationStep extends GatherInformationStep<PythonSca
args: inferPythonArgs(wizardContext.pythonProjectType, wizardContext.ports) ?? [],
bindPort: wizardContext.ports ? wizardContext.ports[0] : PythonDefaultPorts.get(wizardContext.pythonProjectType),
}
};
}
}

Просмотреть файл

@ -29,7 +29,7 @@ export interface DockerBuildTask extends Task {
}
export class DockerBuildTaskProvider extends DockerTaskProvider {
public constructor(helpers: { [key in DockerPlatform]: TaskHelper }) { super('docker-build', helpers) }
public constructor(helpers: { [key in DockerPlatform]: TaskHelper }) { super('docker-build', helpers); }
// TODO: Skip if image is freshly built
protected async executeTaskInternal(context: DockerBuildTaskContext, task: DockerBuildTask): Promise<void> {

Просмотреть файл

@ -23,7 +23,7 @@ export interface DockerComposeTask extends Task {
}
export class DockerComposeTaskProvider extends DockerTaskProvider {
public constructor() { super('docker-compose', undefined) }
public constructor() { super('docker-compose', undefined); }
protected async executeTaskInternal(context: DockerComposeTaskContext, task: DockerComposeTask): Promise<void> {
const definition = cloneObject(task.definition);

Просмотреть файл

@ -26,7 +26,7 @@ export interface DockerRunTask extends Task {
}
export class DockerRunTaskProvider extends DockerTaskProvider {
public constructor(helpers: { [key in DockerPlatform]: TaskHelper }) { super('docker-run', helpers) }
public constructor(helpers: { [key in DockerPlatform]: TaskHelper }) { super('docker-run', helpers); }
// TODO: Skip if container is freshly started, but probably depends on language
protected async executeTaskInternal(context: DockerRunTaskContext, task: DockerRunTask): Promise<void> {

Просмотреть файл

@ -171,7 +171,7 @@ export async function getOfficialBuildTaskForDockerfile(dockerfile: string, fold
}
const items: QuickPickItem[] = buildTasks.map(t => {
return { label: t.name }
return { label: t.name };
});
const item = await ext.ui.showQuickPick(items, { placeHolder: localize('vscode-docker.tasks.helper.chooseBuildDefinition', 'Choose the Docker Build definition.') });

Просмотреть файл

@ -190,7 +190,7 @@ export class NetCoreTaskHelper implements TaskHelper {
public static async isWebApp(appProject: string): Promise<boolean> {
const projectContents = await fse.readFile(appProject);
return /Sdk\s*=\s*\"Microsoft\.NET\.Sdk\.Web\"/ig.test(projectContents.toString());
return /Sdk\s*=\s*"Microsoft\.NET\.Sdk\.Web"/ig.test(projectContents.toString());
}
private async inferUserSecrets(helperOptions: NetCoreTaskOptions): Promise<boolean> {
@ -218,7 +218,7 @@ export class NetCoreTaskHelper implements TaskHelper {
localPath: folder.uri.fsPath,
containerPath: runOptions.os === 'Windows' ? 'C:\\src' : '/src',
permissions: 'rw'
}
};
const debuggerVolume: DockerContainerVolume = {
localPath: vsDbgInstallBasePath,
@ -264,7 +264,9 @@ export class NetCoreTaskHelper implements TaskHelper {
try {
const imageInspection = await ext.dockerClient.inspectImage(undefined, runOptions.image);
userName = imageInspection?.Config?.User;
} catch { } // Best effort
} catch {
// Best effort
}
const hostSecretsFolders = getHostSecretsFolders();
const containerSecretsFolders = getContainerSecretsFolders(runOptions.os, userName);

Просмотреть файл

@ -74,7 +74,7 @@ async function transformBlazorManifest(context: DockerRunTaskContext, inputManif
const outputContents = (new xml2js.Builder()).buildObject(manifest);
await fse.writeFile(outputManifest, outputContents)
await fse.writeFile(outputManifest, outputContents);
}
function containerizePath(oldPath: string, volumes: DockerContainerVolume[], os: PlatformOS): string {

Просмотреть файл

@ -68,6 +68,7 @@ export class NodeTaskHelper implements TaskHelper {
dockerRun: {
env: {
"DEBUG": "*",
// eslint-disable-next-line @typescript-eslint/naming-convention
"NODE_ENV": "development"
}
},

Просмотреть файл

@ -16,6 +16,7 @@ interface PythonExtensionAPI {
}
}
/* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
export namespace PythonExtensionHelper {
export interface DebugLaunchOptions {
host?: string;
@ -65,3 +66,4 @@ export namespace PythonExtensionHelper {
return pyExt;
}
}
/* eslint-enable @typescript-eslint/no-namespace, no-inner-declarations */

Просмотреть файл

@ -62,9 +62,10 @@ export class PythonTaskHelper implements TaskHelper {
if (options.projectType === 'flask') {
dockerRunOptions = {
env: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"FLASK_APP": runOptions.file || runOptions.module
}
}
};
runOptions.module = 'flask';
runOptions.file = undefined;
} else if (options.projectType === 'fastapi') {

Просмотреть файл

@ -75,7 +75,9 @@ export class ActivityMeasurementService implements IActivityMeasurementService {
if (type !== 'overall') {
await this.recordActivity('overall');
}
} catch { } // Best effort only
} catch {
// Best effort
}
}
/**

Просмотреть файл

@ -78,7 +78,9 @@ export class SurveyManager {
}
});
}
} catch { } // Best effort
} catch {
// Best effort
}
}
private async surveyOpen(url: string): Promise<void> {

Просмотреть файл

@ -20,7 +20,7 @@ export const awareness: Survey = {
]),
activationDelayMs: 30 * 1000,
isEligible: isEligible,
}
};
async function isEligible(): Promise<boolean> {
const overallActivity = ext.activityMeasurementService.getActivityMeasurement('overall');

Просмотреть файл

@ -16,7 +16,7 @@ export const nps2: Survey = {
prompt: localize('vscode-docker.survey.nps.prompt', 'Would you be willing to take a quick feedback survey about the Docker Extension for VS Code?'),
activationDelayMs: 60 * 1000,
isEligible: isNPSEligible,
}
};
async function isNPSEligible(): Promise<boolean> {
return vscode.env.language === 'en' || vscode.env.language.startsWith('en-');

Просмотреть файл

@ -22,14 +22,16 @@ export abstract class AzExtParentTreeItemIntermediate extends AzExtParentTreeIte
// The reason is that we don't want to rev the required @types/vscode version in vscode-azureextensionui to accept
// MarkdownString there; but we don't actually need to since it's only passing the value through unchanged.
// TODO: when possible we should remove this
// @ts-expect-error
// @ts-expect-error MarkdownString is not assignable to string
return await callWithTelemetryAndErrorHandling('resolveTooltip', async (actionContext: IActionContext) => {
actionContext.errorHandling.suppressDisplay = true;
actionContext.errorHandling.rethrow = true;
return await this.resolveTooltipInternal(actionContext);
});
} catch { } // Do nothing, fall to the undefined below
} catch {
// Do nothing, fall to the undefined below
}
}
return undefined;

Просмотреть файл

@ -22,7 +22,7 @@ export abstract class AzExtTreeItemIntermediate extends AzExtTreeItem {
// The reason is that we don't want to rev the required @types/vscode version in vscode-azureextensionui to accept
// MarkdownString there; but we don't actually need to since it's only passing the value through unchanged.
// TODO: when possible we should remove this
// @ts-expect-error
// @ts-expect-error MarkdownString is not assignable to string
return await callWithTelemetryAndErrorHandling('resolveTooltip', async (actionContext: IActionContext) => {
actionContext.telemetry.suppressIfSuccessful = true;
actionContext.errorHandling.suppressDisplay = true;
@ -30,7 +30,9 @@ export abstract class AzExtTreeItemIntermediate extends AzExtTreeItem {
return await this.resolveTooltipInternal(actionContext);
});
} catch { } // Do nothing, fall to the undefined below
} catch {
// Do nothing, fall to the undefined below
}
}
return undefined;

Просмотреть файл

@ -33,7 +33,7 @@ export abstract class LocalGroupTreeItemBase<TItem extends DockerObject, TProper
return Math.max(...this._items.map(i => i.CreatedTime));
}
public async loadMoreChildrenImpl(_clearCache: boolean): Promise<AzExtTreeItem[]> {
public async loadMoreChildrenImpl(clearCache: boolean): Promise<AzExtTreeItem[]> {
this._childTreeItems = this.getChildTreeItems();
return this._childTreeItems;
}

Просмотреть файл

@ -39,7 +39,7 @@ export abstract class LocalRootTreeItemBase<TItem extends DockerObject, TPropert
public sortBySettingInfo: ITreeSettingInfo<CommonSortBy> = {
properties: [...sortByProperties],
defaultProperty: 'CreatedTime',
}
};
public abstract treePrefix: string;
public abstract configureExplorerTitle: string;
@ -78,7 +78,7 @@ export abstract class LocalRootTreeItemBase<TItem extends DockerObject, TPropert
protected getRefreshInterval(): number {
const configOptions: WorkspaceConfiguration = workspace.getConfiguration('docker');
return configOptions.get<number>('explorerRefreshInterval', 2000)
return configOptions.get<number>('explorerRefreshInterval', 2000);
}
public registerRefreshEvents(treeView: TreeView<AzExtTreeItem>): void {
@ -130,7 +130,7 @@ export abstract class LocalRootTreeItemBase<TItem extends DockerObject, TPropert
this._itemsFromPolling = undefined;
}
public async loadMoreChildrenImpl(_clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
try {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
ext.activityMeasurementService.recordActivity('overallnoedit');
@ -296,7 +296,7 @@ export abstract class LocalRootTreeItemBase<TItem extends DockerObject, TPropert
description: localize('vscode-docker.tree.config.sortBy.description', 'The property used for sorting.'),
settingInfo: this.sortBySettingInfo
},
]
];
}
public async configureExplorer(context: IActionContext): Promise<void> {

Просмотреть файл

@ -119,7 +119,7 @@ export class ContainersTreeItem extends LocalRootTreeItemBase<DockerContainerInf
dockerTutorialTreeItem.iconPath = getThemedIconPath('docker');
return [dockerTutorialTreeItem];
}
return super.getTreeItemForEmptyList()
return super.getTreeItemForEmptyList();
}
protected areArraysEqual(array1: DockerContainerInfo[] | undefined, array2: DockerContainerInfo[] | undefined): boolean {

Просмотреть файл

@ -73,7 +73,7 @@ export class DirectoryTreeItem extends AzExtParentTreeItemIntermediate {
const name = item[0];
const fileType = item[1];
let itemUri = DockerUri.joinPath(parentUri, name);
const itemUri = DockerUri.joinPath(parentUri, name);
switch (fileType) {
case vscode.FileType.Directory:

Просмотреть файл

@ -87,7 +87,7 @@ export class ContextsTreeItem extends LocalRootTreeItemBase<DockerContext, Conte
description: localize('vscode-docker.tree.contextConfig.description.description', 'Any secondary properties to display.'),
settingInfo: this.descriptionSettingInfo
}
]
];
}
public async createChildImpl(actionContext: ICreateChildImplContext): Promise<ContextTreeItem> {

Просмотреть файл

@ -92,7 +92,6 @@ interface IParsedFullTag {
function parseFullTag(rawTag: string): IParsedFullTag {
let registry: string | undefined;
let namespace: string | undefined;
let repositoryName: string;
let tag: string | undefined;
// Pull out registry or namespace from the beginning
@ -118,20 +117,17 @@ function parseFullTag(rawTag: string): IParsedFullTag {
rawTag = rawTag.substring(0, index);
}
// Whatever's left is the repository name
repositoryName = rawTag;
return {
registry,
repositoryName,
repositoryName: rawTag,
namespace,
tag
};
}
function truncateRegistry(registry: string): string {
let config = workspace.getConfiguration(configPrefix);
let truncateLongRegistryPaths = config.get<boolean>('truncateLongRegistryPaths');
const config = workspace.getConfiguration(configPrefix);
const truncateLongRegistryPaths = config.get<boolean>('truncateLongRegistryPaths');
if (typeof truncateLongRegistryPaths === "boolean" && truncateLongRegistryPaths) {
let truncateMaxLength = config.get<number>('truncateMaxLength');
if (typeof truncateMaxLength !== 'number' || truncateMaxLength < 1) {

Просмотреть файл

@ -43,8 +43,8 @@ export class NetworksTreeItem extends LocalRootTreeItemBase<DockerNetwork, Netwo
}
public async getItems(context: IActionContext): Promise<DockerNetwork[]> {
let config = workspace.getConfiguration(configPrefix);
let showBuiltInNetworks: boolean = config.get<boolean>('networks.showBuiltInNetworks');
const config = workspace.getConfiguration(configPrefix);
const showBuiltInNetworks: boolean = config.get<boolean>('networks.showBuiltInNetworks');
let networks = await ext.dockerClient.getNetworks(context) || [];

Просмотреть файл

@ -25,11 +25,11 @@ export function registerTrees(): void {
ext.containersRoot.registerRefreshEvents(ext.containersTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(containersLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.containersTree.loadMore(node, context));
registerCommand('vscode-docker.containers.refresh', async (_context: IActionContext, node?: AzExtTreeItem) => {
registerCommand('vscode-docker.containers.refresh', async (context: IActionContext, node?: AzExtTreeItem) => {
if (ext.treeInitError) {
await ext.dockerContextManager.refresh();
}
await ext.containersTree.refresh(_context, node);
await ext.containersTree.refresh(context, node);
});
ext.networksRoot = new NetworksTreeItem(undefined);
@ -40,11 +40,11 @@ export function registerTrees(): void {
ext.networksRoot.registerRefreshEvents(ext.networksTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(networksLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.networksTree.loadMore(node, context));
registerCommand('vscode-docker.networks.refresh', async (_context: IActionContext, node?: AzExtTreeItem) => {
registerCommand('vscode-docker.networks.refresh', async (context: IActionContext, node?: AzExtTreeItem) => {
if (ext.treeInitError) {
await ext.dockerContextManager.refresh();
}
await ext.networksTree.refresh(_context, node);
await ext.networksTree.refresh(context, node);
});
ext.imagesRoot = new ImagesTreeItem(undefined);
@ -55,11 +55,11 @@ export function registerTrees(): void {
ext.imagesRoot.registerRefreshEvents(ext.imagesTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(imagesLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.imagesTree.loadMore(node, context));
registerCommand('vscode-docker.images.refresh', async (_context: IActionContext, node?: AzExtTreeItem) => {
registerCommand('vscode-docker.images.refresh', async (context: IActionContext, node?: AzExtTreeItem) => {
if (ext.treeInitError) {
await ext.dockerContextManager.refresh();
}
await ext.imagesTree.refresh(_context, node);
await ext.imagesTree.refresh(context, node);
});
ext.registriesRoot = new RegistriesTreeItem();
@ -69,7 +69,7 @@ export function registerTrees(): void {
ext.context.subscriptions.push(ext.registriesTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(registriesLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.registriesTree.loadMore(node, context));
registerCommand('vscode-docker.registries.refresh', async (_context: IActionContext, node?: AzExtTreeItem) => ext.registriesTree.refresh(_context, node));
registerCommand('vscode-docker.registries.refresh', async (context: IActionContext, node?: AzExtTreeItem) => ext.registriesTree.refresh(context, node));
ext.volumesRoot = new VolumesTreeItem(undefined);
const volumesLoadMore = 'vscode-docker.volumes.loadMore';
@ -79,11 +79,11 @@ export function registerTrees(): void {
ext.volumesRoot.registerRefreshEvents(ext.volumesTreeView);
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
registerCommand(volumesLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.volumesTree.loadMore(node, context));
registerCommand('vscode-docker.volumes.refresh', async (_context: IActionContext, node?: AzExtTreeItem) => {
registerCommand('vscode-docker.volumes.refresh', async (context: IActionContext, node?: AzExtTreeItem) => {
if (ext.treeInitError) {
await ext.dockerContextManager.refresh();
}
await ext.volumesTree.refresh(_context, node);
await ext.volumesTree.refresh(context, node);
});
ext.contextsRoot = new ContextsTreeItem(undefined);
@ -96,7 +96,7 @@ export function registerTrees(): void {
registerCommand(contextsLoadMore, (context: IActionContext, node: AzExtTreeItem) => ext.contextsTree.loadMore(node, context));
// Refresh button will trigger a full refresh of context data from underlying source, the change event will actually refresh the tree
registerCommand('vscode-docker.contexts.refresh', async (_context: IActionContext, node?: AzExtTreeItem) => {
registerCommand('vscode-docker.contexts.refresh', async (context: IActionContext, node?: AzExtTreeItem) => {
if (ext.treeInitError) {
await ext.dockerContextManager.refresh();
}
@ -114,5 +114,5 @@ export function registerTrees(): void {
const helpTreeView = vscode.window.createTreeView('vscode-docker.views.help', { treeDataProvider: helpTreeDataProvider, canSelectMany: false });
ext.context.subscriptions.push(helpTreeView);
registerCommand('vscode-docker.openUrl', async (_context: IActionContext, node: OpenUrlTreeItem) => node.openUrl());
registerCommand('vscode-docker.openUrl', async (context: IActionContext, node: OpenUrlTreeItem) => node.openUrl());
}

Просмотреть файл

@ -18,7 +18,7 @@ export class ConnectedRegistriesTreeItem extends AzExtParentTreeItem {
this.iconPath = new ThemeIcon('link');
}
public async loadMoreChildrenImpl(_clearCache: boolean, _context: IActionContext): Promise<AzExtTreeItem[]> {
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
return this.children;
}

Просмотреть файл

@ -27,8 +27,8 @@ export class RegistriesTreeItem extends AzExtParentTreeItem {
public label: string = localize('vscode-docker.tree.registries.registriesLabel', 'Registries');
public childTypeLabel: string = 'registry provider';
public autoSelectInTreeItemPicker: boolean = true;
public _connectedRegistriesTreeItem: ConnectedRegistriesTreeItem;
private _connectedRegistriesTreeItem: ConnectedRegistriesTreeItem;
private _cachedProviders: ICachedRegistryProvider[];
public constructor() {
@ -37,7 +37,7 @@ export class RegistriesTreeItem extends AzExtParentTreeItem {
this._cachedProviders = ext.context.globalState.get<ICachedRegistryProvider[]>(providersKey, []);
}
public async loadMoreChildrenImpl(_clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
if (this._cachedProviders.length === 0) {
return [new GenericTreeItem(this, {
label: localize('vscode-docker.tree.registries.connectRegistry', 'Connect Registry...'),
@ -84,10 +84,10 @@ export class RegistriesTreeItem extends AzExtParentTreeItem {
detail: rp.detail,
data: rp
};
})
});
picks = picks.sort((p1, p2) => p1.label.localeCompare(p2.label));
let placeHolder: string = localize('vscode-docker.tree.registries.selectProvider', 'Select the provider for your registry');
const placeHolder: string = localize('vscode-docker.tree.registries.selectProvider', 'Select the provider for your registry');
provider = provider ?? (await ext.ui.showQuickPick(picks, { placeHolder, suppressPersistence: true })).data;
if (!provider) {
throw new UserCancelledError();
@ -102,10 +102,10 @@ export class RegistriesTreeItem extends AzExtParentTreeItem {
context.telemetry.properties.providerId = provider.id;
context.telemetry.properties.providerApi = provider.api;
let cachedProvider: ICachedRegistryProvider = {
const cachedProvider: ICachedRegistryProvider = {
id: provider.id,
api: provider.api,
}
};
if (provider.connectWizardOptions) {
const existingProviders: ICachedRegistryProvider[] = this._cachedProviders.filter(rp => rp.id === provider.id);
@ -138,20 +138,20 @@ export class RegistriesTreeItem extends AzExtParentTreeItem {
if (!cachedProvider) {
const picks = this._cachedProviders.map(crp => {
const provider = getRegistryProviders().find(rp => rp.id === crp.id);
let label: string = (provider && provider.label) || crp.id;
let descriptions: string[] = [];
const label: string = (provider && provider.label) || crp.id;
const descriptions: string[] = [];
if (crp.username) {
descriptions.push(localize('vscode-docker.tree.registries.usernameDesc', 'Username: "{0}"', crp.username))
descriptions.push(localize('vscode-docker.tree.registries.usernameDesc', 'Username: "{0}"', crp.username));
}
if (crp.url) {
descriptions.push(localize('vscode-docker.tree.registries.urlDesc', 'URL: "{0}"', crp.url))
descriptions.push(localize('vscode-docker.tree.registries.urlDesc', 'URL: "{0}"', crp.url));
}
return {
label,
description: descriptions[0],
detail: descriptions[1],
data: crp
}
};
});
const placeHolder: string = localize('vscode-docker.tree.registries.selectDisconnect', 'Select the registry to disconnect');
cachedProvider = (await ext.ui.showQuickPick(picks, { placeHolder, suppressPersistence: true })).data;
@ -216,7 +216,7 @@ export class RegistriesTreeItem extends AzExtParentTreeItem {
}
};
return node
return node;
}
}

Просмотреть файл

@ -22,6 +22,7 @@ class BasicOAuthProvider implements IAuthProvider {
const options: RequestInit = {
form: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'grant_type': 'password',
'service': authContext.service,
'scope': authContext.scope

Просмотреть файл

@ -21,8 +21,8 @@ export class AzureAccountTreeItem extends AzureAccountTreeItemBase implements IR
return new SubscriptionTreeItem(this, subContext, this.cachedProvider);
}
public async loadMoreChildrenImpl(_clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
const treeItems: AzExtTreeItem[] = await super.loadMoreChildrenImpl(_clearCache, context);
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
const treeItems: AzExtTreeItem[] = await super.loadMoreChildrenImpl(clearCache, context);
if (treeItems.length === 1 && treeItems[0].commandId === 'extension.open') {
const extensionInstallEventDisposable: Disposable = AzureAccountExtensionListener.onExtensionInstalled(() => {
extensionInstallEventDisposable.dispose();

Просмотреть файл

@ -23,7 +23,7 @@ export class AzureRegistryTreeItem extends DockerV2RegistryTreeItemBase {
private _tasksTreeItem: AzureTasksTreeItem;
public constructor(parent: SubscriptionTreeItem, cachedProvider: ICachedRegistryProvider, private readonly _registry: AcrModels.Registry) {
public constructor(parent: SubscriptionTreeItem, cachedProvider: ICachedRegistryProvider, private readonly registry: AcrModels.Registry) {
super(parent, cachedProvider, azureOAuthProvider);
this._tasksTreeItem = new AzureTasksTreeItem(this);
this.authContext = {
@ -31,18 +31,18 @@ export class AzureRegistryTreeItem extends DockerV2RegistryTreeItemBase {
service: this.host,
subscriptionContext: this.parent.root,
scope: 'registry:catalog:*',
}
};
this.id = this.registryId;
this.iconPath = getIconPath('azureRegistry');
}
public get registryName(): string {
return nonNullProp(this._registry, 'name');
return nonNullProp(this.registry, 'name');
}
public get registryId(): string {
return nonNullProp(this._registry, 'id');
return nonNullProp(this.registry, 'id');
}
public get resourceGroup(): string {
@ -50,7 +50,7 @@ export class AzureRegistryTreeItem extends DockerV2RegistryTreeItemBase {
}
public get registryLocation(): string {
return this._registry.location;
return this.registry.location;
}
public async getClient(): Promise<ContainerRegistryManagementClient> {
@ -63,11 +63,11 @@ export class AzureRegistryTreeItem extends DockerV2RegistryTreeItemBase {
}
public get properties(): unknown {
return this._registry;
return this.registry;
}
public get baseUrl(): string {
return `https://${nonNullProp(this._registry, 'loginServer')}`;
return `https://${nonNullProp(this.registry, 'loginServer')}`;
}
public createRepositoryTreeItem(name: string): AzureRepositoryTreeItem {
@ -105,7 +105,7 @@ export class AzureRegistryTreeItem extends DockerV2RegistryTreeItemBase {
}
public async tryGetAdminCredentials(): Promise<AcrModels.RegistryListCredentialsResult | undefined> {
if (this._registry.adminUserEnabled) {
if (this.registry.adminUserEnabled) {
return await (await this.getClient()).registries.listCredentials(this.resourceGroup, this.registryName);
} else {
return undefined;

Просмотреть файл

@ -49,17 +49,17 @@ export class AzureTaskTreeItem extends AzExtParentTreeItem {
}
public static async hasRunsWithoutTask(registryTI: AzureRegistryTreeItem): Promise<boolean> {
let runListResult = await AzureTaskTreeItem.getTaskRuns(registryTI, AzureTaskTreeItem._noTaskFilter, undefined);
const runListResult = await AzureTaskTreeItem.getTaskRuns(registryTI, AzureTaskTreeItem._noTaskFilter, undefined);
return runListResult.length > 0;
}
public async loadMoreChildrenImpl(clearCache: boolean, _context: IActionContext): Promise<AzExtTreeItem[]> {
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
if (clearCache) {
this._nextLink = undefined;
}
let filter = this._task ? `TaskName eq '${this.taskName}'` : AzureTaskTreeItem._noTaskFilter;
let runListResult = await AzureTaskTreeItem.getTaskRuns(this.parent.parent, filter, this._nextLink);
const filter = this._task ? `TaskName eq '${this.taskName}'` : AzureTaskTreeItem._noTaskFilter;
const runListResult = await AzureTaskTreeItem.getTaskRuns(this.parent.parent, filter, this._nextLink);
this._nextLink = runListResult.nextLink;

Просмотреть файл

@ -25,23 +25,23 @@ export class AzureTasksTreeItem extends AzExtParentTreeItem {
this.iconPath = new ThemeIcon('checklist');
}
public async loadMoreChildrenImpl(clearCache: boolean, _context: IActionContext): Promise<AzExtTreeItem[]> {
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
if (clearCache) {
this._nextLink = undefined;
}
const registryTI = this.parent;
let taskListResult: AcrModels.TaskListResult = this._nextLink === undefined ?
const taskListResult: AcrModels.TaskListResult = this._nextLink === undefined ?
await (await registryTI.getClient()).tasks.list(registryTI.resourceGroup, registryTI.registryName) :
await (await registryTI.getClient()).tasks.listNext(this._nextLink);
this._nextLink = taskListResult.nextLink;
if (clearCache && taskListResult.length === 0) {
return [new OpenUrlTreeItem(this, localize('vscode-docker.tree.registries.azure.learnBuildTask', 'Learn how to create a build task...'), 'https://aka.ms/acr/task')]
return [new OpenUrlTreeItem(this, localize('vscode-docker.tree.registries.azure.learnBuildTask', 'Learn how to create a build task...'), 'https://aka.ms/acr/task')];
} else {
let result: AzExtTreeItem[] = await this.createTreeItemsWithErrorHandling(
const result: AzExtTreeItem[] = await this.createTreeItemsWithErrorHandling(
taskListResult,
'invalidAzureTask',
async t => new AzureTaskTreeItem(this, t),

Просмотреть файл

@ -27,14 +27,14 @@ export class SubscriptionTreeItem extends SubscriptionTreeItemBase implements IR
super(parent, root);
}
public async loadMoreChildrenImpl(clearCache: boolean, _context: IActionContext): Promise<AzExtTreeItem[]> {
public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
if (clearCache) {
this._nextLink = undefined;
}
const armContainerRegistry = await import('@azure/arm-containerregistry');
const client: ContainerRegistryManagementClient = createAzureClient(this.root, armContainerRegistry.ContainerRegistryManagementClient);
let registryListResult: AcrModels.RegistryListResult = this._nextLink === undefined ?
const registryListResult: AcrModels.RegistryListResult = this._nextLink === undefined ?
await client.registries.list() :
await client.registries.listNext(this._nextLink);

Просмотреть файл

@ -20,4 +20,4 @@ export const azureRegistryProvider: IRegistryProvider = {
treeItemFactory: (parent: AzExtParentTreeItem, cachedProvider: ICachedRegistryProvider) => new AzureAccountTreeItem(parent, cachedProvider),
persistAuth: undefined,
removeAuth: undefined,
}
};

Просмотреть файл

@ -21,7 +21,7 @@ export class RegistryPasswordStep extends AzureWizardPromptStep<IConnectRegistry
function validateInput(value: string | undefined): string | undefined {
if (!value) {
return localize('vscode-docker.tree.registries.connectWizard.passwordEmpty', 'Password cannot be empty.')
return localize('vscode-docker.tree.registries.connectWizard.passwordEmpty', 'Password cannot be empty.');
} else {
return undefined;
}

Просмотреть файл

@ -31,7 +31,7 @@ export class RegistryUrlStep extends AzureWizardPromptStep<IConnectRegistryWizar
let protocol: string | undefined;
let host: string | undefined;
try {
let uri = new URL(value);
const uri = new URL(value);
protocol = uri.protocol;
host = uri.host;
} catch {

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше