From a92a005d6897506d3ea40307dfd37788c51a4dcf Mon Sep 17 00:00:00 2001 From: Horace Lee Date: Wed, 11 Aug 2021 02:31:59 +0800 Subject: [PATCH] Use ESlint instead of TSlint (#7719) Migrated TSlint configs to ESlint ones using [tslint-to-eslint-config](https://github.com/typescript-eslint/tslint-to-eslint-config) tool, and refined the configs to better match the current coding style. Changes: - [member-delimiter-style](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md#options) that as suggested default for type definition to be with `semicolon` - Indentation fixes that is enforced by [eslint-indent](https://eslint.org/docs/rules/indent#options) - Added dependencies for ESlint with Typescript - Removed TSlint --- CHANGELOG_PENDING.md | 3 + sdk/nodejs/.eslintrc.js | 191 +++++++++ sdk/nodejs/Makefile | 2 +- sdk/nodejs/asset/archive.ts | 2 +- sdk/nodejs/asset/asset.ts | 2 +- sdk/nodejs/automation/errors.ts | 6 +- sdk/nodejs/automation/projectSettings.ts | 1 - sdk/nodejs/automation/server.ts | 2 +- sdk/nodejs/automation/stack.ts | 60 +-- sdk/nodejs/cmd/dynamic-provider/index.ts | 2 +- sdk/nodejs/cmd/run/index.ts | 2 + sdk/nodejs/cmd/run/run.ts | 2 +- sdk/nodejs/config.ts | 6 +- sdk/nodejs/errors.ts | 4 +- sdk/nodejs/iterable/index.ts | 4 +- sdk/nodejs/log/index.ts | 8 +- sdk/nodejs/output.ts | 79 ++-- sdk/nodejs/package.json | 8 +- sdk/nodejs/provider/provider.ts | 2 +- sdk/nodejs/provider/server.ts | 8 +- sdk/nodejs/queryable/index.ts | 18 +- sdk/nodejs/resource.ts | 42 +- sdk/nodejs/runtime/asyncIterableUtil.ts | 2 +- sdk/nodejs/runtime/closure/codePaths.ts | 8 +- sdk/nodejs/runtime/closure/createClosure.ts | 44 +- sdk/nodejs/runtime/closure/parseFunction.ts | 120 +++--- .../runtime/closure/serializeClosure.ts | 22 +- sdk/nodejs/runtime/closure/v8_v10andLower.ts | 2 +- sdk/nodejs/runtime/closure/v8_v11andHigher.ts | 6 +- sdk/nodejs/runtime/invoke.ts | 4 +- sdk/nodejs/runtime/mocks.ts | 4 +- sdk/nodejs/runtime/resource.ts | 10 +- sdk/nodejs/runtime/rpc.ts | 150 +++---- sdk/nodejs/runtime/settings.ts | 2 +- .../tests/automation/localWorkspace.spec.ts | 2 +- sdk/nodejs/tests/options.spec.ts | 2 +- sdk/nodejs/tests/output.spec.ts | 2 +- sdk/nodejs/tests/resource.spec.ts | 2 +- .../tests/runtime/closureLoader.spec.ts | 2 +- .../runtime/deploymentOnlyModule/config.ts | 2 +- .../tests/runtime/jsClosureCases_10_4.js | 2 +- sdk/nodejs/tests/runtime/jsClosureCases_8.js | 8 +- sdk/nodejs/tests/runtime/langhost/run.spec.ts | 386 +++++++++--------- sdk/nodejs/tests/runtime/props.spec.ts | 50 +-- sdk/nodejs/tests/runtime/tsClosureCases.ts | 2 +- sdk/nodejs/tests/sxs_ts_3.6/index.ts | 2 +- sdk/nodejs/tests/sxs_ts_latest/index.ts | 2 +- sdk/nodejs/tests/unwrap.spec.ts | 2 +- sdk/nodejs/tests_with_mocks/mocks.spec.ts | 52 +-- .../policy/policy_pack_w_config/package.json | 3 +- tslint.json | 125 ------ 51 files changed, 776 insertions(+), 698 deletions(-) create mode 100644 sdk/nodejs/.eslintrc.js delete mode 100644 tslint.json diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 16ac9d7d8..f9a8757a4 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -18,3 +18,6 @@ - [auto/nodejs] - Fix a case where inline programs could exit with outstanding async work. [#7704](https://github.com/pulumi/pulumi/pull/7704) + +- [sdk/nodejs] - Use ESlint instead of TSlint + [#7719](https://github.com/pulumi/pulumi/pull/7719) \ No newline at end of file diff --git a/sdk/nodejs/.eslintrc.js b/sdk/nodejs/.eslintrc.js new file mode 100644 index 000000000..1d9c0443b --- /dev/null +++ b/sdk/nodejs/.eslintrc.js @@ -0,0 +1,191 @@ +module.exports = { + "env": { + "es6": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "eslint-plugin-import", + "@typescript-eslint", + "header" + ], + "ignorePatterns": [ + "**/bin/**/*.ts", + "tests/automation/data/tcfg/*.ts", + "tests/sxs_ts_3.6/*.ts", + "tests/sxs_ts_latest/*.ts", + ], + "rules": { + "header/header": [ + 2, + "line", + [ + { + "pattern": "Copyright \\d{4}-\\d{4}, Pulumi Corporation." + } + ] + ], + "@typescript-eslint/dot-notation": "off", + "@typescript-eslint/explicit-member-accessibility": [ + "off", + { + "accessibility": "explicit" + } + ], + "@typescript-eslint/indent": [ + "error", + 4, + { + "FunctionDeclaration": { + "parameters": "first" + }, + "FunctionExpression": { + "parameters": "first" + } + } + ], + "@typescript-eslint/member-delimiter-style": [ + "error", + { + "multiline": { + "delimiter": "semi", + "requireLast": true + }, + "singleline": { + "delimiter": "semi", + "requireLast": false + } + } + ], + "@typescript-eslint/member-ordering": [ + "error", + { + "default": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "default", + "format": null + } + ], + "@typescript-eslint/no-empty-function": "error", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/no-parameter-properties": "off", + "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/no-shadow": [ + "error", + { + "hoist": "all" + } + ], + "@typescript-eslint/no-unused-expressions": "error", + "@typescript-eslint/no-use-before-define": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/quotes": [ + "error", + "double", + { + "avoidEscape": true, + "allowTemplateLiterals": true + } + ], + "@typescript-eslint/semi": [ + "error" + ], + "@typescript-eslint/type-annotation-spacing": "error", + "brace-style": "off", + "comma-dangle": [ + "error", + "always-multiline" + ], + "curly": "error", + "default-case": "error", + "dot-notation": "off", + "eol-last": "error", + "eqeqeq": [ + "error", + "smart" + ], + "guard-for-in": "error", + "id-blacklist": [ + "error", + "any", + "Number", + "number", + "String", + "string", + "Boolean", + "boolean", + "Undefined", + "undefined" + ], + "id-match": "error", + "import/order": "off", + "indent": "off", + "no-bitwise": "off", + "no-caller": "error", + "no-cond-assign": "off", + "no-console": [ + "error", + { + "allow": [ + "log", + "warn", + "dir", + "timeLog", + "assert", + "clear", + "count", + "countReset", + "group", + "groupEnd", + "table", + "dirxml", + "error", + "groupCollapsed", + "Console", + "profile", + "profileEnd", + "timeStamp", + "context" + ] + } + ], + "no-debugger": "error", + "no-empty": "error", + "no-empty-function": "off", + "no-eval": "error", + "no-fallthrough": "error", + "no-multiple-empty-lines": "off", + "no-new-wrappers": "error", + "no-redeclare": "off", + "no-shadow": "off", + "no-trailing-spaces": "error", + "no-underscore-dangle": "off", + "no-unused-expressions": "error", + "no-unused-labels": "error", + "no-use-before-define": "off", + "no-var": "error", + "prefer-const": "error", + "quotes": "off", + "radix": "error", + "semi": "off", + "spaced-comment": "off", + "@typescript-eslint/no-redeclare": [ + "error" + ] + } +}; diff --git a/sdk/nodejs/Makefile b/sdk/nodejs/Makefile index 65b8cfbcd..caeb95efd 100644 --- a/sdk/nodejs/Makefile +++ b/sdk/nodejs/Makefile @@ -18,7 +18,7 @@ include ../../build/common.mk export PATH:=$(shell yarn bin 2>/dev/null):$(PATH) lint:: - ./node_modules/.bin/tslint -c tslint.json -p tsconfig.json + ./node_modules/.bin/eslint -c .eslintrc.js --ext .ts . build_package:: ./node_modules/.bin/tsc diff --git a/sdk/nodejs/asset/archive.ts b/sdk/nodejs/asset/archive.ts index e8bca3327..fe7ad1e07 100644 --- a/sdk/nodejs/asset/archive.ts +++ b/sdk/nodejs/asset/archive.ts @@ -23,7 +23,7 @@ export abstract class Archive { * A private field to help with RTTI that works in SxS scenarios. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiArchive: boolean = true; /** diff --git a/sdk/nodejs/asset/asset.ts b/sdk/nodejs/asset/asset.ts index 69498b292..2114a5f99 100644 --- a/sdk/nodejs/asset/asset.ts +++ b/sdk/nodejs/asset/asset.ts @@ -22,7 +22,7 @@ export abstract class Asset { * A private field to help with RTTI that works in SxS scenarios. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiAsset: boolean = true; /** diff --git a/sdk/nodejs/automation/errors.ts b/sdk/nodejs/automation/errors.ts index 0ba7a7185..636f63a3c 100644 --- a/sdk/nodejs/automation/errors.ts +++ b/sdk/nodejs/automation/errors.ts @@ -68,8 +68,8 @@ export function createCommandError(result: CommandResult): CommandError { const stderr = result.stderr; return ( notFoundRegex.test(stderr) ? new StackNotFoundError(result) : - alreadyExistsRegex.test(stderr) ? new StackAlreadyExistsError(result) : - stderr.indexOf(conflictText) >= 0 ? new ConcurrentUpdateError(result) : - new CommandError(result) + alreadyExistsRegex.test(stderr) ? new StackAlreadyExistsError(result) : + stderr.indexOf(conflictText) >= 0 ? new ConcurrentUpdateError(result) : + new CommandError(result) ); } diff --git a/sdk/nodejs/automation/projectSettings.ts b/sdk/nodejs/automation/projectSettings.ts index 814cc54c7..ebfe7bfb2 100644 --- a/sdk/nodejs/automation/projectSettings.ts +++ b/sdk/nodejs/automation/projectSettings.ts @@ -1,4 +1,3 @@ - // Copyright 2016-2020, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/sdk/nodejs/automation/server.ts b/sdk/nodejs/automation/server.ts index 869f7c64f..169dae723 100644 --- a/sdk/nodejs/automation/server.ts +++ b/sdk/nodejs/automation/server.ts @@ -74,7 +74,7 @@ export class LanguageServer implements grpc.UntypedServiceImplementation { const engineAddr = args && args.length > 0 ? args[0] : ""; runtime.resetOptions(req.getProject(), req.getStack(), req.getParallel(), engineAddr, - req.getMonitorAddress(), req.getDryrun()); + req.getMonitorAddress(), req.getDryrun()); const config: {[key: string]: string} = {}; for (const [k, v] of req.getConfigMap()?.entries() || []) { diff --git a/sdk/nodejs/automation/stack.ts b/sdk/nodejs/automation/stack.ts index 869f673ec..6877ecfd0 100644 --- a/sdk/nodejs/automation/stack.ts +++ b/sdk/nodejs/automation/stack.ts @@ -97,22 +97,22 @@ export class Stack { this.workspace = workspace; switch (mode) { - case "create": - this.ready = workspace.createStack(name); - return this; - case "select": - this.ready = workspace.selectStack(name); - return this; - case "createOrSelect": - this.ready = workspace.createStack(name).catch((err) => { - if (err instanceof StackAlreadyExistsError) { - return workspace.selectStack(name); - } - throw err; - }); - return this; - default: - throw new Error(`unexpected Stack creation mode: ${mode}`); + case "create": + this.ready = workspace.createStack(name); + return this; + case "select": + this.ready = workspace.selectStack(name); + return this; + case "createOrSelect": + this.ready = workspace.createStack(name).catch((err) => { + if (err instanceof StackAlreadyExistsError) { + return workspace.selectStack(name); + } + throw err; + }); + return this; + default: + throw new Error(`unexpected Stack creation mode: ${mode}`); } } private async readLines(logPath: string, callback: (event: EngineEvent) => void): Promise { @@ -659,20 +659,20 @@ export type UpdateResult = "not-started" | "in-progress" | "succeeded" | "failed * The granular CRUD operation performed on a particular resource during an update. */ export type OpType = "same" - | "create" - | "update" - | "delete" - | "replace" - | "create-replacement" - | "delete-replaced" - | "read" - | "read-replacement" - | "refresh" - | "discard" - | "discard-replaced" - | "remove-pending-replace" - | "import" - | "import-replacement"; +| "create" +| "update" +| "delete" +| "replace" +| "create-replacement" +| "delete-replaced" +| "read" +| "read-replacement" +| "refresh" +| "discard" +| "discard-replaced" +| "remove-pending-replace" +| "import" +| "import-replacement"; /** * A map of operation types and their corresponding counts. diff --git a/sdk/nodejs/cmd/dynamic-provider/index.ts b/sdk/nodejs/cmd/dynamic-provider/index.ts index 307023911..fb2d9d267 100644 --- a/sdk/nodejs/cmd/dynamic-provider/index.ts +++ b/sdk/nodejs/cmd/dynamic-provider/index.ts @@ -324,7 +324,7 @@ function resultIncludingProvider(result: any, props: any): any { // rejected the resource, or an initialization error, where the API server has accepted the // resource, but it failed to initialize (e.g., the app code is continually crashing and the // resource has failed to become alive). -function grpcResponseFromError(e: {id: string, properties: any, message: string, reasons?: string[]}) { +function grpcResponseFromError(e: {id: string; properties: any; message: string; reasons?: string[]}) { // Create response object. const resp = new statusproto.Status(); resp.setCode(grpc.status.UNKNOWN); diff --git a/sdk/nodejs/cmd/run/index.ts b/sdk/nodejs/cmd/run/index.ts index bbfe956dc..84c1aaa5b 100644 --- a/sdk/nodejs/cmd/run/index.ts +++ b/sdk/nodejs/cmd/run/index.ts @@ -113,7 +113,9 @@ function printErrorUsageAndExit(message: string): never { function main(args: string[]): void { // See usage above for the intended usage of this program, including flags and required args. const argv: minimist.ParsedArgs = minimist(args, { + // eslint-disable-next-line id-blacklist boolean: [ "dry-run", "query-mode" ], + // eslint-disable-next-line id-blacklist string: [ "project", "stack", "parallel", "pwd", "monitor", "engine", "tracing" ], unknown: (arg: string) => { return true; diff --git a/sdk/nodejs/cmd/run/run.ts b/sdk/nodejs/cmd/run/run.ts index 7dd4e91ba..e5cf7738d 100644 --- a/sdk/nodejs/cmd/run/run.ts +++ b/sdk/nodejs/cmd/run/run.ts @@ -203,7 +203,7 @@ export function run(argv: minimist.ParsedArgs, } else { log.error( -`Running program '${program}' failed with an unhandled exception: + `Running program '${program}' failed with an unhandled exception: ${defaultMessage}`); } diff --git a/sdk/nodejs/config.ts b/sdk/nodejs/config.ts index 8d1b568a8..bfec585d7 100644 --- a/sdk/nodejs/config.ts +++ b/sdk/nodejs/config.ts @@ -439,7 +439,7 @@ class ConfigTypeError extends RunError { class ConfigEnumError extends RunError { constructor(key: string, v: any, values: any[]) { super(`Configuration '${key}' value '${v}' is not a legal enum value (${JSON.stringify(values)})`); - } + } } /** @@ -459,7 +459,7 @@ class ConfigRangeError extends RunError { range += " chars"; } super(`Configuration '${key}' value '${v}' is outside of the legal range (${range}, inclusive)`); - } + } } /** @@ -468,7 +468,7 @@ class ConfigRangeError extends RunError { class ConfigPatternError extends RunError { constructor(key: string, v: string, regexp: RegExp) { super(`Configuration '${key}' value '${v}' does not match the regular expression ${regexp.toString()}`); - } + } } /** diff --git a/sdk/nodejs/errors.ts b/sdk/nodejs/errors.ts index deca757e9..e4d9b3b73 100644 --- a/sdk/nodejs/errors.ts +++ b/sdk/nodejs/errors.ts @@ -28,7 +28,7 @@ export class RunError extends Error { * A private field to help with RTTI that works in SxS scenarios. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiRunError: boolean = true; /** @@ -55,7 +55,7 @@ export class ResourceError extends Error { * A private field to help with RTTI that works in SxS scenarios. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match public readonly __pulumResourceError: boolean = true; /** diff --git a/sdk/nodejs/iterable/index.ts b/sdk/nodejs/iterable/index.ts index 52deed33b..460d7d3ca 100644 --- a/sdk/nodejs/iterable/index.ts +++ b/sdk/nodejs/iterable/index.ts @@ -28,7 +28,7 @@ import { Input, Output } from "../output"; * */ export function toObject( - iter: Input[]>, selector: (t: T) => Input<[Input, Input]>): Output<{[key: string]: V}> { + iter: Input[]>, selector: (t: T) => Input<[Input, Input]>): Output<{[key: string]: V}> { return Output.create(iter).apply(elems => { const array: Input<[Input, Input]>[] = []; for (const e of elems) { @@ -59,7 +59,7 @@ export function toObject( * */ export function groupBy( - iter: Input[]>, selector: (t: T) => Input<[Input, Input]>): Output<{[key: string]: V[]}> { + iter: Input[]>, selector: (t: T) => Input<[Input, Input]>): Output<{[key: string]: V[]}> { return Output.create(iter).apply(elems => { const array: Input<[Input, Input]>[] = []; for (const e of elems) { diff --git a/sdk/nodejs/log/index.ts b/sdk/nodejs/log/index.ts index 33750cfdb..0ebd0d570 100644 --- a/sdk/nodejs/log/index.ts +++ b/sdk/nodejs/log/index.ts @@ -93,10 +93,10 @@ export function error(msg: string, resource?: resourceTypes.Resource, streamId?: } function log( - engine: any, sev: any, msg: string, - resource: resourceTypes.Resource | undefined, - streamId: number | undefined, - ephemeral: boolean | undefined): Promise { + engine: any, sev: any, msg: string, + resource: resourceTypes.Resource | undefined, + streamId: number | undefined, + ephemeral: boolean | undefined): Promise { // Ensure we log everything in serial order. const keepAlive: () => void = rpcKeepAlive(); diff --git a/sdk/nodejs/output.ts b/sdk/nodejs/output.ts index 19a659254..8e903d9a8 100644 --- a/sdk/nodejs/output.ts +++ b/sdk/nodejs/output.ts @@ -16,7 +16,7 @@ import { Resource } from "./resource"; import * as runtime from "./runtime"; import * as utils from "./utils"; -/*tslint:disable:no-shadowed-variable*/ +/* eslint-disable no-shadow, @typescript-eslint/no-shadow */ /** * Output helps encode the relationship between Resources in a Pulumi application. Specifically an @@ -32,7 +32,7 @@ class OutputImpl implements OutputInstance { * This is internal instead of being truly private, to support mixins and our serialization model. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiOutput: boolean = true; /** @@ -161,11 +161,11 @@ class OutputImpl implements OutputInstance { /** @internal */ public constructor( - resources: Set | Resource[] | Resource, - promise: Promise, - isKnown: Promise, - isSecret: Promise, - allResources: Promise | Resource[] | Resource> | undefined) { + resources: Set | Resource[] | Resource, + promise: Promise, + isKnown: Promise, + isSecret: Promise, + allResources: Promise | Resource[] | Resource> | undefined) { // Always create a copy so that no one accidentally modifies our Resource list. const resourcesCopy = copyResources(resources); @@ -180,7 +180,7 @@ class OutputImpl implements OutputInstance { isKnown = Promise.all([isKnown, promise]).then(([known, val]) => known && !containsUnknowns(val)); const lifted = Promise.all([allResourcesCopy, promise, isKnown, isSecret]) - .then(([liftedResources, value, liftedIsKnown, liftedIsSecret]) => liftInnerOutput(liftedResources, value, liftedIsKnown, liftedIsSecret)); + .then(([liftedResources, value, liftedIsKnown, liftedIsSecret]) => liftInnerOutput(liftedResources, value, liftedIsKnown, liftedIsSecret)); this.resources = () => resourcesCopy; this.allResources = () => lifted.then(l => l.allResources); @@ -299,7 +299,7 @@ To manipulate the value of this Output, use '.apply' instead.`); // we're inside the modern `output` code, so it's safe to call `.allResources!` here. const applied = Promise.all([this.allResources!(), this.promise(/*withUnknowns*/ true), this.isKnown, this.isSecret]) - .then(([allResources, value, isKnown, isSecret]) => applyHelperAsync(allResources, value, isKnown, isSecret, func, !!runWithUnknowns)); + .then(([allResources, value, isKnown, isSecret]) => applyHelperAsync(allResources, value, isKnown, isSecret, func, !!runWithUnknowns)); const result = new OutputImpl( this.resources(), @@ -320,8 +320,8 @@ export function getAllResources(op: OutputInstance): Promise function copyResources(resources: Set | Resource[] | Resource) { const copy = Array.isArray(resources) ? new Set(resources) : - resources instanceof Set ? new Set(resources) : - new Set([resources]); + resources instanceof Set ? new Set(resources) : + new Set([resources]); return copy; } @@ -353,10 +353,10 @@ async function liftInnerOutput(allResources: Set, value: any, isKnown: }; } -// tslint:disable:max-line-length +/* eslint-disable max-len */ async function applyHelperAsync( - allResources: Set, value: T, isKnown: boolean, isSecret: boolean, - func: (t: T) => Input, runWithUnknowns: boolean) { + allResources: Set, value: T, isKnown: boolean, isSecret: boolean, + func: (t: T) => Input, runWithUnknowns: boolean) { if (runtime.isDryRun()) { // During previews only perform the apply if the engine was able to give us an actual value // for this Output. @@ -541,7 +541,7 @@ export function secret(val: Input): Output(val: Output): Output { - return new Output( + return new Output( val.resources(), val.promise(/*withUnknowns*/ true), val.isKnown, Promise.resolve(false), val.allResources!()); } @@ -575,7 +575,7 @@ function createSimpleOutput(val: any) { * In this example, taking a dependency on d3 means a resource will depend on all the resources of * d1 and d2. */ -// tslint:disable:max-line-length +/* eslint-disable max-len */ export function all(val: Record>): Output>>; export function all(values: [Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap]>; export function all(values: [Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap]>; @@ -601,13 +601,14 @@ export function all(val: Input[] | Record>): Output function getAwaitableValue(v: any): any { if (Output.isInstance(v)) { return v.promise(/* withUnknowns */ true); - } else { + } + else { return v; } } async function getPromisedObject( - keysAndOutputs: { key: string; value: any }[]): Promise>> { + keysAndOutputs: { key: string; value: any }[]): Promise>> { const result: Record> = {}; for (const kvp of keysAndOutputs) { result[kvp.key] = await getAwaitableValue(kvp.value); @@ -666,7 +667,7 @@ class Unknown { * This is internal instead of being truly private, to support mixins and our serialization model. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiUnknown: boolean = true; /** @@ -760,8 +761,8 @@ export type Unwrap = // 2. Otherwise, if we have an output, do the same as a promise and just unwrap the inner type. // 3. Otherwise, we have a basic type. Just unwrap that. T extends Promise ? UnwrapSimple : - T extends OutputInstance ? UnwrapSimple : - UnwrapSimple; + T extends OutputInstance ? UnwrapSimple : + UnwrapSimple; type primitive = Function | string | number | boolean | undefined | null; @@ -778,10 +779,10 @@ export type UnwrapSimple = // types have been unwrapped. // 4. return 'never' at the end so that if we've missed something we'll discover it. T extends primitive ? T : - T extends Resource ? T : - T extends Array ? UnwrappedArray : - T extends object ? UnwrappedObject : - never; + T extends Resource ? T : + T extends Array ? UnwrappedArray : + T extends object ? UnwrappedObject : + never; export interface UnwrappedArray extends Array> {} @@ -853,11 +854,11 @@ export interface OutputConstructor { isInstance(obj: any): obj is Output; /** @internal */ new( - resources: Set | Resource[] | Resource, - promise: Promise, - isKnown: Promise, - isSecret: Promise, - allResources: Promise | Resource[] | Resource>): Output; + resources: Set | Resource[] | Resource, + promise: Promise, + isKnown: Promise, + isSecret: Promise, + allResources: Promise | Resource[] | Resource>): Output; } /** @@ -903,7 +904,7 @@ export interface OutputConstructor { * ``` */ export type Output = OutputInstance & Lifted; -// tslint:disable-next-line:variable-name +// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-redeclare,no-underscore-dangle,id-blacklist,id-match export const Output: OutputConstructor = OutputImpl; /** @@ -942,13 +943,13 @@ export const Output: OutputConstructor = OutputImpl; export type Lifted = // Specially handle 'string' since TS doesn't map the 'String.Length' property to it. T extends string ? LiftedObject> : - T extends Array ? LiftedArray : - T extends object ? LiftedObject> : - // fallback to lifting no properties. Note that `Lifted` is used in - // Output = OutputInstance & Lifted - // so returning an empty object just means that we're adding nothing to Output. - // This is needed for cases like `Output`. - {}; + T extends Array ? LiftedArray : + T extends object ? LiftedObject> : + // fallback to lifting no properties. Note that `Lifted` is used in + // Output = OutputInstance & Lifted + // so returning an empty object just means that we're adding nothing to Output. + // This is needed for cases like `Output`. + {}; // The set of property names in T that are *not* functions. type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T]; @@ -957,7 +958,7 @@ type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? nev // If it's require before, keep it required afterwards. export type LiftedObject = { [P in K]: T[P] extends OutputInstance ? Output : - T[P] extends Promise ? Output : Output + T[P] extends Promise ? Output : Output }; export type LiftedArray = { diff --git a/sdk/nodejs/package.json b/sdk/nodejs/package.json index 39fb1826e..cf3db95e4 100644 --- a/sdk/nodejs/package.json +++ b/sdk/nodejs/package.json @@ -34,9 +34,13 @@ "@types/read-package-tree": "^5.2.0", "@types/semver": "^5.5.0", "@types/split2": "^2.1.6", + "@typescript-eslint/eslint-plugin": "^4.29.0", + "@typescript-eslint/parser": "^4.29.0", + "eslint": "^7.32.0", + "eslint-plugin-header": "^3.1.1", + "eslint-plugin-import": "^2.23.4", "istanbul": "^0.4.5", - "mocha": "^3.5.0", - "tslint": "^5.11.0" + "mocha": "^3.5.0" }, "pulumi": { "comment": "Do not remove. Marks this as as a deployment-time-only package" diff --git a/sdk/nodejs/provider/provider.ts b/sdk/nodejs/provider/provider.ts index de5a981f7..8c5002b97 100644 --- a/sdk/nodejs/provider/provider.ts +++ b/sdk/nodejs/provider/provider.ts @@ -209,7 +209,7 @@ export interface Provider { * @param options the options for the resource. */ construct?: (name: string, type: string, inputs: Inputs, options: resource.ComponentResourceOptions) - => Promise; + => Promise; /** * Call calls the indicated method. diff --git a/sdk/nodejs/provider/server.ts b/sdk/nodejs/provider/server.ts index 66c4af11c..6a2b29007 100644 --- a/sdk/nodejs/provider/server.ts +++ b/sdk/nodejs/provider/server.ts @@ -264,7 +264,7 @@ class Server implements grpc.UntypedServiceImplementation { // in its own context, possibly using Node's `createContext` API to avoid modifying global state: // https://nodejs.org/api/vm.html#vm_vm_createcontext_contextobject_options const res = this.constructCallQueue.then(() => this.constructImpl(call, callback)); - // tslint:disable:no-empty + /* eslint-disable no-empty,no-empty-function,@typescript-eslint/no-empty-function */ this.constructCallQueue = res.catch(() => {}); return res; } @@ -355,7 +355,7 @@ class Server implements grpc.UntypedServiceImplementation { // in its own context, possibly using Node's `createContext` API to avoid modifying global state: // https://nodejs.org/api/vm.html#vm_vm_createcontext_contextobject_options const res = this.constructCallQueue.then(() => this.callImpl(call, callback)); - // tslint:disable:no-empty + /* eslint-disable no-empty, no-empty-function, @typescript-eslint/no-empty-function */ this.constructCallQueue = res.catch(() => {}); return res; } @@ -469,7 +469,7 @@ function configureRuntime(req: any, engineAddr: string) { // NOTE: these are globals! We should ensure that all settings are identical between calls, and eventually // refactor so we can avoid the global state. runtime.resetOptions(req.getProject(), req.getStack(), req.getParallel(), engineAddr, - req.getMonitorendpoint(), req.getDryrun()); + req.getMonitorendpoint(), req.getDryrun()); const pulumiConfig: {[key: string]: string} = {}; const rpcConfig = req.getConfigMap(); @@ -513,7 +513,7 @@ async function deserializeInputs(inputsStruct: any, inputDependencies: any): Pro // rejected the resource, or an initialization error, where the API server has accepted the // resource, but it failed to initialize (e.g., the app code is continually crashing and the // resource has failed to become alive). -function grpcResponseFromError(e: {id: string, properties: any, message: string, reasons?: string[]}) { +function grpcResponseFromError(e: {id: string; properties: any; message: string; reasons?: string[]}) { // Create response object. const resp = new statusproto.Status(); resp.setCode(grpc.status.UNKNOWN); diff --git a/sdk/nodejs/queryable/index.ts b/sdk/nodejs/queryable/index.ts index 0bbf5cda9..9a7dbcf20 100644 --- a/sdk/nodejs/queryable/index.ts +++ b/sdk/nodejs/queryable/index.ts @@ -25,20 +25,20 @@ export type ResolvedResource = Omit, "urn" | "ge export type Resolved = T extends Promise ? ResolvedSimple : T extends OutputInstance - ? ResolvedSimple - : ResolvedSimple; + ? ResolvedSimple + : ResolvedSimple; type primitive = string | number | boolean | undefined | null; type ResolvedSimple = T extends primitive ? T : T extends Array - ? ResolvedArray - : T extends Function - ? never - : T extends object - ? ResolvedObject - : never; + ? ResolvedArray + : T extends Function + ? never + : T extends object + ? ResolvedObject + : never; interface ResolvedArray extends Array> {} @@ -48,4 +48,4 @@ type RequiredKeys = { [P in keyof T]: undefined extends T[P] ? never : P }[ke type OptionalKeys = { [P in keyof T]: undefined extends T[P] ? P : never }[keyof T]; type ModifyOptionalProperties = { [P in RequiredKeys]: T[P] } & - { [P in OptionalKeys]?: T[P] }; +{ [P in OptionalKeys]?: T[P] }; diff --git a/sdk/nodejs/resource.ts b/sdk/nodejs/resource.ts index 95d27aba9..733437010 100644 --- a/sdk/nodejs/resource.ts +++ b/sdk/nodejs/resource.ts @@ -76,14 +76,14 @@ export abstract class Resource { * A private field to help with RTTI that works in SxS scenarios. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiResource: boolean = true; /** * The optional parent of this resource. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __parentResource: Resource | undefined; /** @@ -125,7 +125,7 @@ export abstract class Resource { * * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public __childResources: Set | undefined; /** @@ -138,7 +138,7 @@ export abstract class Resource { * When set to true, protect ensures this resource cannot be deleted. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match private readonly __protect: boolean; /** @@ -149,7 +149,7 @@ export abstract class Resource { * cases where they are passed "old" resources. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match __transformations?: ResourceTransformation[]; /** @@ -160,7 +160,7 @@ export abstract class Resource { * cases where they are passed "old" resources. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match readonly __aliases?: Input[]; /** @@ -171,14 +171,14 @@ export abstract class Resource { * cases where they are passed "old" resources. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match private readonly __name?: string; /** * The set of providers to use for child resources. Keyed by package name (e.g. "aws"). * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match private readonly __providers: Record; /** @@ -187,14 +187,14 @@ export abstract class Resource { */ // Note: This is deliberately not named `__provider` as that conflicts with the property // used by the `dynamic.Resource` class. - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match readonly __prov?: ProviderResource; /** * The specified provider version. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match readonly __version?: string; public static isInstance(obj: any): obj is Resource { @@ -454,10 +454,10 @@ export interface Alias { // collapseAliasToUrn turns an Alias into a URN given a set of default data function collapseAliasToUrn( - alias: Input, - defaultName: string, - defaultType: string, - defaultParent: Resource | undefined): Output { + alias: Input, + defaultName: string, + defaultType: string, + defaultParent: Resource | undefined): Output { return output(alias).apply(a => { if (typeof a === "string") { @@ -684,7 +684,7 @@ export abstract class CustomResource extends Resource { * A private field to help with RTTI that works in SxS scenarios. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiCustomResource: boolean; /** @@ -692,7 +692,7 @@ export abstract class CustomResource extends Resource { * classes that inherit from `CustomResource`. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiType: string; /** @@ -745,7 +745,7 @@ export abstract class ProviderResource extends CustomResource { private readonly pkg: string; /** @internal */ - // tslint:disable-next-line: variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public __registrationId?: string; public static async register(provider: ProviderResource | undefined): Promise { @@ -792,19 +792,19 @@ export class ComponentResource extends Resource { * A private field to help with RTTI that works in SxS scenarios. * @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __pulumiComponentResource = true; /** @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __data: Promise; /** @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match private __registered = false; /** @internal */ - // tslint:disable-next-line:variable-name + // eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match public readonly __remote: boolean; /** diff --git a/sdk/nodejs/runtime/asyncIterableUtil.ts b/sdk/nodejs/runtime/asyncIterableUtil.ts index ae843ece3..b36d3a451 100644 --- a/sdk/nodejs/runtime/asyncIterableUtil.ts +++ b/sdk/nodejs/runtime/asyncIterableUtil.ts @@ -72,7 +72,7 @@ export class PushableAsyncIterable implements AsyncIterable { [Symbol.asyncIterator]() { const t = this; return { - async next(): Promise<{ done: boolean; value: T | undefined; }> { + async next(): Promise<{ done: boolean; value: T | undefined }> { const value = await t.shift(); if (value === closeValue) { return { value: undefined, done: true }; diff --git a/sdk/nodejs/runtime/closure/codePaths.ts b/sdk/nodejs/runtime/closure/codePaths.ts index 78fbf45e0..37416cb42 100644 --- a/sdk/nodejs/runtime/closure/codePaths.ts +++ b/sdk/nodejs/runtime/closure/codePaths.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable:max-line-length +/* eslint-disable max-len */ import * as fs from "fs"; import * as normalize from "normalize-package-data"; @@ -162,9 +162,9 @@ function isSubsumedByHigherPath(normalizedPath: string, normalizedPathSet: Set, - excludedPackages: Set, - logResource: Resource | undefined): Promise> { + includedPackages: Set, + excludedPackages: Set, + logResource: Resource | undefined): Promise> { return new Promise((resolve, reject) => { readPackageTree(".", undefined, (err: any, root: readPackageTree.Node) => { try { diff --git a/sdk/nodejs/runtime/closure/createClosure.ts b/sdk/nodejs/runtime/closure/createClosure.ts index 8265f16c5..37056bea9 100644 --- a/sdk/nodejs/runtime/closure/createClosure.ts +++ b/sdk/nodejs/runtime/closure/createClosure.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable:max-line-length +/* eslint-disable max-len */ import * as upath from "upath"; import { ResourceError } from "../../errors"; @@ -101,7 +101,7 @@ export interface Entry { json?: any; // An RegExp. Will be serialized as 'new RegExp(re.source, re.flags)' - regexp?: { source: string, flags: string }; + regexp?: { source: string; flags: string }; // a closure we are dependent on. function?: FunctionInfo; @@ -181,7 +181,7 @@ interface ContextFrame { functionLocation?: FunctionLocation; capturedFunctionName?: string; capturedVariableName?: string; - capturedModule?: { name: string, value: any }; + capturedModule?: { name: string; value: any }; } interface ClosurePropertyDescriptor { @@ -195,7 +195,7 @@ interface ClosurePropertyDescriptor { value?: any; writable?: boolean; get?: () => any; - set?: (v: any)=> void; + set?: (v: any) => void; } /* @@ -213,7 +213,7 @@ class SerializedOutput { public apply(func: (t: T) => Input): Output { throw new Error( -"'apply' is not allowed from inside a cloud-callback. Use 'get' to retrieve the value of this Output directly."); + "'apply' is not allowed from inside a cloud-callback. Use 'get' to retrieve the value of this Output directly."); } public get(): T { @@ -339,7 +339,7 @@ export async function createClosureInfoAsync( // see http://www.ecma-international.org/ecma-262/6.0/#sec-generatorfunction-objects and // http://www.ecma-international.org/ecma-262/6.0/figure-2.png async function addGeneratorEntriesAsync() { - // tslint:disable-next-line:no-empty + // eslint-disable-next-line no-empty,no-empty-function,@typescript-eslint/no-empty-function const emptyGenerator = function* (): any { }; await addEntriesAsync( @@ -362,8 +362,8 @@ export async function createClosureInfoAsync( * final FunctionInfo. */ async function analyzeFunctionInfoAsync( - func: Function, context: Context, - serialize: (o: any) => boolean, logInfo?: boolean): Promise { + func: Function, context: Context, + serialize: (o: any) => boolean, logInfo?: boolean): Promise { // logInfo = logInfo || func.name === "addHandler"; @@ -687,7 +687,7 @@ function throwSerializationError( message += getTrimmedFunctionCode(func); const moduleIndex = context.frames.findIndex( - f => f.capturedModule !== undefined); + f => f.capturedModule !== undefined); if (moduleIndex >= 0) { const module = context.frames[moduleIndex].capturedModule!; @@ -782,10 +782,10 @@ async function isDefaultFunctionPrototypeAsync(func: Function, prototypeProp: an } async function createPropertyInfoAsync( - descriptor: ClosurePropertyDescriptor, - context: Context, - serialize: (o: any) => boolean, - logInfo: boolean | undefined): Promise { + descriptor: ClosurePropertyDescriptor, + context: Context, + serialize: (o: any) => boolean, + logInfo: boolean | undefined): Promise { const propertyInfo = { hasValue: descriptor.value !== undefined }; propertyInfo.configurable = descriptor.configurable; @@ -793,11 +793,11 @@ async function createPropertyInfoAsync( propertyInfo.writable = descriptor.writable; if (descriptor.get) { propertyInfo.get = await getOrCreateEntryAsync( - descriptor.get, undefined, context, serialize, logInfo); + descriptor.get, undefined, context, serialize, logInfo); } if (descriptor.set) { propertyInfo.set = await getOrCreateEntryAsync( - descriptor.set, undefined, context, serialize, logInfo); + descriptor.set, undefined, context, serialize, logInfo); } return propertyInfo; @@ -818,10 +818,10 @@ function getOrCreateNameEntryAsync( * specific properties. If propNames is not provided, or is empty, serialize out all properties. */ async function getOrCreateEntryAsync( - obj: any, capturedObjectProperties: CapturedPropertyChain[] | undefined, - context: Context, - serialize: (o: any) => boolean, - logInfo: boolean | undefined): Promise { + obj: any, capturedObjectProperties: CapturedPropertyChain[] | undefined, + context: Context, + serialize: (o: any) => boolean, + logInfo: boolean | undefined): Promise { // Check if this is a special number that we cannot json serialize. Instead, we'll just inject // the code necessary to represent the number on the other side. Note: we have to do this @@ -1046,7 +1046,7 @@ async function getOrCreateEntryAsync( // Serializes out only the subset of properties of this object that we have seen used // and have recorded in localCapturedPropertyChains async function serializeSomeObjectPropertiesAsync( - object: ObjectInfo, localCapturedPropertyChains: CapturedPropertyChain[]): Promise { + object: ObjectInfo, localCapturedPropertyChains: CapturedPropertyChain[]): Promise { // validate our invariants. for (const chain of localCapturedPropertyChains) { @@ -1422,8 +1422,8 @@ async function getOwnPropertyDescriptors(obj: any): Promise { return (descriptor.get || descriptor.set) ? - undefined : - obj[getNameOrSymbol(descriptor)]; + undefined : + obj[getNameOrSymbol(descriptor)]; } async function getPropertyAsync(obj: any, name: string): Promise { diff --git a/sdk/nodejs/runtime/closure/parseFunction.ts b/sdk/nodejs/runtime/closure/parseFunction.ts index 375720420..0b07b1afd 100644 --- a/sdk/nodejs/runtime/closure/parseFunction.ts +++ b/sdk/nodejs/runtime/closure/parseFunction.ts @@ -239,7 +239,7 @@ function tryParseAsArrowFunction(toParse: string): boolean { } function makeFunctionDeclaration( - v: string, isAsync: boolean, isFunctionDeclaration: boolean): [string, ParsedFunctionCode] { + v: string, isAsync: boolean, isFunctionDeclaration: boolean): [string, ParsedFunctionCode] { let prefix = isAsync ? "async " : ""; prefix += "function "; @@ -338,18 +338,18 @@ function computeUsesNonLexicalThis(file: ts.SourceFile): boolean { } switch (node.kind) { - case ts.SyntaxKind.SuperKeyword: - case ts.SyntaxKind.ThisKeyword: - usesNonLexicalThis = true; - break; + case ts.SyntaxKind.SuperKeyword: + case ts.SyntaxKind.ThisKeyword: + usesNonLexicalThis = true; + break; - case ts.SyntaxKind.CallExpression: - return visitCallExpression(node); + case ts.SyntaxKind.CallExpression: + return visitCallExpression(node); - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - return visitBaseFunction(node); + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.FunctionExpression: + return visitBaseFunction(node); // Note: it is intentional that we ignore ArrowFunction. If we use 'this' inside of it, // then that should be considered a use of the non-lexical-this from an outer function. @@ -357,8 +357,8 @@ function computeUsesNonLexicalThis(file: ts.SourceFile): boolean { // function f() { var v = () => console.log(this) } // // case ts.SyntaxKind.ArrowFunction: - default: - break; + default: + break; } ts.forEachChild(node, walk); @@ -494,35 +494,35 @@ function computeCapturedVariableNames(file: ts.SourceFile): CapturedVariables { } switch (node.kind) { - case ts.SyntaxKind.Identifier: - return visitIdentifier(node); - case ts.SyntaxKind.ThisKeyword: - return visitThisExpression(node); - case ts.SyntaxKind.Block: - return visitBlockStatement(node); - case ts.SyntaxKind.CallExpression: - return visitCallExpression(node); - case ts.SyntaxKind.CatchClause: - return visitCatchClause(node); - case ts.SyntaxKind.MethodDeclaration: - return visitMethodDeclaration(node); - case ts.SyntaxKind.MetaProperty: - // don't walk down an es6 metaproperty (i.e. "new.target"). It doesn't - // capture anything. - return; - case ts.SyntaxKind.PropertyAssignment: - return visitPropertyAssignment(node); - case ts.SyntaxKind.PropertyAccessExpression: - return visitPropertyAccessExpression(node); - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.FunctionExpression: - return visitFunctionDeclarationOrExpression(node); - case ts.SyntaxKind.ArrowFunction: - return visitBaseFunction(node, /*isArrowFunction:*/true, /*name:*/ undefined); - case ts.SyntaxKind.VariableDeclaration: - return visitVariableDeclaration(node); - default: - break; + case ts.SyntaxKind.Identifier: + return visitIdentifier(node); + case ts.SyntaxKind.ThisKeyword: + return visitThisExpression(node); + case ts.SyntaxKind.Block: + return visitBlockStatement(node); + case ts.SyntaxKind.CallExpression: + return visitCallExpression(node); + case ts.SyntaxKind.CatchClause: + return visitCatchClause(node); + case ts.SyntaxKind.MethodDeclaration: + return visitMethodDeclaration(node); + case ts.SyntaxKind.MetaProperty: + // don't walk down an es6 metaproperty (i.e. "new.target"). It doesn't + // capture anything. + return; + case ts.SyntaxKind.PropertyAssignment: + return visitPropertyAssignment(node); + case ts.SyntaxKind.PropertyAccessExpression: + return visitPropertyAccessExpression(node); + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.FunctionExpression: + return visitFunctionDeclarationOrExpression(node); + case ts.SyntaxKind.ArrowFunction: + return visitBaseFunction(node, /*isArrowFunction:*/true, /*name:*/ undefined); + case ts.SyntaxKind.VariableDeclaration: + return visitVariableDeclaration(node); + default: + break; } ts.forEachChild(node, walk); @@ -625,7 +625,7 @@ function computeCapturedVariableNames(file: ts.SourceFile): CapturedVariables { } function visitFunctionDeclarationOrExpression( - node: ts.FunctionDeclaration | ts.FunctionExpression): void { + node: ts.FunctionDeclaration | ts.FunctionExpression): void { // A function declaration is special in one way: its identifier is added to the current function's // var-style variables, so that its name is in scope no matter the order of surrounding references to it. @@ -637,9 +637,9 @@ function computeCapturedVariableNames(file: ts.SourceFile): CapturedVariables { } function visitBaseFunction( - node: ts.FunctionLikeDeclarationBase, - isArrowFunction: boolean, - functionName: ts.Identifier | undefined): void { + node: ts.FunctionLikeDeclarationBase, + isArrowFunction: boolean, + functionName: ts.Identifier | undefined): void { // First, push new free vars list, scope, and function vars const savedRequired = required; const savedOptional = optional; @@ -794,27 +794,27 @@ function computeCapturedVariableNames(file: ts.SourceFile): CapturedVariables { } switch (n.kind) { - case ts.SyntaxKind.Identifier: - return visitVariableDeclarationIdentifier(n, isVar); - case ts.SyntaxKind.ObjectBindingPattern: - case ts.SyntaxKind.ArrayBindingPattern: - const bindingPattern = n; - for (const element of bindingPattern.elements) { - if (ts.isBindingElement(element)) { - visitBindingElement(element, isVar); - } + case ts.SyntaxKind.Identifier: + return visitVariableDeclarationIdentifier(n, isVar); + case ts.SyntaxKind.ObjectBindingPattern: + case ts.SyntaxKind.ArrayBindingPattern: + const bindingPattern = n; + for (const element of bindingPattern.elements) { + if (ts.isBindingElement(element)) { + visitBindingElement(element, isVar); } + } - return; - default: - return; + return; + default: + return; } } function visitVariableDeclaration(node: ts.VariableDeclaration): void { - // tslint:disable-next-line:max-line-length + // eslint-disable-next-line max-len const isLet = node.parent !== undefined && ts.isVariableDeclarationList(node.parent) && (node.parent.flags & ts.NodeFlags.Let) !== 0; - // tslint:disable-next-line:max-line-length + // eslint-disable-next-line max-len const isConst = node.parent !== undefined && ts.isVariableDeclarationList(node.parent) && (node.parent.flags & ts.NodeFlags.Const) !== 0; const isVar = !isLet && !isConst; diff --git a/sdk/nodejs/runtime/closure/serializeClosure.ts b/sdk/nodejs/runtime/closure/serializeClosure.ts index 983a51c03..02f4bf403 100644 --- a/sdk/nodejs/runtime/closure/serializeClosure.ts +++ b/sdk/nodejs/runtime/closure/serializeClosure.ts @@ -92,8 +92,8 @@ export interface SerializedFunction { * @param args Arguments to use to control the serialization of the JavaScript function. */ export async function serializeFunction( - func: Function, - args: SerializeFunctionArgs = {}): Promise { + func: Function, + args: SerializeFunctionArgs = {}): Promise { const exportName = args.exportName || "handler"; const serialize = args.serialize || (_ => true); @@ -110,8 +110,8 @@ export async function serializeFunction( * @deprecated Please use 'serializeFunction' instead. */ export async function serializeFunctionAsync( - func: Function, - serialize?: (o: any) => boolean): Promise { + func: Function, + serialize?: (o: any) => boolean): Promise { log.warn("'function serializeFunctionAsync' is deprecated. Please use 'serializeFunction' instead."); serialize = serialize || (_ => true); @@ -129,9 +129,9 @@ export async function serializeFunctionAsync( * @param c The FunctionInfo to be serialized into a module string. */ function serializeJavaScriptText( - outerClosure: closure.ClosureInfo, - exportName: string, - isFactoryFunction: boolean): SerializedFunction { + outerClosure: closure.ClosureInfo, + exportName: string, + isFactoryFunction: boolean): SerializedFunction { // Now produce a textual representation of the closure and its serialized captured environment. @@ -257,7 +257,7 @@ function serializeJavaScriptText( } function simpleEnvEntryToString( - envEntry: closure.Entry, varName: string): string { + envEntry: closure.Entry, varName: string): string { if (envEntry.hasOwnProperty("json")) { return JSON.stringify(envEntry.json); @@ -285,7 +285,7 @@ function serializeJavaScriptText( } function complexEnvEntryToString( - envEntry: closure.Entry, varName: string): string { + envEntry: closure.Entry, varName: string): string { // Call all environment variables __e to make them unique. But suffix // them with the original name of the property to help provide context when // looking at the source. @@ -401,7 +401,7 @@ function serializeJavaScriptText( } function emitComplexObjectProperties( - envVar: string, varName: string, objEntry: closure.ObjectInfo): void { + envVar: string, varName: string, objEntry: closure.ObjectInfo): void { for (const [keyEntry, { info, entry: valEntry }] of objEntry.env) { const subName = typeof keyEntry.json === "string" ? keyEntry.json : "sym"; @@ -451,7 +451,7 @@ function serializeJavaScriptText( } function emitArray( - envVar: string, arr: closure.Entry[], varName: string): void { + envVar: string, arr: closure.Entry[], varName: string): void { if (arr.some(deepContainsObjOrArrayOrRegExp) || isSparse(arr) || hasNonNumericIndices(arr)) { // we have a complex child. Because of the possibility of recursion in the object // graph, we have to spit out this variable initialized (but empty) first. Then we can diff --git a/sdk/nodejs/runtime/closure/v8_v10andLower.ts b/sdk/nodejs/runtime/closure/v8_v10andLower.ts index 811220237..d61bcfe6c 100644 --- a/sdk/nodejs/runtime/closure/v8_v10andLower.ts +++ b/sdk/nodejs/runtime/closure/v8_v10andLower.ts @@ -102,7 +102,7 @@ function getScript(func: Function): V8Script | undefined { const getSourcePosition: (func: Function) => V8SourcePosition = new Function("func", "return %FunctionGetScriptSourcePosition(func);") as any; -function scriptPositionInfo(script: V8Script, pos: V8SourcePosition): {line: number, column: number} { +function scriptPositionInfo(script: V8Script, pos: V8SourcePosition): {line: number; column: number} { if (isNodeAtLeastV10) { const scriptPositionInfoFunc = new Function("script", "pos", "return %ScriptPositionInfo(script, pos, false);") as any; diff --git a/sdk/nodejs/runtime/closure/v8_v11andHigher.ts b/sdk/nodejs/runtime/closure/v8_v11andHigher.ts index 5ce284e76..05db19c00 100644 --- a/sdk/nodejs/runtime/closure/v8_v11andHigher.ts +++ b/sdk/nodejs/runtime/closure/v8_v11andHigher.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable:max-line-length +/* eslint-disable max-len */ import * as inspector from "inspector"; import * as util from "util"; @@ -193,8 +193,8 @@ async function getRuntimeIdForFunctionAsync(func: Function): Promiseawait v8Hooks.getSessionAsync(); const post = util.promisify(session.post); diff --git a/sdk/nodejs/runtime/invoke.ts b/sdk/nodejs/runtime/invoke.ts index e51e6fc66..fff6f825f 100644 --- a/sdk/nodejs/runtime/invoke.ts +++ b/sdk/nodejs/runtime/invoke.ts @@ -209,7 +209,7 @@ function createInvokeRequest(tok: string, serialized: any, provider: string | un function getProvider(tok: string, opts: InvokeOptions) { return opts.provider ? opts.provider : - opts.parent ? opts.parent.getProvider(tok) : undefined; + opts.parent ? opts.parent.getProvider(tok) : undefined; } function deserializeResponse(tok: string, resp: any): any { @@ -329,7 +329,7 @@ export function call(tok: string, props: Inputs, res?: Resource): Output { } function createOutput(label: string): - [Output, (v: T, isKnown: boolean, isSecret: boolean, deps?: Resource[], err?: Error | undefined) => void] { +[Output, (v: T, isKnown: boolean, isSecret: boolean, deps?: Resource[], err?: Error | undefined) => void] { let resolveValue: (v: T) => void; let rejectValue: (err: Error) => void; let resolveIsKnown: (v: boolean) => void; diff --git a/sdk/nodejs/runtime/mocks.ts b/sdk/nodejs/runtime/mocks.ts index b00cdd867..bc7ae01ea 100644 --- a/sdk/nodejs/runtime/mocks.ts +++ b/sdk/nodejs/runtime/mocks.ts @@ -93,11 +93,11 @@ export interface Mocks { * @param args: MockResourceArgs */ - newResource(args: MockResourceArgs): { id: string | undefined, state: Record }; + newResource(args: MockResourceArgs): { id: string | undefined; state: Record }; } export class MockMonitor { - readonly resources = new Map(); + readonly resources = new Map(); constructor(readonly mocks: Mocks) { } diff --git a/sdk/nodejs/runtime/resource.ts b/sdk/nodejs/runtime/resource.ts index 5946aad44..6e5904208 100644 --- a/sdk/nodejs/runtime/resource.ts +++ b/sdk/nodejs/runtime/resource.ts @@ -450,7 +450,7 @@ async function prepareResource(label: string, res: Resource, custom: boolean, re rejectIsKnown = reject; }), `resolveURNIsKnown(${label})`), - /*isSecret:*/ Promise.resolve(false), + /*isSecret:*/ Promise.resolve(false), Promise.resolve(res)); resolveURN = (v, err) => { @@ -478,7 +478,7 @@ async function prepareResource(label: string, res: Resource, custom: boolean, re resolveValue = resolve; rejectValue = reject; }), - `resolveID(${label})`), + `resolveID(${label})`), debuggablePromise(new Promise((resolve, reject) => { resolveIsKnown = resolve; rejectIsKnown = reject; @@ -630,7 +630,7 @@ async function getAllTransitivelyReferencedResourceURNs(resources: Set // Then we filter to only include Custom and Remote resources. const transitivelyReachableCustomResources = [...transitivelyReachableResources] - .filter(r => CustomResource.isInstance(r) || (r as ComponentResource).__remote); + .filter(r => CustomResource.isInstance(r) || (r as ComponentResource).__remote); const promises = transitivelyReachableCustomResources.map(r => r.urn.promise()); const urns = await Promise.all(promises); return new Set(urns); @@ -814,8 +814,8 @@ export function listResourceOutputs( }).then(({ outputs }) => utils.values(outputs)), ) .map>(({ type: typ, outputs }) => { - return { ...outputs, __pulumiType: typ }; - }) + return { ...outputs, __pulumiType: typ }; + }) .filter(typeFilter); } diff --git a/sdk/nodejs/runtime/rpc.ts b/sdk/nodejs/runtime/rpc.ts index 46ca4ae54..dd6bdd63a 100644 --- a/sdk/nodejs/runtime/rpc.ts +++ b/sdk/nodejs/runtime/rpc.ts @@ -112,10 +112,10 @@ export function transferProperties(onto: Resource, label: string, props: Inputs) * be remoted over to registerResource. */ async function serializeFilteredProperties( - label: string, - props: Inputs, - acceptKey: (k: string) => boolean, - ): Promise<[Record, Map>]> { + label: string, + props: Inputs, + acceptKey: (k: string) => boolean, +): Promise<[Record, Map>]> { const propertyToDependentResources = new Map>(); @@ -232,9 +232,9 @@ export function resolveProperties( // present during previews (i.e. isDryRun() will be true). resolve(value, /*isKnown*/ true, isSecret, deps[k]); } - catch (err) { + catch (resolveError) { throw new Error( - `Unable to set property '${k}' on resource '${name}' [${t}]; error: ${errorString(err)}`); + `Unable to set property '${k}' on resource '${name}' [${t}]; error: ${errorString(resolveError)}`); } } @@ -499,83 +499,83 @@ export function deserializeProperty(prop: any): any { const sig: any = prop[specialSigKey]; if (sig) { switch (sig) { - case specialAssetSig: - if (prop["path"]) { - return new asset.FileAsset(prop["path"]); - } - else if (prop["text"]) { - return new asset.StringAsset(prop["text"]); - } - else if (prop["uri"]) { - return new asset.RemoteAsset(prop["uri"]); - } - else { - throw new Error("Invalid asset encountered when unmarshaling resource property"); - } - case specialArchiveSig: - if (prop["assets"]) { - const assets: asset.AssetMap = {}; - for (const name of Object.keys(prop["assets"])) { - const a = deserializeProperty(prop["assets"][name]); - if (!(asset.Asset.isInstance(a)) && !(asset.Archive.isInstance(a))) { - throw new Error( - "Expected an AssetArchive's assets to be unmarshaled Asset or Archive objects"); - } - assets[name] = a; + case specialAssetSig: + if (prop["path"]) { + return new asset.FileAsset(prop["path"]); + } + else if (prop["text"]) { + return new asset.StringAsset(prop["text"]); + } + else if (prop["uri"]) { + return new asset.RemoteAsset(prop["uri"]); + } + else { + throw new Error("Invalid asset encountered when unmarshaling resource property"); + } + case specialArchiveSig: + if (prop["assets"]) { + const assets: asset.AssetMap = {}; + for (const name of Object.keys(prop["assets"])) { + const a = deserializeProperty(prop["assets"][name]); + if (!(asset.Asset.isInstance(a)) && !(asset.Archive.isInstance(a))) { + throw new Error( + "Expected an AssetArchive's assets to be unmarshaled Asset or Archive objects"); } - return new asset.AssetArchive(assets); + assets[name] = a; } - else if (prop["path"]) { - return new asset.FileArchive(prop["path"]); - } - else if (prop["uri"]) { - return new asset.RemoteArchive(prop["uri"]); - } - else { - throw new Error("Invalid archive encountered when unmarshaling resource property"); - } - case specialSecretSig: - return { - [specialSigKey]: specialSecretSig, - value: deserializeProperty(prop["value"]), - }; - case specialResourceSig: - // Deserialize the resource into a live Resource reference - const urn = prop["urn"]; - const version = prop["packageVersion"]; + return new asset.AssetArchive(assets); + } + else if (prop["path"]) { + return new asset.FileArchive(prop["path"]); + } + else if (prop["uri"]) { + return new asset.RemoteArchive(prop["uri"]); + } + else { + throw new Error("Invalid archive encountered when unmarshaling resource property"); + } + case specialSecretSig: + return { + [specialSigKey]: specialSecretSig, + value: deserializeProperty(prop["value"]), + }; + case specialResourceSig: + // Deserialize the resource into a live Resource reference + const urn = prop["urn"]; + const version = prop["packageVersion"]; - const urnParts = urn.split("::"); - const qualifiedType = urnParts[2]; - const urnName = urnParts[3]; + const urnParts = urn.split("::"); + const qualifiedType = urnParts[2]; + const urnName = urnParts[3]; - const type = qualifiedType.split("$").pop()!; - const typeParts = type.split(":"); - const pkgName = typeParts[0]; - const modName = typeParts.length > 1 ? typeParts[1] : ""; - const typName = typeParts.length > 2 ? typeParts[2] : ""; - const isProvider = pkgName === "pulumi" && modName === "providers"; + const type = qualifiedType.split("$").pop()!; + const typeParts = type.split(":"); + const pkgName = typeParts[0]; + const modName = typeParts.length > 1 ? typeParts[1] : ""; + const typName = typeParts.length > 2 ? typeParts[2] : ""; + const isProvider = pkgName === "pulumi" && modName === "providers"; - if (isProvider) { - const resourcePackage = getResourcePackage(typName, version); - if (resourcePackage) { - return resourcePackage.constructProvider(urnName, type, urn); - } - } else { - const resourceModule = getResourceModule(pkgName, modName, version); - if (resourceModule) { - return resourceModule.construct(urnName, type, urn); - } + if (isProvider) { + const resourcePackage = getResourcePackage(typName, version); + if (resourcePackage) { + return resourcePackage.constructProvider(urnName, type, urn); } - - // If we've made it here, deserialize the reference as either a URN or an ID (if present). - if (prop["id"]) { - const id = prop["id"]; - return deserializeProperty(id === "" ? unknownValue : id); + } else { + const resourceModule = getResourceModule(pkgName, modName, version); + if (resourceModule) { + return resourceModule.construct(urnName, type, urn); } - return urn; + } - default: - throw new Error(`Unrecognized signature '${sig}' when unmarshaling resource property`); + // If we've made it here, deserialize the reference as either a URN or an ID (if present). + if (prop["id"]) { + const id = prop["id"]; + return deserializeProperty(id === "" ? unknownValue : id); + } + return urn; + + default: + throw new Error(`Unrecognized signature '${sig}' when unmarshaling resource property`); } } diff --git a/sdk/nodejs/runtime/settings.ts b/sdk/nodejs/runtime/settings.ts index 950385c6d..9da2db60e 100644 --- a/sdk/nodejs/runtime/settings.ts +++ b/sdk/nodejs/runtime/settings.ts @@ -32,7 +32,7 @@ const grpcChannelOptions = { "grpc.max_receive_message_length": maxRPCMessageSiz /** * excessiveDebugOutput enables, well, pretty excessive debug output pertaining to resources and properties. */ -export let excessiveDebugOutput: boolean = false; +export const excessiveDebugOutput: boolean = false; /** * Options is a bag of settings that controls the behavior of previews and deployments diff --git a/sdk/nodejs/tests/automation/localWorkspace.spec.ts b/sdk/nodejs/tests/automation/localWorkspace.spec.ts index f89b6b0a2..41c006dd0 100644 --- a/sdk/nodejs/tests/automation/localWorkspace.spec.ts +++ b/sdk/nodejs/tests/automation/localWorkspace.spec.ts @@ -628,7 +628,7 @@ describe("LocalWorkspace", () => { // pulumi up await assert.rejects(stack.up(), (err: Error) => { - return err.stack!.indexOf("Detected multiple versions of '@pulumi/pulumi'") >= 0; + return err.stack!.indexOf("Detected multiple versions of '@pulumi/pulumi'") >= 0; }); // pulumi destroy diff --git a/sdk/nodejs/tests/options.spec.ts b/sdk/nodejs/tests/options.spec.ts index db0bac3ec..b4aab31ca 100644 --- a/sdk/nodejs/tests/options.spec.ts +++ b/sdk/nodejs/tests/options.spec.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable +/* eslint-disable */ import * as assert from "assert"; import { ComponentResourceOptions, ProviderResource, merge, mergeOptions } from "../resource"; diff --git a/sdk/nodejs/tests/output.spec.ts b/sdk/nodejs/tests/output.spec.ts index f37608cde..05235bc79 100644 --- a/sdk/nodejs/tests/output.spec.ts +++ b/sdk/nodejs/tests/output.spec.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable +/* eslint-disable */ import * as assert from "assert"; import { Output, all, concat, interpolate, output, unknown, secret, unsecret, isSecret } from "../output"; diff --git a/sdk/nodejs/tests/resource.spec.ts b/sdk/nodejs/tests/resource.spec.ts index ee610b395..cce362b5b 100644 --- a/sdk/nodejs/tests/resource.spec.ts +++ b/sdk/nodejs/tests/resource.spec.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable +/* eslint-disable */ import * as assert from "assert"; import { Output, concat, interpolate, output } from "../output"; diff --git a/sdk/nodejs/tests/runtime/closureLoader.spec.ts b/sdk/nodejs/tests/runtime/closureLoader.spec.ts index a4419bc3e..575ab689f 100644 --- a/sdk/nodejs/tests/runtime/closureLoader.spec.ts +++ b/sdk/nodejs/tests/runtime/closureLoader.spec.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable +/* eslint-disable */ // Make sure we are listening for v8 events as they're necessary to get things like file locations // for serialization errors. We need to do this first, before we even get around to running tests. diff --git a/sdk/nodejs/tests/runtime/deploymentOnlyModule/config.ts b/sdk/nodejs/tests/runtime/deploymentOnlyModule/config.ts index 0cdb10370..f4bdae330 100644 --- a/sdk/nodejs/tests/runtime/deploymentOnlyModule/config.ts +++ b/sdk/nodejs/tests/runtime/deploymentOnlyModule/config.ts @@ -51,7 +51,7 @@ export class Config { return undefined; } return v; - } + } /** * fullKey turns a simple configuration key into a fully resolved one, by prepending the bag's name. diff --git a/sdk/nodejs/tests/runtime/jsClosureCases_10_4.js b/sdk/nodejs/tests/runtime/jsClosureCases_10_4.js index 828bab162..91ae2d5c2 100644 --- a/sdk/nodejs/tests/runtime/jsClosureCases_10_4.js +++ b/sdk/nodejs/tests/runtime/jsClosureCases_10_4.js @@ -11,7 +11,7 @@ const cases = []; cases.push({ title: "Captures bigint", - // tslint:disable-next-line + // eslint-disable-next-line func: function () { console.log(zeroBigInt + smallBigInt + negativeBigInt + largeBigInt + negativeBigInt + negativeLargeBigInt); }, expectText: `exports.handler = __f0; diff --git a/sdk/nodejs/tests/runtime/jsClosureCases_8.js b/sdk/nodejs/tests/runtime/jsClosureCases_8.js index 75f766e0b..4546ec567 100644 --- a/sdk/nodejs/tests/runtime/jsClosureCases_8.js +++ b/sdk/nodejs/tests/runtime/jsClosureCases_8.js @@ -4,7 +4,7 @@ const cases = []; cases.push({ title: "Async anonymous function closure (js)", - // tslint:disable-next-line + // eslint-disable-next-line func: async function (a) { await a; }, expectText: `exports.handler = __f0; @@ -22,7 +22,7 @@ return async function (a) { await a; }; cases.push({ title: "Async anonymous function closure - extra space (js)", - // tslint:disable-next-line + // eslint-disable-next-line func: async function (a) { await a; }, expectText: `exports.handler = __f0; @@ -40,7 +40,7 @@ return async function (a) { await a; }; cases.push({ title: "Async named function closure (js)", - // tslint:disable-next-line + // eslint-disable-next-line func: async function foo(a) { await a; }, expectText: `exports.handler = __foo; @@ -58,7 +58,7 @@ return async function /*foo*/(a) { await a; }; cases.push({ title: "Async arrow function closure (js)", - // tslint:disable-next-line + // eslint-disable-next-line func: async (a) => { await a; }, expectText: `exports.handler = __f0; diff --git a/sdk/nodejs/tests/runtime/langhost/run.spec.ts b/sdk/nodejs/tests/runtime/langhost/run.spec.ts index 7376392a2..69afc4647 100644 --- a/sdk/nodejs/tests/runtime/langhost/run.spec.ts +++ b/sdk/nodejs/tests/runtime/langhost/run.spec.ts @@ -47,18 +47,18 @@ interface RunCase { }; skipRootResourceEndpoints?: boolean; showRootResourceRegistration?: boolean; - invoke?: (ctx: any, tok: string, args: any, version: string, provider: string) => { failures: any, ret: any }; + invoke?: (ctx: any, tok: string, args: any, version: string, provider: string) => { failures: any; ret: any }; readResource?: (ctx: any, t: string, name: string, id: string, par: string, state: any, version: string) => { - urn: URN | undefined, props: any | undefined, + urn: URN | undefined; props: any | undefined; }; registerResource?: (ctx: any, dryrun: boolean, t: string, name: string, res: any, dependencies?: string[], - custom?: boolean, protect?: boolean, parent?: string, provider?: string, - propertyDeps?: any, ignoreChanges?: string[], version?: string, importID?: string, - replaceOnChanges?: string[]) => { - urn: URN | undefined, id: ID | undefined, props: any | undefined, + custom?: boolean, protect?: boolean, parent?: string, provider?: string, + propertyDeps?: any, ignoreChanges?: string[], version?: string, importID?: string, + replaceOnChanges?: string[]) => { + urn: URN | undefined; id: ID | undefined; props: any | undefined; }; registerResourceOutputs?: (ctx: any, dryrun: boolean, urn: URN, - t: string, name: string, res: any, outputs: any | undefined) => void; + t: string, name: string, res: any, outputs: any | undefined) => void; log?: (ctx: any, severity: any, message: string, urn: URN, streamId: number) => void; getRootResource?: (ctx: any) => { urn: string }; setRootResource?: (ctx: any, urn: string) => void; @@ -211,42 +211,42 @@ describe("rpc", () => { let id: ID | undefined; let props: any | undefined; switch (t) { - case "test:index:ResourceA": { - assert.strictEqual(name, "resourceA"); - assert.deepStrictEqual(res, { inprop: 777 }); - if (!dryrun) { - id = name; - props = { outprop: "output yeah" }; - } - break; + case "test:index:ResourceA": { + assert.strictEqual(name, "resourceA"); + assert.deepStrictEqual(res, { inprop: 777 }); + if (!dryrun) { + id = name; + props = { outprop: "output yeah" }; } - case "test:index:ResourceB": { - assert.strictEqual(name, "resourceB"); - assert.deepStrictEqual(dependencies, ["test:index:ResourceA::resourceA"]); + break; + } + case "test:index:ResourceB": { + assert.strictEqual(name, "resourceB"); + assert.deepStrictEqual(dependencies, ["test:index:ResourceA::resourceA"]); - if (dryrun) { - // If this is a dry-run, we will have no known values. - assert.deepStrictEqual(res, { - otherIn: runtime.unknownValue, - otherOut: runtime.unknownValue, - }); - } - else { - // Otherwise, we will: - assert.deepStrictEqual(res, { - otherIn: 777, - otherOut: "output yeah", - }); - } - - if (!dryrun) { - id = name; - } - break; + if (dryrun) { + // If this is a dry-run, we will have no known values. + assert.deepStrictEqual(res, { + otherIn: runtime.unknownValue, + otherOut: runtime.unknownValue, + }); } - default: - assert.fail(`Unrecognized resource type ${t}`); - throw new Error(); + else { + // Otherwise, we will: + assert.deepStrictEqual(res, { + otherIn: 777, + otherOut: "output yeah", + }); + } + + if (!dryrun) { + id = name; + } + break; + } + default: + assert.fail(`Unrecognized resource type ${t}`); + throw new Error(); } return { urn: makeUrn(t, name), @@ -491,27 +491,27 @@ describe("rpc", () => { }, log: (ctx: any, severity: number, message: string, urn: URN, streamId: number) => { switch (message) { - case "info message": - assert.strictEqual(severity, engineproto.LogSeverity.INFO); - return; - case "warning message": - assert.strictEqual(severity, engineproto.LogSeverity.WARNING); - return; - case "error message": - assert.strictEqual(severity, engineproto.LogSeverity.ERROR); - return; - case "attached to resource": - assert.strictEqual(severity, engineproto.LogSeverity.INFO); - assert.strictEqual(urn, ctx.testUrn); - return; - case "with streamid": - assert.strictEqual(severity, engineproto.LogSeverity.INFO); - assert.strictEqual(urn, ctx.testUrn); - assert.strictEqual(streamId, 42); - return; - default: - assert.fail("unexpected message: " + message); - break; + case "info message": + assert.strictEqual(severity, engineproto.LogSeverity.INFO); + return; + case "warning message": + assert.strictEqual(severity, engineproto.LogSeverity.WARNING); + return; + case "error message": + assert.strictEqual(severity, engineproto.LogSeverity.ERROR); + return; + case "attached to resource": + assert.strictEqual(severity, engineproto.LogSeverity.INFO); + assert.strictEqual(urn, ctx.testUrn); + return; + case "with streamid": + assert.strictEqual(severity, engineproto.LogSeverity.INFO); + assert.strictEqual(urn, ctx.testUrn); + assert.strictEqual(streamId, 42); + return; + default: + assert.fail("unexpected message: " + message); + break; } }, }, @@ -583,40 +583,40 @@ describe("rpc", () => { assert.strictEqual(t, "test:index:MyResource"); switch (name) { - case "resA": - assert.deepStrictEqual(deps, []); - assert.deepStrictEqual(propertyDeps, {}); - break; - case "resB": - assert.deepStrictEqual(deps, ["resA"]); - assert.deepStrictEqual(propertyDeps, {}); - break; - case "resC": - assert.deepStrictEqual(deps, ["resA", "resB"]); - assert.deepStrictEqual(propertyDeps, { - "propA": ["resA"], - "propB": ["resB"], - "propC": [], - }); - break; - case "resD": - assert.deepStrictEqual(deps, ["resA", "resB", "resC"]); - assert.deepStrictEqual(propertyDeps, { - "propA": ["resA", "resB"], - "propB": ["resC"], - "propC": [], - }); - break; - case "resE": - assert.deepStrictEqual(deps, ["resA", "resB", "resC", "resD"]); - assert.deepStrictEqual(propertyDeps, { - "propA": ["resC"], - "propB": ["resA", "resB"], - "propC": [], - }); - break; - default: - break; + case "resA": + assert.deepStrictEqual(deps, []); + assert.deepStrictEqual(propertyDeps, {}); + break; + case "resB": + assert.deepStrictEqual(deps, ["resA"]); + assert.deepStrictEqual(propertyDeps, {}); + break; + case "resC": + assert.deepStrictEqual(deps, ["resA", "resB"]); + assert.deepStrictEqual(propertyDeps, { + "propA": ["resA"], + "propB": ["resB"], + "propC": [], + }); + break; + case "resD": + assert.deepStrictEqual(deps, ["resA", "resB", "resC"]); + assert.deepStrictEqual(propertyDeps, { + "propA": ["resA", "resB"], + "propB": ["resC"], + "propC": [], + }); + break; + case "resE": + assert.deepStrictEqual(deps, ["resA", "resB", "resC", "resD"]); + assert.deepStrictEqual(propertyDeps, { + "propA": ["resC"], + "propB": ["resA", "resB"], + "propC": [], + }); + break; + default: + break; } return { urn: name, id: undefined, props: { "outprop": "qux" } }; @@ -628,9 +628,9 @@ describe("rpc", () => { expectResourceCount: 2, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "cust1": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, ["test:index:MyResource::cust1"]); break; - default: throw new Error("Didn't check: " + name); + case "cust1": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, ["test:index:MyResource::cust1"]); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -641,10 +641,10 @@ describe("rpc", () => { expectResourceCount: 3, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "cust1": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, ["test:index:MyResource::cust1"]); break; - case "cust3": assert.deepStrictEqual(deps, ["test:index:MyResource::cust1"]); break; - default: throw new Error("Didn't check: " + name); + case "cust1": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, ["test:index:MyResource::cust1"]); break; + case "cust3": assert.deepStrictEqual(deps, ["test:index:MyResource::cust1"]); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -661,10 +661,10 @@ describe("rpc", () => { expectResourceCount: 3, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "cust1": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, []); break; - case "comp1": assert.deepStrictEqual(deps, []); break; - default: throw new Error("Didn't check: " + name); + case "cust1": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, []); break; + case "comp1": assert.deepStrictEqual(deps, []); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -675,11 +675,11 @@ describe("rpc", () => { expectResourceCount: 4, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "cust1": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, []); break; - case "comp1": assert.deepStrictEqual(deps, []); break; - case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1", "test:index:MyCustomResource::cust2"]); break; - default: throw new Error("Didn't check: " + name); + case "cust1": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, []); break; + case "comp1": assert.deepStrictEqual(deps, []); break; + case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1", "test:index:MyCustomResource::cust2"]); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -690,13 +690,13 @@ describe("rpc", () => { expectResourceCount: 6, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "comp1": assert.deepStrictEqual(deps, []); break; - case "cust1": assert.deepStrictEqual(deps, []); break; - case "comp2": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, []); break; - case "cust3": assert.deepStrictEqual(deps, []); break; - case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1", "test:index:MyCustomResource::cust2", "test:index:MyCustomResource::cust3"]); break; - default: throw new Error("Didn't check: " + name); + case "comp1": assert.deepStrictEqual(deps, []); break; + case "cust1": assert.deepStrictEqual(deps, []); break; + case "comp2": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, []); break; + case "cust3": assert.deepStrictEqual(deps, []); break; + case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1", "test:index:MyCustomResource::cust2", "test:index:MyCustomResource::cust3"]); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -707,17 +707,17 @@ describe("rpc", () => { expectResourceCount: 10, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "comp1": assert.deepStrictEqual(deps, []); break; - case "cust1": assert.deepStrictEqual(deps, []); break; - case "comp2": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, []); break; - case "cust3": assert.deepStrictEqual(deps, []); break; - case "cust4": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2"]); break; - case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1", "test:index:MyCustomResource::cust2", "test:index:MyCustomResource::cust3"]); break; - case "res2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2", "test:index:MyCustomResource::cust3"]); break; - case "res3": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2"]); break; - case "res4": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust4"]); break; - default: throw new Error("Didn't check: " + name); + case "comp1": assert.deepStrictEqual(deps, []); break; + case "cust1": assert.deepStrictEqual(deps, []); break; + case "comp2": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, []); break; + case "cust3": assert.deepStrictEqual(deps, []); break; + case "cust4": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2"]); break; + case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1", "test:index:MyCustomResource::cust2", "test:index:MyCustomResource::cust3"]); break; + case "res2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2", "test:index:MyCustomResource::cust3"]); break; + case "res3": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2"]); break; + case "res4": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust4"]); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -728,13 +728,13 @@ describe("rpc", () => { expectResourceCount: 6, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "comp1": assert.deepStrictEqual(deps, []); break; - case "cust1": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; - case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; - case "res2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; - case "res3": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2"]); break; - default: throw new Error("Didn't check: " + name); + case "comp1": assert.deepStrictEqual(deps, []); break; + case "cust1": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; + case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; + case "res2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; + case "res3": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust2"]); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -745,10 +745,10 @@ describe("rpc", () => { expectResourceCount: 3, registerResource: (ctx, dryrun, t, name, res, deps) => { switch (name) { - case "cust1": assert.deepStrictEqual(deps, []); break; - case "cust2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; - case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; - default: throw new Error("Didn't check: " + name); + case "cust1": assert.deepStrictEqual(deps, []); break; + case "cust2": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; + case "res1": assert.deepStrictEqual(deps, ["test:index:MyCustomResource::cust1"]); break; + default: throw new Error("Didn't check: " + name); } return { urn: makeUrn(t, name), id: undefined, props: undefined }; }, @@ -813,19 +813,19 @@ describe("rpc", () => { custom?: boolean, protect?: boolean, parent?: string, provider?: string, propertyDeps?: any, ignoreChanges?: string[], version?: string, importID?: string, replaceOnChanges?: string[], - ) => { + ) => { switch (name) { - case "testResource": - assert.strictEqual("0.19.1", version); - break; - case "testResource2": - assert.strictEqual("0.19.2", version); - break; - case "testResource3": - assert.strictEqual("", version); - break; - default: - assert.fail(`unknown resource: ${name}`); + case "testResource": + assert.strictEqual("0.19.1", version); + break; + case "testResource2": + assert.strictEqual("0.19.2", version); + break; + case "testResource3": + assert.strictEqual("", version); + break; + default: + assert.fail(`unknown resource: ${name}`); } return { urn: makeUrn(t, name), @@ -835,17 +835,17 @@ describe("rpc", () => { }, invoke: (ctx: any, tok: string, args: any, version: string) => { switch (tok) { - case "invoke:index:doit": - assert.strictEqual(version, "0.19.1"); - break; - case "invoke:index:doit_v2": - assert.strictEqual(version, "0.19.2"); - break; - case "invoke:index:doit_noversion": - assert.strictEqual(version, ""); - break; - default: - assert.fail(`unknown invoke: ${tok}`); + case "invoke:index:doit": + assert.strictEqual(version, "0.19.1"); + break; + case "invoke:index:doit_v2": + assert.strictEqual(version, "0.19.2"); + break; + case "invoke:index:doit_noversion": + assert.strictEqual(version, ""); + break; + default: + assert.fail(`unknown invoke: ${tok}`); } return { @@ -855,14 +855,14 @@ describe("rpc", () => { }, readResource: (ctx: any, t: string, name: string, id: string, par: string, state: any, version: string) => { switch (name) { - case "foo": - assert.strictEqual(version, "0.20.0"); - break; - case "foo_noversion": - assert.strictEqual(version, ""); - break; - default: - assert.fail(`unknown read: ${name}`); + case "foo": + assert.strictEqual(version, "0.20.0"); + break; + case "foo_noversion": + assert.strictEqual(version, ""); + break; + default: + assert.fail(`unknown read: ${name}`); } return { urn: makeUrn(t, name), @@ -1400,27 +1400,27 @@ function parentDefaultsRegisterResource( const rpath = name.split("/"); for (let i = 1; i < rpath.length; i++) { switch (rpath[i]) { - case "c0": - case "r0": - // Pass through parent values - break; - case "c1": - case "r1": - // Force protect to false - expectProtect = false; - break; - case "c2": - case "r2": - // Force protect to true - expectProtect = true; - break; - case "c3": - case "r3": - // Force provider - expectProviderName = `${rpath.slice(0, i).join("/")}-p`; - break; - default: - assert.fail(`unexpected path element in name: ${rpath[i]}`); + case "c0": + case "r0": + // Pass through parent values + break; + case "c1": + case "r1": + // Force protect to false + expectProtect = false; + break; + case "c2": + case "r2": + // Force protect to true + expectProtect = true; + break; + case "c3": + case "r3": + // Force provider + expectProviderName = `${rpath.slice(0, i).join("/")}-p`; + break; + default: + assert.fail(`unexpected path element in name: ${rpath[i]}`); } } @@ -1526,7 +1526,7 @@ async function createMockEngineAsync( return { server: server, addr: `0.0.0.0:${port}` }; } -function serveLanguageHostProcess(engineAddr: string): { proc: childProcess.ChildProcess, addr: Promise } { +function serveLanguageHostProcess(engineAddr: string): { proc: childProcess.ChildProcess; addr: Promise } { // A quick note about this: // // Normally, `pulumi-language-nodejs` launches `./node-modules/@pulumi/pulumi/cmd/run` which is responsible diff --git a/sdk/nodejs/tests/runtime/props.spec.ts b/sdk/nodejs/tests/runtime/props.spec.ts index c34425be9..cd9c00b14 100644 --- a/sdk/nodejs/tests/runtime/props.spec.ts +++ b/sdk/nodejs/tests/runtime/props.spec.ts @@ -41,12 +41,12 @@ class TestErrorResource extends CustomResource { class TestResourceModule implements runtime.ResourceModule { construct(name: string, type: string, urn: string): Resource { switch (type) { - case "test:index:component": - return new TestComponentResource(name, {urn}); - case "test:index:custom": - return new TestCustomResource(name, type, {urn}); - default: - throw new Error(`unknown resource type ${type}`); + case "test:index:component": + return new TestComponentResource(name, {urn}); + case "test:index:custom": + return new TestCustomResource(name, type, {urn}); + default: + throw new Error(`unknown resource type ${type}`); } } } @@ -56,54 +56,58 @@ class TestMocks implements runtime.Mocks { throw new Error(`unknown function ${args.token}`); } - newResource(args: runtime.MockResourceArgs): { id: string | undefined, state: Record } { + newResource(args: runtime.MockResourceArgs): { id: string | undefined; state: Record } { switch (args.type) { - case "test:index:component": - return {id: undefined, state: {}}; - case "test:index:custom": - case "test2:index:custom": - return { - id: runtime.isDryRun() ? undefined : "test-id", - state: {}, - }; - case "error": - throw new Error("this is an intentional error"); - default: - throw new Error(`unknown resource type ${args.type}`); + case "test:index:component": + return {id: undefined, state: {}}; + case "test:index:custom": + case "test2:index:custom": + return { + id: runtime.isDryRun() ? undefined : "test-id", + state: {}, + }; + case "error": + throw new Error("this is an intentional error"); + default: + throw new Error(`unknown resource type ${args.type}`); } } } -// tslint:disable-next-line:variable-name +// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match const TestStrEnum = { Foo: "foo", Bar: "bar", } as const; +// eslint-disable-next-line @typescript-eslint/no-redeclare type TestStrEnum = (typeof TestStrEnum)[keyof typeof TestStrEnum]; -// tslint:disable-next-line:variable-name +// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match const TestIntEnum = { One: 1, Zero: 0, } as const; +// eslint-disable-next-line @typescript-eslint/no-redeclare type TestIntEnum = (typeof TestIntEnum)[keyof typeof TestIntEnum]; -// tslint:disable-next-line:variable-name +// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match const TestNumEnum = { One: 1.0, ZeroPointOne: 0.1, } as const; +// eslint-disable-next-line @typescript-eslint/no-redeclare type TestNumEnum = (typeof TestNumEnum)[keyof typeof TestNumEnum]; -// tslint:disable-next-line:variable-name +// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match const TestBoolEnum = { One: true, Zero: false, } as const; +// eslint-disable-next-line @typescript-eslint/no-redeclare type TestBoolEnum = (typeof TestBoolEnum)[keyof typeof TestBoolEnum]; interface TestInputs { diff --git a/sdk/nodejs/tests/runtime/tsClosureCases.ts b/sdk/nodejs/tests/runtime/tsClosureCases.ts index 3a5101f3a..5bd88f9b2 100644 --- a/sdk/nodejs/tests/runtime/tsClosureCases.ts +++ b/sdk/nodejs/tests/runtime/tsClosureCases.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable +/* eslint-disable */ import * as assert from "assert"; import { EOL } from "os"; diff --git a/sdk/nodejs/tests/sxs_ts_3.6/index.ts b/sdk/nodejs/tests/sxs_ts_3.6/index.ts index 927eb2448..141010233 100644 --- a/sdk/nodejs/tests/sxs_ts_3.6/index.ts +++ b/sdk/nodejs/tests/sxs_ts_3.6/index.ts @@ -1,4 +1,4 @@ -// tslint:disable:file-header +/* eslint-disable header/header */ // See README.md for information on what to do if this test fails. diff --git a/sdk/nodejs/tests/sxs_ts_latest/index.ts b/sdk/nodejs/tests/sxs_ts_latest/index.ts index 927eb2448..141010233 100644 --- a/sdk/nodejs/tests/sxs_ts_latest/index.ts +++ b/sdk/nodejs/tests/sxs_ts_latest/index.ts @@ -1,4 +1,4 @@ -// tslint:disable:file-header +/* eslint-disable header/header */ // See README.md for information on what to do if this test fails. diff --git a/sdk/nodejs/tests/unwrap.spec.ts b/sdk/nodejs/tests/unwrap.spec.ts index f491731ad..e063c7d40 100644 --- a/sdk/nodejs/tests/unwrap.spec.ts +++ b/sdk/nodejs/tests/unwrap.spec.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// tslint:disable +/* eslint-disable */ import * as assert from "assert"; import { all, output, Output, unknown } from "../index"; diff --git a/sdk/nodejs/tests_with_mocks/mocks.spec.ts b/sdk/nodejs/tests_with_mocks/mocks.spec.ts index 105ecd1d8..93c1503a8 100644 --- a/sdk/nodejs/tests_with_mocks/mocks.spec.ts +++ b/sdk/nodejs/tests_with_mocks/mocks.spec.ts @@ -20,31 +20,31 @@ import { MockCallArgs, MockResourceArgs } from "../runtime"; pulumi.runtime.setMocks({ call: (args: MockCallArgs) => { switch (args.token) { - case "test:index:MyFunction": - return { out_value: 59 }; - default: - return {}; + case "test:index:MyFunction": + return { out_value: 59 }; + default: + return {}; } }, - newResource: (args: MockResourceArgs): {id: string, state: any} => { + newResource: (args: MockResourceArgs): {id: string; state: any} => { switch (args.type) { - case "aws:ec2/instance:Instance": - assert.strictEqual(args.custom, true); - const state = { - arn: "arn:aws:ec2:us-west-2:123456789012:instance/i-1234567890abcdef0", - instanceState: "running", - primaryNetworkInterfaceId: "eni-12345678", - privateDns: "ip-10-0-1-17.ec2.internal", - publicDns: "ec2-203-0-113-12.compute-1.amazonaws.com", - publicIP: "203.0.113.12", - }; - return { id: "i-1234567890abcdef0", state: { ...args.inputs, ...state } }; - case "pkg:index:MyCustom": - assert.strictEqual(args.custom, true); - return { id: args.name + "_id", state: args.inputs }; - default: - assert.strictEqual(args.custom, false); - return { id: "", state: {} }; + case "aws:ec2/instance:Instance": + assert.strictEqual(args.custom, true); + const state = { + arn: "arn:aws:ec2:us-west-2:123456789012:instance/i-1234567890abcdef0", + instanceState: "running", + primaryNetworkInterfaceId: "eni-12345678", + privateDns: "ip-10-0-1-17.ec2.internal", + publicDns: "ec2-203-0-113-12.compute-1.amazonaws.com", + publicIP: "203.0.113.12", + }; + return { id: "i-1234567890abcdef0", state: { ...args.inputs, ...state } }; + case "pkg:index:MyCustom": + assert.strictEqual(args.custom, true); + return { id: args.name + "_id", state: args.inputs }; + default: + assert.strictEqual(args.custom, false); + return { id: "", state: {} }; } }, }); @@ -68,10 +68,10 @@ class Instance extends pulumi.CustomResource { pulumi.runtime.registerResourceModule("aws", "ec2/instance", { construct: (name: string, type: string, urn: string): pulumi.Resource => { switch (type) { - case "aws:ec2/instance:Instance": - return new Instance(name, { urn }); - default: - throw new Error(`unknown resource type ${type}`); + case "aws:ec2/instance:Instance": + return new Instance(name, { urn }); + default: + throw new Error(`unknown resource type ${type}`); } }, }); diff --git a/tests/integration/policy/policy_pack_w_config/package.json b/tests/integration/policy/policy_pack_w_config/package.json index 5fc13296d..1832a8786 100644 --- a/tests/integration/policy/policy_pack_w_config/package.json +++ b/tests/integration/policy/policy_pack_w_config/package.json @@ -6,7 +6,6 @@ }, "devDependencies": { "@types/mocha": "^2.2.42", - "@types/node": "^10.12.7", - "tslint": "^5.11.0" + "@types/node": "^10.12.7" } } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 50963782d..000000000 --- a/tslint.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "rules": { - "align": [ - true, - "parameters", - "statements" - ], - "ban": false, - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "curly": true, - "eofline": true, - "forin": true, - "indent": [ - true, - "spaces" - ], - "interface-name": false, - "jsdoc-format": false, - "label-position": true, - "max-line-length": [ - true, - 120 - ], - "member-access": false, - "member-ordering": [ - true, - "static-before-instance", - "variables-before-functions" - ], - "no-any": false, - "no-arg": true, - "no-bitwise": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-debugger": true, - "no-duplicate-variable": true, - "no-empty": true, - "no-eval": true, - "no-inferrable-types": false, - "no-internal-module": true, - "no-parameter-properties": false, - "no-require-imports": true, - "no-shadowed-variable": true, - "no-string-literal": false, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unused-expression": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "no-var-requires": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "ordered-imports": true, - "prefer-const": true, - "quotemark": [ - true, - "double", - "avoid-escape" - ], - "radix": true, - "semicolon": true, - "switch-default": true, - "trailing-comma": [ - true, - { - "multiline": "always", - "singleline": "never" - } - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef": [ - false, - "call-signature", - "parameter", - "property-declaration", - "variable-declaration", - "member-variable-declaration" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": [ - true, - "check-format", - "allow-leading-underscore", - "ban-keywords" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-module", - "check-separator", - "check-type" - ] - - } -}