diff --git a/.eslintrc.json b/.eslintrc.json index 6a697a746..149220ab8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -248,6 +248,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "eol-last": [ "error", "always" diff --git a/packages/@aws-cdk/cdk-build-tools/.eslintrc.json b/packages/@aws-cdk/cdk-build-tools/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/@aws-cdk/cdk-build-tools/.eslintrc.json +++ b/packages/@aws-cdk/cdk-build-tools/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/cdk-build-tools/lib/bockfs.ts b/packages/@aws-cdk/cdk-build-tools/lib/bockfs.ts index c96d1b9ea..be170d12d 100644 --- a/packages/@aws-cdk/cdk-build-tools/lib/bockfs.ts +++ b/packages/@aws-cdk/cdk-build-tools/lib/bockfs.ts @@ -37,7 +37,9 @@ namespace bockfs { * Turn a fake path into a real path */ export function path(fakePath: string) { - if (fakePath.startsWith('/')) { fakePath = fakePath.slice(1); } // Force path to be non-absolute + if (fakePath.startsWith('/')) { + fakePath = fakePath.slice(1); + } // Force path to be non-absolute return path_.join(bockFsRoot, fakePath); } diff --git a/packages/@aws-cdk/cdk-build-tools/lib/os.ts b/packages/@aws-cdk/cdk-build-tools/lib/os.ts index 2af5c1ac0..3218e3c04 100644 --- a/packages/@aws-cdk/cdk-build-tools/lib/os.ts +++ b/packages/@aws-cdk/cdk-build-tools/lib/os.ts @@ -145,13 +145,19 @@ export async function makeExecutable(javascriptFile: string): Promise { */ async function makeShellScriptExecutable(script: string) { try { - if (await canExecute(script)) { return; } - if (!await isShellScript(script)) { return; } + if (await canExecute(script)) { + return; + } + if (!await isShellScript(script)) { + return; + } await util.promisify(fs.chmod)(script, 0o755); } catch (e: any) { // If it happens that this file doesn't exist, that's fine. It's // probably a file that can be found on the $PATH. - if (e.code === 'ENOENT') { return; } + if (e.code === 'ENOENT') { + return; + } throw e; } } @@ -161,7 +167,9 @@ async function canExecute(fileName: string): Promise { await util.promisify(fs.access)(fileName, fs.constants.X_OK); return true; } catch (e: any) { - if (e.code === 'EACCES') { return false; } + if (e.code === 'EACCES') { + return false; + } throw e; } } diff --git a/packages/@aws-cdk/cdk-build-tools/lib/package-info.ts b/packages/@aws-cdk/cdk-build-tools/lib/package-info.ts index 6687cfb49..35e4d92bc 100644 --- a/packages/@aws-cdk/cdk-build-tools/lib/package-info.ts +++ b/packages/@aws-cdk/cdk-build-tools/lib/package-info.ts @@ -70,7 +70,9 @@ export async function listFiles(dirName: string, predicate: (x: File) => boolean return ret; } catch (e: any) { - if (e.code === 'ENOENT') { return []; } + if (e.code === 'ENOENT') { + return []; + } throw e; } } diff --git a/packages/@aws-cdk/cdk-build-tools/lib/timer.ts b/packages/@aws-cdk/cdk-build-tools/lib/timer.ts index 7b1fdb9cf..06b9e70e4 100644 --- a/packages/@aws-cdk/cdk-build-tools/lib/timer.ts +++ b/packages/@aws-cdk/cdk-build-tools/lib/timer.ts @@ -22,7 +22,9 @@ export class Timer { } public humanTime() { - if (!this.timeMs) { return '???'; } + if (!this.timeMs) { + return '???'; + } const parts = []; diff --git a/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json b/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json +++ b/packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/cdk-cli-wrapper/lib/utils.ts b/packages/@aws-cdk/cdk-cli-wrapper/lib/utils.ts index 6d1a076eb..b8e8c6c0e 100644 --- a/packages/@aws-cdk/cdk-cli-wrapper/lib/utils.ts +++ b/packages/@aws-cdk/cdk-cli-wrapper/lib/utils.ts @@ -14,7 +14,9 @@ export function exec(commandLine: string[], options: { cwd?: string; json?: bool cwd: options.cwd, }); - if (proc.error) { throw proc.error; } + if (proc.error) { + throw proc.error; + } if (proc.status !== 0) { if (process.stderr) { // will be 'null' in verbose mode process.stderr.write(proc.stderr); @@ -26,7 +28,9 @@ export function exec(commandLine: string[], options: { cwd?: string; json?: bool try { if (options.json) { - if (output.length === 0) { return {}; } + if (output.length === 0) { + return {}; + } return JSON.parse(output); } diff --git a/packages/@aws-cdk/cdk-cli-wrapper/test/cdk-wrapper.test.ts b/packages/@aws-cdk/cdk-cli-wrapper/test/cdk-wrapper.test.ts index c3ee6bb51..19b1be9fe 100644 --- a/packages/@aws-cdk/cdk-cli-wrapper/test/cdk-wrapper.test.ts +++ b/packages/@aws-cdk/cdk-cli-wrapper/test/cdk-wrapper.test.ts @@ -18,7 +18,8 @@ beforeEach(() => { }); spawnMock = jest.spyOn(child_process, 'spawn').mockImplementation(jest.fn(() => { return { - on: jest.fn(() => {}), + on: jest.fn(() => { + }), } as unknown as child_process.ChildProcess; })); }); diff --git a/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json b/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json index 2c8cc03e8..3f4770523 100644 --- a/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json +++ b/packages/@aws-cdk/cli-lib-alpha/.eslintrc.json @@ -162,6 +162,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts b/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts index 120818dc8..e11eac064 100644 --- a/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts +++ b/packages/@aws-cdk/cli-lib-alpha/lib/cli.ts @@ -133,7 +133,8 @@ export class AwsCdkCli implements IAwsCdkCli { private constructor( private readonly cli: (args: string[]) => Promise, - ) {} + ) { + } /** * Execute the CLI with a list of arguments diff --git a/packages/@aws-cdk/cli-lib-alpha/test/cli.test.ts b/packages/@aws-cdk/cli-lib-alpha/test/cli.test.ts index 81be36f59..26cbf0879 100644 --- a/packages/@aws-cdk/cli-lib-alpha/test/cli.test.ts +++ b/packages/@aws-cdk/cli-lib-alpha/test/cli.test.ts @@ -13,7 +13,9 @@ jest.mock('../../../aws-cdk/lib', () => { exec: jest.fn(original.exec), }; }); -const stdoutMock = jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; }); +const stdoutMock = jest.spyOn(process.stdout, 'write').mockImplementation(() => { + return true; +}); beforeEach(() => { stdoutMock.mockClear(); diff --git a/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json b/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json +++ b/packages/@aws-cdk/cli-plugin-contract/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json b/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json +++ b/packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts index fe6502762..83649c51d 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts +++ b/packages/@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts @@ -125,7 +125,8 @@ export interface AmiContextQuery extends ContextLookupRoleOptions { /** * Query to availability zone context provider */ -export interface AvailabilityZonesContextQuery extends ContextLookupRoleOptions {} +export interface AvailabilityZonesContextQuery extends ContextLookupRoleOptions { +} /** * Query to hosted zone context provider @@ -256,7 +257,8 @@ export interface LoadBalancerFilter extends ContextLookupRoleOptions { /** * Query input for looking up a load balancer */ -export interface LoadBalancerContextQuery extends LoadBalancerFilter {} +export interface LoadBalancerContextQuery extends LoadBalancerFilter { +} /** * The protocol for connections from clients to the load balancer diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts index 8a1b3e706..c2e3b2226 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts +++ b/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts @@ -347,7 +347,8 @@ export class Manifest { }); } - private constructor() {} + private constructor() { + } } type Endofunctor = (x: A) => A; diff --git a/packages/@aws-cdk/cloudformation-diff/.eslintrc.json b/packages/@aws-cdk/cloudformation-diff/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/@aws-cdk/cloudformation-diff/.eslintrc.json +++ b/packages/@aws-cdk/cloudformation-diff/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts index a033be264..f944b1f53 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts @@ -168,7 +168,9 @@ function propagateReplacedReferences(template: object, logicalId: string): boole function replaceReference(obj: any) { const keys = Object.keys(obj); - if (keys.length !== 1) { return false; } + if (keys.length !== 1) { + return false; + } const key = keys[0]; if (key === 'Ref') { diff --git a/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts b/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts index ff5237469..cde26116e 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts @@ -182,7 +182,9 @@ export class TemplateDiff implements ITemplateDiff { const ret = new Array(); for (const [resourceLogicalId, resourceChange] of Object.entries(this.resources.changes)) { - if (!resourceChange) { continue; } + if (!resourceChange) { + continue; + } const commonProps = { oldProperties: resourceChange.oldProperties, @@ -370,7 +372,8 @@ export class PropertyDifference extends Difference { } export class DifferenceCollection> { - constructor(private readonly diffs: { [logicalId: string]: T }) {} + constructor(private readonly diffs: { [logicalId: string]: T }) { + } public get changes(): { [logicalId: string]: T } { return onlyChanges(this.diffs); @@ -382,7 +385,9 @@ export class DifferenceCollection> { public get(logicalId: string): T { const ret = this.diffs[logicalId]; - if (!ret) { throw new Error(`No object with logical ID '${logicalId}'`); } + if (!ret) { + throw new Error(`No object with logical ID '${logicalId}'`); + } return ret; } @@ -518,7 +523,9 @@ export enum ResourceImpact { * able to determine some properties impact). */ function worstImpact(one: ResourceImpact, two?: ResourceImpact): ResourceImpact { - if (!two) { return one; } + if (!two) { + return one; + } const badness = { [ResourceImpact.NO_CHANGE]: 0, [ResourceImpact.WILL_IMPORT]: 0, @@ -685,7 +692,9 @@ export class ResourceDifference implements IDifference { } // Check the Type first if (this.resourceTypes.oldType !== this.resourceTypes.newType) { - if (this.resourceTypes.oldType === undefined) { return ResourceImpact.WILL_CREATE; } + if (this.resourceTypes.oldType === undefined) { + return ResourceImpact.WILL_CREATE; + } if (this.resourceTypes.newType === undefined) { return this.oldValue!.DeletionPolicy === 'Retain' ? ResourceImpact.WILL_ORPHAN diff --git a/packages/@aws-cdk/cloudformation-diff/lib/diff/util.ts b/packages/@aws-cdk/cloudformation-diff/lib/diff/util.ts index 44dfeb1cd..bb8cae305 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/diff/util.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/diff/util.ts @@ -17,7 +17,9 @@ import { Resource, SpecDatabase } from '@aws-cdk/service-spec-types'; * @returns +true+ if both +lvalue+ and +rvalue+ are equivalent to each other. */ export function deepEqual(lvalue: any, rvalue: any): boolean { - if (lvalue === rvalue) { return true; } + if (lvalue === rvalue) { + return true; + } // CloudFormation allows passing strings into boolean-typed fields if (((typeof lvalue === 'string' && typeof rvalue === 'boolean') || (typeof lvalue === 'boolean' && typeof rvalue === 'string')) && @@ -30,12 +32,20 @@ export function deepEqual(lvalue: any, rvalue: any): boolean { safeParseFloat(lvalue) === safeParseFloat(rvalue)) { return true; } - if (typeof lvalue !== typeof rvalue) { return false; } - if (Array.isArray(lvalue) !== Array.isArray(rvalue)) { return false; } + if (typeof lvalue !== typeof rvalue) { + return false; + } + if (Array.isArray(lvalue) !== Array.isArray(rvalue)) { + return false; + } if (Array.isArray(lvalue) /* && Array.isArray(rvalue) */) { - if (lvalue.length !== rvalue.length) { return false; } + if (lvalue.length !== rvalue.length) { + return false; + } for (let i = 0 ; i < lvalue.length ; i++) { - if (!deepEqual(lvalue[i], rvalue[i])) { return false; } + if (!deepEqual(lvalue[i], rvalue[i])) { + return false; + } } return true; } @@ -45,15 +55,23 @@ export function deepEqual(lvalue: any, rvalue: any): boolean { return false; } const keys = Object.keys(lvalue); - if (keys.length !== Object.keys(rvalue).length) { return false; } + if (keys.length !== Object.keys(rvalue).length) { + return false; + } for (const key of keys) { - if (!rvalue.hasOwnProperty(key)) { return false; } + if (!rvalue.hasOwnProperty(key)) { + return false; + } if (key === 'DependsOn') { - if (!dependsOnEqual(lvalue[key], rvalue[key])) { return false; } + if (!dependsOnEqual(lvalue[key], rvalue[key])) { + return false; + } // check differences other than `DependsOn` continue; } - if (!deepEqual(lvalue[key], rvalue[key])) { return false; } + if (!deepEqual(lvalue[key], rvalue[key])) { + return false; + } } return true; } @@ -84,7 +102,9 @@ function dependsOnEqual(lvalue: any, rvalue: any): boolean { // allows arrays passed to DependsOn to be equivalent irrespective of element order if (Array.isArray(lvalue) && Array.isArray(rvalue)) { - if (lvalue.length !== rvalue.length) { return false; } + if (lvalue.length !== rvalue.length) { + return false; + } for (let i = 0 ; i < lvalue.length ; i++) { for (let j = 0 ; j < lvalue.length ; j++) { if ((!deepEqual(lvalue[i], rvalue[j])) && (j === lvalue.length - 1)) { diff --git a/packages/@aws-cdk/cloudformation-diff/lib/format-table.ts b/packages/@aws-cdk/cloudformation-diff/lib/format-table.ts index d74d1bc0e..3cb423655 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/format-table.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/format-table.ts @@ -28,7 +28,9 @@ function lineBetween(rowA: string[], rowB: string[]) { } function buildColumnConfig(widths: number[] | undefined): { [index: number]: table.ColumnUserConfig } | undefined { - if (widths === undefined) { return undefined; } + if (widths === undefined) { + return undefined; + } const ret: { [index: number]: table.ColumnUserConfig } = {}; widths.forEach((width, i) => { @@ -60,7 +62,9 @@ function calculateColumnWidths(rows: string[][], terminalWidth: number): number[ const contentWidth = terminalWidth - 2 - columns.length * 3; // If we don't exceed the terminal width, do nothing - if (sum(columns) <= contentWidth) { return columns; } + if (sum(columns) <= contentWidth) { + return columns; + } const fairShare = Math.min(contentWidth / columns.length); const smallColumns = columns.filter(w => w < fairShare); diff --git a/packages/@aws-cdk/cloudformation-diff/lib/format.ts b/packages/@aws-cdk/cloudformation-diff/lib/format.ts index a44ff1dc1..a2d1474a5 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/format.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/format.ts @@ -67,7 +67,9 @@ export function formatSecurityChanges( } function formatSecurityChangesWithBanner(formatter: Formatter, templateDiff: TemplateDiff) { - if (!templateDiff.iamChanges.hasChanges && !templateDiff.securityGroupChanges.hasChanges) { return; } + if (!templateDiff.iamChanges.hasChanges && !templateDiff.securityGroupChanges.hasChanges) { + return; + } formatter.formatIamChanges(templateDiff.iamChanges); formatter.formatSecurityGroupChanges(templateDiff.securityGroupChanges); @@ -130,7 +132,9 @@ export class Formatter { * @param diff the difference to be rendered. */ public formatDifference(type: string, logicalId: string, diff: Difference | undefined) { - if (!diff || !diff.isDifferent) { return; } + if (!diff || !diff.isDifferent) { + return; + } let value; @@ -154,7 +158,9 @@ export class Formatter { * @param diff the change to be rendered. */ public formatResourceDifference(_type: string, logicalId: string, diff: ResourceDifference) { - if (!diff.isDifferent) { return; } + if (!diff.isDifferent) { + return; + } const resourceType = diff.isRemoval ? diff.oldResourceType : diff.newResourceType; @@ -172,15 +178,23 @@ export class Formatter { } public formatResourcePrefix(diff: ResourceDifference) { - if (diff.isImport) { return IMPORT; } + if (diff.isImport) { + return IMPORT; + } return this.formatPrefix(diff); } public formatPrefix(diff: Difference) { - if (diff.isAddition) { return ADDITION; } - if (diff.isUpdate) { return UPDATE; } - if (diff.isRemoval) { return REMOVAL; } + if (diff.isAddition) { + return ADDITION; + } + if (diff.isUpdate) { + return UPDATE; + } + if (diff.isRemoval) { + return REMOVAL; + } return chalk.white('[?]'); } @@ -191,8 +205,12 @@ export class Formatter { * @returns the formatted string, with color applied. */ public formatValue(value: any, color: (str: string) => string) { - if (value == null) { return undefined; } - if (typeof value === 'string') { return color(value); } + if (value == null) { + return undefined; + } + if (typeof value === 'string') { + return color(value); + } return color(JSON.stringify(value)); } @@ -311,7 +329,9 @@ export class Formatter { */ public readConstructPathsFrom(templateDiff: TemplateDiff) { for (const [logicalId, resourceDiff] of Object.entries(templateDiff.resources)) { - if (!resourceDiff) { continue; } + if (!resourceDiff) { + continue; + } const oldPathMetadata = resourceDiff.oldValue?.Metadata?.[PATH_METADATA_KEY]; if (oldPathMetadata && !(logicalId in this.logicalToPathMap)) { @@ -369,7 +389,9 @@ export class Formatter { } public formatIamChanges(changes: IamChanges) { - if (!changes.hasChanges) { return; } + if (!changes.hasChanges) { + return; + } if (changes.statements.hasChanges) { this.printSectionHeader('IAM Statement Changes'); @@ -396,7 +418,9 @@ export class Formatter { } public formatSecurityGroupChanges(changes: SecurityGroupChanges) { - if (!changes.hasChanges) { return; } + if (!changes.hasChanges) { + return; + } this.printSectionHeader('Security Group Changes'); this.print(formatTable(this.deepSubstituteBracedLogicalIds(changes.summarize()), this.stream.columns)); @@ -454,7 +478,9 @@ function _diffStrings(oldStr: string, newStr: string, context: number): string[] const baseIndent = _findIndent(hunk.lines); for (const line of hunk.lines) { // Don't care about termination newline. - if (line === '\\ No newline at end of file') { continue; } + if (line === '\\ No newline at end of file') { + continue; + } const marker = line.charAt(0); const text = line.slice(1 + baseIndent); switch (marker) { diff --git a/packages/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.ts b/packages/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.ts index 9f0f0fae6..5e20b9614 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.ts @@ -330,7 +330,9 @@ export class IamChanges { * Parse a list of policies on an identity */ private readIdentityPolicies(policies: any, logicalId: string): Statement[] { - if (policies === undefined || !Array.isArray(policies)) { return []; } + if (policies === undefined || !Array.isArray(policies)) { + return []; + } const appliesToPrincipal = 'AWS:${' + logicalId + '}'; @@ -347,7 +349,9 @@ export class IamChanges { * Parse an IAM::Policy resource */ private readIdentityPolicyResource(properties: any): Statement[] { - if (properties === undefined) { return []; } + if (properties === undefined) { + return []; + } properties = renderIntrinsics(properties); @@ -359,7 +363,9 @@ export class IamChanges { } private readSsoInstanceACAConfigs(properties: any, logicalId: string): SsoInstanceACAConfig[] { - if (properties === undefined) { return []; } + if (properties === undefined) { + return []; + } properties = renderIntrinsics(properties); @@ -371,7 +377,9 @@ export class IamChanges { } private readSsoAssignments(properties: any, logicalId: string): SsoAssignment[] { - if (properties === undefined) { return []; } + if (properties === undefined) { + return []; + } properties = renderIntrinsics(properties); @@ -387,7 +395,9 @@ export class IamChanges { } private readSsoPermissionSet(properties: any, logicalId: string): SsoPermissionSet[] { - if (properties === undefined) { return []; } + if (properties === undefined) { + return []; + } properties = renderIntrinsics(properties); @@ -401,7 +411,9 @@ export class IamChanges { } private readResourceStatements(policy: any, logicalId: string): Statement[] { - if (policy === undefined) { return []; } + if (policy === undefined) { + return []; + } const appliesToResource = '${' + logicalId + '.Arn}'; return defaultResource(appliesToResource, parseStatements(renderIntrinsics(policy.Statement))); @@ -411,7 +423,9 @@ export class IamChanges { * Parse an AWS::*::{Bucket,Topic,Queue}policy */ private readResourcePolicyResource(properties: any): Statement[] { - if (properties === undefined) { return []; } + if (properties === undefined) { + return []; + } properties = renderIntrinsics(properties); @@ -432,14 +446,18 @@ export class IamChanges { } private readManagedPolicies(policyArns: any, logicalId: string): ManagedPolicyAttachment[] { - if (!policyArns) { return []; } + if (!policyArns) { + return []; + } const rep = '${' + logicalId + '}'; return ManagedPolicyAttachment.parseManagedPolicies(rep, renderIntrinsics(policyArns)); } private readLambdaStatements(properties?: PropertyMap): Statement[] { - if (!properties) { return []; } + if (!properties) { + return []; + } return [parseLambdaPermission(renderIntrinsics(properties))]; } diff --git a/packages/@aws-cdk/cloudformation-diff/lib/iam/statement.ts b/packages/@aws-cdk/cloudformation-diff/lib/iam/statement.ts index cb203498b..2b5bfa5ca 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/iam/statement.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/iam/statement.ts @@ -146,8 +146,12 @@ export interface TargetsJson { * Parse a list of statements from undefined, a Statement, or a list of statements */ export function parseStatements(x: any): Statement[] { - if (x === undefined) { x = []; } - if (!Array.isArray(x)) { x = [x]; } + if (x === undefined) { + x = []; + } + if (!Array.isArray(x)) { + x = [x]; + } return x.map((s: any) => new Statement(s)); } @@ -180,15 +184,21 @@ export function parseLambdaPermission(x: any): Statement { } } if (x.SourceArn !== undefined) { - if (statement.Condition === undefined) { statement.Condition = {}; } + if (statement.Condition === undefined) { + statement.Condition = {}; + } statement.Condition.ArnLike = { 'AWS:SourceArn': x.SourceArn }; } if (x.SourceAccount !== undefined) { - if (statement.Condition === undefined) { statement.Condition = {}; } + if (statement.Condition === undefined) { + statement.Condition = {}; + } statement.Condition.StringEquals = { 'AWS:SourceAccount': x.SourceAccount }; } if (x.EventSourceToken !== undefined) { - if (statement.Condition === undefined) { statement.Condition = {}; } + if (statement.Condition === undefined) { + statement.Condition = {}; + } statement.Condition.StringEquals = { 'lambda:EventSourceToken': x.EventSourceToken }; } @@ -285,13 +295,19 @@ function expectString(x: unknown): string | undefined { } function expectEffect(x: unknown): Effect { - if (x === Effect.Allow || x === Effect.Deny) { return x as Effect; } + if (x === Effect.Allow || x === Effect.Deny) { + return x as Effect; + } return Effect.Unknown; } function forceListOfStrings(x: unknown): string[] { - if (typeof x === 'string') { return [x]; } - if (typeof x === 'undefined' || x === null) { return []; } + if (typeof x === 'string') { + return [x]; + } + if (typeof x === 'undefined' || x === null) { + return []; + } if (Array.isArray(x)) { return x.map(e => forceListOfStrings(e).join(',')); @@ -312,7 +328,9 @@ function forceListOfStrings(x: unknown): string[] { * Render the Condition column */ export function renderCondition(condition: any): string { - if (!condition || Object.keys(condition).length === 0) { return ''; } + if (!condition || Object.keys(condition).length === 0) { + return ''; + } const jsonRepresentation = JSON.stringify(condition, undefined, 2); // The JSON representation looks like this: diff --git a/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-changes.ts b/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-changes.ts index 3d6092067..90eed7ab5 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-changes.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-changes.ts @@ -97,7 +97,9 @@ export class SecurityGroupChanges { } private readInlineRules(rules: any, logicalId: string): SecurityGroupRule[] { - if (!rules || !Array.isArray(rules)) { return []; } + if (!rules || !Array.isArray(rules)) { + return []; + } // UnCloudFormation so the parser works in an easier domain @@ -110,7 +112,9 @@ export class SecurityGroupChanges { } private readRuleResource(resource: any): SecurityGroupRule[] { - if (!resource) { return []; } + if (!resource) { + return []; + } // UnCloudFormation so the parser works in an easier domain diff --git a/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-rule.ts b/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-rule.ts index 47f7fd7de..4df15fc0d 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-rule.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/network/security-group-rule.ts @@ -55,12 +55,18 @@ export class SecurityGroupRule { } public describeProtocol() { - if (this.ipProtocol === '-1') { return 'Everything'; } + if (this.ipProtocol === '-1') { + return 'Everything'; + } const ipProtocol = this.ipProtocol.toUpperCase(); - if (this.fromPort === -1) { return `All ${ipProtocol}`; } - if (this.fromPort === this.toPort) { return `${ipProtocol} ${this.fromPort}`; } + if (this.fromPort === -1) { + return `All ${ipProtocol}`; + } + if (this.fromPort === this.toPort) { + return `${ipProtocol} ${this.fromPort}`; + } return `${ipProtocol} ${this.fromPort}-${this.toPort}`; } @@ -68,8 +74,12 @@ export class SecurityGroupRule { if (this.peer) { switch (this.peer.kind) { case 'cidr-ip': - if (this.peer.ip === '0.0.0.0/0') { return 'Everyone (IPv4)'; } - if (this.peer.ip === '::/0') { return 'Everyone (IPv6)'; } + if (this.peer.ip === '0.0.0.0/0') { + return 'Everyone (IPv4)'; + } + if (this.peer.ip === '::/0') { + return 'Everyone (IPv6)'; + } return `${this.peer.ip}`; case 'prefix-list': return `${this.peer.prefixListId}`; case 'security-group': return `${this.peer.securityGroupId}`; @@ -108,10 +118,16 @@ export interface PrefixListPeer { export type RulePeer = CidrIpPeer | SecurityGroupPeer | PrefixListPeer; function peerEqual(a?: RulePeer, b?: RulePeer) { - if ((a === undefined) !== (b === undefined)) { return false; } - if (a === undefined) { return true; } + if ((a === undefined) !== (b === undefined)) { + return false; + } + if (a === undefined) { + return true; + } - if (a.kind !== b!.kind) { return false; } + if (a.kind !== b!.kind) { + return false; + } switch (a.kind) { case 'cidr-ip': return a.ip === (b as typeof a).ip; case 'security-group': return a.securityGroupId === (b as typeof a).securityGroupId; diff --git a/packages/@aws-cdk/cloudformation-diff/lib/render-intrinsics.ts b/packages/@aws-cdk/cloudformation-diff/lib/render-intrinsics.ts index cb4142f78..45c7bde19 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/render-intrinsics.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/render-intrinsics.ts @@ -23,13 +23,21 @@ export function renderIntrinsics(x: any): any { return x.filter(el => !isNoValue(el)).map(renderIntrinsics); } - if (isNoValue(x)) { return undefined; } + if (isNoValue(x)) { + return undefined; + } const intrinsic = getIntrinsic(x); if (intrinsic) { - if (intrinsic.fn === 'Ref') { return '${' + intrinsic.args + '}'; } - if (intrinsic.fn === 'Fn::GetAtt') { return '${' + intrinsic.args[0] + '.' + intrinsic.args[1] + '}'; } - if (intrinsic.fn === 'Fn::Join') { return unCloudFormationFnJoin(intrinsic.args[0], intrinsic.args[1]); } + if (intrinsic.fn === 'Ref') { + return '${' + intrinsic.args + '}'; + } + if (intrinsic.fn === 'Fn::GetAtt') { + return '${' + intrinsic.args[0] + '.' + intrinsic.args[1] + '}'; + } + if (intrinsic.fn === 'Fn::Join') { + return unCloudFormationFnJoin(intrinsic.args[0], intrinsic.args[1]); + } return stringifyIntrinsic(intrinsic.fn, intrinsic.args); } @@ -57,8 +65,12 @@ function stringifyIntrinsic(fn: string, args: any) { } function getIntrinsic(x: any): Intrinsic | undefined { - if (x === undefined || x === null || Array.isArray(x)) { return undefined; } - if (typeof x !== 'object') { return undefined; } + if (x === undefined || x === null || Array.isArray(x)) { + return undefined; + } + if (typeof x !== 'object') { + return undefined; + } const keys = Object.keys(x); return keys.length === 1 && (keys[0] === 'Ref' || keys[0].startsWith('Fn::')) ? { fn: keys[0], args: x[keys[0]] } : undefined; } diff --git a/packages/@aws-cdk/cloudformation-diff/lib/util.ts b/packages/@aws-cdk/cloudformation-diff/lib/util.ts index 5f1bf7024..7e0195741 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/util.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/util.ts @@ -9,7 +9,9 @@ export function makeComparator(keyFn: (x: T) => U[]) { for (let i = 0; i < len; i++) { const c = compare(keyA[i], keyB[i]); - if (c !== 0) { return c; } + if (c !== 0) { + return c; + } } // Arrays are the same up to the min length -- shorter array sorts first @@ -18,8 +20,12 @@ export function makeComparator(keyFn: (x: T) => U[]) { } function compare(a: T, b: T) { - if (a < b) { return -1; } - if (b < a) { return 1; } + if (a < b) { + return -1; + } + if (b < a) { + return 1; + } return 0; } @@ -28,12 +34,18 @@ export function dropIfEmpty(xs: T[]): T[] | undefined { } export function deepRemoveUndefined(x: any): any { - if (typeof x === undefined || x === null) { return x; } - if (Array.isArray(x)) { return x.map(deepRemoveUndefined); } + if (typeof x === undefined || x === null) { + return x; + } + if (Array.isArray(x)) { + return x.map(deepRemoveUndefined); + } if (typeof x === 'object') { for (const [key, value] of Object.entries(x)) { x[key] = deepRemoveUndefined(value); - if (x[key] === undefined) { delete x[key]; } + if (x[key] === undefined) { + delete x[key]; + } } return x; } diff --git a/packages/@aws-cdk/cloudformation-diff/test/network/rule.test.ts b/packages/@aws-cdk/cloudformation-diff/test/network/rule.test.ts index f0ad92e0a..92772f65a 100644 --- a/packages/@aws-cdk/cloudformation-diff/test/network/rule.test.ts +++ b/packages/@aws-cdk/cloudformation-diff/test/network/rule.test.ts @@ -17,7 +17,9 @@ test('can parse cidr-ip', () => { expect(rule.toPort).toEqual(20); const peer = rule.peer!; - if (peer.kind !== 'cidr-ip') { throw new Error('Fail'); } + if (peer.kind !== 'cidr-ip') { + throw new Error('Fail'); + } expect(peer.ip).toEqual('1.2.3.4/8'); }); @@ -27,7 +29,9 @@ test('can parse cidr-ip 6', () => { }); const peer = rule.peer!; - if (peer.kind !== 'cidr-ip') { throw new Error('Fail'); } + if (peer.kind !== 'cidr-ip') { + throw new Error('Fail'); + } expect(peer.ip).toEqual('::/0'); }); @@ -38,7 +42,9 @@ test('can parse securityGroup', () => { }); const peer = rule.peer!; - if (peer.kind !== 'security-group') { throw new Error('Fail'); } + if (peer.kind !== 'security-group') { + throw new Error('Fail'); + } expect(peer.securityGroupId).toEqual('sg-1234'); } }); @@ -50,7 +56,9 @@ test('can parse prefixlist', () => { }); const peer = rule.peer!; - if (peer.kind !== 'prefix-list') { throw new Error('Fail'); } + if (peer.kind !== 'prefix-list') { + throw new Error('Fail'); + } expect(peer.prefixListId).toEqual('pl-1'); } }); diff --git a/packages/@aws-cdk/cloudformation-diff/test/test-arbitraries.ts b/packages/@aws-cdk/cloudformation-diff/test/test-arbitraries.ts index d9b7b1789..5459e2734 100644 --- a/packages/@aws-cdk/cloudformation-diff/test/test-arbitraries.ts +++ b/packages/@aws-cdk/cloudformation-diff/test/test-arbitraries.ts @@ -77,12 +77,24 @@ export const twoArbitraryStatements = fc.record({ const original = op.statement1; const modified = Object.create(original, {}); - if (op.copySid) { modified.Sid = op.statement2.Sid; } - if (op.copyEffect) { modified.Effect = op.statement2.Effect; } - if (op.copyResource) { modified.Resource = op.statement2.Resource; modified.NotResource = op.statement2.NotResource; } - if (op.copyAction) { modified.Action = op.statement2.Action; modified.NotAction = op.statement2.NotAction; } - if (op.copyPrincipal) { modified.Principal = op.statement2.Principal; modified.NotPrincipal = op.statement2.NotPrincipal; } - if (op.copyCondition) { modified.Condition = op.statement2.Condition; } + if (op.copySid) { + modified.Sid = op.statement2.Sid; + } + if (op.copyEffect) { + modified.Effect = op.statement2.Effect; + } + if (op.copyResource) { + modified.Resource = op.statement2.Resource; modified.NotResource = op.statement2.NotResource; + } + if (op.copyAction) { + modified.Action = op.statement2.Action; modified.NotAction = op.statement2.NotAction; + } + if (op.copyPrincipal) { + modified.Principal = op.statement2.Principal; modified.NotPrincipal = op.statement2.NotPrincipal; + } + if (op.copyCondition) { + modified.Condition = op.statement2.Condition; + } return { statement1: original, statement2: modified }; }); @@ -112,12 +124,24 @@ export const twoArbitraryRules = fc.record({ const original = op.rule1; const modified = Object.create(original, {}); - if (op.copyIp) { modified.IpProtocol = op.rule2.IpProtocol; } - if (op.copyFromPort) { modified.FromPort = op.rule2.FromPort; } - if (op.copyToPort) { modified.ToPort = op.rule2.ToPort; } - if (op.copyCidrIp) { modified.CidrIp = op.rule2.CidrIp; } - if (op.copySecurityGroupId) { modified.DestinationSecurityGroupId = op.rule2.DestinationSecurityGroupId; } - if (op.copyPrefixListId) { modified.DestinationPrefixListId = op.rule2.DestinationPrefixListId; } + if (op.copyIp) { + modified.IpProtocol = op.rule2.IpProtocol; + } + if (op.copyFromPort) { + modified.FromPort = op.rule2.FromPort; + } + if (op.copyToPort) { + modified.ToPort = op.rule2.ToPort; + } + if (op.copyCidrIp) { + modified.CidrIp = op.rule2.CidrIp; + } + if (op.copySecurityGroupId) { + modified.DestinationSecurityGroupId = op.rule2.DestinationSecurityGroupId; + } + if (op.copyPrefixListId) { + modified.DestinationPrefixListId = op.rule2.DestinationPrefixListId; + } return { rule1: original, rule2: modified }; }); diff --git a/packages/@aws-cdk/node-bundle/.eslintrc.json b/packages/@aws-cdk/node-bundle/.eslintrc.json index 73ce760f7..f34f94963 100644 --- a/packages/@aws-cdk/node-bundle/.eslintrc.json +++ b/packages/@aws-cdk/node-bundle/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/node-bundle/src/api/violation.ts b/packages/@aws-cdk/node-bundle/src/api/violation.ts index a791b7fd6..90270462a 100644 --- a/packages/@aws-cdk/node-bundle/src/api/violation.ts +++ b/packages/@aws-cdk/node-bundle/src/api/violation.ts @@ -63,7 +63,8 @@ export interface Violation { * Report encapsulating a list of violations. */ export class ViolationsReport { - constructor(private readonly _violations: Violation[]) {} + constructor(private readonly _violations: Violation[]) { + } /** * The list of violations. diff --git a/packages/@aws-cdk/node-bundle/src/cli-main.ts b/packages/@aws-cdk/node-bundle/src/cli-main.ts index c46e05caa..80455c94d 100644 --- a/packages/@aws-cdk/node-bundle/src/cli-main.ts +++ b/packages/@aws-cdk/node-bundle/src/cli-main.ts @@ -28,7 +28,9 @@ export async function cliMain(cliArgs: string[]) { .strict() // require a VALID subcommand, and only supported options .fail((msg, err) => { // Throw an error in test mode, exit with an error code otherwise - if (err) { throw err; } + if (err) { + throw err; + } if (process.env.NODE_ENV === 'test') { throw new Error(msg); } diff --git a/packages/@aws-cdk/toolkit-lib/.eslintrc.json b/packages/@aws-cdk/toolkit-lib/.eslintrc.json index e907a9e7f..59578d7e0 100644 --- a/packages/@aws-cdk/toolkit-lib/.eslintrc.json +++ b/packages/@aws-cdk/toolkit-lib/.eslintrc.json @@ -162,6 +162,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts index 090b315f5..327a200ec 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts @@ -67,7 +67,8 @@ export class DiffMethod { private constructor( public readonly method: 'change-set' | 'template-only' | 'local-file', public readonly options: ChangeSetDiffOptions | CloudFormationDiffOptions | { path: string }, - ) {} + ) { + } } export interface DiffOptions { diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/identity-source.ts b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/identity-source.ts index 03af4537d..32f89b217 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/identity-source.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/identity-source.ts @@ -5,7 +5,8 @@ import { ICloudAssemblySource } from './types'; * A CloudAssemblySource that is representing a already existing and produced CloudAssembly. */ export class IdentityCloudAssemblySource implements ICloudAssemblySource { - public constructor(private readonly cloudAssembly: cxapi.CloudAssembly) {} + public constructor(private readonly cloudAssembly: cxapi.CloudAssembly) { + } public async produce(): Promise { return this.cloudAssembly; diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts index c6f0dca8f..f4d0e2d2e 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts @@ -119,9 +119,13 @@ function missingContextKeys(missing?: MissingContext[]): Set { * Are two sets equal to each other */ function equalSets(a: Set, b: Set) { - if (a.size !== b.size) { return false; } + if (a.size !== b.size) { + return false; + } for (const x of a) { - if (!b.has(x)) { return false; } + if (!b.has(x)) { + return false; + } } return true; } diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/logger.ts b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/logger.ts index caaaceef7..82e6f0256 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/logger.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/logger.ts @@ -105,8 +105,10 @@ export function withTrimmedWhitespace(ioHost: IIoHost): IIoHost { export function asSdkLogger(ioHost: IIoHost, action: ToolkitAction): Logger { return new class implements Logger { // This is too much detail for our logs - public trace(..._content: any[]) {} - public debug(..._content: any[]) {} + public trace(..._content: any[]) { + } + public debug(..._content: any[]) { + } /** * Info is called mostly (exclusively?) for successful API calls diff --git a/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts b/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts index 73a3ae077..6a162525c 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts @@ -335,7 +335,9 @@ export class Toolkit extends CloudAssemblySourceBuilder implements AsyncDisposab const question = `${motivation}\nDo you wish to deploy these changes`; // @todo reintroduce concurrency and corked logging in CliHost const confirmed = await ioHost.requestResponse(confirm('CDK_TOOLKIT_I5060', question, motivation, true, concurrency)); - if (!confirmed) { throw new ToolkitError('Aborted by user'); } + if (!confirmed) { + throw new ToolkitError('Aborted by user'); + } } } @@ -412,7 +414,9 @@ export class Toolkit extends CloudAssemblySourceBuilder implements AsyncDisposab await ioHost.notify(warn(`${motivation}. Rolling back first (--force).`)); } else { const confirmed = await ioHost.requestResponse(confirm('CDK_TOOLKIT_I5050', question, motivation, true, concurrency)); - if (!confirmed) { throw new ToolkitError('Aborted by user'); } + if (!confirmed) { + throw new ToolkitError('Aborted by user'); + } } // Perform a rollback @@ -435,7 +439,9 @@ export class Toolkit extends CloudAssemblySourceBuilder implements AsyncDisposab await ioHost.notify(warn(`${motivation}. Proceeding with regular deployment (--force).`)); } else { const confirmed = await ioHost.requestResponse(confirm('CDK_TOOLKIT_I5050', question, motivation, true, concurrency)); - if (!confirmed) { throw new ToolkitError('Aborted by user'); } + if (!confirmed) { + throw new ToolkitError('Aborted by user'); + } } // Go around through the 'while' loop again but switch rollback to true. diff --git a/packages/@aws-cdk/user-input-gen/.eslintrc.json b/packages/@aws-cdk/user-input-gen/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/@aws-cdk/user-input-gen/.eslintrc.json +++ b/packages/@aws-cdk/user-input-gen/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/yarn-cling/.eslintrc.json b/packages/@aws-cdk/yarn-cling/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/@aws-cdk/yarn-cling/.eslintrc.json +++ b/packages/@aws-cdk/yarn-cling/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/@aws-cdk/yarn-cling/lib/hoisting.ts b/packages/@aws-cdk/yarn-cling/lib/hoisting.ts index 7031b9891..e5d1d7355 100644 --- a/packages/@aws-cdk/yarn-cling/lib/hoisting.ts +++ b/packages/@aws-cdk/yarn-cling/lib/hoisting.ts @@ -32,7 +32,9 @@ export function hoistDependencies(packageTree: PackageLockPackage) { // Move the children of the parent onto the same level if there are no conflicts function moveUp(node: PackageLockPackage, parent?: PackageLockPackage) { - if (!node.dependencies) { return; } + if (!node.dependencies) { + return; + } // Recurse for (const child of Object.values(node.dependencies)) { @@ -51,7 +53,9 @@ export function hoistDependencies(packageTree: PackageLockPackage) { } function removeDupes(node: PackageLockPackage, rootPath: Array) { - if (!node.dependencies) { return; } + if (!node.dependencies) { + return; + } // Any dependencies here that are the same in the parent can be removed for (const [depName, depPackage] of Object.entries(node.dependencies)) { @@ -67,7 +71,9 @@ export function hoistDependencies(packageTree: PackageLockPackage) { } function removeUseless(node: PackageLockPackage) { - if (!node.dependencies) { return; } + if (!node.dependencies) { + return; + } for (const [depName, depPkg] of Object.entries(node.dependencies)) { if (!necessaryInTree(depName, depPkg.version, node)) { delete node.dependencies[depName]; @@ -95,7 +101,9 @@ export function hoistDependencies(packageTree: PackageLockPackage) { } function recordOriginalDependencies(node: PackageLockPackage) { - if (!node.dependencies) { return; } + if (!node.dependencies) { + return; + } let list = originalDependencies.get(node); if (!list) { @@ -113,10 +121,14 @@ export function hoistDependencies(packageTree: PackageLockPackage) { if (originalDependencies.get(tree)?.includes(`${name}@${version}`)) { return true; } - if (!tree.dependencies) { return false; } + if (!tree.dependencies) { + return false; + } for (const depPackage of Object.values(tree.dependencies)) { - if (necessaryInTree(name, version, depPackage)) { return true; } + if (necessaryInTree(name, version, depPackage)) { + return true; + } } return false; } @@ -141,7 +153,9 @@ export function renderTree(tree: PackageLockPackage): string[] { for (let i = 0; i < as.length && i < bs.length; i++) { const cmp = as[i].localeCompare(bs[i]); - if (cmp !== 0) { return cmp; } + if (cmp !== 0) { + return cmp; + } } return as.length - bs.length; diff --git a/packages/@aws-cdk/yarn-cling/lib/index.ts b/packages/@aws-cdk/yarn-cling/lib/index.ts index c65d36a68..0b17985b8 100644 --- a/packages/@aws-cdk/yarn-cling/lib/index.ts +++ b/packages/@aws-cdk/yarn-cling/lib/index.ts @@ -118,8 +118,12 @@ async function dependenciesFor(deps: Record, yarnLock: YarnLock, } // Simplify by removing useless entries - if (Object.keys(ret[depName].requires ?? {}).length === 0) { delete ret[depName].requires; } - if (Object.keys(ret[depName].dependencies ?? {}).length === 0) { delete ret[depName].dependencies; } + if (Object.keys(ret[depName].requires ?? {}).length === 0) { + delete ret[depName].requires; + } + if (Object.keys(ret[depName].dependencies ?? {}).length === 0) { + delete ret[depName].dependencies; + } } return ret; @@ -153,7 +157,9 @@ async function fileExists(fullPath: string): Promise { await fs.stat(fullPath); return true; } catch (e: any) { - if (e.code === 'ENOENT' || e.code === 'ENOTDIR') { return false; } + if (e.code === 'ENOENT' || e.code === 'ENOTDIR') { + return false; + } throw e; } } @@ -253,7 +259,9 @@ export function checkRequiredVersions(root: PackageLock | PackageLockPackage) { // For every 'requires' dependency, find the version it actually got resolved to and compare. for (const [name, range] of Object.entries(entry.requires)) { const resolvedPackage = findResolved(name, [entry, ...parentChain]); - if (!resolvedPackage) { continue; } + if (!resolvedPackage) { + continue; + } if (!semver.satisfies(resolvedPackage.version, range)) { // Ruh-roh. diff --git a/packages/aws-cdk/.eslintrc.json b/packages/aws-cdk/.eslintrc.json index 2eefee123..d69bbb859 100644 --- a/packages/aws-cdk/.eslintrc.json +++ b/packages/aws-cdk/.eslintrc.json @@ -163,6 +163,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts b/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts index 4c17dc396..8b5025088 100644 --- a/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts +++ b/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts @@ -142,7 +142,8 @@ export class SdkProvider { public readonly defaultRegion: string, private readonly requestHandler: NodeHttpHandlerOptions = {}, private readonly logger?: Logger, - ) {} + ) { + } /** * Return an SDK which can do operations in the given environment diff --git a/packages/aws-cdk/lib/api/aws-auth/tracing.ts b/packages/aws-cdk/lib/api/aws-auth/tracing.ts index e4624d9d2..2da14d371 100644 --- a/packages/aws-cdk/lib/api/aws-auth/tracing.ts +++ b/packages/aws-cdk/lib/api/aws-auth/tracing.ts @@ -27,7 +27,9 @@ function traceCall(receiver: object, _propertyKey: string, descriptor: PropertyD descriptor.value = function (...args: any[]) { const logger = (this as any).logger; - if (!ENABLED || typeof logger?.info !== 'function') { return fn.apply(this, args); } + if (!ENABLED || typeof logger?.info !== 'function') { + return fn.apply(this, args); + } logger.info.apply(logger, [`[trace] ${' '.repeat(INDENT)}${className || this.constructor.name || '(anonymous)'}#${fn.name}()`]); INDENT += 2; @@ -52,7 +54,9 @@ function traceCall(receiver: object, _propertyKey: string, descriptor: PropertyD export function traceMemberMethods(constructor: Function) { // Instance members for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(constructor.prototype))) { - if (typeof descriptor.value !== 'function') { continue; } + if (typeof descriptor.value !== 'function') { + continue; + } const newDescriptor = traceCall(constructor.prototype, name, descriptor, constructor.name) ?? descriptor; Object.defineProperty(constructor.prototype, name, newDescriptor); } diff --git a/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts b/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts index 380e44aef..4d8547d73 100644 --- a/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts +++ b/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts @@ -20,7 +20,8 @@ export class Bootstrapper { constructor( private readonly source: BootstrapSource = { source: 'default' }, private readonly msg: IoMessaging, - ) {} + ) { + } public bootstrapEnvironment( environment: cxapi.Environment, diff --git a/packages/aws-cdk/lib/api/bootstrap/deploy-bootstrap.ts b/packages/aws-cdk/lib/api/bootstrap/deploy-bootstrap.ts index ccfd783a5..b7044e0b0 100644 --- a/packages/aws-cdk/lib/api/bootstrap/deploy-bootstrap.ts +++ b/packages/aws-cdk/lib/api/bootstrap/deploy-bootstrap.ts @@ -52,7 +52,8 @@ export class BootstrapStack { private readonly toolkitStackName: string, private readonly currentToolkitInfo: ToolkitInfo, private readonly msg: IoMessaging, - ) {} + ) { + } public get parameters(): Record { return this.currentToolkitInfo.found ? this.currentToolkitInfo.bootstrapStack.parameters : {}; diff --git a/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts index 8a40daf56..23e594790 100644 --- a/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts +++ b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts @@ -311,7 +311,8 @@ export class StackCollection { */ public async validateMetadata( failAt: 'warn' | 'error' | 'none' = 'error', - logger: (level: 'info' | 'error' | 'warn', msg: cxapi.SynthesisMessage) => Promise = async () => {}, + logger: (level: 'info' | 'error' | 'warn', msg: cxapi.SynthesisMessage) => Promise = async () => { + }, ) { let warnings = false; let errors = false; diff --git a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts index 4c7a708e2..58e5a7cd7 100644 --- a/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts +++ b/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts @@ -118,9 +118,13 @@ function missingContextKeys(missing?: cxapi.MissingContext[]): Set { } function setsEqual(a: Set, b: Set) { - if (a.size !== b.size) { return false; } + if (a.size !== b.size) { + return false; + } for (const x of a) { - if (!b.has(x)) { return false; } + if (!b.has(x)) { + return false; + } } return true; } diff --git a/packages/aws-cdk/lib/api/cxapp/environments.ts b/packages/aws-cdk/lib/api/cxapp/environments.ts index a1b8c66e6..8dbc8a719 100644 --- a/packages/aws-cdk/lib/api/cxapp/environments.ts +++ b/packages/aws-cdk/lib/api/cxapp/environments.ts @@ -10,7 +10,9 @@ export function looksLikeGlob(environment: string) { // eslint-disable-next-line max-len export async function globEnvironmentsFromStacks(stacks: StackCollection, environmentGlobs: string[], sdk: SdkProvider): Promise { - if (environmentGlobs.length === 0) { return []; } + if (environmentGlobs.length === 0) { + return []; + } const availableEnvironments = new Array(); for (const stack of stacks.stackArtifacts) { @@ -62,7 +64,9 @@ function distinct(envs: cxapi.Environment[]): cxapi.Environment[] { const unique: { [id: string]: cxapi.Environment } = {}; for (const env of envs) { const id = `${env.account || 'default'}/${env.region || 'default'}`; - if (id in unique) { continue; } + if (id in unique) { + continue; + } unique[id] = env; } return Object.values(unique); diff --git a/packages/aws-cdk/lib/api/cxapp/exec.ts b/packages/aws-cdk/lib/api/cxapp/exec.ts index 2def56328..e5782e1d3 100644 --- a/packages/aws-cdk/lib/api/cxapp/exec.ts +++ b/packages/aws-cdk/lib/api/cxapp/exec.ts @@ -207,9 +207,13 @@ export async function prepareContext(settings: Settings, context: {[key: string] } const versionReporting: boolean = settings.get(['versionReporting']) ?? true; - if (versionReporting) { context[cxapi.ANALYTICS_REPORTING_ENABLED_CONTEXT] = true; } + if (versionReporting) { + context[cxapi.ANALYTICS_REPORTING_ENABLED_CONTEXT] = true; + } // We need to keep on doing this for framework version from before this flag was deprecated. - if (!versionReporting) { context['aws:cdk:disable-version-reporting'] = true; } + if (!versionReporting) { + context['aws:cdk:disable-version-reporting'] = true; + } const stagingEnabled = settings.get(['staging']) ?? true; if (!stagingEnabled) { diff --git a/packages/aws-cdk/lib/api/deployments/asset-publishing.ts b/packages/aws-cdk/lib/api/deployments/asset-publishing.ts index a18ca3dae..62577ab52 100644 --- a/packages/aws-cdk/lib/api/deployments/asset-publishing.ts +++ b/packages/aws-cdk/lib/api/deployments/asset-publishing.ts @@ -84,7 +84,8 @@ export class PublishingAws implements IAws { * Environment where the stack we're deploying is going */ private readonly targetEnv: Environment, - ) {} + ) { + } public async discoverPartition(): Promise { return (await this.aws.baseCredentialsPartition(this.targetEnv, Mode.ForWriting)) ?? 'aws'; diff --git a/packages/aws-cdk/lib/api/deployments/assets.ts b/packages/aws-cdk/lib/api/deployments/assets.ts index 2dc542dcf..866354367 100644 --- a/packages/aws-cdk/lib/api/deployments/assets.ts +++ b/packages/aws-cdk/lib/api/deployments/assets.ts @@ -147,6 +147,8 @@ async function prepareDockerImageAsset( imageTag, }); - if (!asset.imageNameParameter) { return {}; } + if (!asset.imageNameParameter) { + return {}; + } return { [asset.imageNameParameter]: `${repositoryUri}:${imageTag}` }; } diff --git a/packages/aws-cdk/lib/api/deployments/cloudformation.ts b/packages/aws-cdk/lib/api/deployments/cloudformation.ts index 41c941ebd..f3892e701 100644 --- a/packages/aws-cdk/lib/api/deployments/cloudformation.ts +++ b/packages/aws-cdk/lib/api/deployments/cloudformation.ts @@ -84,7 +84,8 @@ export class CloudFormationStack { public readonly stackName: string, private readonly stack?: Stack, private readonly retrieveProcessedTemplate: boolean = false, - ) {} + ) { + } /** * Retrieve the stack's deployed template @@ -649,7 +650,8 @@ export class TemplateParameters { return new TemplateParameters(template.Parameters || {}); } - constructor(private readonly params: Record) {} + constructor(private readonly params: Record) { + } /** * Calculate stack parameters to pass from the given desired parameter values diff --git a/packages/aws-cdk/lib/api/environment/environment-resources.ts b/packages/aws-cdk/lib/api/environment/environment-resources.ts index d5a0d6582..084296830 100644 --- a/packages/aws-cdk/lib/api/environment/environment-resources.ts +++ b/packages/aws-cdk/lib/api/environment/environment-resources.ts @@ -19,7 +19,8 @@ import { type EcrRepositoryInfo, ToolkitInfo } from '../toolkit-info'; export class EnvironmentResourcesRegistry { private readonly cache = new Map(); - constructor(private readonly toolkitStackName?: string) {} + constructor(private readonly toolkitStackName?: string) { + } public for(resolvedEnvironment: Environment, sdk: SDK, msg: IoMessaging) { const key = `${resolvedEnvironment.account}:${resolvedEnvironment.region}`; @@ -51,7 +52,8 @@ export class EnvironmentResources { private readonly msg: IoMessaging, private readonly cache: EnvironmentCache, private readonly toolkitStackName?: string, - ) {} + ) { + } /** * Look up the toolkit for a given environment, using a given SDK diff --git a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts index a338d996a..4ccdb84e3 100644 --- a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts +++ b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts @@ -13,7 +13,8 @@ export class LazyListStackResources implements ListStackResources { constructor( private readonly sdk: SDK, private readonly stackName: string, - ) {} + ) { + } public async listStackResources(): Promise { if (this.stackResources === undefined) { @@ -29,12 +30,14 @@ export interface LookupExport { lookupExport(name: string): Promise; } -export class LookupExportError extends Error {} +export class LookupExportError extends Error { +} export class LazyLookupExport implements LookupExport { private cachedExports: { [name: string]: Export } = {}; - constructor(private readonly sdk: SDK) {} + constructor(private readonly sdk: SDK) { + } async lookupExport(name: string): Promise { if (this.cachedExports[name]) { @@ -72,7 +75,8 @@ export class LazyLookupExport implements LookupExport { } } -export class CfnEvaluationException extends Error {} +export class CfnEvaluationException extends Error { +} export interface ResourceDefinition { readonly LogicalId: string; diff --git a/packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts b/packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts index 384291165..f8fe42e4b 100644 --- a/packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts +++ b/packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts @@ -32,7 +32,8 @@ export class ImageAsset { public readonly size: number, public readonly tags: string[], public readonly manifest: string, - ) {} + ) { + } private getTag(tag: string) { return this.tags.find(t => t.includes(tag)); @@ -75,7 +76,8 @@ export class ImageAsset { export class ObjectAsset { private cached_tags: Tag[] | undefined = undefined; - public constructor(private readonly bucket: string, public readonly key: string, public readonly size: number) {} + public constructor(private readonly bucket: string, public readonly key: string, public readonly size: number) { + } public fileName(): string { return this.key.split('.')[0]; @@ -776,7 +778,9 @@ function partition(xs: Iterable, pred: (x: A) => boolean): { included: A[] function imageMap(imageIds: ImageIdentifier[]) { const images: Record = {}; for (const image of imageIds ?? []) { - if (!image.imageDigest || !image.imageTag) { continue; } + if (!image.imageDigest || !image.imageTag) { + continue; + } if (!images[image.imageDigest]) { images[image.imageDigest] = []; } diff --git a/packages/aws-cdk/lib/api/hotswap/common.ts b/packages/aws-cdk/lib/api/hotswap/common.ts index 1314cdb1f..6b23fc3da 100644 --- a/packages/aws-cdk/lib/api/hotswap/common.ts +++ b/packages/aws-cdk/lib/api/hotswap/common.ts @@ -189,7 +189,8 @@ export class ClassifiedChanges { public readonly change: HotswappableChangeCandidate, public readonly hotswappableProps: PropDiffs, public readonly nonHotswappableProps: PropDiffs, - ) {} + ) { + } public reportNonHotswappablePropertyChanges(ret: ChangeHotswapResult): void { const nonHotswappablePropNames = Object.keys(this.nonHotswappableProps); diff --git a/packages/aws-cdk/lib/api/hotswap/lambda-functions.ts b/packages/aws-cdk/lib/api/hotswap/lambda-functions.ts index 64ec5a534..cd78fb189 100644 --- a/packages/aws-cdk/lib/api/hotswap/lambda-functions.ts +++ b/packages/aws-cdk/lib/api/hotswap/lambda-functions.ts @@ -27,7 +27,8 @@ export async function isHotswappableLambdaFunctionChange( resourceNames: [], propsChanged: [], service: 'lambda', - apply: async (_sdk: SDK) => {}, + apply: async (_sdk: SDK) => { + }, }, ]; } @@ -164,7 +165,8 @@ function classifyAliasChanges(change: HotswappableChangeCandidate): ChangeHotswa propsChanged: [], service: 'lambda', resourceNames: [], - apply: async (_sdk: SDK) => {}, + apply: async (_sdk: SDK) => { + }, }); } diff --git a/packages/aws-cdk/lib/api/resource-import/importer.ts b/packages/aws-cdk/lib/api/resource-import/importer.ts index 80366a80c..3246aa4fc 100644 --- a/packages/aws-cdk/lib/api/resource-import/importer.ts +++ b/packages/aws-cdk/lib/api/resource-import/importer.ts @@ -508,7 +508,9 @@ function fmtdict(xs: Record) { * deleting stateful resources in the process of importing to CDK. */ function addDefaultDeletionPolicy(resource: any): any { - if (resource.DeletionPolicy) { return resource; } + if (resource.DeletionPolicy) { + return resource; + } return { ...resource, diff --git a/packages/aws-cdk/lib/api/settings.ts b/packages/aws-cdk/lib/api/settings.ts index 41eee46c9..2d5c1ee13 100644 --- a/packages/aws-cdk/lib/api/settings.ts +++ b/packages/aws-cdk/lib/api/settings.ts @@ -27,7 +27,8 @@ export class Settings { constructor( private settings: SettingsMap = {}, public readonly readOnly = false, - ) {} + ) { + } public async load(fileName: string): Promise { if (this.readOnly) { diff --git a/packages/aws-cdk/lib/api/toolkit-info.ts b/packages/aws-cdk/lib/api/toolkit-info.ts index d2019acd2..b013319b0 100644 --- a/packages/aws-cdk/lib/api/toolkit-info.ts +++ b/packages/aws-cdk/lib/api/toolkit-info.ts @@ -114,7 +114,8 @@ export abstract class ToolkitInfo { public abstract readonly bootstrapStack: CloudFormationStack; public abstract readonly stackName: string; - constructor() {} + constructor() { + } } /** diff --git a/packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts b/packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts index c358e4329..d0a688e32 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts @@ -53,7 +53,8 @@ export class StackEventPoller { constructor( private readonly cfn: ICloudFormationClient, private readonly props: StackEventPollerProps, - ) {} + ) { + } /** * From all accumulated events, return only the errors diff --git a/packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts b/packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts index 488f95282..6263859e5 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts @@ -13,7 +13,8 @@ export class StackStatus { constructor( public readonly name: string, public readonly reason?: string, - ) {} + ) { + } get isCreationFailure(): boolean { return this.name === _StackStatus.ROLLBACK_COMPLETE || this.name === _StackStatus.ROLLBACK_FAILED; diff --git a/packages/aws-cdk/lib/api/util/display.ts b/packages/aws-cdk/lib/api/util/display.ts index 11a18a722..0f0a96453 100644 --- a/packages/aws-cdk/lib/api/util/display.ts +++ b/packages/aws-cdk/lib/api/util/display.ts @@ -65,7 +65,9 @@ function cll() { } function terminalWrap(width: number | undefined, lines: string[]) { - if (width === undefined) { return lines; } + if (width === undefined) { + return lines; + } return lines.flatMap(line => wrapAnsi(line, width - 1, { hard: true, @@ -82,6 +84,8 @@ function expandNewlines(lines: string[]): string[] { } function getMaxBlockHeight(windowHeight: number | undefined, lastHeight: number, lines: string[]): number { - if (windowHeight === undefined) { return Math.max(lines.length, lastHeight); } + if (windowHeight === undefined) { + return Math.max(lines.length, lastHeight); + } return lines.length < windowHeight ? lines.length : windowHeight - 1; } diff --git a/packages/aws-cdk/lib/api/util/rwlock.ts b/packages/aws-cdk/lib/api/util/rwlock.ts index a71236845..219680c29 100644 --- a/packages/aws-cdk/lib/api/util/rwlock.ts +++ b/packages/aws-cdk/lib/api/util/rwlock.ts @@ -99,7 +99,9 @@ export class RWLock { */ private async currentWriter(): Promise { const contents = await readFileIfExists(this.writerFile); - if (!contents) { return undefined; } + if (!contents) { + return undefined; + } const pid = parseInt(contents, 10); if (!processExists(pid)) { @@ -123,7 +125,9 @@ export class RWLock { children = await fs.readdir(this.directory, { encoding: 'utf-8' }); } catch (e: any) { // Can't be locked if the directory doesn't exist - if (e.code === 'ENOENT') { return []; } + if (e.code === 'ENOENT') { + return []; + } throw e; } @@ -165,7 +169,9 @@ async function readFileIfExists(filename: string): Promise { try { return await fs.readFile(filename, { encoding: 'utf-8' }); } catch (e: any) { - if (e.code === 'ENOENT') { return undefined; } + if (e.code === 'ENOENT') { + return undefined; + } throw e; } } diff --git a/packages/aws-cdk/lib/cli/cdk-toolkit.ts b/packages/aws-cdk/lib/cli/cdk-toolkit.ts index 8d9be4ae1..53fc91273 100644 --- a/packages/aws-cdk/lib/cli/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cli/cdk-toolkit.ts @@ -1208,8 +1208,12 @@ export class CdkToolkit { */ private async validateStacks(stacks: StackCollection) { let failAt: 'warn' | 'error' | 'none' = 'error'; - if (this.props.ignoreErrors) { failAt = 'none'; } - if (this.props.strict) { failAt = 'warn'; } + if (this.props.ignoreErrors) { + failAt = 'none'; + } + if (this.props.strict) { + failAt = 'warn'; + } await stacks.validateMetadata(failAt, stackMetadataLogger(this.props.verbose)); } @@ -1871,7 +1875,9 @@ async function askUserConfirmation( } const confirmed = await promptly.confirm(`${chalk.cyan(question)} (y/n)?`); - if (!confirmed) { throw new ToolkitError('Aborted by user'); } + if (!confirmed) { + throw new ToolkitError('Aborted by user'); + } }); } diff --git a/packages/aws-cdk/lib/cli/platform-warnings.ts b/packages/aws-cdk/lib/cli/platform-warnings.ts index cb7beba43..8144cc9f0 100644 --- a/packages/aws-cdk/lib/cli/platform-warnings.ts +++ b/packages/aws-cdk/lib/cli/platform-warnings.ts @@ -21,13 +21,21 @@ export function isVersionBetween(version: string, lower: string, upper: string) const lo = splitVersion(lower); const up = splitVersion(upper); - while (lo.length < ver.length) { lo.push(0); } - while (up.length < ver.length) { up.push(9999999); } + while (lo.length < ver.length) { + lo.push(0); + } + while (up.length < ver.length) { + up.push(9999999); + } let n = ver.length; for (let i = 0; i < n; i++) { - if (lo[i] < ver[i] && ver[i] < up[i]) { return true; } - if (lo[i] > ver[i] || ver[i] > up[i]) { return false; } + if (lo[i] < ver[i] && ver[i] < up[i]) { + return true; + } + if (lo[i] > ver[i] || ver[i] > up[i]) { + return false; + } } return false; diff --git a/packages/aws-cdk/lib/cli/user-input.ts b/packages/aws-cdk/lib/cli/user-input.ts index 56c93df7c..a51ae5e9d 100644 --- a/packages/aws-cdk/lib/cli/user-input.ts +++ b/packages/aws-cdk/lib/cli/user-input.ts @@ -1331,4 +1331,5 @@ export interface DocsOptions { * * @struct */ -export interface DoctorOptions {} +export interface DoctorOptions { +} diff --git a/packages/aws-cdk/lib/commands/docs.ts b/packages/aws-cdk/lib/commands/docs.ts index 9bb8eb657..fdec35978 100644 --- a/packages/aws-cdk/lib/commands/docs.ts +++ b/packages/aws-cdk/lib/commands/docs.ts @@ -27,8 +27,12 @@ export async function docs(options: DocsOptions): Promise { debug(`An error occurred when trying to open a browser: ${err.stack || err.message}`); return resolve(0); } - if (stdout) { debug(stdout); } - if (stderr) { warning(stderr); } + if (stdout) { + debug(stdout); + } + if (stderr) { + warning(stderr); + } resolve(0); }); }); diff --git a/packages/aws-cdk/lib/commands/doctor.ts b/packages/aws-cdk/lib/commands/doctor.ts index 7bd587a06..425c91a59 100644 --- a/packages/aws-cdk/lib/commands/doctor.ts +++ b/packages/aws-cdk/lib/commands/doctor.ts @@ -61,7 +61,11 @@ function displayCdkEnvironmentVariables() { } function anonymizeAwsVariable(name: string, value: string) { - if (name === 'AWS_ACCESS_KEY_ID') { return value.slice(0, 4) + ''; } // Show ASIA/AKIA key type, but hide identifier - if (name === 'AWS_SECRET_ACCESS_KEY' || name === 'AWS_SESSION_TOKEN' || name === 'AWS_SECURITY_TOKEN') { return ''; } + if (name === 'AWS_ACCESS_KEY_ID') { + return value.slice(0, 4) + ''; + } // Show ASIA/AKIA key type, but hide identifier + if (name === 'AWS_SECRET_ACCESS_KEY' || name === 'AWS_SESSION_TOKEN' || name === 'AWS_SECURITY_TOKEN') { + return ''; + } return value; } diff --git a/packages/aws-cdk/lib/context-providers/ami.ts b/packages/aws-cdk/lib/context-providers/ami.ts index 5aebbae5f..162a7d4b3 100644 --- a/packages/aws-cdk/lib/context-providers/ami.ts +++ b/packages/aws-cdk/lib/context-providers/ami.ts @@ -8,7 +8,8 @@ import { ContextProviderError } from '../toolkit/error'; * Plugin to search AMIs for the current account */ export class AmiContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } public async getValue(args: AmiContextQuery) { const region = args.region; diff --git a/packages/aws-cdk/lib/context-providers/availability-zones.ts b/packages/aws-cdk/lib/context-providers/availability-zones.ts index 935dbad2c..1f4f5e2e1 100644 --- a/packages/aws-cdk/lib/context-providers/availability-zones.ts +++ b/packages/aws-cdk/lib/context-providers/availability-zones.ts @@ -8,7 +8,8 @@ import { debug } from '../logging'; * Plugin to retrieve the Availability Zones for the current account */ export class AZContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } public async getValue(args: AvailabilityZonesContextQuery) { const region = args.region; diff --git a/packages/aws-cdk/lib/context-providers/endpoint-service-availability-zones.ts b/packages/aws-cdk/lib/context-providers/endpoint-service-availability-zones.ts index 9fbc44193..448770559 100644 --- a/packages/aws-cdk/lib/context-providers/endpoint-service-availability-zones.ts +++ b/packages/aws-cdk/lib/context-providers/endpoint-service-availability-zones.ts @@ -7,7 +7,8 @@ import { debug } from '../logging'; * Plugin to retrieve the Availability Zones for an endpoint service */ export class EndpointServiceAZContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } public async getValue(args: EndpointServiceAvailabilityZonesContextQuery) { const region = args.region; diff --git a/packages/aws-cdk/lib/context-providers/hosted-zones.ts b/packages/aws-cdk/lib/context-providers/hosted-zones.ts index c3c1cc923..fdbaf7220 100644 --- a/packages/aws-cdk/lib/context-providers/hosted-zones.ts +++ b/packages/aws-cdk/lib/context-providers/hosted-zones.ts @@ -7,7 +7,8 @@ import { debug } from '../logging'; import { ContextProviderError } from '../toolkit/error'; export class HostedZoneContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } public async getValue(args: HostedZoneContextQuery): Promise { const account = args.account; diff --git a/packages/aws-cdk/lib/context-providers/keys.ts b/packages/aws-cdk/lib/context-providers/keys.ts index ed56e3684..a6decc74f 100644 --- a/packages/aws-cdk/lib/context-providers/keys.ts +++ b/packages/aws-cdk/lib/context-providers/keys.ts @@ -8,7 +8,8 @@ import { debug } from '../logging'; import { ContextProviderError } from '../toolkit/error'; export class KeyContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } public async getValue(args: KeyContextQuery) { const kms = (await initContextProviderSdk(this.aws, args)).kms(); diff --git a/packages/aws-cdk/lib/context-providers/load-balancers.ts b/packages/aws-cdk/lib/context-providers/load-balancers.ts index 1d9faccec..04499b63b 100644 --- a/packages/aws-cdk/lib/context-providers/load-balancers.ts +++ b/packages/aws-cdk/lib/context-providers/load-balancers.ts @@ -14,7 +14,8 @@ import { ContextProviderError } from '../toolkit/error'; * Provides load balancer context information. */ export class LoadBalancerContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } async getValue(query: LoadBalancerContextQuery): Promise { if (!query.loadBalancerArn && !query.loadBalancerTags) { @@ -41,7 +42,8 @@ export class LoadBalancerContextProviderPlugin implements ContextProviderPlugin * Provides load balancer listener context information */ export class LoadBalancerListenerContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } async getValue(query: LoadBalancerListenerContextQuery): Promise { if (!query.listenerArn && !query.loadBalancerArn && !query.loadBalancerTags) { @@ -80,7 +82,8 @@ class LoadBalancerProvider { private readonly client: IElasticLoadBalancingV2Client, private readonly filter: LoadBalancerListenerContextQuery, private readonly listener?: Listener, - ) {} + ) { + } public async getLoadBalancer(): Promise { const loadBalancers = await this.getLoadBalancers(); diff --git a/packages/aws-cdk/lib/context-providers/security-groups.ts b/packages/aws-cdk/lib/context-providers/security-groups.ts index 712dae114..451a3e21a 100644 --- a/packages/aws-cdk/lib/context-providers/security-groups.ts +++ b/packages/aws-cdk/lib/context-providers/security-groups.ts @@ -6,7 +6,8 @@ import type { ContextProviderPlugin } from '../api/plugin'; import { ContextProviderError } from '../toolkit/error'; export class SecurityGroupContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } async getValue(args: SecurityGroupContextQuery): Promise { if (args.securityGroupId && args.securityGroupName) { diff --git a/packages/aws-cdk/lib/context-providers/ssm-parameters.ts b/packages/aws-cdk/lib/context-providers/ssm-parameters.ts index 2092cecce..f7ac0a204 100644 --- a/packages/aws-cdk/lib/context-providers/ssm-parameters.ts +++ b/packages/aws-cdk/lib/context-providers/ssm-parameters.ts @@ -9,7 +9,8 @@ import { ContextProviderError } from '../toolkit/error'; * Plugin to read arbitrary SSM parameter names */ export class SSMContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } public async getValue(args: SSMParameterContextQuery) { const region = args.region; diff --git a/packages/aws-cdk/lib/context-providers/vpcs.ts b/packages/aws-cdk/lib/context-providers/vpcs.ts index f889813de..4f434f782 100644 --- a/packages/aws-cdk/lib/context-providers/vpcs.ts +++ b/packages/aws-cdk/lib/context-providers/vpcs.ts @@ -7,7 +7,8 @@ import { ContextProviderPlugin } from '../api/plugin'; import { debug } from '../logging'; import { ContextProviderError } from '../toolkit/error'; export class VpcNetworkContextProviderPlugin implements ContextProviderPlugin { - constructor(private readonly aws: SdkProvider) {} + constructor(private readonly aws: SdkProvider) { + } public async getValue(args: VpcContextQuery) { const ec2 = (await initContextProviderSdk(this.aws, args)).ec2(); diff --git a/packages/aws-cdk/lib/diff.ts b/packages/aws-cdk/lib/diff.ts index 289c183b7..3e8c7b192 100644 --- a/packages/aws-cdk/lib/diff.ts +++ b/packages/aws-cdk/lib/diff.ts @@ -185,18 +185,30 @@ function obscureDiff(diff: TemplateDiff) { if (diff.unknown) { // see https://github.com/aws/aws-cdk/issues/17942 diff.unknown = diff.unknown.filter(change => { - if (!change) { return true; } - if (change.newValue?.CheckBootstrapVersion) { return false; } - if (change.oldValue?.CheckBootstrapVersion) { return false; } + if (!change) { + return true; + } + if (change.newValue?.CheckBootstrapVersion) { + return false; + } + if (change.oldValue?.CheckBootstrapVersion) { + return false; + } return true; }); } if (diff.resources) { diff.resources = diff.resources.filter(change => { - if (!change) { return true; } - if (change.newResourceType === 'AWS::CDK::Metadata') { return false; } - if (change.oldResourceType === 'AWS::CDK::Metadata') { return false; } + if (!change) { + return true; + } + if (change.newResourceType === 'AWS::CDK::Metadata') { + return false; + } + if (change.oldResourceType === 'AWS::CDK::Metadata') { + return false; + } return true; }); } diff --git a/packages/aws-cdk/lib/notices.ts b/packages/aws-cdk/lib/notices.ts index 281da9281..3939ae5c6 100644 --- a/packages/aws-cdk/lib/notices.ts +++ b/packages/aws-cdk/lib/notices.ts @@ -136,7 +136,9 @@ export class NoticesFilter { return [new FilteredNotice(notice)]; function compareNames(pattern: string, target: string | undefined): boolean { - if (target == null) { return false; } + if (target == null) { + return false; + } return pattern.endsWith('.') ? target.startsWith(pattern) : pattern === target; } @@ -344,7 +346,8 @@ export interface Notice { export class FilteredNotice { private readonly dynamicValues: { [key: string]: string } = {}; - public constructor(public readonly notice: Notice) {} + public constructor(public readonly notice: Notice) { + } public addDynamicValue(key: string, value: string) { this.dynamicValues[`{resolve:${key}}`] = value; diff --git a/packages/aws-cdk/lib/util/directories.ts b/packages/aws-cdk/lib/util/directories.ts index f020cafce..db02138ba 100644 --- a/packages/aws-cdk/lib/util/directories.ts +++ b/packages/aws-cdk/lib/util/directories.ts @@ -25,7 +25,8 @@ export function cdkHomeDir() { userInfoHome = undefined; } home = path.join((userInfoHome ?? os.homedir()).trim(), '.cdk'); - } catch {} + } catch { + } return process.env.CDK_HOME ? path.resolve(process.env.CDK_HOME) : home || fs.mkdtempSync(path.join(tmpDir, '.cdk')).trim(); diff --git a/packages/aws-cdk/lib/util/objects.ts b/packages/aws-cdk/lib/util/objects.ts index 5f7cc5e33..26c9513c3 100644 --- a/packages/aws-cdk/lib/util/objects.ts +++ b/packages/aws-cdk/lib/util/objects.ts @@ -20,8 +20,12 @@ export function applyDefaults(hash: any, defaults: any) { * Return whether the given parameter is an empty object or empty list. */ export function isEmpty(x: any) { - if (x == null) { return false; } - if (isArray(x)) { return x.length === 0; } + if (x == null) { + return false; + } + if (isArray(x)) { + return x.length === 0; + } return Object.keys(x).length === 0; } @@ -31,10 +35,18 @@ export function isEmpty(x: any) { * Does not support cycles. */ export function deepClone(x: any): any { - if (typeof x === 'undefined') { return undefined; } - if (x === null) { return null; } - if (isArray(x)) { return x.map(deepClone); } - if (isObject(x)) { return makeObject(mapObject(x, (k, v) => [k, deepClone(v)] as [string, any])); } + if (typeof x === 'undefined') { + return undefined; + } + if (x === null) { + return null; + } + if (isArray(x)) { + return x.map(deepClone); + } + if (isObject(x)) { + return makeObject(mapObject(x, (k, v) => [k, deepClone(v)] as [string, any])); + } return x; } @@ -90,7 +102,9 @@ export function deepSet(x: any, path: string[], value: any) { while (path.length > 1 && isObject(x)) { const key = path.shift()!; - if (!(key in x)) { x[key] = {}; } + if (!(key in x)) { + x[key] = {}; + } x = x[key]; } @@ -123,7 +137,9 @@ export function deepMerge(...objects: Array | undefined>) { const value = source[key]; if (isObject(value)) { - if (!isObject(target[key])) { target[key] = {}; } // Overwrite on purpose + if (!isObject(target[key])) { + target[key] = {}; + } // Overwrite on purpose mergeOne(target[key], value); } else if (typeof value !== 'undefined') { target[key] = value; @@ -133,7 +149,9 @@ export function deepMerge(...objects: Array | undefined>) { const others = objects.filter(x => x != null) as Array>; - if (others.length === 0) { return {}; } + if (others.length === 0) { + return {}; + } const into = others.splice(0, 1)[0]; others.forEach(other => mergeOne(into, other)); diff --git a/packages/aws-cdk/lib/util/parallel.ts b/packages/aws-cdk/lib/util/parallel.ts index 01aa0ba92..bea503a06 100644 --- a/packages/aws-cdk/lib/util/parallel.ts +++ b/packages/aws-cdk/lib/util/parallel.ts @@ -33,8 +33,12 @@ export async function parallelPromises(n: number, promises: Array<() => Promi function start(fn: () => Promise) { count += 1; fn() - .then((result) => { ret.push(result); }) - .catch((e) => { error = e; }) + .then((result) => { + ret.push(result); + }) + .catch((e) => { + error = e; + }) .finally(() => { count -= 1; tick(); diff --git a/packages/aws-cdk/lib/util/work-graph-builder.ts b/packages/aws-cdk/lib/util/work-graph-builder.ts index f9c9cc340..1c6888754 100644 --- a/packages/aws-cdk/lib/util/work-graph-builder.ts +++ b/packages/aws-cdk/lib/util/work-graph-builder.ts @@ -22,7 +22,9 @@ export class WorkGraphBuilder { }; private readonly graph = new WorkGraph(); - constructor(private readonly prebuildAssets: boolean, private readonly idPrefix = '') { } + constructor(private readonly prebuildAssets: boolean, private readonly idPrefix = '') { + + } private addStack(artifact: cxapi.CloudFormationStackArtifact) { this.graph.addNodes({ diff --git a/packages/aws-cdk/lib/util/work-graph.ts b/packages/aws-cdk/lib/util/work-graph.ts index 020889303..ad5d4065a 100644 --- a/packages/aws-cdk/lib/util/work-graph.ts +++ b/packages/aws-cdk/lib/util/work-graph.ts @@ -319,7 +319,9 @@ export class WorkGraph { const self = this; for (const nodeId of Object.keys(this.nodes)) { const cycle = recurse(nodeId, [nodeId]); - if (cycle) { return cycle; } + if (cycle) { + return cycle; + } } return undefined; @@ -335,7 +337,9 @@ export class WorkGraph { } const cycle = recurse(dep, [...path, dep]); - if (cycle) { return cycle; } + if (cycle) { + return cycle; + } } return undefined; diff --git a/packages/aws-cdk/lib/util/yaml-cfn.ts b/packages/aws-cdk/lib/util/yaml-cfn.ts index e46c8f8d6..9ee9c69f0 100644 --- a/packages/aws-cdk/lib/util/yaml-cfn.ts +++ b/packages/aws-cdk/lib/util/yaml-cfn.ts @@ -31,7 +31,9 @@ export function deserialize(str: string): any { function makeTagForCfnIntrinsic(intrinsicName: string, addFnPrefix: boolean): yaml_types.Schema.CustomTag { return { - identify(value: any) { return typeof value === 'string'; }, + identify(value: any) { + return typeof value === 'string'; + }, tag: `!${intrinsicName}`, resolve: (_doc: yaml.Document, cstNode: yaml_cst.CST.Node) => { const ret: any = {}; diff --git a/packages/cdk-assets/.eslintrc.json b/packages/cdk-assets/.eslintrc.json index 329f4c360..7b0dd17bb 100644 --- a/packages/cdk-assets/.eslintrc.json +++ b/packages/cdk-assets/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/packages/cdk-assets/lib/aws-types.ts b/packages/cdk-assets/lib/aws-types.ts index 8ec7a4982..aa82723bb 100644 --- a/packages/cdk-assets/lib/aws-types.ts +++ b/packages/cdk-assets/lib/aws-types.ts @@ -137,7 +137,8 @@ export interface GetBucketEncryptionOutput { export interface GetBucketEncryptionCommandOutput extends GetBucketEncryptionOutput, - MetadataBearer {} + MetadataBearer { +} export interface GetBucketLocationCommandInput { /** @@ -200,7 +201,8 @@ export interface GetBucketLocationOutput { LocationConstraint?: BucketLocationConstraint; } -export interface GetBucketLocationCommandOutput extends GetBucketLocationOutput, MetadataBearer {} +export interface GetBucketLocationCommandOutput extends GetBucketLocationOutput, MetadataBearer { +} export const EncodingType = { url: 'url', @@ -663,7 +665,8 @@ export interface ListObjectsV2Output { RequestCharged?: RequestCharged; } -export interface ListObjectsV2CommandOutput extends ListObjectsV2Output, MetadataBearer {} +export interface ListObjectsV2CommandOutput extends ListObjectsV2Output, MetadataBearer { +} export const ObjectCannedACL = { authenticated_read: 'authenticated-read', @@ -1271,7 +1274,8 @@ export interface CompleteMultipartUploadOutput { export interface CompleteMultipartUploadCommandOutput extends CompleteMultipartUploadOutput, - MetadataBearer {} + MetadataBearer { +} export interface ImageIdentifier { /** @@ -1343,9 +1347,11 @@ export interface DescribeImagesRequest { filter?: DescribeImagesFilter; } -export interface DescribeImagesCommandInput extends DescribeImagesRequest {} +export interface DescribeImagesCommandInput extends DescribeImagesRequest { +} -export interface DescribeImagesCommandOutput extends DescribeImagesResponse, MetadataBearer {} +export interface DescribeImagesCommandOutput extends DescribeImagesResponse, MetadataBearer { +} export const ScanStatus = { ACTIVE: 'ACTIVE', @@ -1519,7 +1525,8 @@ export interface DescribeRepositoriesRequest { maxResults?: number; } -export interface DescribeRepositoriesCommandInput extends DescribeRepositoriesRequest {} +export interface DescribeRepositoriesCommandInput extends DescribeRepositoriesRequest { +} export const ImageTagMutability = { IMMUTABLE: 'IMMUTABLE', @@ -1642,7 +1649,8 @@ export interface DescribeRepositoriesResponse { export interface DescribeRepositoriesCommandOutput extends DescribeRepositoriesResponse, - MetadataBearer {} + MetadataBearer { +} export interface GetAuthorizationTokenRequest { /** @@ -1654,7 +1662,8 @@ export interface GetAuthorizationTokenRequest { registryIds?: string[]; } -export interface GetAuthorizationTokenCommandInput extends GetAuthorizationTokenRequest {} +export interface GetAuthorizationTokenCommandInput extends GetAuthorizationTokenRequest { +} export interface AuthorizationData { /** @@ -1688,7 +1697,8 @@ export interface GetAuthorizationTokenResponse { export interface GetAuthorizationTokenCommandOutput extends GetAuthorizationTokenResponse, - MetadataBearer {} + MetadataBearer { +} export interface GetSecretValueRequest { /** @@ -1716,7 +1726,8 @@ export interface GetSecretValueRequest { VersionStage?: string; } -export interface GetSecretValueCommandInput extends GetSecretValueRequest {} +export interface GetSecretValueCommandInput extends GetSecretValueRequest { +} export interface GetSecretValueResponse { /** @@ -1761,4 +1772,5 @@ export interface GetSecretValueResponse { CreatedDate?: Date; } -export interface GetSecretValueCommandOutput extends GetSecretValueResponse, MetadataBearer {} +export interface GetSecretValueCommandOutput extends GetSecretValueResponse, MetadataBearer { +} diff --git a/packages/cdk-assets/lib/private/docker-credentials.ts b/packages/cdk-assets/lib/private/docker-credentials.ts index 5a1883d03..bca4383f5 100644 --- a/packages/cdk-assets/lib/private/docker-credentials.ts +++ b/packages/cdk-assets/lib/private/docker-credentials.ts @@ -42,7 +42,8 @@ export function cdkCredentialsConfig(): DockerCredentialsConfig | undefined { _cdkCredentials = JSON.parse( fs.readFileSync(cdkCredentialsConfigFile(), { encoding: 'utf-8' }), ) as DockerCredentialsConfig; - } catch {} + } catch { + } } return _cdkCredentials; } diff --git a/packages/cdk-assets/lib/private/docker.ts b/packages/cdk-assets/lib/private/docker.ts index 0da1f7533..ebc45dd1a 100644 --- a/packages/cdk-assets/lib/private/docker.ts +++ b/packages/cdk-assets/lib/private/docker.ts @@ -58,7 +58,8 @@ export class Docker { constructor( private readonly eventEmitter: EventEmitter, private readonly subprocessOutputDestination: SubprocessOutputDestination, - ) {} + ) { + } /** * Whether an image with the given tag exists diff --git a/packages/cdk-assets/lib/private/handlers/container-images.ts b/packages/cdk-assets/lib/private/handlers/container-images.ts index c10e8ad7e..f50640066 100644 --- a/packages/cdk-assets/lib/private/handlers/container-images.ts +++ b/packages/cdk-assets/lib/private/handlers/container-images.ts @@ -24,7 +24,8 @@ export class ContainerImageAssetHandler implements IAssetHandler { private readonly asset: DockerImageManifestEntry, private readonly host: IHandlerHost, private readonly options: IHandlerOptions, - ) {} + ) { + } public async build(): Promise { const initOnce = await this.initOnce(); @@ -159,7 +160,8 @@ class ContainerImageBuilder { private readonly workDir: string, private readonly asset: DockerImageManifestEntry, private readonly host: IHandlerHost, - ) {} + ) { + } async build(): Promise { return this.asset.source.executable diff --git a/packages/cdk-assets/lib/private/handlers/files.ts b/packages/cdk-assets/lib/private/handlers/files.ts index e7c6d0432..6c41e3655 100644 --- a/packages/cdk-assets/lib/private/handlers/files.ts +++ b/packages/cdk-assets/lib/private/handlers/files.ts @@ -31,7 +31,8 @@ export class FileAssetHandler implements IAssetHandler { this.fileCacheRoot = path.join(workDir, '.cache'); } - public async build(): Promise {} + public async build(): Promise { + } public async isPublished(): Promise { const destination = await replaceAwsPlaceholders(this.asset.destination, this.host.aws); @@ -299,7 +300,8 @@ class BucketInformation { private readonly ownerships = new Map(); private readonly encryptions = new Map(); - private constructor() {} + private constructor() { + } public async bucketOwnership( s3: IS3Client, diff --git a/packages/cdk-assets/test/fake-listener.ts b/packages/cdk-assets/test/fake-listener.ts index 1b0268534..d5f4b55c9 100644 --- a/packages/cdk-assets/test/fake-listener.ts +++ b/packages/cdk-assets/test/fake-listener.ts @@ -4,7 +4,8 @@ export class FakeListener implements IPublishProgressListener { public readonly types = new Array(); public readonly messages = new Array(); - constructor(private readonly doAbort = false) {} + constructor(private readonly doAbort = false) { + } public onPublishEvent(_type: EventType, event: IPublishProgress): void { this.messages.push(event.message); diff --git a/packages/cdk-assets/test/logging.test.ts b/packages/cdk-assets/test/logging.test.ts index da257c5a4..a8b7b580e 100644 --- a/packages/cdk-assets/test/logging.test.ts +++ b/packages/cdk-assets/test/logging.test.ts @@ -12,7 +12,8 @@ describe('Logging System', () => { const originalConsoleError = console.error; beforeEach(() => { - consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => { + }); }); afterEach(() => { diff --git a/packages/cdk-assets/test/private/docker.test.ts b/packages/cdk-assets/test/private/docker.test.ts index 58cc8d109..5caaa2a84 100644 --- a/packages/cdk-assets/test/private/docker.test.ts +++ b/packages/cdk-assets/test/private/docker.test.ts @@ -20,7 +20,8 @@ afterEach(() => { }); beforeEach(() => { - docker = new Docker(() => {}, 'ignore'); + docker = new Docker(() => { + }, 'ignore'); }); describe('Docker', () => { diff --git a/packages/cdk-assets/test/shell-logging.test.ts b/packages/cdk-assets/test/shell-logging.test.ts index f48616de4..716fb6676 100644 --- a/packages/cdk-assets/test/shell-logging.test.ts +++ b/packages/cdk-assets/test/shell-logging.test.ts @@ -18,7 +18,8 @@ describe('shell', () => { progressListener.onPublishEvent(eventType, { message, percentComplete: 0, - abort: () => {}, + abort: () => { + }, }); }; mockfs({ diff --git a/packages/cdk/.eslintrc.json b/packages/cdk/.eslintrc.json index d65ae59f9..05af8db46 100644 --- a/packages/cdk/.eslintrc.json +++ b/packages/cdk/.eslintrc.json @@ -165,6 +165,10 @@ "@stylistic/no-extra-semi": [ "error" ], + "@stylistic/curly-newline": [ + "error", + "always" + ], "comma-spacing": [ "error", { diff --git a/projenrc/eslint.ts b/projenrc/eslint.ts index 5a4081b3d..b5ee27b18 100644 --- a/projenrc/eslint.ts +++ b/projenrc/eslint.ts @@ -17,6 +17,7 @@ export const ESLINT_RULES = { '@stylistic/member-delimiter-style': ['error'], // require semicolon delimiter '@stylistic/comma-dangle': ['error', 'always-multiline'], // ensures clean diffs, see https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8 '@stylistic/no-extra-semi': ['error'], // no extra semicolons + '@stylistic/curly-newline': ['error', 'always'], // improves the diff, COE action item 'comma-spacing': ['error', { before: false, after: true }], // space after, no space before 'no-multi-spaces': ['error', { ignoreEOLComments: false }], // no multi spaces 'array-bracket-spacing': ['error', 'never'], // [1, 2, 3]