diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.graphql.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.graphql.ts index 9c9e4a4c501e7..754e3404ffe19 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.graphql.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.graphql.ts @@ -178,12 +178,12 @@ customerDS.createResolver('MutationRemoveCustomer', { responseMappingTemplate: MappingTemplate.dynamoDbResultItem(), }); -const ops = [ - { suffix: 'Eq', op: KeyCondition.eq }, - { suffix: 'Lt', op: KeyCondition.lt }, - { suffix: 'Le', op: KeyCondition.le }, - { suffix: 'Gt', op: KeyCondition.gt }, - { suffix: 'Ge', op: KeyCondition.ge }, +const ops: Array<{ suffix: string; op: (x: string, y: string) => KeyCondition }> = [ + { suffix: 'Eq', op: (x, y) => KeyCondition.eq(x, y) }, + { suffix: 'Lt', op: (x, y) => KeyCondition.lt(x, y) }, + { suffix: 'Le', op: (x, y) => KeyCondition.le(x, y) }, + { suffix: 'Gt', op: (x, y) => KeyCondition.gt(x, y) }, + { suffix: 'Ge', op: (x, y) => KeyCondition.ge(x, y) }, ]; for (const { suffix, op } of ops) { orderDS.createResolver(`QueryGetCustomerOrders${suffix}`, { diff --git a/packages/@aws-cdk/aws-eks-v2-alpha/lib/managed-nodegroup.ts b/packages/@aws-cdk/aws-eks-v2-alpha/lib/managed-nodegroup.ts index 9da3b7ee6b252..6003b52942a93 100644 --- a/packages/@aws-cdk/aws-eks-v2-alpha/lib/managed-nodegroup.ts +++ b/packages/@aws-cdk/aws-eks-v2-alpha/lib/managed-nodegroup.ts @@ -633,7 +633,7 @@ function getPossibleAmiTypes(instanceTypes: InstanceType[]): NodegroupAmiType[] const architectures: Set = new Set(instanceTypes.map(typeToArch)); if (architectures.size === 0) { // protective code, the current implementation will never result in this. - throw new Error(`Cannot determine any ami type compatible with instance types: ${instanceTypes.map(i => i.toString).join(', ')}`); + throw new Error(`Cannot determine any ami type compatible with instance types: ${instanceTypes.map(i => i.toString()).join(', ')}`); } if (architectures.size > 1) { diff --git a/packages/@aws-cdk/aws-glue-alpha/lib/triggers/workflow.ts b/packages/@aws-cdk/aws-glue-alpha/lib/triggers/workflow.ts index 422332a464f55..a10c3c1d9eaf6 100644 --- a/packages/@aws-cdk/aws-glue-alpha/lib/triggers/workflow.ts +++ b/packages/@aws-cdk/aws-glue-alpha/lib/triggers/workflow.ts @@ -137,7 +137,7 @@ export abstract class WorkflowBase extends cdk.Resource implements IWorkflow { ...options, workflowName: this.workflowName, type: 'ON_DEMAND', - actions: options.actions?.map(this.renderAction), + actions: options.actions?.map(this.renderAction.bind(this)), description: options.description || undefined, }); @@ -162,7 +162,7 @@ export abstract class WorkflowBase extends cdk.Resource implements IWorkflow { ...options, workflowName: this.workflowName, type: 'SCHEDULED', - actions: options.actions?.map(this.renderAction), + actions: options.actions?.map(this.renderAction.bind(this)), schedule: dailySchedule.expressionString, startOnCreation: options.startOnCreation ?? false, }); @@ -189,7 +189,7 @@ export abstract class WorkflowBase extends cdk.Resource implements IWorkflow { ...options, workflowName: this.workflowName, type: 'SCHEDULED', - actions: options.actions?.map(this.renderAction), + actions: options.actions?.map(this.renderAction.bind(this)), schedule: weeklySchedule.expressionString, startOnCreation: options.startOnCreation ?? false, }); @@ -210,7 +210,7 @@ export abstract class WorkflowBase extends cdk.Resource implements IWorkflow { ...options, workflowName: this.workflowName, type: 'SCHEDULED', - actions: options.actions?.map(this.renderAction), + actions: options.actions?.map(this.renderAction.bind(this)), schedule: options.schedule.expressionString, startOnCreation: options.startOnCreation ?? false, }); @@ -231,7 +231,7 @@ export abstract class WorkflowBase extends cdk.Resource implements IWorkflow { ...options, workflowName: this.workflowName, type: 'EVENT', - actions: options.actions?.map(this.renderAction), + actions: options.actions?.map(this.renderAction.bind(this)), eventBatchingCondition: this.renderEventBatchingCondition(options), description: options.description ?? undefined, }); @@ -253,7 +253,7 @@ export abstract class WorkflowBase extends cdk.Resource implements IWorkflow { ...options, workflowName: this.workflowName, type: 'CONDITIONAL', - actions: options.actions?.map(this.renderAction), + actions: options.actions?.map(this.renderAction.bind(this)), predicate: this.renderPredicate(options), eventBatchingCondition: this.renderEventBatchingCondition(options), description: options.description ?? undefined, diff --git a/packages/@aws-cdk/aws-iot-alpha/test/topic-rule.test.ts b/packages/@aws-cdk/aws-iot-alpha/test/topic-rule.test.ts index aa34582618ca4..8220d5ffd0620 100644 --- a/packages/@aws-cdk/aws-iot-alpha/test/topic-rule.test.ts +++ b/packages/@aws-cdk/aws-iot-alpha/test/topic-rule.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import { Template } from 'aws-cdk-lib/assertions'; import * as cdk from 'aws-cdk-lib'; import * as iot from '../lib'; diff --git a/packages/@aws-cdk/aws-kinesisanalytics-flink-alpha/test/application.test.ts b/packages/@aws-cdk/aws-kinesisanalytics-flink-alpha/test/application.test.ts index 3f4d4a4224d0a..14ec7dce49dc7 100644 --- a/packages/@aws-cdk/aws-kinesisanalytics-flink-alpha/test/application.test.ts +++ b/packages/@aws-cdk/aws-kinesisanalytics-flink-alpha/test/application.test.ts @@ -857,31 +857,31 @@ describe('Application', () => { // Table driven test with: [method, metricName, default statistic] const assertions: Array<[(options?: cloudwatch.MetricOptions) => cloudwatch.Metric, string, string]> = [ - [flinkApp.metricKpus, 'KPUs', 'Average'], - [flinkApp.metricDowntime, 'downtime', 'Average'], - [flinkApp.metricUptime, 'uptime', 'Average'], - [flinkApp.metricFullRestarts, 'fullRestarts', 'Sum'], - [flinkApp.metricNumberOfFailedCheckpoints, 'numberOfFailedCheckpoints', 'Sum'], - [flinkApp.metricLastCheckpointDuration, 'lastCheckpointDuration', 'Maximum'], - [flinkApp.metricLastCheckpointSize, 'lastCheckpointSize', 'Maximum'], - [flinkApp.metricCpuUtilization, 'cpuUtilization', 'Average'], - [flinkApp.metricHeapMemoryUtilization, 'heapMemoryUtilization', 'Average'], - [flinkApp.metricOldGenerationGCTime, 'oldGenerationGCTime', 'Sum'], - [flinkApp.metricOldGenerationGCCount, 'oldGenerationGCCount', 'Sum'], - [flinkApp.metricThreadsCount, 'threadsCount', 'Average'], - [flinkApp.metricNumRecordsIn, 'numRecordsIn', 'Average'], - [flinkApp.metricNumRecordsInPerSecond, 'numRecordsInPerSecond', 'Average'], - [flinkApp.metricNumRecordsOut, 'numRecordsOut', 'Average'], - [flinkApp.metricNumRecordsOutPerSecond, 'numRecordsOutPerSecond', 'Average'], - [flinkApp.metricNumLateRecordsDropped, 'numLateRecordsDropped', 'Sum'], - [flinkApp.metricCurrentInputWatermark, 'currentInputWatermark', 'Maximum'], - [flinkApp.metricCurrentOutputWatermark, 'currentOutputWatermark', 'Maximum'], - [flinkApp.metricManagedMemoryUsed, 'managedMemoryUsed', 'Average'], - [flinkApp.metricManagedMemoryTotal, 'managedMemoryTotal', 'Average'], - [flinkApp.metricManagedMemoryUtilization, 'managedMemoryUtilization', 'Average'], - [flinkApp.metricIdleTimeMsPerSecond, 'idleTimeMsPerSecond', 'Average'], - [flinkApp.metricBackPressuredTimeMsPerSecond, 'backPressuredTimeMsPerSecond', 'Average'], - [flinkApp.metricBusyTimePerMsPerSecond, 'busyTimePerMsPerSecond', 'Average'], + [x => flinkApp.metricKpus(x), 'KPUs', 'Average'], + [x => flinkApp.metricDowntime(x), 'downtime', 'Average'], + [x => flinkApp.metricUptime(x), 'uptime', 'Average'], + [x => flinkApp.metricFullRestarts(x), 'fullRestarts', 'Sum'], + [x => flinkApp.metricNumberOfFailedCheckpoints(x), 'numberOfFailedCheckpoints', 'Sum'], + [x => flinkApp.metricLastCheckpointDuration(x), 'lastCheckpointDuration', 'Maximum'], + [x => flinkApp.metricLastCheckpointSize(x), 'lastCheckpointSize', 'Maximum'], + [x => flinkApp.metricCpuUtilization(x), 'cpuUtilization', 'Average'], + [x => flinkApp.metricHeapMemoryUtilization(x), 'heapMemoryUtilization', 'Average'], + [x => flinkApp.metricOldGenerationGCTime(x), 'oldGenerationGCTime', 'Sum'], + [x => flinkApp.metricOldGenerationGCCount(x), 'oldGenerationGCCount', 'Sum'], + [x => flinkApp.metricThreadsCount(x), 'threadsCount', 'Average'], + [x => flinkApp.metricNumRecordsIn(x), 'numRecordsIn', 'Average'], + [x => flinkApp.metricNumRecordsInPerSecond(x), 'numRecordsInPerSecond', 'Average'], + [x => flinkApp.metricNumRecordsOut(x), 'numRecordsOut', 'Average'], + [x => flinkApp.metricNumRecordsOutPerSecond(x), 'numRecordsOutPerSecond', 'Average'], + [x => flinkApp.metricNumLateRecordsDropped(x), 'numLateRecordsDropped', 'Sum'], + [x => flinkApp.metricCurrentInputWatermark(x), 'currentInputWatermark', 'Maximum'], + [x => flinkApp.metricCurrentOutputWatermark(x), 'currentOutputWatermark', 'Maximum'], + [x => flinkApp.metricManagedMemoryUsed(x), 'managedMemoryUsed', 'Average'], + [x => flinkApp.metricManagedMemoryTotal(x), 'managedMemoryTotal', 'Average'], + [x => flinkApp.metricManagedMemoryUtilization(x), 'managedMemoryUtilization', 'Average'], + [x => flinkApp.metricIdleTimeMsPerSecond(x), 'idleTimeMsPerSecond', 'Average'], + [x => flinkApp.metricBackPressuredTimeMsPerSecond(x), 'backPressuredTimeMsPerSecond', 'Average'], + [x => flinkApp.metricBusyTimePerMsPerSecond(x), 'busyTimePerMsPerSecond', 'Average'], ]; assertions.forEach(([method, metricName, defaultStatistic]) => { diff --git a/packages/@aws-cdk/aws-lambda-go-alpha/test/bundling.test.ts b/packages/@aws-cdk/aws-lambda-go-alpha/test/bundling.test.ts index b8f2f7a85ff13..b30d32b7119a8 100644 --- a/packages/@aws-cdk/aws-lambda-go-alpha/test/bundling.test.ts +++ b/packages/@aws-cdk/aws-lambda-go-alpha/test/bundling.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as child_process from 'child_process'; import * as os from 'os'; import * as path from 'path'; diff --git a/packages/@aws-cdk/aws-lambda-go-alpha/test/function.test.ts b/packages/@aws-cdk/aws-lambda-go-alpha/test/function.test.ts index c1989bbc4acbb..355b04aebb55f 100644 --- a/packages/@aws-cdk/aws-lambda-go-alpha/test/function.test.ts +++ b/packages/@aws-cdk/aws-lambda-go-alpha/test/function.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as path from 'path'; import { Template } from 'aws-cdk-lib/assertions'; import { Runtime } from 'aws-cdk-lib/aws-lambda'; diff --git a/packages/@aws-cdk/aws-lambda-python-alpha/test/bundling.test.ts b/packages/@aws-cdk/aws-lambda-python-alpha/test/bundling.test.ts index 9a108cda638e5..0897fc613e4dc 100644 --- a/packages/@aws-cdk/aws-lambda-python-alpha/test/bundling.test.ts +++ b/packages/@aws-cdk/aws-lambda-python-alpha/test/bundling.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as fs from 'fs'; import * as path from 'path'; import { Architecture, Code, Runtime } from 'aws-cdk-lib/aws-lambda'; diff --git a/packages/@aws-cdk/aws-lambda-python-alpha/test/function.test.ts b/packages/@aws-cdk/aws-lambda-python-alpha/test/function.test.ts index cb4f1db8c3bcd..e061ec123b67f 100644 --- a/packages/@aws-cdk/aws-lambda-python-alpha/test/function.test.ts +++ b/packages/@aws-cdk/aws-lambda-python-alpha/test/function.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as path from 'path'; import { Template } from 'aws-cdk-lib/assertions'; import { Code, Runtime, Architecture } from 'aws-cdk-lib/aws-lambda'; diff --git a/packages/@aws-cdk/aws-lambda-python-alpha/test/layer.test.ts b/packages/@aws-cdk/aws-lambda-python-alpha/test/layer.test.ts index 548b9579a8b10..779a7dff264b9 100644 --- a/packages/@aws-cdk/aws-lambda-python-alpha/test/layer.test.ts +++ b/packages/@aws-cdk/aws-lambda-python-alpha/test/layer.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as path from 'path'; import { Runtime } from 'aws-cdk-lib/aws-lambda'; import { DockerImage, Stack } from 'aws-cdk-lib'; diff --git a/packages/@aws-cdk/aws-pipes-alpha/test/pipe.test.ts b/packages/@aws-cdk/aws-pipes-alpha/test/pipe.test.ts index 08ead1d7add00..cd556467d1d51 100644 --- a/packages/@aws-cdk/aws-pipes-alpha/test/pipe.test.ts +++ b/packages/@aws-cdk/aws-pipes-alpha/test/pipe.test.ts @@ -469,6 +469,7 @@ describe('Pipe', () => { expect(pipe.pipeRole).toBe(role); expect(source.grantRead).toHaveBeenCalledWith(role); expect(target.grantPush).toHaveBeenCalledWith(role); + // eslint-disable-next-line @typescript-eslint/unbound-method expect(enrichment.grantInvoke).toHaveBeenCalledWith(role); }); diff --git a/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts b/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts index 8c53833710837..ed1405a3c65d3 100644 --- a/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts +++ b/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts @@ -1,4 +1,3 @@ -import * as child_process from 'child_process'; import * as path from 'path'; import * as fs from 'fs-extra'; import { snapshotTestWorker } from '../../lib/workers/extract'; @@ -33,7 +32,6 @@ describe('Snapshot tests', () => { test('has snapshot', () => { // WHEN - jest.spyOn(child_process, 'spawnSync').mockResolvedValue; const test = { fileName: path.join(directory, 'xxxxx.test-with-snapshot.js'), discoveryRoot: directory, @@ -46,7 +44,6 @@ describe('Snapshot tests', () => { test('failed snapshot', () => { // WHEN - jest.spyOn(child_process, 'spawnSync').mockRejectedValue; const test = { fileName: path.join(directory, 'xxxxx.test-with-snapshot-assets-diff.js'), discoveryRoot: directory, diff --git a/packages/aws-cdk-lib/aws-backup/lib/plan.ts b/packages/aws-cdk-lib/aws-backup/lib/plan.ts index 4f87d0b7f7e42..98f96404a4240 100644 --- a/packages/aws-cdk-lib/aws-backup/lib/plan.ts +++ b/packages/aws-cdk-lib/aws-backup/lib/plan.ts @@ -200,7 +200,7 @@ export class BackupPlan extends Resource implements IBackupPlan { }); } - private planCopyActions(props: BackupPlanCopyActionProps): CfnBackupPlan.CopyActionResourceTypeProperty { + private planCopyActions(this: void, props: BackupPlanCopyActionProps): CfnBackupPlan.CopyActionResourceTypeProperty { return { destinationBackupVaultArn: props.destinationBackupVault.backupVaultArn, lifecycle: (props.deleteAfter || props.moveToColdStorageAfter) && { diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/geo-restriction.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/geo-restriction.ts index 71c4692e960f2..3d3ad46cb2acf 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/geo-restriction.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/geo-restriction.ts @@ -11,7 +11,7 @@ export class GeoRestriction { * that you want to allow. Include one element for each country. * See ISO 3166-1-alpha-2 code on the *International Organization for Standardization* website */ - public static allowlist(...locations: string[]) { + public static allowlist(this: void, ...locations: string[]) { return new GeoRestriction('whitelist', GeoRestriction.validateLocations(locations)); } @@ -22,7 +22,7 @@ export class GeoRestriction { * that you want to deny. Include one element for each country. * See ISO 3166-1-alpha-2 code on the *International Organization for Standardization* website */ - public static denylist(...locations: string[]) { + public static denylist(this: void, ...locations: string[]) { return new GeoRestriction('blacklist', GeoRestriction.validateLocations(locations)); } diff --git a/packages/aws-cdk-lib/aws-config/lib/rule.ts b/packages/aws-cdk-lib/aws-config/lib/rule.ts index 58d10d0b9bd9f..5655fe44d9bb8 100644 --- a/packages/aws-cdk-lib/aws-config/lib/rule.ts +++ b/packages/aws-cdk-lib/aws-config/lib/rule.ts @@ -449,6 +449,7 @@ export class CustomRule extends RuleNew { } const hash = createHash('sha256') .update(JSON.stringify({ + /* eslint-disable-next-line @typescript-eslint/unbound-method *//* REMOVEME: this is a latent bug */ fnName: props.lambdaFunction.functionName.toString, accountId: Stack.of(this).resolve(this.env.account), region: Stack.of(this).resolve(this.env.region), diff --git a/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts b/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts index a31d6310f9916..582ccbbd6c7d6 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts @@ -655,42 +655,42 @@ export class InitPackage extends InitElement { /** * Install an RPM from an HTTP URL or a location on disk */ - public static rpm(location: string, options: LocationPackageOptions = {}): InitPackage { + public static rpm(this: void, location: string, options: LocationPackageOptions = {}): InitPackage { return new InitPackage('rpm', [location], options.key, options.serviceRestartHandles); } /** * Install a package using Yum */ - public static yum(packageName: string, options: NamedPackageOptions = {}): InitPackage { + public static yum(this: void, packageName: string, options: NamedPackageOptions = {}): InitPackage { return new InitPackage('yum', options.version ?? [], packageName, options.serviceRestartHandles); } /** * Install a package from RubyGems */ - public static rubyGem(gemName: string, options: NamedPackageOptions = {}): InitPackage { + public static rubyGem(this: void, gemName: string, options: NamedPackageOptions = {}): InitPackage { return new InitPackage('rubygems', options.version ?? [], gemName, options.serviceRestartHandles); } /** * Install a package from PyPI */ - public static python(packageName: string, options: NamedPackageOptions = {}): InitPackage { + public static python(this: void, packageName: string, options: NamedPackageOptions = {}): InitPackage { return new InitPackage('python', options.version ?? [], packageName, options.serviceRestartHandles); } /** * Install a package using APT */ - public static apt(packageName: string, options: NamedPackageOptions = {}): InitPackage { + public static apt(this: void, packageName: string, options: NamedPackageOptions = {}): InitPackage { return new InitPackage('apt', options.version ?? [], packageName, options.serviceRestartHandles); } /** * Install an MSI package from an HTTP URL or a location on disk */ - public static msi(location: string, options: LocationPackageOptions = {}): InitPackage { + public static msi(this: void, location: string, options: LocationPackageOptions = {}): InitPackage { // The MSI package version must be a string, not an array. return new class extends InitPackage { protected renderPackageVersions() { return location; } diff --git a/packages/aws-cdk-lib/aws-ec2/test/ip-addresses.test.ts b/packages/aws-cdk-lib/aws-ec2/test/ip-addresses.test.ts index 176a58d1256a6..66959367afc9a 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/ip-addresses.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/ip-addresses.test.ts @@ -12,12 +12,12 @@ describe('Cidr vpc allocation', () => { test('Default Cidr returns ipv4IpamPoolId as undefined', () => { const ipAddresses = IpAddresses.cidr('10.0.0.0/16'); - expect(ipAddresses.allocateVpcCidr().ipv4IpamPoolId).toBeUndefined; + expect(ipAddresses.allocateVpcCidr().ipv4IpamPoolId).toBeUndefined(); }); test('Default Cidr returns ipv4NetmaskLength as undefined', () => { const ipAddresses = IpAddresses.cidr('10.0.0.0/16'); - expect(ipAddresses.allocateVpcCidr().ipv4NetmaskLength).toBeUndefined; + expect(ipAddresses.allocateVpcCidr().ipv4NetmaskLength).toBeUndefined(); }); }); @@ -102,7 +102,7 @@ describe('AwsIpam vpc allocation', () => { test('AwsIpam returns cidrBlock as undefined', () => { const ipAddresses = IpAddresses.awsIpamAllocation(awsIpamProps); - expect(ipAddresses.allocateVpcCidr().cidrBlock).toBeUndefined; + expect(ipAddresses.allocateVpcCidr().cidrBlock).toBeUndefined(); }); test('AwsIpam returns the correct vpc ipv4IpamPoolId', () => { diff --git a/packages/aws-cdk-lib/aws-ec2/test/vpc.from-lookup.test.ts b/packages/aws-cdk-lib/aws-ec2/test/vpc.from-lookup.test.ts index 61017268f452c..f81c1f33f29b6 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/vpc.from-lookup.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/vpc.from-lookup.test.ts @@ -380,6 +380,7 @@ interface MockVpcContextResponse { function mockVpcContextProviderWith( response: MockVpcContextResponse, paramValidator?: (options: cxschema.VpcContextQuery) => void) { + // eslint-disable-next-line @typescript-eslint/unbound-method const previous = ContextProvider.getValue; ContextProvider.getValue = (_scope: Construct, options: GetContextValueOptions) => { // do some basic sanity checks diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/load-balanced-fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/load-balanced-fargate-service.test.ts index 47ea75005002a..a2103a64367d6 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/load-balanced-fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/load-balanced-fargate-service.test.ts @@ -710,7 +710,7 @@ describe('ApplicationLoadBalancedFargateService', () => { // THEN expect(() => { service.internalDesiredCount; - }).toBeTruthy; + }).toBeTruthy(); }); test('multiple capacity provider strategies are set', () => { diff --git a/packages/aws-cdk-lib/aws-ecs/test/cluster.test.ts b/packages/aws-cdk-lib/aws-ecs/test/cluster.test.ts index 766cc151825a9..ceaad7dfd62e5 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/cluster.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/cluster.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import { testDeprecated } from '@aws-cdk/cdk-build-tools'; import { Annotations, Match, Template } from '../../assertions'; import * as autoscaling from '../../aws-autoscaling'; diff --git a/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-task-definition.test.ts b/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-task-definition.test.ts index 4f8f4f264ed0d..ec3dd14fe145b 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-task-definition.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-task-definition.test.ts @@ -352,7 +352,7 @@ describe('fargate task definition', () => { // THEN expect(() => { taskDefinition.ephemeralStorageGiB; - }).toBeTruthy; + }).toBeTruthy(); }); test('runtime testing for windows container', () => { diff --git a/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts b/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts index e9d877c165be4..7204fd081e79e 100644 --- a/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts +++ b/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts @@ -646,7 +646,7 @@ function getPossibleAmiTypes(instanceTypes: InstanceType[]): NodegroupAmiType[] const architectures: Set = new Set(instanceTypes.map(typeToArch)); if (architectures.size === 0) { // protective code, the current implementation will never result in this. - throw new Error(`Cannot determine any ami type compatible with instance types: ${instanceTypes.map(i => i.toString).join(', ')}`); + throw new Error(`Cannot determine any ami type compatible with instance types: ${instanceTypes.map(i => i.toString()).join(', ')}`); } if (architectures.size > 1) { diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/listener-certificate.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/listener-certificate.ts index 9bee4dc7daf39..dbf7ade510bb0 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/listener-certificate.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/listener-certificate.ts @@ -17,14 +17,14 @@ export class ListenerCertificate implements IListenerCertificate { /** * Use an ACM certificate as a listener certificate */ - public static fromCertificateManager(acmCertificate: acm.ICertificate) { + public static fromCertificateManager(this: void, acmCertificate: acm.ICertificate) { return new ListenerCertificate(acmCertificate.certificateArn); } /** * Use any certificate, identified by its ARN, as a listener certificate */ - public static fromArn(certificateArn: string) { + public static fromArn(this: void, certificateArn: string) { return new ListenerCertificate(certificateArn); } diff --git a/packages/aws-cdk-lib/aws-iam/lib/principals.ts b/packages/aws-cdk-lib/aws-iam/lib/principals.ts index 746618be630cf..35fbb69fb76f2 100644 --- a/packages/aws-cdk-lib/aws-iam/lib/principals.ts +++ b/packages/aws-cdk-lib/aws-iam/lib/principals.ts @@ -92,14 +92,14 @@ export class ComparablePrincipal { /** * Whether or not the given principal is a comparable principal */ - public static isComparablePrincipal(x: IPrincipal): x is IComparablePrincipal { + public static isComparablePrincipal(this: void, x: IPrincipal): x is IComparablePrincipal { return 'dedupeString' in x; } /** * Return the dedupeString of the given principal, if available */ - public static dedupeStringFor(x: IPrincipal): string | undefined { + public static dedupeStringFor(this: void, x: IPrincipal): string | undefined { return ComparablePrincipal.isComparablePrincipal(x) ? x.dedupeString() : undefined; } } diff --git a/packages/aws-cdk-lib/aws-kinesis/lib/kinesis-fixed-canned-metrics.ts b/packages/aws-cdk-lib/aws-kinesis/lib/kinesis-fixed-canned-metrics.ts index c5c650d07e534..68e795291900c 100644 --- a/packages/aws-cdk-lib/aws-kinesis/lib/kinesis-fixed-canned-metrics.ts +++ b/packages/aws-cdk-lib/aws-kinesis/lib/kinesis-fixed-canned-metrics.ts @@ -9,7 +9,7 @@ import { KinesisMetrics as CannedMetrics } from './kinesis-canned-metrics.genera * Stream Metrics reference: https://docs.aws.amazon.com/streams/latest/dev/monitoring-with-cloudwatch.html */ export class KinesisMetrics { - public static getRecordsBytesAverage(dimensions: { StreamName: string }) { + public static getRecordsBytesAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'GetRecords.Bytes', @@ -17,7 +17,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static getRecordsSuccessAverage(dimensions: { StreamName: string }) { + public static getRecordsSuccessAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'GetRecords.Success', @@ -25,7 +25,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static getRecordsRecordsAverage(dimensions: { StreamName: string }) { + public static getRecordsRecordsAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'GetRecords.Records', @@ -33,7 +33,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static getRecordsLatencyAverage(dimensions: { StreamName: string }) { + public static getRecordsLatencyAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'GetRecords.Latency', @@ -41,7 +41,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static putRecordBytesAverage(dimensions: { StreamName: string }) { + public static putRecordBytesAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecord.Bytes', @@ -49,7 +49,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static putRecordLatencyAverage(dimensions: { StreamName: string }) { + public static putRecordLatencyAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecord.Latency', @@ -57,22 +57,22 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static getRecordsIteratorAgeMillisecondsMaximum(dimensions: { StreamName: string }) { + public static getRecordsIteratorAgeMillisecondsMaximum(this: void, dimensions: { StreamName: string }) { return CannedMetrics.getRecordsIteratorAgeMillisecondsMaximum(dimensions); } - public static putRecordSuccessAverage(dimensions: { StreamName: string }) { + public static putRecordSuccessAverage(this: void, dimensions: { StreamName: string }) { return { ...CannedMetrics.putRecordSuccessSum(dimensions), statistic: 'Average', }; } - public static putRecordsBytesAverage(dimensions: { StreamName: string }) { + public static putRecordsBytesAverage(this: void, dimensions: { StreamName: string }) { return { ...CannedMetrics.putRecordsBytesSum(dimensions), statistic: 'Average', }; } - public static putRecordsLatencyAverage(dimensions: { StreamName: string }) { + public static putRecordsLatencyAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecords.Latency', @@ -80,7 +80,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static putRecordsSuccessAverage(dimensions: { StreamName: string }) { + public static putRecordsSuccessAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecords.Success', @@ -88,7 +88,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static putRecordsTotalRecordsAverage(dimensions: { StreamName: string }) { + public static putRecordsTotalRecordsAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecords.TotalRecords', @@ -96,7 +96,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static putRecordsSuccessfulRecordsAverage(dimensions: { StreamName: string }) { + public static putRecordsSuccessfulRecordsAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecords.SuccessfulRecords', @@ -104,7 +104,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static putRecordsFailedRecordsAverage(dimensions: { StreamName: string }) { + public static putRecordsFailedRecordsAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecords.FailedRecords', @@ -112,7 +112,7 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static putRecordsThrottledRecordsAverage(dimensions: { StreamName: string }) { + public static putRecordsThrottledRecordsAverage(this: void, dimensions: { StreamName: string }) { return { namespace: 'AWS/Kinesis', metricName: 'PutRecords.ThrottledRecords', @@ -120,25 +120,25 @@ export class KinesisMetrics { statistic: 'Average', }; } - public static incomingBytesAverage(dimensions: { StreamName: string }) { + public static incomingBytesAverage(this: void, dimensions: { StreamName: string }) { return { ...CannedMetrics.incomingBytesSum(dimensions), statistic: 'Average', }; } - public static incomingRecordsAverage(dimensions: { StreamName: string }) { + public static incomingRecordsAverage(this: void, dimensions: { StreamName: string }) { return { ...CannedMetrics.incomingRecordsSum(dimensions), statistic: 'Average', }; } - public static readProvisionedThroughputExceededAverage(dimensions: { StreamName: string }) { + public static readProvisionedThroughputExceededAverage(this: void, dimensions: { StreamName: string }) { return { ...CannedMetrics.readProvisionedThroughputExceededSum(dimensions), statistic: 'Average', }; } - public static writeProvisionedThroughputExceededAverage(dimensions: { StreamName: string }) { + public static writeProvisionedThroughputExceededAverage(this: void, dimensions: { StreamName: string }) { return { ...CannedMetrics.writeProvisionedThroughputExceededSum(dimensions), statistic: 'Average', diff --git a/packages/aws-cdk-lib/aws-kinesis/lib/stream.ts b/packages/aws-cdk-lib/aws-kinesis/lib/stream.ts index 5f5a29f29f0b2..b17638f9dbc94 100644 --- a/packages/aws-cdk-lib/aws-kinesis/lib/stream.ts +++ b/packages/aws-cdk-lib/aws-kinesis/lib/stream.ts @@ -448,7 +448,7 @@ abstract class StreamBase extends Resource implements IStream { node: this.node, stack: this.stack, env: this.env, - applyRemovalPolicy: this.applyRemovalPolicy, + applyRemovalPolicy: x => this.applyRemovalPolicy(x), }, }); } diff --git a/packages/aws-cdk-lib/aws-kms/test/key.from-lookup.test.ts b/packages/aws-cdk-lib/aws-kms/test/key.from-lookup.test.ts index aadb45daf7f2a..7dc46cf8a0e11 100644 --- a/packages/aws-cdk-lib/aws-kms/test/key.from-lookup.test.ts +++ b/packages/aws-cdk-lib/aws-kms/test/key.from-lookup.test.ts @@ -105,6 +105,7 @@ interface MockKeyContextResponse { function mockKeyContextProviderWith( response: MockKeyContextResponse, paramValidator?: (options: cxschema.KeyContextQuery) => void) { + // eslint-disable-next-line @typescript-eslint/unbound-method const previous = ContextProvider.getValue; ContextProvider.getValue = (_scope: Construct, options: GetContextValueOptions) => { // do some basic sanity checks diff --git a/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts b/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts index e1163f8067327..ad53c74e2ab85 100644 --- a/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as child_process from 'child_process'; import * as fs from 'fs'; import * as os from 'os'; diff --git a/packages/aws-cdk-lib/aws-lambda-nodejs/test/function.test.ts b/packages/aws-cdk-lib/aws-lambda-nodejs/test/function.test.ts index ce61643613197..c962a9cba0452 100644 --- a/packages/aws-cdk-lib/aws-lambda-nodejs/test/function.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-nodejs/test/function.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as child_process from 'child_process'; import { bockfs } from '@aws-cdk/cdk-build-tools'; import { Annotations, Template, Match } from '../../assertions'; diff --git a/packages/aws-cdk-lib/aws-lambda/lib/function-base.ts b/packages/aws-cdk-lib/aws-lambda/lib/function-base.ts index 5963134800710..144e91a9df7c1 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/function-base.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/function-base.ts @@ -611,7 +611,7 @@ export abstract class FunctionBase extends Resource implements IFunction, ec2.IC node: this.node, stack: this.stack, env: this.env, - applyRemovalPolicy: this.applyRemovalPolicy, + applyRemovalPolicy: x => this.applyRemovalPolicy(x), }, }); diff --git a/packages/aws-cdk-lib/aws-stepfunctions/lib/private/json-path.ts b/packages/aws-cdk-lib/aws-stepfunctions/lib/private/json-path.ts index d4ba825cf55a2..6a55a7905fbfd 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/lib/private/json-path.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/lib/private/json-path.ts @@ -4,7 +4,7 @@ import { captureStackTrace, IResolvable, IResolveContext, Token, Tokenization } const JSON_PATH_TOKEN_SYMBOL = Symbol.for('@aws-cdk/aws-stepfunctions.JsonPathToken'); export class JsonPathToken implements IResolvable { - public static isJsonPathToken(x: IResolvable): x is JsonPathToken { + public static isJsonPathToken(this: void, x: IResolvable): x is JsonPathToken { return (x as any)[JSON_PATH_TOKEN_SYMBOL] === true; } diff --git a/packages/aws-cdk-lib/aws-synthetics/test/code.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/code.test.ts index 05c717959cab1..a9191e44698ad 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/code.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/code.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ import * as fs from 'fs'; import * as path from 'path'; import { Template } from '../../assertions'; diff --git a/packages/aws-cdk-lib/core/lib/cfn-mapping.ts b/packages/aws-cdk-lib/core/lib/cfn-mapping.ts index ccfaa0312e937..4d72f2da186f0 100644 --- a/packages/aws-cdk-lib/core/lib/cfn-mapping.ts +++ b/packages/aws-cdk-lib/core/lib/cfn-mapping.ts @@ -135,7 +135,7 @@ export class CfnMapping extends CfnRefElement { return mapping; } - private validateAlphanumeric(value: any) { + private validateAlphanumeric(this: void, value: any) { // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html if (value.match(/[^a-zA-Z0-9]/g)) { throw new Error(`Attribute name '${value}' must contain only alphanumeric characters.`); diff --git a/packages/aws-cdk-lib/core/lib/cfn-resource.ts b/packages/aws-cdk-lib/core/lib/cfn-resource.ts index 587baac478638..023e9d11555fe 100644 --- a/packages/aws-cdk-lib/core/lib/cfn-resource.ts +++ b/packages/aws-cdk-lib/core/lib/cfn-resource.ts @@ -36,7 +36,7 @@ export class CfnResource extends CfnRefElement { /** * Check whether the given object is a CfnResource */ - public static isCfnResource(x: any): x is CfnResource { + public static isCfnResource(this: void, x: any): x is CfnResource { return x !== null && typeof(x) === 'object' && x.cfnResourceType !== undefined; } diff --git a/packages/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.ts b/packages/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.ts index 28055405bb313..22bc1695bec84 100644 --- a/packages/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.ts +++ b/packages/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.ts @@ -89,7 +89,7 @@ export class FromCloudFormation { return new FromCloudFormationResult(value); } - public static getBoolean(value: any): FromCloudFormationResult { + public static getBoolean(this: void, value: any): FromCloudFormationResult { if (typeof value === 'string') { // CloudFormation allows passing strings as boolean switch (value) { @@ -122,7 +122,7 @@ export class FromCloudFormation { // won't always return a string; if the input can't be resolved to a string, // the input will be returned. - public static getString(value: any): FromCloudFormationResult { + public static getString(this: void, value: any): FromCloudFormationResult { // if the string is a deploy-time value, serialize it to a Token if (isResolvableObject(value)) { return new FromCloudFormationResult(value.toString()); @@ -147,7 +147,7 @@ export class FromCloudFormation { // won't always return a number; if the input can't be parsed to a number, // the input will be returned. - public static getNumber(value: any): FromCloudFormationResult { + public static getNumber(this: void, value: any): FromCloudFormationResult { // if the string is a deploy-time value, serialize it to a Token if (isResolvableObject(value)) { return new FromCloudFormationResult(Token.asNumber(value)); @@ -166,7 +166,7 @@ export class FromCloudFormation { return new FromCloudFormationResult(value); } - public static getStringArray(value: any): FromCloudFormationResult { + public static getStringArray(this: void, value: any): FromCloudFormationResult { // if the array is a deploy-time value, serialize it to a Token if (isResolvableObject(value)) { return new FromCloudFormationResult(Token.asList(value)); @@ -176,7 +176,7 @@ export class FromCloudFormation { return FromCloudFormation.getArray(FromCloudFormation.getString)(value); } - public static getArray(mapper: (arg: any) => FromCloudFormationResult): (x: any) => FromCloudFormationResult { + public static getArray(this: void, mapper: (arg: any) => FromCloudFormationResult): (x: any) => FromCloudFormationResult { return (value: any) => { if (!Array.isArray(value)) { // break the type system, and just return the given value, @@ -198,7 +198,7 @@ export class FromCloudFormation { }; } - public static getMap(mapper: (arg: any) => FromCloudFormationResult): (x: any) => FromCloudFormationResult<{ [key: string]: T }> { + public static getMap(this: void, mapper: (arg: any) => FromCloudFormationResult): (x: any) => FromCloudFormationResult<{ [key: string]: T }> { return (value: any) => { if (typeof value !== 'object') { // if the input is not a map (= object in JS land), @@ -219,7 +219,7 @@ export class FromCloudFormation { }; } - public static getCfnTag(tag: any): FromCloudFormationResult { + public static getCfnTag(this: void, tag: any): FromCloudFormationResult { if (isResolvableObject(tag)) { return new FromCloudFormationResult(tag); } return tag == null ? new FromCloudFormationResult({ } as any) // break the type system - this should be detected at runtime by a tag validator @@ -232,7 +232,7 @@ export class FromCloudFormation { /** * Return a function that, when applied to a value, will return the first validly deserialized one */ - public static getTypeUnion(validators: Validator[], mappers: Array<(x: any) => FromCloudFormationResult>): + public static getTypeUnion(this: void, validators: Validator[], mappers: Array<(x: any) => FromCloudFormationResult>): (x: any) => FromCloudFormationResult { return (value: any) => { for (let i = 0; i < validators.length; i++) { diff --git a/packages/aws-cdk-lib/core/lib/resolvable.ts b/packages/aws-cdk-lib/core/lib/resolvable.ts index fe41ee78d20a1..2de97f4e955ed 100644 --- a/packages/aws-cdk-lib/core/lib/resolvable.ts +++ b/packages/aws-cdk-lib/core/lib/resolvable.ts @@ -181,7 +181,7 @@ export class DefaultTokenResolver implements ITokenResolver { * Resolve string fragments to Tokens */ public resolveString(fragments: TokenizedStringFragments, context: IResolveContext) { - return fragments.mapTokens({ mapToken: context.resolve }).join(this.concat); + return fragments.mapTokens({ mapToken: x => context.resolve(x) }).join(this.concat); } public resolveList(xs: string[], context: IResolveContext) { @@ -197,6 +197,6 @@ export class DefaultTokenResolver implements ITokenResolver { throw new Error(`Cannot concatenate strings in a tokenized string array, got: ${xs[0]}`); } - return fragments.mapTokens({ mapToken: context.resolve }).firstValue; + return fragments.mapTokens({ mapToken: (x) => context.resolve(x) }).firstValue; } } diff --git a/packages/aws-cdk-lib/core/lib/stack.ts b/packages/aws-cdk-lib/core/lib/stack.ts index 00c5be83b9803..509063206b2f7 100644 --- a/packages/aws-cdk-lib/core/lib/stack.ts +++ b/packages/aws-cdk-lib/core/lib/stack.ts @@ -207,7 +207,7 @@ export class Stack extends Construct implements ITaggable { * * We do attribute detection since we can't reliably use 'instanceof'. */ - public static isStack(x: any): x is Stack { + public static isStack(this: void, x: any): x is Stack { return x !== null && typeof(x) === 'object' && STACK_SYMBOL in x; } @@ -601,7 +601,7 @@ export class Stack extends Construct implements ITaggable { /** * Convert an object, potentially containing tokens, to a JSON string */ - public toJsonString(obj: any, space?: number): string { + public toJsonString(this: void, obj: any, space?: number): string { return CloudFormationLang.toJSON(obj, space).toString(); } diff --git a/packages/aws-cdk-lib/core/lib/stage.ts b/packages/aws-cdk-lib/core/lib/stage.ts index 11a8aa12d3d4e..aa33e37e4ea14 100644 --- a/packages/aws-cdk-lib/core/lib/stage.ts +++ b/packages/aws-cdk-lib/core/lib/stage.ts @@ -106,7 +106,7 @@ export class Stage extends Construct { * Test whether the given construct is a stage. * */ - public static isStage(x: any ): x is Stage { + public static isStage(this: void, x: any): x is Stage { return x !== null && typeof(x) === 'object' && STAGE_SYMBOL in x; } diff --git a/packages/aws-cdk-lib/core/lib/token.ts b/packages/aws-cdk-lib/core/lib/token.ts index 8dc31e8bf2a34..6517d7d778aec 100644 --- a/packages/aws-cdk-lib/core/lib/token.ts +++ b/packages/aws-cdk-lib/core/lib/token.ts @@ -59,7 +59,7 @@ export class Token { * * @param obj The object to test. */ - public static isUnresolved(obj: any): boolean { + public static isUnresolved(this: void, obj: any): boolean { return unresolved(obj); } diff --git a/packages/aws-cdk-lib/core/test/fs/fs-fingerprint.test.ts b/packages/aws-cdk-lib/core/test/fs/fs-fingerprint.test.ts index 3b5b97b807106..40a438628674c 100644 --- a/packages/aws-cdk-lib/core/test/fs/fs-fingerprint.test.ts +++ b/packages/aws-cdk-lib/core/test/fs/fs-fingerprint.test.ts @@ -222,6 +222,7 @@ describe('fs fingerprint', () => { test('normalizes relative path', () => { // Simulate a Windows path.relative() + // eslint-disable-next-line @typescript-eslint/unbound-method const originalPathRelative = path.relative; const pathRelativeSpy = jest.spyOn(path, 'relative').mockImplementation((from: string, to: string): string => { return originalPathRelative(from, to).replace(/\//g, '\\'); diff --git a/packages/aws-cdk-lib/core/test/metadata.test.ts b/packages/aws-cdk-lib/core/test/metadata.test.ts index 8f0143da391ad..5d2877812efa2 100644 --- a/packages/aws-cdk-lib/core/test/metadata.test.ts +++ b/packages/aws-cdk-lib/core/test/metadata.test.ts @@ -196,6 +196,7 @@ describe('addMethodMetadata & addConstructMetadata', () => { metadata.addMethodMetadata(mockScope, 'testMethod', { key: 'value' }); // Assert + // eslint-disable-next-line @typescript-eslint/unbound-method expect(Annotations.of).toHaveBeenCalledWith(mockScope); expect(mockAnnotations.addWarningV2).toHaveBeenCalledWith( '@aws-cdk/core:addMethodMetadataFailed', @@ -214,6 +215,7 @@ describe('addMethodMetadata & addConstructMetadata', () => { metadata.addConstructMetadata(mockScope, { key: 'value' }); // Assert + // eslint-disable-next-line @typescript-eslint/unbound-method expect(Annotations.of).toHaveBeenCalledWith(mockScope); expect(mockAnnotations.addWarningV2).toHaveBeenCalledWith( '@aws-cdk/core:addConstructMetadataFailed', diff --git a/packages/aws-cdk-lib/cx-api/lib/artifacts/asset-manifest-artifact.ts b/packages/aws-cdk-lib/cx-api/lib/artifacts/asset-manifest-artifact.ts index f5f80fb599e87..0a017aa08de39 100644 --- a/packages/aws-cdk-lib/cx-api/lib/artifacts/asset-manifest-artifact.ts +++ b/packages/aws-cdk-lib/cx-api/lib/artifacts/asset-manifest-artifact.ts @@ -28,7 +28,7 @@ export class AssetManifestArtifact extends CloudArtifact { * unpredictably. It is safest to avoid using `instanceof`, and using * this type-testing method instead. */ - public static isAssetManifestArtifact(art: any): art is AssetManifestArtifact { + public static isAssetManifestArtifact(this: void, art: any): art is AssetManifestArtifact { return art && typeof art === 'object' && art[ASSET_MANIFEST_ARTIFACT_SYM]; } diff --git a/packages/aws-cdk-lib/pipelines/lib/blueprint/shell-step.ts b/packages/aws-cdk-lib/pipelines/lib/blueprint/shell-step.ts index 45c7baae66344..2fd909c0cad6e 100644 --- a/packages/aws-cdk-lib/pipelines/lib/blueprint/shell-step.ts +++ b/packages/aws-cdk-lib/pipelines/lib/blueprint/shell-step.ts @@ -149,7 +149,7 @@ export class ShellStep extends Step { this.commands = props.commands; this.installCommands = props.installCommands ?? []; this.env = props.env ?? {}; - this.envFromCfnOutputs = mapValues(props.envFromCfnOutputs ?? {}, StackOutputReference.fromCfnOutput); + this.envFromCfnOutputs = mapValues(props.envFromCfnOutputs ?? {}, x => StackOutputReference.fromCfnOutput(x)); // 'env' is the only thing that can contain outputs this.discoverReferencedOutputs({ diff --git a/packages/aws-cdk-lib/region-info/lib/region-info.ts b/packages/aws-cdk-lib/region-info/lib/region-info.ts index 6c090bd7daa12..b1cf5231f46d3 100644 --- a/packages/aws-cdk-lib/region-info/lib/region-info.ts +++ b/packages/aws-cdk-lib/region-info/lib/region-info.ts @@ -10,7 +10,7 @@ export class RegionInfo { * may not be an exaustive list of all available AWS regions. */ public static get regions(): RegionInfo[] { - return Fact.regions.map(RegionInfo.get); + return Fact.regions.map(x => RegionInfo.get(x)); } /** diff --git a/packages/aws-cdk-lib/testhelpers/jest-bufferedconsole.ts b/packages/aws-cdk-lib/testhelpers/jest-bufferedconsole.ts index 7dac07c7fc7da..efeee1cdf8f32 100644 --- a/packages/aws-cdk-lib/testhelpers/jest-bufferedconsole.ts +++ b/packages/aws-cdk-lib/testhelpers/jest-bufferedconsole.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable import/no-extraneous-dependencies */ /** * A Jest environment that buffers outputs to `console.log()` and only shows it for failing tests. diff --git a/tools/@aws-cdk/cdk-build-tools/config/eslintrc.js b/tools/@aws-cdk/cdk-build-tools/config/eslintrc.js index c418d6c78f32e..ec1a864cf1647 100644 --- a/tools/@aws-cdk/cdk-build-tools/config/eslintrc.js +++ b/tools/@aws-cdk/cdk-build-tools/config/eslintrc.js @@ -224,6 +224,9 @@ module.exports = { ], }], + // Too easy to make mistakes + '@typescript-eslint/unbound-method': 'error', + // Overrides for plugin:jest/recommended "jest/expect-expect": "off", "jest/no-conditional-expect": "off", diff --git a/tools/@aws-cdk/spec2cdk/lib/cdk/canned-metrics.ts b/tools/@aws-cdk/spec2cdk/lib/cdk/canned-metrics.ts index b6dbc0565b862..9a87c2ceed871 100644 --- a/tools/@aws-cdk/spec2cdk/lib/cdk/canned-metrics.ts +++ b/tools/@aws-cdk/spec2cdk/lib/cdk/canned-metrics.ts @@ -136,6 +136,10 @@ export class MetricsClass extends ClassType { static: true, returnType: Type.fromName(this.scope, this.returnType.name, [dimensionsType]), parameters: [ + { + name: 'this', + type: Type.VOID, + }, { name: 'dimensions', type: dimensionsType,