Switch to ESLint (#242)
This commit is contained in:
Родитель
af2e3cf2d1
Коммит
c1231add78
|
@ -0,0 +1,2 @@
|
|||
gulpfile.ts
|
||||
.eslintrc.js
|
|
@ -0,0 +1,38 @@
|
|||
module.exports = {
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "tsconfig.json",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"import"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
],
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"no-useless-escape": "off",
|
||||
"no-inner-declarations": "off",
|
||||
"no-case-declarations": "off",
|
||||
"@typescript-eslint/prefer-regexp-exec": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ "argsIgnorePattern": "^_" }
|
||||
],
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
"@typescript-eslint/unbound-method": "off",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
||||
"@typescript-eslint/restrict-template-expressions": "off",
|
||||
"@typescript-eslint/no-namespace": "off",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
"@typescript-eslint/require-await": "off"
|
||||
}
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"ms-vscode.vscode-typescript-tslint-plugin",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-vscode.azure-account",
|
||||
"ms-azuretools.vscode-azureresourcegroups"
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.tslint": true,
|
||||
"source.fixAll.eslint": true,
|
||||
"source.organizeImports": true
|
||||
},
|
||||
"editor.detectIndentation": false,
|
||||
|
@ -14,7 +14,6 @@
|
|||
"**/node_modules": true,
|
||||
".vscode-test": true
|
||||
},
|
||||
"tslint.ignoreDefinitionFiles": true,
|
||||
"typescript.preferences.importModuleSpecifier": "relative",
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
{
|
||||
"type": "npm",
|
||||
"script": "lint",
|
||||
"problemMatcher": "$tslint5"
|
||||
"problemMatcher": "$eslint-stylish"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ testOutput/**
|
|||
testWorkspace/**
|
||||
tools/**
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
eslint.json
|
||||
typings/**
|
||||
webpack.config*
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// tslint:disable:no-implicit-dependencies (this allows the use of dev dependencies)
|
||||
|
||||
import * as fse from 'fs-extra';
|
||||
import * as gulp from 'gulp';
|
||||
import * as path from 'path';
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
10
package.json
10
package.json
|
@ -266,8 +266,8 @@
|
|||
"cleanReadme": "gulp cleanReadme",
|
||||
"compile": "tsc -watch",
|
||||
"package": "vsce package --githubBranch main",
|
||||
"lint": "tslint --project tsconfig.json -t verbose",
|
||||
"lint-fix": "tslint --project tsconfig.json -t verbose --fix",
|
||||
"lint": "eslint --ext .ts .",
|
||||
"lint-fix": "eslint --ext .ts . --fix",
|
||||
"pretest": "npm run webpack-prod && gulp preTest",
|
||||
"test": "node ./out/test/runTest.js",
|
||||
"webpack": "npm run build && gulp webpack-dev",
|
||||
|
@ -282,14 +282,16 @@
|
|||
"@types/node": "^12.19.16",
|
||||
"@types/vscode": "1.48.0",
|
||||
"@types/which": "^1.3.2",
|
||||
"@typescript-eslint/eslint-plugin": "^4.14.2",
|
||||
"@typescript-eslint/parser": "^4.14.2",
|
||||
"eslint": "^7.19.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"glob": "^7.1.6",
|
||||
"gulp": "^4.0.2",
|
||||
"mocha": "^8.3.2",
|
||||
"mocha-junit-reporter": "^2.0.0",
|
||||
"mocha-multi-reporters": "^1.5.1",
|
||||
"ts-node": "^7.0.1",
|
||||
"tslint": "^5.14.0",
|
||||
"tslint-microsoft-contrib": "^5.2.1",
|
||||
"typescript": "^3.9.7",
|
||||
"vsce": "^1.87.1",
|
||||
"vscode-azureextensiondev": "^0.9.2",
|
||||
|
|
|
@ -27,7 +27,6 @@ export async function addSshKey(context: IActionContext, node?: VirtualMachineTr
|
|||
filters: { 'SSH Public Key': ['pub'] }
|
||||
}))[0];
|
||||
|
||||
// tslint:disable-next-line: strict-boolean-expressions
|
||||
const extensionName: string = 'enablevmaccess';
|
||||
let vmExtension: ComputeManagementModels.VirtualMachineExtension;
|
||||
|
||||
|
@ -44,7 +43,6 @@ export async function addSshKey(context: IActionContext, node?: VirtualMachineTr
|
|||
|
||||
vmExtension.protectedSettings = {
|
||||
ssh_key: (await fse.readFile(sshPublicKey.fsPath)).toString(),
|
||||
// tslint:disable-next-line: strict-boolean-expressions
|
||||
username: vm.osProfile && vm.osProfile.adminUsername || 'azureuser'
|
||||
};
|
||||
|
||||
|
@ -54,7 +52,7 @@ export async function addSshKey(context: IActionContext, node?: VirtualMachineTr
|
|||
await window.withProgress({ location: ProgressLocation.Notification, title: addingSshKey }, async (): Promise<void> => {
|
||||
ext.outputChannel.appendLog(addingSshKey);
|
||||
await computeClient.virtualMachineExtensions.createOrUpdate(nonNullValueAndProp(node, 'resourceGroup'), nonNullValueAndProp(node, 'name'), extensionName, vmExtension);
|
||||
window.showInformationMessage(addingSshKeySucceeded);
|
||||
void window.showInformationMessage(addingSshKeySucceeded);
|
||||
ext.outputChannel.appendLog(addingSshKeySucceeded);
|
||||
});
|
||||
|
||||
|
|
|
@ -16,5 +16,5 @@ export async function copyIpAddress(context: IActionContext, node?: VirtualMachi
|
|||
|
||||
await vscode.env.clipboard.writeText(await node.getIpAddress());
|
||||
const message: string = localize('copiedIpAddress', '"{0}"\'s IP address has been copied to the clipboard', node.name);
|
||||
vscode.window.showInformationMessage(message);
|
||||
void vscode.window.showInformationMessage(message);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ export class NetworkInterfaceCreateStep extends AzureWizardExecuteStep<IVirtualM
|
|||
|
||||
for (let i: number = 0; i < 3; i += 1) {
|
||||
// as this isn't being used for security purposes, it should be sufficient to use Math.random()
|
||||
// tslint:disable-next-line: insecure-random
|
||||
niName += Math.round(Math.random() * 9);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,12 +77,10 @@ export class PassphrasePromptStep extends AzureWizardPromptStep<IVirtualMachineW
|
|||
const numeric: RegExp = /[0-9]/;
|
||||
const specialCharacters: RegExp = /[!@#\$%\^&\*]/;
|
||||
|
||||
// tslint:disable: strict-boolean-expressions
|
||||
const lowercaseRequirement: number = password.match(lowercase)?.length || 0;
|
||||
const uppercaseRequirement: number = password.match(uppercase)?.length || 0;
|
||||
const numericRequirement: number = password.match(numeric)?.length || 0;
|
||||
const specialCharactersRequirement: number = password.match(specialCharacters)?.length || 0;
|
||||
// tslint:enable: strict-boolean-expressions
|
||||
|
||||
return lowercaseRequirement + uppercaseRequirement + numericRequirement + specialCharactersRequirement;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ export class VirtualMachineCreateStep extends AzureWizardExecuteStep<IVirtualMac
|
|||
|
||||
const osProfile: ComputeManagementModels.OSProfile = { computerName: vmName, adminUsername: context.adminUsername };
|
||||
if (context.os === VirtualMachineOS.linux) {
|
||||
// tslint:disable-next-line: strict-boolean-expressions
|
||||
const { sshKeyName, keyData } = await createSshKey(context, vmName, context.passphrase || '');
|
||||
context.sshKeyName = sshKeyName;
|
||||
const linuxConfiguration: ComputeManagementModels.LinuxConfiguration = {
|
||||
|
@ -83,7 +82,7 @@ export class VirtualMachineCreateStep extends AzureWizardExecuteStep<IVirtualMac
|
|||
|
||||
const viewOutput: MessageItem = { title: 'View Output' };
|
||||
// Note: intentionally not waiting for the result of this before returning
|
||||
window.showInformationMessage(createdVm, viewOutput).then(async (result: MessageItem | undefined) => {
|
||||
void window.showInformationMessage(createdVm, viewOutput).then(async (result: MessageItem | undefined) => {
|
||||
await callWithTelemetryAndErrorHandling('postCreateVM', async (c: IActionContext) => {
|
||||
c.telemetry.properties.dialogResult = result?.title;
|
||||
if (result === viewOutput) {
|
||||
|
|
|
@ -29,7 +29,6 @@ export async function openInRemoteSsh(context: IActionContext, node?: VirtualMac
|
|||
const hostName: string = await node.getIpAddress();
|
||||
|
||||
const hostConfig: SSHConfig.HostConfigurationDirective | undefined = sshConfig.find(hostEntry => {
|
||||
// tslint:disable-next-line: strict-boolean-expressions
|
||||
return hostEntry.config && hostEntry.config.find(config => {
|
||||
const castedConfig: SSHConfig.BaseConfigurationDirective = <SSHConfig.BaseConfigurationDirective>config;
|
||||
return castedConfig.param === 'HostName' && castedConfig.value === hostName;
|
||||
|
|
|
@ -10,7 +10,7 @@ import { localize } from "../localize";
|
|||
|
||||
export const remoteSshExtensionId: string = 'ms-vscode-remote.remote-ssh';
|
||||
export async function verifyRemoteSshExtension(context: IActionContext): Promise<void> {
|
||||
// tslint:disable-next-line:no-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const extension: Extension<any> | undefined = extensions.getExtension(remoteSshExtensionId);
|
||||
if (extension) {
|
||||
if (!extension.isActive) {
|
||||
|
@ -18,8 +18,7 @@ export async function verifyRemoteSshExtension(context: IActionContext): Promise
|
|||
}
|
||||
|
||||
} else {
|
||||
// tslint:disable-next-line: no-floating-promises
|
||||
ext.ui.showWarningMessage(localize('remoteSshInstall', 'You must have the ["Remote - SSH" extension](command:azureVirtualMachines.showRemoteSshExtension) installed to perform this operation.'));
|
||||
void ext.ui.showWarningMessage(localize('remoteSshInstall', 'You must have the ["Remote - SSH" extension](command:azureVirtualMachines.showRemoteSshExtension) installed to perform this operation.'));
|
||||
context.telemetry.properties.cancelStep = 'installRemoteSsh';
|
||||
context.errorHandling.suppressDisplay = true;
|
||||
throw new Error(`${remoteSshExtensionId} extension is not installed.`);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
import { AzExtTreeDataProvider, AzureTreeItem, AzureUserInput, callWithTelemetryAndErrorHandling, createApiProvider, createAzExtOutputChannel, IActionContext, registerCommand, registerErrorHandler, registerReportIssueCommand, registerUIExtensionVariables } from 'vscode-azureextensionui';
|
||||
// tslint:disable-next-line:no-submodule-imports
|
||||
import { AzureExtensionApi, AzureExtensionApiProvider } from 'vscode-azureextensionui/api';
|
||||
import { addSshKey } from './commands/addSshKey';
|
||||
import { revealTreeItem } from './commands/api/revealTreeItem';
|
||||
|
@ -58,7 +57,7 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta
|
|||
registerCommand('azureVirtualMachines.viewProperties', viewProperties);
|
||||
registerCommand('azureVirtualMachines.openInRemoteSsh', openInRemoteSsh);
|
||||
registerCommand('azureVirtualMachines.showOutputChannel', () => { ext.outputChannel.show(); });
|
||||
registerCommand('azureVirtualMachines.showRemoteSshExtension', () => { vscode.commands.executeCommand('extension.open', remoteSshExtensionId); });
|
||||
registerCommand('azureVirtualMachines.showRemoteSshExtension', () => { void vscode.commands.executeCommand('extension.open', remoteSshExtensionId); });
|
||||
|
||||
// Suppress "Report an Issue" button for all errors in favor of the command
|
||||
registerErrorHandler(c => c.errorHandling.suppressReportIssue = true);
|
||||
|
@ -71,6 +70,6 @@ export async function activateInternal(context: vscode.ExtensionContext, perfSta
|
|||
}]);
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-empty
|
||||
export function deactivateInternal(): void {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ export class VirtualMachineTreeItem extends AzureTreeItem {
|
|||
super(parent);
|
||||
this.virtualMachine = vm;
|
||||
this._state = instanceView ? this.getStateFromInstanceView(instanceView) : undefined;
|
||||
this.contextValue = !!(vm.osProfile?.linuxConfiguration) ? VirtualMachineTreeItem.linuxContextValue : VirtualMachineTreeItem.windowsContextValue;
|
||||
this.contextValue = vm.osProfile?.linuxConfiguration ? VirtualMachineTreeItem.linuxContextValue : VirtualMachineTreeItem.windowsContextValue;
|
||||
}
|
||||
|
||||
public getUser(): string {
|
||||
|
@ -118,10 +118,9 @@ export class VirtualMachineTreeItem extends AzureTreeItem {
|
|||
throw new Error(messageDeleteWithErrors);
|
||||
}
|
||||
|
||||
// tslint:disable-next-line: no-floating-promises
|
||||
ext.ui.showWarningMessage(`${messageDeleteWithErrors} Check the [output channel](command:${ext.prefix}.showOutputChannel) for more information.`);
|
||||
void ext.ui.showWarningMessage(`${messageDeleteWithErrors} Check the [output channel](command:${ext.prefix}.showOutputChannel) for more information.`);
|
||||
} else {
|
||||
vscode.window.showInformationMessage(deleteSucceeded);
|
||||
void vscode.window.showInformationMessage(deleteSucceeded);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ export function nonNullProp<TSource, TKey extends keyof TSource>(source: TSource
|
|||
export function nonNullValue<T>(value: T | undefined | null, propertyNameOrMessage?: string): T {
|
||||
if (isNullOrUndefined(value)) {
|
||||
throw new Error(
|
||||
// tslint:disable-next-line:prefer-template
|
||||
'Internal error: Expected value to be neither null nor undefined'
|
||||
+ (propertyNameOrMessage ? `: ${propertyNameOrMessage}` : ''));
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ export async function configureSshConfig(vmti: VirtualMachineTreeItem, sshKeyPat
|
|||
// if the host can't be computed, it returns an empty {}
|
||||
const hostEntry: SSHConfig.ResolvedConfiguration = sshConfig.compute(host);
|
||||
|
||||
if (!!hostEntry.Host) {
|
||||
if (hostEntry.Host) {
|
||||
let count: number = 2;
|
||||
|
||||
// increment until host doesn't already exist
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
module.exports = {
|
||||
"extends": [
|
||||
"../.eslintrc.js"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/require-await": "off",
|
||||
"@typescript-eslint/no-floating-promises": "off"
|
||||
}
|
||||
};
|
|
@ -9,7 +9,7 @@ import { } from 'vscode-azureextensionui';
|
|||
import { ext } from '../extension.bundle';
|
||||
|
||||
export let longRunningTestsEnabled: boolean;
|
||||
export let testUserInput: TestUserInput = new TestUserInput(vscode);
|
||||
export const testUserInput: TestUserInput = new TestUserInput(vscode);
|
||||
|
||||
// Runs before all tests
|
||||
suiteSetup(async function (this: Mocha.Context): Promise<void> {
|
||||
|
@ -19,7 +19,6 @@ suiteSetup(async function (this: Mocha.Context): Promise<void> {
|
|||
ext.outputChannel = new TestOutputChannel();
|
||||
ext.ui = testUserInput;
|
||||
|
||||
// tslint:disable-next-line:strict-boolean-expressions
|
||||
longRunningTestsEnabled = !/^(false|0)?$/i.test(process.env.ENABLE_LONG_RUNNING_TESTS || '');
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import * as glob from 'glob';
|
|||
import * as Mocha from 'mocha';
|
||||
import * as path from 'path';
|
||||
|
||||
// tslint:disable-next-line: export-name
|
||||
export async function run(): Promise<void> {
|
||||
const options: Mocha.MochaOptions = {
|
||||
ui: 'tdd',
|
||||
|
@ -45,12 +44,11 @@ function addEnvVarsToMochaOptions(options: Mocha.MochaOptions): void {
|
|||
const match: RegExpMatchArray | null = envVar.match(/^mocha_(.+)/i);
|
||||
if (match) {
|
||||
const [, option] = match;
|
||||
// tslint:disable-next-line:strict-boolean-expressions
|
||||
let value: string | number = process.env[envVar] || '';
|
||||
if (typeof value === 'string' && !isNaN(parseInt(value))) {
|
||||
value = parseInt(value);
|
||||
}
|
||||
// tslint:disable-next-line: no-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
||||
(<any>options)[option] = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,5 +25,4 @@ async function main(): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
// tslint:disable-next-line: no-floating-promises
|
||||
main();
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"align": false,
|
||||
"max-func-body-length": false,
|
||||
"no-any": false,
|
||||
"no-console": false,
|
||||
"no-empty": false,
|
||||
"no-implicit-dependencies": [
|
||||
true,
|
||||
"dev",
|
||||
[
|
||||
"vscode"
|
||||
]
|
||||
],
|
||||
"no-multiline-string": false,
|
||||
"no-non-null-assertion": false,
|
||||
"no-unexternalized-strings": false,
|
||||
"no-unsafe-any": false,
|
||||
"typedef": [
|
||||
true,
|
||||
"call-signature",
|
||||
"parameter",
|
||||
"property-declaration",
|
||||
"member-variable-declaration"
|
||||
]
|
||||
}
|
||||
}
|
94
tslint.json
94
tslint.json
|
@ -1,94 +0,0 @@
|
|||
{
|
||||
"extends": "tslint-microsoft-contrib",
|
||||
"rules": {
|
||||
"await-promise": [
|
||||
true,
|
||||
"Thenable"
|
||||
],
|
||||
"no-backbone-get-set-outside-model": false,
|
||||
"radix": false,
|
||||
"strict-boolean-expressions": [
|
||||
true,
|
||||
"allow-string",
|
||||
"allow-undefined-union",
|
||||
"allow-mix",
|
||||
"allow-null-union"
|
||||
],
|
||||
"completed-docs": [
|
||||
false,
|
||||
"classes"
|
||||
],
|
||||
"import-name": false,
|
||||
"max-line-length": [
|
||||
false,
|
||||
140
|
||||
],
|
||||
"missing-jsdoc": false,
|
||||
"no-relative-imports": false,
|
||||
"no-void-expression": [
|
||||
true,
|
||||
"ignore-arrow-function-shorthand"
|
||||
],
|
||||
"variable-name": [
|
||||
true,
|
||||
"ban-keywords",
|
||||
"check-format",
|
||||
"allow-leading-underscore"
|
||||
],
|
||||
"linebreak-style": false,
|
||||
"newline-before-return": false,
|
||||
"no-single-line-block-comment": false,
|
||||
"quotemark": [
|
||||
false,
|
||||
"single"
|
||||
],
|
||||
"no-unexternalized-strings": [
|
||||
true,
|
||||
{
|
||||
"signatures": [
|
||||
"localize",
|
||||
"nls.localize"
|
||||
],
|
||||
"keyIndex": 0,
|
||||
"messageIndex": 1
|
||||
}
|
||||
],
|
||||
"no-implicit-dependencies": [
|
||||
true,
|
||||
[
|
||||
"vscode"
|
||||
]
|
||||
],
|
||||
"switch-final-break": false,
|
||||
"prefer-object-spread": false,
|
||||
"no-return-await": false,
|
||||
"no-parameter-reassignment": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"function-name": [
|
||||
true,
|
||||
{
|
||||
"static-method-regex": "^[a-z][\\w_]+$"
|
||||
}
|
||||
],
|
||||
"typedef": [
|
||||
true,
|
||||
"call-signature",
|
||||
"arrow-call-signature",
|
||||
"parameter",
|
||||
// "arrow-parameter",
|
||||
"property-declaration",
|
||||
"variable-declaration",
|
||||
"member-variable-declaration"
|
||||
],
|
||||
"prefer-template": [
|
||||
true,
|
||||
"allow-single-concat"
|
||||
],
|
||||
"no-use-before-declare": false
|
||||
},
|
||||
"linterOptions": {
|
||||
"exclude": [
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче