diff --git a/.gitignore b/.gitignore index 32870916d6561..3fb446b50982f 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,5 @@ read*lock # Nx cache .nx/ +.traces +*.tmp diff --git a/build.sh b/build.sh index 2816034dba8f8..1a3d4c5039e5b 100755 --- a/build.sh +++ b/build.sh @@ -47,6 +47,10 @@ done export NODE_OPTIONS="--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}" +if $ci; then + export CI=true +fi + # Temporary log memory for long builds (this may mess with tests that check stderr) # export NODE_OPTIONS="-r $PWD/scripts/log-memory.js ${NODE_OPTIONS:-}" @@ -116,6 +120,10 @@ echo "========================================================================== echo "building..." time npx lerna run $bail --concurrency=$concurrency $runtarget $flags || fail +echo "=============[ MEMORY AND TIMING TRACES ]====================================================" +cat .traces/* +echo "=============================================================================================" + if [ "$check_compat" == "true" ]; then /bin/bash scripts/check-api-compatibility.sh fi diff --git a/packages/@aws-cdk/custom-resource-handlers/.gitignore b/packages/@aws-cdk/custom-resource-handlers/.gitignore index cbbe46ddaf561..567f7a21e9ad5 100644 --- a/packages/@aws-cdk/custom-resource-handlers/.gitignore +++ b/packages/@aws-cdk/custom-resource-handlers/.gitignore @@ -32,4 +32,3 @@ scripts/*.d.ts !lib/aws-certificatemanager/dns-validated-certificate-handler/index.js !test/aws-certificatemanager/dns-validated-certificate-handler.test.js -!lib/aws-cloudfront/edge-function/index.js diff --git a/packages/@aws-cdk/custom-resource-handlers/test/aws-certificatemanager/dns-validated-certificate-handler.test.js b/packages/@aws-cdk/custom-resource-handlers/test/aws-certificatemanager/dns-validated-certificate-handler.test.js deleted file mode 100644 index a42372f2b387e..0000000000000 --- a/packages/@aws-cdk/custom-resource-handlers/test/aws-certificatemanager/dns-validated-certificate-handler.test.js +++ /dev/null @@ -1,1490 +0,0 @@ -'use strict'; - -const LambdaTester = require('lambda-tester').noVersionCheck(); -const sinon = require('sinon'); -const handler = require('..'); -const nock = require('nock'); -const { mockClient } = require('aws-sdk-client-mock'); -const acm = require('@aws-sdk/client-acm'); -const r53 = require('@aws-sdk/client-route-53'); -const ResponseURL = 'https://cloudwatch-response-mock.example.com/'; - -jest.mock('@aws-sdk/client-acm', () => { - const actual = jest.requireActual('@aws-sdk/client-acm'); - return { - ...actual, - waitUntilCertificateValidated: async () => {}, - }; -}); - -jest.mock('@aws-sdk/client-route-53', () => { - const actual = jest.requireActual('@aws-sdk/client-route-53'); - return { - ...actual, - waitUntilResourceRecordSetsChanged: async () => {}, - }; -}); - -const acmMock = mockClient(acm.ACMClient); -const r53Mock = mockClient(r53.Route53Client); - -describe('DNS Validated Certificate Handler', () => { - let origLog = console.log; - const testRequestId = 'f4ef1b10-c39a-44e3-99c0-fbf7e53c3943'; - const testDomainName = 'test.example.com'; - const testSubjectAlternativeName = 'foo.example.com'; - const testHostedZoneId = '/hostedzone/Z3P5QSUBK4POTI'; - const testCertificateArn = 'arn:aws:acm:region:123456789012:certificate/12345678-1234-1234-1234-123456789012'; - const testRRName = '_3639ac514e785e898d2646601fa951d5.example.com'; - const testRRValue = '_x2.acm-validations.aws'; - const testAltRRName = '_3639ac514e785e898d2646601fa951d5.foo.example.com'; - const testAltRRValue = '_x3.acm-validations.aws'; - const testTags = { Tag1: 'Test1', Tag2: 'Test2' }; - const testTagsValue = [{ Key: 'Tag1', Value: 'Test1' }, { Key: 'Tag2', Value: 'Test2' }]; - const spySleep = sinon.spy(function (ms) { - return Promise.resolve(); - }); - - beforeEach(() => { - handler.withDefaultResponseURL(ResponseURL); - handler.withWaiter(function () { - // Mock waiter is merely a self-fulfilling promise - return new Promise((resolve) => { - resolve(); - }); - }); - handler.withSleep(spySleep); - console.log = function () { }; - }); - afterEach(() => { - // Restore waiters and logger - handler.resetWaiter(); - handler.resetSleep(); - handler.resetMaxAttempts(); - r53Mock.reset(); - acmMock.reset(); - nock.cleanAll(); - console.log = origLog; - spySleep.resetHistory(); - }); - - test('Empty event payload fails', () => { - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED' && body.Reason === 'Unsupported request type undefined'; - }).reply(200); - return LambdaTester(handler.certificateRequestHandler) - .event({}) - .expectResolve(() => { - expect(request.isDone()).toBe(true); - }); - }); - - test('Bogus operation fails', () => { - const bogusType = 'bogus'; - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED' && body.Reason === 'Unsupported request type ' + bogusType; - }).reply(200); - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: bogusType - }) - .expectResolve(() => { - expect(request.isDone()).toBe(true); - }); - }); - - test('Create operation requests a certificate', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({}); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS', - Options: { - CertificateTransparencyLoggingPreference: undefined - } - })); - sinon.assert.calledWith(changeResourceRecordSetsFake, sinon.match({ - ChangeBatch: { - Changes: [{ - Action: 'UPSERT', - ResourceRecordSet: { - Name: testRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testRRValue - }] - } - }] - }, - HostedZoneId: testHostedZoneId - })); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Create operation with `SubjectAlternativeNames` requests a certificate with validation records for all options', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [ - { - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }, { - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testAltRRName, - Type: 'CNAME', - Value: testAltRRValue - } - } - ] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({ - Certificate: testCertificateArn, - Tags: testTags, - }); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - SubjectAlternativeNames: [testSubjectAlternativeName], - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags, - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS', - SubjectAlternativeNames: [testSubjectAlternativeName] - })); - sinon.assert.calledWith(changeResourceRecordSetsFake, sinon.match({ - ChangeBatch: { - Changes: [ - { - Action: 'UPSERT', - ResourceRecordSet: { - Name: testRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testRRValue - }] - } - }, { - Action: 'UPSERT', - ResourceRecordSet: { - Name: testAltRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testAltRRValue - }] - } - } - ] - }, - HostedZoneId: testHostedZoneId - })); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Create operation with `SubjectAlternativeNames` requests a certificate for all options without duplicates', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [ - { - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }, { - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testAltRRName, - Type: 'CNAME', - Value: testAltRRValue - } - }, { - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - } - ] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({ - Certificate: testCertificateArn, - Tags: testTags, - }); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags, - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS' - })); - sinon.assert.calledWith(changeResourceRecordSetsFake, sinon.match({ - ChangeBatch: { - Changes: [ - { - Action: 'UPSERT', - ResourceRecordSet: { - Name: testRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testRRValue - }] - } - }, { - Action: 'UPSERT', - ResourceRecordSet: { - Name: testAltRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testAltRRValue - }] - } - } - ] - }, - HostedZoneId: testHostedZoneId - })); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Create operation with `SubjectAlternativeNames` gracefully handles partial results from DescribeCertificate', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [ - { - ValidationStatus: 'PENDING_VALIDATION', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }, - { - ValidationStatus: 'PENDING_VALIDATION', - }, - ] - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [ - { - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }, - { - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testAltRRName, - Type: 'CNAME', - Value: testAltRRValue - } - }, - ] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({ - Certificate: testCertificateArn, - Tags: testTags, - }); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags, - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS' - })); - sinon.assert.calledWith(changeResourceRecordSetsFake, sinon.match({ - ChangeBatch: { - Changes: [ - { - Action: 'UPSERT', - ResourceRecordSet: { - Name: testRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testRRValue - }] - } - }, { - Action: 'UPSERT', - ResourceRecordSet: { - Name: testAltRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testAltRRValue - }] - } - } - ] - }, - HostedZoneId: testHostedZoneId - })); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Create operation fails after more than 60s if certificate has no DomainValidationOptions', () => { - handler.withRandom(() => 0); - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED' && - body.Reason.startsWith('Response from describeCertificate did not contain DomainValidationOptions'); - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS' - })); - expect(request.isDone()).toBe(true); - const totalSleep = spySleep.getCalls().map(call => call.args[0]).reduce((p, n) => p + n, 0); - expect(totalSleep).toBeGreaterThan(60 * 1000); - }); - }); - - test('Create operation fails within 360s and 10 attempts if certificate has no DomainValidationOptions', () => { - handler.withRandom(() => 1); - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED' && - body.Reason.startsWith('Response from describeCertificate did not contain DomainValidationOptions'); - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS' - })); - expect(request.isDone()).toBe(true); - expect(spySleep.callCount).toBe(10); - const totalSleep = spySleep.getCalls().map(call => call.args[0]).reduce((p, n) => p + n, 0); - expect(totalSleep).toBeLessThan(360 * 1000); - }); - }); - - test('Create operation with a maximum of 1 attempts describes the certificate once', () => { - handler.withMaxAttempts(1); - - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - - const describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const addTagsToCertificateFake = sinon.fake.resolves({ - Certificate: testCertificateArn, - Tags: testTags, - }); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags, - } - }) - .expectResolve(() => { - sinon.assert.calledOnce(describeCertificateFake); - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn, - })); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Create operation succeeds with no tags passed', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({ - Certificate: testCertificateArn, - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1' - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS' - })); - sinon.assert.calledWith(changeResourceRecordSetsFake, sinon.match({ - ChangeBatch: { - Changes: [{ - Action: 'UPSERT', - ResourceRecordSet: { - Name: testRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testRRValue - }] - } - }] - }, - HostedZoneId: testHostedZoneId - })); - sinon.assert.neverCalledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Create operation with `CertificateTransparencyLoggingPreference` requests a certificate with that preference set', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({}); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Create', - RequestId: testRequestId, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - CertificateTransparencyLoggingPreference: 'DISABLED', - Tags: testTags - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS', - Options: { - CertificateTransparencyLoggingPreference: 'DISABLED' - } - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Delete operation deletes the certificate', () => { - const describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - } - }); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const deleteCertificateFake = sinon.fake.resolves({}); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Delete operation is idempotent', () => { - const error = new Error(); - error.name = 'ResourceNotFoundException'; - - const describeCertificateFake = sinon.fake.rejects(error); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const deleteCertificateFake = sinon.fake.rejects(error); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.neverCalledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Update operation requests a certificate', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({}); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Update', - RequestId: testRequestId, - OldResourceProperties: { - DomainName: 'example.com', - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags - }, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags - } - }) - .expectResolve(() => { - sinon.assert.calledWith(requestCertificateFake, sinon.match({ - DomainName: testDomainName, - ValidationMethod: 'DNS', - Options: { - CertificateTransparencyLoggingPreference: undefined - } - })); - sinon.assert.calledWith(changeResourceRecordSetsFake, sinon.match({ - ChangeBatch: { - Changes: [{ - Action: 'UPSERT', - ResourceRecordSet: { - Name: testRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testRRValue - }] - } - }] - }, - HostedZoneId: testHostedZoneId - })); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Update operation updates tags only', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({}); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Update', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - OldResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags, - }, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: { - ...testTags, - Tag4: 'Value4', - }, - } - }) - .expectResolve(() => { - sinon.assert.notCalled(requestCertificateFake); - sinon.assert.notCalled(changeResourceRecordSetsFake); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": [{ Key: 'Tag1', Value: 'Test1' }, { Key: 'Tag2', Value: 'Test2' }, { Key: 'Tag4', Value: 'Value4' }], - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Update operation does not request certificate if removal policy is changed', () => { - const requestCertificateFake = sinon.fake.resolves({ - CertificateArn: testCertificateArn, - }); - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - - const addTagsToCertificateFake = sinon.fake.resolves({}); - - const changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - - acmMock.on(acm.RequestCertificateCommand).callsFake(requestCertificateFake); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - acmMock.on(acm.AddTagsToCertificateCommand).callsFake(addTagsToCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Update', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - OldResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags, - }, - ResourceProperties: { - DomainName: testDomainName, - HostedZoneId: testHostedZoneId, - Region: 'us-east-1', - Tags: testTags, - RemovalPolicy: 'retain', - } - }) - .expectResolve(() => { - sinon.assert.notCalled(requestCertificateFake); - sinon.assert.notCalled(changeResourceRecordSetsFake); - sinon.assert.calledWith(addTagsToCertificateFake, sinon.match({ - "CertificateArn": testCertificateArn, - "Tags": testTagsValue, - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Delete operation succeeds if certificate becomes not-in-use', () => { - const usedByArn = 'arn:aws:cloudfront::123456789012:distribution/d111111abcdef8'; - - const describeCertificateFake = sinon.stub(); - describeCertificateFake.onFirstCall().resolves({ - Certificate: { - CertificateArn: testCertificateArn, - InUseBy: [usedByArn], - } - }); - describeCertificateFake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - InUseBy: [], - } - }); - - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const deleteCertificateFake = sinon.fake.resolves({}); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Delete operation fails within 360s and 10 attempts if certificate is in-use', () => { - const usedByArn = 'arn:aws:cloudfront::123456789012:distribution/d111111abcdef8'; - - const describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - InUseBy: [usedByArn], - } - }); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const error = new Error(); - error.name = 'ResourceInUseException'; - const deleteCertificateFake = sinon.fake.rejects(error); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.neverCalledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - const totalSleep = spySleep.getCalls().map(call => call.args[0]).reduce((p, n) => p + n, 0); - expect(totalSleep).toBeLessThan(360 * 1000); - expect(spySleep.callCount).toBe(10); - expect(request.isDone()).toBe(true); - }); - }); - - test('Delete operation fails if some other error is encountered during describe', () => { - const error = new Error(); - error.name = 'SomeOtherException'; - - const describeCertificateFake = sinon.fake.rejects(error); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const deleteCertificateFake = sinon.fake.resolves({}); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.neverCalledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Delete operation fails if some other error is encountered during delete', () => { - const describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn - } - }); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const error = new Error(); - error.name = 'SomeOtherException'; - const deleteCertificateFake = sinon.fake.rejects(error); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('Delete operation with a maximum of 1 attempts describes the certificate once', () => { - handler.withMaxAttempts(1); - - const describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - } - }); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const deleteCertificateFake = sinon.fake.resolves({}); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - expect(request.isDone()).toBe(true); - }); - }); - - describe('Delete option record cleanup', () => { - let describeCertificateFake; - let deleteCertificateFake; - let changeResourceRecordSetsFake; - - beforeEach(() => { - deleteCertificateFake = sinon.fake.resolves({}); - acmMock.on(acm.DeleteCertificateCommand).callsFake(deleteCertificateFake); - changeResourceRecordSetsFake = sinon.fake.resolves({ - ChangeInfo: { - Id: 'bogus' - } - }); - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - - describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - DomainValidationOptions: [{ - ValidationStatus: 'SUCCESS', - ResourceRecord: { - Name: testRRName, - Type: 'CNAME', - Value: testRRValue - } - }] - } - }); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - }); - - test('ignores records if CleanupRecords is not set', () => { - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - HostedZoneId: testHostedZoneId, - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.notCalled(changeResourceRecordSetsFake); - expect(request.isDone()).toBe(true); - }); - }); - - test('ignores records if CleanupRecords is not set to "true"', () => { - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - HostedZoneId: testHostedZoneId, - CleanupRecords: 'TRUE', // Not "true" - } - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.notCalled(changeResourceRecordSetsFake); - expect(request.isDone()).toBe(true); - }); - }); - - test('deletes records if CleanupRecords is set to true and records are present', () => { - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'SUCCESS'; - }).reply(200); - - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - HostedZoneId: testHostedZoneId, - CleanupRecords: 'true', - }, - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(deleteCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.calledWith(changeResourceRecordSetsFake, sinon.match({ - ChangeBatch: { - Changes: [{ - Action: 'DELETE', - ResourceRecordSet: { - Name: testRRName, - Type: 'CNAME', - TTL: 60, - ResourceRecords: [{ - Value: testRRValue - }] - } - }] - }, - HostedZoneId: testHostedZoneId - })); - expect(request.isDone()).toBe(true); - }); - }); - - test('fails if CleanupRecords is set to true and records are not present', () => { - describeCertificateFake = sinon.fake.resolves({ - Certificate: { - CertificateArn: testCertificateArn, - } - }); - acmMock.on(acm.DescribeCertificateCommand).callsFake(describeCertificateFake); - - const request = nock(ResponseURL).put('/', body => { - return body.Status === 'FAILED' && - body.Reason.startsWith('Response from describeCertificate did not contain DomainValidationOptions'); - }).reply(200); - - r53Mock.on(r53.ChangeResourceRecordSetsCommand).callsFake(changeResourceRecordSetsFake); - - return LambdaTester(handler.certificateRequestHandler) - .event({ - RequestType: 'Delete', - RequestId: testRequestId, - PhysicalResourceId: testCertificateArn, - ResourceProperties: { - Region: 'us-east-1', - HostedZoneId: testHostedZoneId, - CleanupRecords: 'true', - }, - }) - .expectResolve(() => { - sinon.assert.calledWith(describeCertificateFake, sinon.match({ - CertificateArn: testCertificateArn - })); - sinon.assert.notCalled(deleteCertificateFake); - sinon.assert.notCalled(changeResourceRecordSetsFake); - expect(request.isDone()).toBe(true); - }); - }); - }); -}); diff --git a/packages/@aws-cdk/cx-api/tsconfig.json b/packages/@aws-cdk/cx-api/tsconfig.json index e275e033f112b..89c99d4e91fd0 100644 --- a/packages/@aws-cdk/cx-api/tsconfig.json +++ b/packages/@aws-cdk/cx-api/tsconfig.json @@ -33,8 +33,7 @@ "**/*.ts" ], "exclude": [ - "node_modules", - "**/test/**/*.ts" + "node_modules" ], "references": [ { diff --git a/packages/aws-cdk-lib/assertions/test/match.test.ts b/packages/aws-cdk-lib/assertions/test/match.test.ts index 1651ce6ce0bd2..ed438a43b56ee 100644 --- a/packages/aws-cdk-lib/assertions/test/match.test.ts +++ b/packages/aws-cdk-lib/assertions/test/match.test.ts @@ -423,7 +423,7 @@ describe('Matchers', () => { function expectPass(matcher: Matcher, target: any): void { const result = matcher.test(target); if (result.hasFailed()) { - throw new Error(result.toHumanStrings().join('\n')); // eslint-disable-line jest/no-jasmine-globals + throw new Error(result.toHumanStrings().join('\n')); } } diff --git a/packages/aws-cdk-lib/aws-apigateway/test/integration.test.ts b/packages/aws-cdk-lib/aws-apigateway/test/integration.test.ts index 07776a80a6653..6cf992529f7b3 100644 --- a/packages/aws-cdk-lib/aws-apigateway/test/integration.test.ts +++ b/packages/aws-cdk-lib/aws-apigateway/test/integration.test.ts @@ -2,7 +2,6 @@ import { Match, Template } from '../../assertions'; import * as ec2 from '../../aws-ec2'; import * as elbv2 from '../../aws-elasticloadbalancingv2'; import * as iam from '../../aws-iam'; -import { Runtime, Code, Function } from '../../aws-lambda'; import * as cdk from '../../core'; import * as apigw from '../lib'; diff --git a/packages/aws-cdk-lib/aws-apigateway/test/lambda-api.test.ts b/packages/aws-cdk-lib/aws-apigateway/test/lambda-api.test.ts index 896fef58db849..b8a1f92af9823 100644 --- a/packages/aws-cdk-lib/aws-apigateway/test/lambda-api.test.ts +++ b/packages/aws-cdk-lib/aws-apigateway/test/lambda-api.test.ts @@ -446,7 +446,7 @@ describe('LambdaRestApi inherits from RestApi prop injector test ', () => { this.constructUniqueId = apigw.RestApi.PROPERTY_INJECTION_ID; } - inject(originalProps: apigw.RestApiProps, context: cdk.InjectionContext): apigw.RestApiProps { + inject(originalProps: apigw.RestApiProps, _context: cdk.InjectionContext): apigw.RestApiProps { return { endpointTypes: [apigw.EndpointType.REGIONAL], deploy: false, diff --git a/packages/aws-cdk-lib/aws-apigateway/test/restapi.test.ts b/packages/aws-cdk-lib/aws-apigateway/test/restapi.test.ts index c4b995457eeee..2943828bfe86d 100644 --- a/packages/aws-cdk-lib/aws-apigateway/test/restapi.test.ts +++ b/packages/aws-cdk-lib/aws-apigateway/test/restapi.test.ts @@ -1811,7 +1811,7 @@ describe('SpecRestApi', () => { const api = apigw.RestApi.fromRestApiId(stack, 'Api', 'api-id'); // THEN - const result = api.addToResourcePolicy(new iam.PolicyStatement({ + const result = (api as any).addToResourcePolicy(new iam.PolicyStatement({ actions: ['execute-api:Invoke'], resources: [Stack.of(stack).formatArn({ service: 'execute-api', @@ -1831,7 +1831,7 @@ describe('SpecRestApi', () => { }); // THEN - const result = api.addToResourcePolicy(new iam.PolicyStatement({ + const result = (api as any).addToResourcePolicy(new iam.PolicyStatement({ actions: ['execute-api:Invoke'], resources: [Stack.of(stack).formatArn({ service: 'execute-api', diff --git a/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/jwt.test.ts b/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/jwt.test.ts index 1b12c69ae6b1e..a99d7ca95854e 100644 --- a/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/jwt.test.ts +++ b/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/jwt.test.ts @@ -79,12 +79,11 @@ describe('HttpJwtAuthorizer', () => { test('should throw error when acessing authorizer before it been bound to route', () => { // GIVEN - const stack = new Stack(); const t = () => { const authorizer = new HttpJwtAuthorizer('BooksAuthorizer', 'https://test.us.auth0.com', { jwtAudience: ['3131231'], }); - const authorizerId = authorizer.authorizerId; + void(authorizer.authorizerId); }; // THEN diff --git a/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/lambda.test.ts b/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/lambda.test.ts index ef04b15c5d103..93f963fda2426 100644 --- a/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/lambda.test.ts +++ b/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/lambda.test.ts @@ -194,7 +194,7 @@ describe('HttpLambdaAuthorizer', () => { const t = () => { const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', handler); - const authorizerId = authorizer.authorizerId; + void(authorizer.authorizerId); }; // THEN diff --git a/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/user-pool.test.ts b/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/user-pool.test.ts index d5155d969bbf6..d5f32ee29c2b0 100644 --- a/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/user-pool.test.ts +++ b/packages/aws-cdk-lib/aws-apigatewayv2-authorizers/test/http/user-pool.test.ts @@ -137,7 +137,7 @@ describe('HttpUserPoolAuthorizer', () => { const authorizer = new HttpUserPoolAuthorizer('BooksAuthorizer', userPool, { userPoolClients: [userPoolClient1, userPoolClient2], }); - const authorizerId = authorizer.authorizerId; + void(authorizer.authorizerId); }; // THEN diff --git a/packages/aws-cdk-lib/aws-apigatewayv2/test/http/domain-name.test.ts b/packages/aws-cdk-lib/aws-apigatewayv2/test/http/domain-name.test.ts index 6822b68d39fc7..f5bbb4adc6fe0 100644 --- a/packages/aws-cdk-lib/aws-apigatewayv2/test/http/domain-name.test.ts +++ b/packages/aws-cdk-lib/aws-apigatewayv2/test/http/domain-name.test.ts @@ -340,7 +340,7 @@ describe('DomainName', () => { test.each([IpAddressType.IPV4, IpAddressType.DUAL_STACK])('ipAddressType is set', (ipAddressType) => { const stack = new Stack(); - const dn = new DomainName(stack, 'DomainName', { + new DomainName(stack, 'DomainName', { domainName, certificate: Certificate.fromCertificateArn(stack, 'cert', certArn), ipAddressType, diff --git a/packages/aws-cdk-lib/aws-apigatewayv2/test/websocket/api-key.test.ts b/packages/aws-cdk-lib/aws-apigatewayv2/test/websocket/api-key.test.ts index e5b652ae71154..b72898a63e697 100644 --- a/packages/aws-cdk-lib/aws-apigatewayv2/test/websocket/api-key.test.ts +++ b/packages/aws-cdk-lib/aws-apigatewayv2/test/websocket/api-key.test.ts @@ -251,7 +251,7 @@ describe('api key', () => { // GIVEN const stack = new cdk.Stack(); const api = new WebSocketApi(stack, 'test-api'); - const stage = WebSocketStage.fromWebSocketStageAttributes(stack, 'Stage', { + WebSocketStage.fromWebSocketStageAttributes(stack, 'Stage', { api: api, stageName: 'MyStage', }); diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync-environment-variables.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync-environment-variables.test.ts index 5a1c5e449f4f9..da1b2935ed5e4 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync-environment-variables.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync-environment-variables.test.ts @@ -188,7 +188,7 @@ describe('environment variables', () => { test('throws if length of key-value pairs for environment variables is greater than 50', () => { // WHEN - const vars = {}; + const vars: Record = {}; for (let i = 0; i < 51; i++) { vars[`EnvKey${i}`] = `non-empty-${i}`; } diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-eventbridge.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-eventbridge.test.ts index 554f114d7e4d4..e1fe97dd87baa 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-eventbridge.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-eventbridge.test.ts @@ -1,4 +1,3 @@ -import * as path from 'path'; import { Template } from '../../assertions'; import * as eventBridge from '../../aws-events'; import * as cdk from '../../core'; diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-http.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-http.test.ts index 0cfb9a0ed20d7..7aa95c6637f38 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-http.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-http.test.ts @@ -1,4 +1,3 @@ -import * as path from 'path'; import { Template } from '../../assertions'; import * as sfn from '../../aws-stepfunctions'; import * as cdk from '../../core'; diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-opensearch.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-opensearch.test.ts index ed734940f5088..71c2f62d31c8b 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-opensearch.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-opensearch.test.ts @@ -1,4 +1,3 @@ -import * as path from 'path'; import { Template } from '../../assertions'; import * as opensearch from '../../aws-opensearchservice'; import * as cdk from '../../core'; diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-rds.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-rds.test.ts index 05c320d12f87c..6ad7326ca6a90 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-rds.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync-eventapi-rds.test.ts @@ -1,4 +1,3 @@ -import * as path from 'path'; import { Template } from '../../assertions'; import { Vpc, SecurityGroup, SubnetType } from '../../aws-ec2'; import { DatabaseSecret, DatabaseClusterEngine, AuroraMysqlEngineVersion, ServerlessCluster, DatabaseCluster, ClusterInstance, AuroraPostgresEngineVersion } from '../../aws-rds'; diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync-merged-api.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync-merged-api.test.ts index eeeae418596b6..7163b51b2b12d 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync-merged-api.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync-merged-api.test.ts @@ -50,7 +50,7 @@ beforeEach(() => { test('appsync supports merged API', () => { // WHEN - const mergedApi = new appsync.GraphqlApi(stack, 'merged-api', { + new appsync.GraphqlApi(stack, 'merged-api', { name: 'api', definition: appsync.Definition.fromSourceApis({ sourceApis: [ @@ -72,7 +72,7 @@ test('appsync supports merged API', () => { test('appsync supports merged API - ARN identifier flag enabled', () => { // WHEN - const mergedApi = new appsync.GraphqlApi(stackWithFlag, 'merged-api', { + new appsync.GraphqlApi(stackWithFlag, 'merged-api', { name: 'api', definition: appsync.Definition.fromSourceApis({ sourceApis: [ diff --git a/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts b/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts index 60181a10b6058..b8004edc470ca 100644 --- a/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts +++ b/packages/aws-cdk-lib/aws-appsync/test/appsync.test.ts @@ -335,7 +335,7 @@ test('when query limits are set, they should be used on API', () => { test('when query depth limit is out of range, it throws an error', () => { const errorString = 'You must specify a query depth limit between 0 and 75.'; - const buildWithLimit = (name, queryDepthLimit) => { + const buildWithLimit = (name: string, queryDepthLimit: number) => { new appsync.GraphqlApi(stack, name, { authorizationConfig: {}, name: 'query-limits', @@ -353,7 +353,7 @@ test('when query depth limit is out of range, it throws an error', () => { test('when resolver limit is out of range, it throws an error', () => { const errorString = 'You must specify a resolver count limit between 0 and 10000.'; - const buildWithLimit = (name, resolverCountLimit) => { + const buildWithLimit = (name: string, resolverCountLimit: number) => { new appsync.GraphqlApi(stack, name, { authorizationConfig: {}, name: 'query-limits', diff --git a/packages/aws-cdk-lib/aws-cloudformation/test/nested-stack.test.ts b/packages/aws-cdk-lib/aws-cloudformation/test/nested-stack.test.ts index 234d1d4ffbc23..de831b01b094e 100644 --- a/packages/aws-cdk-lib/aws-cloudformation/test/nested-stack.test.ts +++ b/packages/aws-cdk-lib/aws-cloudformation/test/nested-stack.test.ts @@ -9,7 +9,6 @@ import { App, CfnParameter, CfnResource, ContextProvider, LegacyStackSynthesizer import * as cxapi from '../../cx-api'; import { NestedStack } from '../lib/nested-stack'; -/* eslint-disable @cdklabs/no-core-construct */ /* eslint-disable max-len */ describeDeprecated('NestedStack', () => { diff --git a/packages/aws-cdk-lib/aws-cloudformation/test/resource.test.ts b/packages/aws-cdk-lib/aws-cloudformation/test/resource.test.ts index 236669c45ee73..00c01a88b471b 100644 --- a/packages/aws-cdk-lib/aws-cloudformation/test/resource.test.ts +++ b/packages/aws-cdk-lib/aws-cloudformation/test/resource.test.ts @@ -6,7 +6,6 @@ import * as sns from '../../aws-sns'; import * as cdk from '../../core'; import { CustomResource, CustomResourceProvider } from '../lib'; -/* eslint-disable @cdklabs/no-core-construct */ /* eslint-disable @stylistic/quote-props */ describeDeprecated('custom resources honor removalPolicy', () => { diff --git a/packages/aws-cdk-lib/aws-cloudfront-origins/test/s3-bucket-origin.test.ts b/packages/aws-cdk-lib/aws-cloudfront-origins/test/s3-bucket-origin.test.ts index fec73f76314eb..f885b8df686f3 100644 --- a/packages/aws-cdk-lib/aws-cloudfront-origins/test/s3-bucket-origin.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront-origins/test/s3-bucket-origin.test.ts @@ -3,7 +3,7 @@ import * as cloudfront from '../../aws-cloudfront/index'; import * as origins from '../../aws-cloudfront-origins'; import * as kms from '../../aws-kms'; import * as s3 from '../../aws-s3/index'; -import { App, Duration, Fn, Stack } from '../../core'; +import { App, Duration, Stack } from '../../core'; describe('S3BucketOrigin', () => { describe('withOriginAccessControl', () => { diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts index 491b47fea2a48..63123db3738d4 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/distribution.test.ts @@ -1477,7 +1477,7 @@ describe('Distribution metrics tests', () => { additionalMetricsRequired: true, errorMetricName: `${errorCode} error rate`, })), - ]; + ] as const; const defaultMetrics = [ { name: 'Requests', method: 'metricRequests', statistic: 'Sum', additionalMetricsRequired: false, errorMetricName: '' }, @@ -1486,16 +1486,16 @@ describe('Distribution metrics tests', () => { { name: 'TotalErrorRate', method: 'metricTotalErrorRate', statistic: 'Average', additionalMetricsRequired: false, errorMetricName: '' }, { name: '4xxErrorRate', method: 'metric4xxErrorRate', statistic: 'Average', additionalMetricsRequired: false, errorMetricName: '' }, { name: '5xxErrorRate', method: 'metric5xxErrorRate', statistic: 'Average', additionalMetricsRequired: false, errorMetricName: '' }, - ]; + ] as const; - test.each(additionalMetrics.concat(defaultMetrics))('get %s metric', (metric) => { + test.each([... additionalMetrics, ...defaultMetrics])('get %s metric', (metric) => { const origin = defaultOrigin(); const dist = new Distribution(stack, 'MyDist', { defaultBehavior: { origin }, publishAdditionalMetrics: metric.additionalMetricsRequired, }); - const metricObj = dist[metric.method](); + const metricObj = (dist as any)[metric.method](); expect(metricObj).toEqual(new cloudwatch.Metric({ namespace: 'AWS/CloudFront', @@ -1514,7 +1514,7 @@ describe('Distribution metrics tests', () => { }); expect(() => { - dist[metric.method](); + (dist as any)[metric.method](); }).toThrow(new RegExp(`${metric.errorMetricName} metric is only available if 'publishAdditionalMetrics' is set 'true'`)); }); }); @@ -1576,7 +1576,7 @@ describe('attachWebAclId', () => { test('does not validate unresolved token webAclId', () => { const origin = defaultOrigin(); - const distribution = new Distribution(stack, 'MyDist', { + new Distribution(stack, 'MyDist', { defaultBehavior: { origin }, webAclId: Token.asString({ Ref: 'SomeWebAcl' }), // unresolved token }); diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/key-value-store.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/key-value-store.test.ts index d59746d6f9cfc..e90b98cc667ac 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/key-value-store.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/key-value-store.test.ts @@ -1,7 +1,7 @@ import * as path from 'node:path'; import { Match, Template } from '../../assertions'; import * as s3 from '../../aws-s3'; -import { App, Stack } from '../../core'; +import { Stack } from '../../core'; import { KeyValueStore, ImportSource } from '../lib'; describe('Key Value Store', () => { diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/test-origin.ts b/packages/aws-cdk-lib/aws-cloudfront/test/test-origin.ts index 89136213a3928..2509ce06f4266 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/test-origin.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/test-origin.ts @@ -26,7 +26,7 @@ export class TestOriginGroup implements IOrigin { private readonly primaryDomainName: string, private readonly secondaryDomainName: string, ) {} - /* eslint-disable @cdklabs/no-core-construct */ + public bind(scope: Construct, options: OriginBindOptions): OriginBindConfig { const primaryOrigin = new TestOrigin(this.primaryDomainName); const secondaryOrigin = new TestOrigin(this.secondaryDomainName); diff --git a/packages/aws-cdk-lib/aws-cloudwatch/test/alarm-anomaly-detection.test.ts b/packages/aws-cdk-lib/aws-cloudwatch/test/alarm-anomaly-detection.test.ts index 855b33b0dfb7e..cca8cf05b4817 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/test/alarm-anomaly-detection.test.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/test/alarm-anomaly-detection.test.ts @@ -1,7 +1,6 @@ -import { Construct } from 'constructs'; -import { Match, Template, Annotations } from '../../assertions'; +import { Match, Template } from '../../assertions'; import { Duration, Stack } from '../../core'; -import { Alarm, AnomalyDetectionAlarm, ComparisonOperator, CfnAlarm, Metric, MathExpression, TreatMissingData } from '../lib'; +import { Alarm, AnomalyDetectionAlarm, ComparisonOperator, Metric, MathExpression, TreatMissingData } from '../lib'; describe('AnomalyDetectionAlarm', () => { let stack: Stack; @@ -173,7 +172,7 @@ describe('AnomalyDetectionAlarm', () => { describe('Behavior', () => { test('correctly sets up anomaly detection band', () => { // WHEN - const alarm = new AnomalyDetectionAlarm(stack, 'Alarm', { + new AnomalyDetectionAlarm(stack, 'Alarm', { metric, evaluationPeriods: 3, comparisonOperator: ComparisonOperator.LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD, diff --git a/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts b/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts index 503743a31977c..1b90424ac12f2 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/test/graphs.test.ts @@ -1111,9 +1111,6 @@ describe('Graphs', () => { }); test('cannot specify an end without a start in GraphWidget', () => { - // GIVEN - const stack = new Stack(); - // THEN expect(() => { new GraphWidget({ @@ -1125,9 +1122,6 @@ describe('Graphs', () => { }); test('cannot specify an end without a start in SingleValueWidget', () => { - // GIVEN - const stack = new Stack(); - // THEN expect(() => { new SingleValueWidget({ @@ -1138,9 +1132,6 @@ describe('Graphs', () => { }); test('cannot specify an end without a start in GaugeWidget', () => { - // GIVEN - const stack = new Stack(); - // THEN expect(() => { new GaugeWidget({ @@ -1197,8 +1188,8 @@ describe('Graphs', () => { }); describe('TableWidget', () => { - let stack; - let metric; + let stack: Stack; + let metric: Metric; beforeEach(() => { stack = new Stack(); diff --git a/packages/aws-cdk-lib/aws-codebuild/test/build-spec.test.ts b/packages/aws-cdk-lib/aws-codebuild/test/build-spec.test.ts index a148394bbb903..5387ba1ede648 100644 --- a/packages/aws-cdk-lib/aws-codebuild/test/build-spec.test.ts +++ b/packages/aws-cdk-lib/aws-codebuild/test/build-spec.test.ts @@ -2,7 +2,6 @@ import * as codebuild from '../lib'; /* eslint-disable @stylistic/quote-props */ -/* eslint-disable quotes */ describe('Test BuildSpec merge', () => { test('merge two simple specs', () => { diff --git a/packages/aws-cdk-lib/aws-codepipeline-actions/test/cloudformation/pipeline-actions.test.ts b/packages/aws-cdk-lib/aws-codepipeline-actions/test/cloudformation/pipeline-actions.test.ts index 2f89bd4a1be6c..4b465226c8df3 100644 --- a/packages/aws-cdk-lib/aws-codepipeline-actions/test/cloudformation/pipeline-actions.test.ts +++ b/packages/aws-cdk-lib/aws-codepipeline-actions/test/cloudformation/pipeline-actions.test.ts @@ -96,9 +96,9 @@ describe('Pipeline Actions', () => { Condition: { StringEqualsIfExists: { 'cloudformation:ChangeSetName': 'MyChangeSet' } }, Effect: 'Allow', Resource: [ - // eslint-disable-next-line max-len + { 'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':cloudformation:', { Ref: 'AWS::Region' }, ':', { Ref: 'AWS::AccountId' }, ':stack/StackA/*']] }, - // eslint-disable-next-line max-len + { 'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':cloudformation:', { Ref: 'AWS::Region' }, ':', { Ref: 'AWS::AccountId' }, ':stack/StackB/*']] }, ], }, @@ -168,9 +168,9 @@ describe('Pipeline Actions', () => { Condition: { StringEqualsIfExists: { 'cloudformation:ChangeSetName': 'MyChangeSet' } }, Effect: 'Allow', Resource: [ - // eslint-disable-next-line max-len + { 'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':cloudformation:', { Ref: 'AWS::Region' }, ':', { Ref: 'AWS::AccountId' }, ':stack/StackA/*']] }, - // eslint-disable-next-line max-len + { 'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':cloudformation:', { Ref: 'AWS::Region' }, ':', { Ref: 'AWS::AccountId' }, ':stack/StackB/*']] }, ], }, diff --git a/packages/aws-cdk-lib/aws-codepipeline-actions/test/codecommit/codecommit-source-action.test.ts b/packages/aws-cdk-lib/aws-codepipeline-actions/test/codecommit/codecommit-source-action.test.ts index 56ba7ab80b157..ac163c8cd9b82 100644 --- a/packages/aws-cdk-lib/aws-codepipeline-actions/test/codecommit/codecommit-source-action.test.ts +++ b/packages/aws-cdk-lib/aws-codepipeline-actions/test/codecommit/codecommit-source-action.test.ts @@ -199,16 +199,16 @@ describe('CodeCommit Source Action', () => { const stack = new Stack(); const eventPattern - = { - 'detail-type': ['CodeCommit Repository State Change'], - 'resources': ['foo'], - 'source': ['aws.codecommit'], - 'detail': { - referenceType: ['branch'], - event: ['referenceCreated', 'referenceUpdated'], - referenceName: ['test-branch'], - }, - }; + = { + 'detail-type': ['CodeCommit Repository State Change'], + 'resources': ['foo'], + 'source': ['aws.codecommit'], + 'detail': { + referenceType: ['branch'], + event: ['referenceCreated', 'referenceUpdated'], + referenceName: ['test-branch'], + }, + }; minimalPipeline(stack, cpactions.CodeCommitTrigger.EVENTS, { customEventRule: { diff --git a/packages/aws-cdk-lib/aws-codepipeline-actions/test/commands/commands-action.test.ts b/packages/aws-cdk-lib/aws-codepipeline-actions/test/commands/commands-action.test.ts index 7318f11be6cd2..d2a351d913733 100644 --- a/packages/aws-cdk-lib/aws-codepipeline-actions/test/commands/commands-action.test.ts +++ b/packages/aws-cdk-lib/aws-codepipeline-actions/test/commands/commands-action.test.ts @@ -1,6 +1,5 @@ import { Match, Template } from '../../../assertions'; import * as codepipeline from '../../../aws-codepipeline'; -import { Key } from '../../../aws-kms'; import { Bucket } from '../../../aws-s3'; import { Stack } from '../../../core'; import * as cpactions from '../../lib'; diff --git a/packages/aws-cdk-lib/aws-codepipeline-actions/test/inspector/inspector-source-code-scan-action.test.ts b/packages/aws-cdk-lib/aws-codepipeline-actions/test/inspector/inspector-source-code-scan-action.test.ts index caaa489bf4735..7da447ce3fe6b 100644 --- a/packages/aws-cdk-lib/aws-codepipeline-actions/test/inspector/inspector-source-code-scan-action.test.ts +++ b/packages/aws-cdk-lib/aws-codepipeline-actions/test/inspector/inspector-source-code-scan-action.test.ts @@ -1,6 +1,5 @@ import { Match, Template } from '../../../assertions'; import * as codepipeline from '../../../aws-codepipeline'; -import * as ecr from '../../../aws-ecr'; import { Bucket } from '../../../aws-s3'; import { Stack } from '../../../core'; import * as cpactions from '../../lib'; diff --git a/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts b/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts index 3768f3386e79a..e645de0fe2052 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts +++ b/packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts @@ -27,7 +27,6 @@ import { InputFormat, ApproximateCreationDateTimePrecision, ContributorInsightsMode, - SchemaOptions, } from '../lib'; import { ReplicaProvider } from '../lib/replica-provider'; @@ -4413,7 +4412,7 @@ test('Resource policy test', () => { }); // WHEN - const table = new Table(stack, 'Table', { + new Table(stack, 'Table', { partitionKey: { name: 'id', type: AttributeType.STRING }, resourcePolicy: doc, }); @@ -4727,7 +4726,7 @@ test('Kinesis Stream - precision timestamp', () => { const stream = new kinesis.Stream(stack, 'Stream'); // WHEN - const table = new Table(stack, 'Table', { + new Table(stack, 'Table', { partitionKey: { name: 'id', type: AttributeType.STRING }, kinesisStream: stream, kinesisPrecisionTimestamp: ApproximateCreationDateTimePrecision.MILLISECOND, @@ -4753,7 +4752,7 @@ test('Kinesis Stream - precision timestamp', () => { test('Contributor Insights Specification - table', () => { const stack = new Stack(); - const table = new Table(stack, CONSTRUCT_NAME, { + new Table(stack, CONSTRUCT_NAME, { partitionKey: TABLE_PARTITION_KEY, sortKey: TABLE_SORT_KEY, contributorInsightsSpecification: { @@ -4784,7 +4783,7 @@ test('Contributor Insights Specification - table', () => { test('Contributor Insights Specification - table - without mode', () => { const stack = new Stack(); - const table = new Table(stack, CONSTRUCT_NAME, { + new Table(stack, CONSTRUCT_NAME, { partitionKey: TABLE_PARTITION_KEY, sortKey: TABLE_SORT_KEY, contributorInsightsSpecification: { @@ -4985,7 +4984,7 @@ test('Throws when multi-attribute sortKeys and sortKey are specified', () => { sortKey: TABLE_SORT_KEY, }); - const index = table.addGlobalSecondaryIndex({ + table.addGlobalSecondaryIndex({ indexName: GSI_NAME, partitionKeys: [GSI_PARTITION_KEY, GSI_PARTITION_KEY_TWO], sortKey: GSI_SORT_KEY, diff --git a/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts b/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts index 380b460fb1e0b..cff0b48cb7c48 100644 --- a/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts +++ b/packages/aws-cdk-lib/aws-dynamodb/test/table-v2.test.ts @@ -3192,7 +3192,7 @@ test('Resource policy test', () => { }); // WHEN - const table = new TableV2(stack, 'Table', { + new TableV2(stack, 'Table', { partitionKey: { name: 'metric', type: AttributeType.STRING }, resourcePolicy: doc, }); @@ -3229,7 +3229,7 @@ test('Warm Throughput test on-demand', () => { const stack = new Stack(undefined, 'Stack', { env: { region: 'eu-west-1' } }); // WHEN - const table = new TableV2(stack, 'Table', { + new TableV2(stack, 'Table', { partitionKey: { name: 'id', type: AttributeType.STRING }, warmThroughput: { readUnitsPerSecond: 13000, @@ -3556,7 +3556,7 @@ test('TableV2 addToResourcePolicy allows scoped ARN resources when table has exp test('Contributor Insights Specification - tableV2', () => { const stack = new Stack(); - const table = new TableV2(stack, 'TableV2', { + new TableV2(stack, 'TableV2', { partitionKey: { name: 'hashKey', type: AttributeType.STRING }, sortKey: { name: 'sortKey', type: AttributeType.NUMBER }, contributorInsightsSpecification: { @@ -3593,7 +3593,7 @@ test('Contributor Insights Specification - tableV2', () => { test('Contributor Insights Specification - tableV2 - without mode', () => { const stack = new Stack(); - const table = new TableV2(stack, 'TableV2', { + new TableV2(stack, 'TableV2', { partitionKey: { name: 'hashKey', type: AttributeType.STRING }, sortKey: { name: 'sortKey', type: AttributeType.NUMBER }, contributorInsightsSpecification: { @@ -3628,7 +3628,7 @@ test('Contributor Insights Specification - tableV2 - without mode', () => { test('Contributor Insights Specification - index', () => { const stack = new Stack(undefined, 'Stack', { env: { region: 'eu-west-1' } }); - const table = new TableV2(stack, 'TableV2', { + new TableV2(stack, 'TableV2', { partitionKey: { name: 'hashKey', type: AttributeType.STRING }, sortKey: { name: 'sortKey', type: AttributeType.NUMBER }, globalSecondaryIndexes: [ @@ -3702,7 +3702,7 @@ test('ContributorInsightsSpecification && ContributorInsights - v2', () => { const stack = new Stack(); expect(() => { - const table = new TableV2(stack, 'Tablev2', { + new TableV2(stack, 'Tablev2', { partitionKey: { name: 'pk', type: AttributeType.STRING }, sortKey: { name: 'sk', type: AttributeType.STRING }, contributorInsights: true, diff --git a/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts b/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts index 560839ca8d25d..18adf98b4037a 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/bastion-host.test.ts @@ -229,7 +229,6 @@ describe('bastion host', () => { const stack = new Stack(); const vpc = new Vpc(stack, 'VPC'); const sshKeys = ['foo', 'bar']; - const hashdigest = '450c0dd0c96b2841'; // WHEN const bastionHostOld = new BastionHostLinux(stack, 'BastionHostUserDataCausesReplacement', { diff --git a/packages/aws-cdk-lib/aws-ec2/test/instance-requirements.test.ts b/packages/aws-cdk-lib/aws-ec2/test/instance-requirements.test.ts index 43c1006b28ea5..2d5102bfa6e89 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/instance-requirements.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/instance-requirements.test.ts @@ -1,4 +1,3 @@ -import { Size } from '../../core'; import { AcceleratorManufacturer, AcceleratorName, @@ -7,7 +6,6 @@ import { BurstablePerformance, CpuManufacturer, InstanceGeneration, - InstanceRequirementsConfig, LocalStorage, LocalStorageType, } from '../lib'; 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 66959367afc9a..7af3879c6f8c3 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 @@ -394,7 +394,7 @@ type CfnSplit = { count: number; hostbits: number; select: number; -} +}; test.each([ // Index into first block diff --git a/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts b/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts index d4278cc394aba..3b6e0653e0951 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts @@ -39,8 +39,6 @@ import { WindowsVersion, } from '../lib'; -/* eslint-disable jest/expect-expect */ - describe('LaunchTemplate', () => { let app: App; let stack: Stack; diff --git a/packages/aws-cdk-lib/aws-ec2/test/volume.test.ts b/packages/aws-cdk-lib/aws-ec2/test/volume.test.ts index 936dac43858ff..26ea86787b084 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/volume.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/volume.test.ts @@ -1,7 +1,6 @@ import { Match, Template } from '../../assertions'; import { AccountRootPrincipal, Role } from '../../aws-iam'; import * as kms from '../../aws-kms'; -import { SnapStartConf } from '../../aws-lambda'; import * as cdk from '../../core'; import { SizeRoundingBehavior } from '../../core'; import * as cxapi from '../../cx-api'; diff --git a/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint-service.test.ts b/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint-service.test.ts index 40e95bb5a406e..a2f819c94b345 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint-service.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint-service.test.ts @@ -3,7 +3,6 @@ import { Template } from '../../assertions'; import { ArnPrincipal } from '../../aws-iam'; import { Stack } from '../../core'; -// eslint-disable-next-line max-len import { IpAddressType, IVpcEndpointServiceLoadBalancer, Vpc, VpcEndpointService } from '../lib'; /** diff --git a/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint.test.ts b/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint.test.ts index 0837ee5d0cc8f..ad704d4a82ef1 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/vpc-endpoint.test.ts @@ -2,7 +2,7 @@ import { Match, Template } from '../../assertions'; import { AnyPrincipal, PolicyStatement } from '../../aws-iam'; import * as cxschema from '../../cloud-assembly-schema'; import { ContextProvider, Fn, Stack } from '../../core'; -// eslint-disable-next-line max-len + import { GatewayVpcEndpoint, GatewayVpcEndpointAwsService, 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 f81c1f33f29b6..61017268f452c 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,7 +380,6 @@ 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-ec2/test/vpc.test.ts b/packages/aws-cdk-lib/aws-ec2/test/vpc.test.ts index 44e2e2f4bde0d..31b210185f122 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/vpc.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/vpc.test.ts @@ -368,7 +368,7 @@ describe('vpc', () => { test('with only reserved subnets as public subnets, should not create the internet gateway', () => { const stack = getTestStack(); - const vpc = new Vpc(stack, 'TheVPC', { + new Vpc(stack, 'TheVPC', { subnetConfiguration: [ { subnetType: SubnetType.PRIVATE_ISOLATED, @@ -387,7 +387,7 @@ describe('vpc', () => { test('with only reserved subnets as private subnets with egress, should not create the internet gateway', () => { const stack = getTestStack(); - const vpc = new Vpc(stack, 'TheVPC', { + new Vpc(stack, 'TheVPC', { subnetConfiguration: [ { subnetType: SubnetType.PRIVATE_ISOLATED, @@ -2305,7 +2305,6 @@ describe('vpc', () => { const subnet = Subnet.fromSubnetId(stack, 'subnet1', 'pub-1'); // THEN - // eslint-disable-next-line max-len expect(() => subnet.availabilityZone).toThrow("You cannot reference a Subnet's availability zone if it was not supplied. Add the availabilityZone when importing using Subnet.fromSubnetAttributes()"); }); @@ -2318,7 +2317,6 @@ describe('vpc', () => { // THEN expect(subnet.subnetId).toEqual('pub-1'); - // eslint-disable-next-line max-len expect(() => subnet.availabilityZone).toThrow("You cannot reference a Subnet's availability zone if it was not supplied. Add the availabilityZone when importing using Subnet.fromSubnetAttributes()"); }); @@ -2742,7 +2740,7 @@ describe('vpc', () => { const stack = new Stack(app, 'DualStackStack'); // WHEN - const vpc = new Vpc(stack, 'Vpc', { + new Vpc(stack, 'Vpc', { ipProtocol: IpProtocol.DUAL_STACK, }); @@ -2760,7 +2758,7 @@ describe('vpc', () => { const stack = new Stack(app, 'DualStackStack'); // WHEN - const vpc = new Vpc(stack, 'Vpc', { + new Vpc(stack, 'Vpc', { ipProtocol: IpProtocol.DUAL_STACK, subnetConfiguration: [ { @@ -2779,7 +2777,7 @@ describe('vpc', () => { const stack = new Stack(app, 'DualStackStack'); // WHEN - const vpc = new Vpc(stack, 'Vpc', { + new Vpc(stack, 'Vpc', { ipProtocol: IpProtocol.DUAL_STACK, subnetConfiguration: [ { @@ -2803,7 +2801,7 @@ describe('vpc', () => { const stack = new Stack(app, 'DualStackStack'); // WHEN stack.node.setContext(EC2_REQUIRE_PRIVATE_SUBNETS_FOR_EGRESSONLYINTERNETGATEWAY, true); - const vpc = new Vpc(stack, 'Vpc', { + new Vpc(stack, 'Vpc', { ipProtocol: IpProtocol.DUAL_STACK, subnetConfiguration: [ { @@ -2826,7 +2824,7 @@ describe('vpc', () => { const stack = new Stack(app, 'DualStackStack'); stack.node.setContext(EC2_REQUIRE_PRIVATE_SUBNETS_FOR_EGRESSONLYINTERNETGATEWAY, true); // WHEN - const vpc = new Vpc(stack, 'Vpc', { + new Vpc(stack, 'Vpc', { ipProtocol: IpProtocol.DUAL_STACK, subnetConfiguration: [ { diff --git a/packages/aws-cdk-lib/aws-ecr/test/repository.test.ts b/packages/aws-cdk-lib/aws-ecr/test/repository.test.ts index d3815a147abf6..e1785c5337c66 100644 --- a/packages/aws-cdk-lib/aws-ecr/test/repository.test.ts +++ b/packages/aws-cdk-lib/aws-ecr/test/repository.test.ts @@ -194,7 +194,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":1,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}', }, }); @@ -211,7 +211,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":1,"selection":{"tagStatus":"tagged","tagPatternList":["abc*"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}', }, }); @@ -272,7 +272,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":1,"selection":{"tagStatus":"tagged","tagPatternList":["abc*d*e*f*"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}', }, }); @@ -335,7 +335,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":1,"selection":{"tagStatus":"any","countType":"sinceImagePushed","countNumber":5,"countUnit":"days"},"action":{"type":"expire"}}]}', }, }); @@ -354,7 +354,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":1,"selection":{"tagStatus":"any","countType":"imageCountMoreThan","countNumber":5},"action":{"type":"expire"}}]}', }, }); @@ -372,7 +372,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["b"],"countType":"imageCountMoreThan","countNumber":5},"action":{"type":"expire"}},{"rulePriority":11,"selection":{"tagStatus":"tagged","tagPrefixList":["a"],"countType":"imageCountMoreThan","countNumber":5},"action":{"type":"expire"}}]}', }, }); @@ -390,7 +390,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":1,"selection":{"tagStatus":"tagged","tagPrefixList":["important"],"countType":"imageCountMoreThan","countNumber":999},"action":{"type":"expire"}},{"rulePriority":2,"selection":{"tagStatus":"any","countType":"imageCountMoreThan","countNumber":5},"action":{"type":"expire"}}]}', }, }); @@ -410,7 +410,7 @@ describe('repository', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { 'LifecyclePolicy': { - // eslint-disable-next-line max-len + 'LifecyclePolicyText': '{"rules":[{"rulePriority":1,"selection":{"tagStatus":"any","countType":"imageCountMoreThan","countNumber":3},"action":{"type":"expire"}}]}', }, }); 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 fa2237529b4d2..665ba729954b9 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 @@ -1366,7 +1366,7 @@ describe('ApplicationLoadBalancedFargateService', () => { }, }, desiredCount: 2, - taskDefinition, + taskDefinition: taskDefinition as any, })).toThrow(); }); diff --git a/packages/aws-cdk-lib/aws-ecs/test/alternate-target-configuration.test.ts b/packages/aws-cdk-lib/aws-ecs/test/alternate-target-configuration.test.ts index ea807f95bb4a0..35b8adbf22dce 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/alternate-target-configuration.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/alternate-target-configuration.test.ts @@ -3,7 +3,6 @@ import * as ec2 from '../../aws-ec2'; import * as elbv2 from '../../aws-elasticloadbalancingv2'; import * as iam from '../../aws-iam'; import * as cdk from '../../core'; -import { App, Stack } from '../../core'; import * as ecs from '../lib'; describe('AlternateTarget', () => { @@ -303,7 +302,7 @@ describe('AlternateTarget', () => { taskDefinition, }); - const nlb = new elbv2.NetworkLoadBalancer(stack, 'NLB', { vpc }); + new elbv2.NetworkLoadBalancer(stack, 'NLB', { vpc }); const nlbBlueTargetGroup = new elbv2.NetworkTargetGroup(stack, 'NlbBlueTG', { vpc, port: 80, diff --git a/packages/aws-cdk-lib/aws-ecs/test/base-service.test.ts b/packages/aws-cdk-lib/aws-ecs/test/base-service.test.ts index d2b332c95dd52..55f85ab38fff8 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/base-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/base-service.test.ts @@ -1,9 +1,7 @@ import { Template, Match } from '../../assertions'; import * as ec2 from '../../aws-ec2'; -import * as elbv2 from '../../aws-elasticloadbalancingv2'; import * as iam from '../../aws-iam'; import * as kms from '../../aws-kms'; -import * as lambda from '../../aws-lambda'; import * as cdk from '../../core'; import { App, Stack } from '../../core'; import * as cxapi from '../../cx-api'; @@ -218,7 +216,7 @@ describe('For alarm-based rollbacks', () => { maxHealthyPercent: 200, }); - const template = Template.fromStack(stack); + Template.fromStack(stack); // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECS::Service', { DeploymentConfiguration: settings, 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 0116283340951..ec74288d20c93 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/cluster.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/cluster.test.ts @@ -96,7 +96,6 @@ describe('cluster', () => { { Ref: 'EcsCluster97242B84', }, - // eslint-disable-next-line max-len ' >> /etc/ecs/ecs.config\nsudo iptables --insert FORWARD 1 --in-interface docker+ --destination 169.254.169.254/32 --jump DROP\nsudo service iptables save\necho ECS_AWSVPC_BLOCK_IMDS=true >> /etc/ecs/ecs.config', ], ], @@ -265,7 +264,6 @@ describe('cluster', () => { { Ref: 'EcsCluster97242B84', }, - // eslint-disable-next-line max-len ' >> /etc/ecs/ecs.config\nsudo iptables --insert FORWARD 1 --in-interface docker+ --destination 169.254.169.254/32 --jump DROP\nsudo service iptables save\necho ECS_AWSVPC_BLOCK_IMDS=true >> /etc/ecs/ecs.config', ], ], @@ -791,7 +789,6 @@ describe('cluster', () => { { Ref: 'EcsCluster97242B84', }, - // eslint-disable-next-line max-len ' >> /etc/ecs/ecs.config\nsudo iptables --insert FORWARD 1 --in-interface docker+ --destination 169.254.169.254/32 --jump DROP\nsudo service iptables save\necho ECS_AWSVPC_BLOCK_IMDS=true >> /etc/ecs/ecs.config', ], ], @@ -1785,7 +1782,6 @@ describe('cluster', () => { { Ref: 'EcsCluster97242B84', }, - // eslint-disable-next-line max-len ' >> /etc/ecs/ecs.config\nsudo iptables --insert FORWARD 1 --in-interface docker+ --destination 169.254.169.254/32 --jump DROP\nsudo service iptables save\necho ECS_AWSVPC_BLOCK_IMDS=true >> /etc/ecs/ecs.config', ], ], @@ -4980,7 +4976,7 @@ describe('canContainersAccessInstanceRole behaviour', () => { wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole }); }).toThrow(cdkConfigurations.expectedSynthError); } else { - wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole }); + wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole as any }); cdkConfigurations.assertion(stack); } }); @@ -5273,7 +5269,7 @@ describe('canContainersAccessInstanceRole behaviour', () => { wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole }); }).toThrow(cdkConfigurations.expectedSynthError); } else { - wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole }); + wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole as any }); cdkConfigurations.assertion(stack); } }); @@ -5587,7 +5583,7 @@ describe('canContainersAccessInstanceRole behaviour', () => { wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole }); }).toThrow(cdkConfigurations.expectedSynthError); } else { - wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole }); + wayToCreateCluster({ stack, canContainersAccessInstanceRole: cdkConfigurations.canContainersAccessInstanceRole as any }); cdkConfigurations.assertion(stack); } }); diff --git a/packages/aws-cdk-lib/aws-ecs/test/credential-spec.test.ts b/packages/aws-cdk-lib/aws-ecs/test/credential-spec.test.ts index 158e08a2f06d5..3d54db6c3b981 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/credential-spec.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/credential-spec.test.ts @@ -3,8 +3,6 @@ import * as ssm from '../../aws-ssm'; import * as cdk from '../../core'; import * as ecs from '../lib'; -/* eslint-disable dot-notation */ - describe('credential spec', () => { describe('ecs.DomainJoinedCredentialSpec', () => { test('returns the correct prefixId and location', () => { diff --git a/packages/aws-cdk-lib/aws-ecs/test/deployment-lifecycle-hook-target.test.ts b/packages/aws-cdk-lib/aws-ecs/test/deployment-lifecycle-hook-target.test.ts index ac9022533dcc4..90a92d7fe577c 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/deployment-lifecycle-hook-target.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/deployment-lifecycle-hook-target.test.ts @@ -3,7 +3,6 @@ import * as ec2 from '../../aws-ec2'; import * as iam from '../../aws-iam'; import * as lambda from '../../aws-lambda'; import * as cdk from '../../core'; -import { App, Stack } from '../../core'; import * as ecs from '../lib'; describe('DeploymentLifecycleHookTarget', () => { diff --git a/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts b/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts index b9ffc8a90fd95..c60156d726420 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts @@ -1666,7 +1666,7 @@ describe('ec2 service', () => { addDefaultCapacityProvider(cluster, stack, vpc); const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); - const container = taskDefinition.addContainer('web', { + taskDefinition.addContainer('web', { image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), memoryLimitMiB: 512, }); @@ -1688,7 +1688,7 @@ describe('ec2 service', () => { addDefaultCapacityProvider(cluster, stack, vpc); const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); - const container = taskDefinition.addContainer('web', { + taskDefinition.addContainer('web', { image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), memoryLimitMiB: 512, }); @@ -1711,7 +1711,7 @@ describe('ec2 service', () => { addDefaultCapacityProvider(cluster, stack, vpc); const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); - const container = taskDefinition.addContainer('web', { + taskDefinition.addContainer('web', { image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), memoryLimitMiB: 512, }); @@ -1735,7 +1735,7 @@ describe('ec2 service', () => { addDefaultCapacityProvider(cluster, stack, vpc); const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); - const container = taskDefinition.addContainer('web', { + taskDefinition.addContainer('web', { image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), memoryLimitMiB: 512, }); diff --git a/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-task-definition.test.ts b/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-task-definition.test.ts index 48e053c52b5be..245c4b4bde914 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-task-definition.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-task-definition.test.ts @@ -454,7 +454,7 @@ describe('ec2 task definition', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}', RegistryId: '123456789101', }, diff --git a/packages/aws-cdk-lib/aws-ecs/test/environment-file.test.ts b/packages/aws-cdk-lib/aws-ecs/test/environment-file.test.ts index 695185078b82c..fa9c071325a9f 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/environment-file.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/environment-file.test.ts @@ -3,8 +3,6 @@ import * as cdk from '../../core'; import * as cxapi from '../../cx-api'; import * as ecs from '../lib'; -/* eslint-disable dot-notation */ - describe('environment file', () => { describe('ecs.EnvironmentFile.fromAsset', () => { test('fails if asset is not a single file', () => { diff --git a/packages/aws-cdk-lib/aws-ecs/test/external/external-service.test.ts b/packages/aws-cdk-lib/aws-ecs/test/external/external-service.test.ts index c5337a68d3ce7..eccf755060829 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/external/external-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/external/external-service.test.ts @@ -475,7 +475,7 @@ describe('external service', () => { test('warning if minHealthyPercent not set for an external service', () => { // GIVEN - const service = new ecs.ExternalService(stack, 'ExternalService', { + new ecs.ExternalService(stack, 'ExternalService', { cluster, taskDefinition, }); @@ -487,7 +487,7 @@ describe('external service', () => { test('no warning if minHealthyPercent set for an external service', () => { // GIVEN - const service = new ecs.ExternalService(stack, 'ExternalService', { + new ecs.ExternalService(stack, 'ExternalService', { cluster, taskDefinition, minHealthyPercent: 100, diff --git a/packages/aws-cdk-lib/aws-ecs/test/external/external-task-definition.test.ts b/packages/aws-cdk-lib/aws-ecs/test/external/external-task-definition.test.ts index 3ac58eaa8c680..1ad38d20d26bc 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/external/external-task-definition.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/external/external-task-definition.test.ts @@ -338,7 +338,7 @@ describe('external task definition', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', { LifecyclePolicy: { - // eslint-disable-next-line max-len + LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}', RegistryId: '123456789101', }, diff --git a/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-service.test.ts index 0a97e44b82fb5..8c4a8cefd15e2 100644 --- a/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs/test/fargate/fargate-service.test.ts @@ -1379,7 +1379,7 @@ describe('fargate service', () => { image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), }); - const service = new ecs.FargateService(stack, 'FargateService', { + new ecs.FargateService(stack, 'FargateService', { cluster, taskDefinition, }); @@ -1399,7 +1399,7 @@ describe('fargate service', () => { image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), }); - const service = new ecs.FargateService(stack, 'FargateService', { + new ecs.FargateService(stack, 'FargateService', { cluster, taskDefinition, minHealthyPercent: 50, @@ -4270,7 +4270,7 @@ describe('fargate service', () => { test('with circuit breaker and deployment controller feature flag enabled', () => { // GIVEN const disableCircuitBreakerEcsDeploymentControllerFeatureFlag = - { [cxapi.ECS_DISABLE_EXPLICIT_DEPLOYMENT_CONTROLLER_FOR_CIRCUIT_BREAKER]: true }; + { [cxapi.ECS_DISABLE_EXPLICIT_DEPLOYMENT_CONTROLLER_FOR_CIRCUIT_BREAKER]: true }; const app = new App({ context: disableCircuitBreakerEcsDeploymentControllerFeatureFlag }); const stack = new cdk.Stack(app); const cluster = new ecs.Cluster(stack, 'EcsCluster'); diff --git a/packages/aws-cdk-lib/aws-eks/test/access-policy.test.ts b/packages/aws-cdk-lib/aws-eks/test/access-policy.test.ts index 66cb2e69e20c4..a78e03bd6383a 100644 --- a/packages/aws-cdk-lib/aws-eks/test/access-policy.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/access-policy.test.ts @@ -67,7 +67,7 @@ describe('AccessPolicyArn', () => { ['AMAZON_EKS_ADMIN_VIEW_POLICY', 'AmazonEKSAdminViewPolicy'], ['AMAZON_EKS_EDIT_POLICY', 'AmazonEKSEditPolicy'], ['AMAZON_EKS_VIEW_POLICY', 'AmazonEKSViewPolicy'], - ]; + ] as const; test.each(policyTestCases)('static property %s', (propertyName, policyName) => { expect(AccessPolicyArn[propertyName].policyArn).toEqual(`arn:${Aws.PARTITION}:eks::aws:cluster-access-policy/${policyName}`); diff --git a/packages/aws-cdk-lib/aws-eks/test/awsauth.test.ts b/packages/aws-cdk-lib/aws-eks/test/awsauth.test.ts index 9f0d93ade959f..b92a43979d907 100644 --- a/packages/aws-cdk-lib/aws-eks/test/awsauth.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/awsauth.test.ts @@ -6,8 +6,6 @@ import * as cdk from '../../core'; import { Cluster, KubernetesManifest, KubernetesVersion, AuthenticationMode } from '../lib'; import { AwsAuth } from '../lib/aws-auth'; -/* eslint-disable max-len */ - const CLUSTER_VERSION = KubernetesVersion.V1_16; describe('aws auth', () => { diff --git a/packages/aws-cdk-lib/aws-eks/test/cluster.test.ts b/packages/aws-cdk-lib/aws-eks/test/cluster.test.ts index 28f8c831f94f3..cd6f12b80ace9 100644 --- a/packages/aws-cdk-lib/aws-eks/test/cluster.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/cluster.test.ts @@ -17,8 +17,6 @@ import { HelmChart } from '../lib'; import { KubectlProvider } from '../lib/kubectl-provider'; import { BottleRocketImage } from '../lib/private/bottlerocket'; -/* eslint-disable max-len */ - const CLUSTER_VERSION = eks.KubernetesVersion.V1_25; describe('cluster', () => { @@ -1510,7 +1508,7 @@ describe('cluster', () => { test('throws warning when `outputConfigCommand=true` and `mastersRole` is not specified', () => { // GIVEN - const { app, stack } = testFixtureNoVpc(); + const { stack } = testFixtureNoVpc(); // WHEN new eks.Cluster(stack, 'Cluster', { @@ -3508,16 +3506,6 @@ describe('cluster', () => { }); }); - describe('kubectlLayer annotation', () => { - function message(version: string) { - return [ - `You created a cluster with Kubernetes Version 1.${version} without specifying the kubectlLayer property.`, - 'The property will become required instead of optional in 2025 Jan. Please update your CDK code to provide a kubectlLayer.', - '[ack: @aws-cdk/aws-eks:clusterKubectlLayerNotSpecified]', - ].join(' '); - } - }); - test('custom awscli layer can be provided', () => { // GIVEN const { stack } = testFixture(); @@ -3789,6 +3777,7 @@ describe('cluster', () => { cidrs: remoteNodeNetworkCidrs, }, ], + kubectlLayer: undefined as any, }); // THEN @@ -3824,6 +3813,7 @@ describe('cluster', () => { cidrs: remotePodNetworkCidrs, }, ], + kubectlLayer: undefined as any, }); // THEN @@ -3866,6 +3856,7 @@ describe('cluster', () => { cidrs: remotePodNetworkCidrs, }, ], + kubectlLayer: undefined as any, }); }).toThrow(`Remote node network CIDR block ${overlappingCidr} should not overlap with remote pod network CIDR block ${overlappingCidr}`); }); @@ -3889,6 +3880,7 @@ describe('cluster', () => { cidrs: remoteNodeNetworkCidrs2, }, ], + kubectlLayer: undefined as any, }); }).toThrow(`CIDR block ${overlappingCidr} in remote node network #1 should not overlap with CIDR block ${overlappingCidr} in remote node network #2`); }); @@ -3918,6 +3910,7 @@ describe('cluster', () => { cidrs: remotePodNetworkCidrs2, }, ], + kubectlLayer: undefined as any, }); }).toThrow(`CIDR block ${overlappingCidr} in remote pod network #1 should not overlap with CIDR block ${overlappingCidr} in remote pod network #2`); }); @@ -3937,6 +3930,7 @@ describe('cluster', () => { cidrs: remoteNodeNetworkCidrs, }, ], + kubectlLayer: undefined as any, }); }).toThrow(`CIDR ${overlappingCidr} should not overlap with another CIDR in remote node network #1`); }); @@ -3962,6 +3956,7 @@ describe('cluster', () => { cidrs: remotePodNetworkCidrs, }, ], + kubectlLayer: undefined as any, }); }).toThrow(`CIDR ${overlappingCidr} should not overlap with another CIDR in remote pod network #1`); }); diff --git a/packages/aws-cdk-lib/aws-eks/test/example.ssh-into-nodes.lit.ts b/packages/aws-cdk-lib/aws-eks/test/example.ssh-into-nodes.lit.ts index 7412b4b996a4d..f49b8cbf06d8c 100644 --- a/packages/aws-cdk-lib/aws-eks/test/example.ssh-into-nodes.lit.ts +++ b/packages/aws-cdk-lib/aws-eks/test/example.ssh-into-nodes.lit.ts @@ -11,6 +11,7 @@ class EksClusterStack extends cdk.Stack { const cluster = new eks.Cluster(this, 'EKSCluster', { vpc, version: eks.KubernetesVersion.V1_21, + kubectlLayer: undefined as any, }); /// !show diff --git a/packages/aws-cdk-lib/aws-eks/test/fargate.test.ts b/packages/aws-cdk-lib/aws-eks/test/fargate.test.ts index 485a39d4a4e11..e123cac0f7f29 100644 --- a/packages/aws-cdk-lib/aws-eks/test/fargate.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/fargate.test.ts @@ -1,5 +1,5 @@ import { KubectlV31Layer } from '@aws-cdk/lambda-layer-kubectl-v31'; -import { Template, Match } from '../../assertions'; +import { Template } from '../../assertions'; import * as ec2 from '../../aws-ec2'; import * as iam from '../../aws-iam'; import * as kms from '../../aws-kms'; diff --git a/packages/aws-cdk-lib/aws-eks/test/helm-chart.test.ts b/packages/aws-cdk-lib/aws-eks/test/helm-chart.test.ts index 4cfe709a5bda5..d9c943515f747 100644 --- a/packages/aws-cdk-lib/aws-eks/test/helm-chart.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/helm-chart.test.ts @@ -6,8 +6,6 @@ import { App, Duration, Stack } from '../../core'; import * as eks from '../lib'; import { Cluster, KubernetesVersion } from '../lib'; -/* eslint-disable max-len */ - describe('helm chart', () => { describe('add Helm chart', () => { let app: App; diff --git a/packages/aws-cdk-lib/aws-eks/test/k8s-manifest.test.ts b/packages/aws-cdk-lib/aws-eks/test/k8s-manifest.test.ts index 3e9485d33e017..b0f4b4d37875a 100644 --- a/packages/aws-cdk-lib/aws-eks/test/k8s-manifest.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/k8s-manifest.test.ts @@ -1,11 +1,8 @@ import { KubectlV31Layer } from '@aws-cdk/lambda-layer-kubectl-v31'; -import { testFixtureNoVpc } from './util'; import { Template } from '../../assertions'; import { App, CfnResource, Stack } from '../../core'; import { Cluster, KubernetesManifest, KubernetesVersion, HelmChart } from '../lib'; -/* eslint-disable max-len */ - describe('k8s manifest', () => { let app: App; let stack: Stack; diff --git a/packages/aws-cdk-lib/aws-eks/test/nodegroup.test.ts b/packages/aws-cdk-lib/aws-eks/test/nodegroup.test.ts index 8572a9b008f29..05a638c474b88 100644 --- a/packages/aws-cdk-lib/aws-eks/test/nodegroup.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/nodegroup.test.ts @@ -10,8 +10,6 @@ import * as eks from '../lib'; import { NodegroupAmiType, TaintEffect } from '../lib'; import { isGpuInstanceType } from '../lib/private/nodegroup'; -/* eslint-disable max-len */ - const CLUSTER_VERSION = eks.KubernetesVersion.V1_21; describe('node group', () => { diff --git a/packages/aws-cdk-lib/aws-eks/test/service-account.test.ts b/packages/aws-cdk-lib/aws-eks/test/service-account.test.ts index d09eb66511295..32b5e4333028f 100644 --- a/packages/aws-cdk-lib/aws-eks/test/service-account.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/service-account.test.ts @@ -6,8 +6,6 @@ import { App, Stack } from '../../core'; import * as eks from '../lib'; import { Cluster, KubernetesVersion } from '../lib'; -/* eslint-disable max-len */ - describe('service account', () => { describe('add Service Account', () => { test('should have unique resource name', () => { diff --git a/packages/aws-cdk-lib/aws-eks/test/user-data.test.ts b/packages/aws-cdk-lib/aws-eks/test/user-data.test.ts index a2adfd41568fd..e082336c7f5ae 100644 --- a/packages/aws-cdk-lib/aws-eks/test/user-data.test.ts +++ b/packages/aws-cdk-lib/aws-eks/test/user-data.test.ts @@ -5,8 +5,6 @@ import { App, Stack } from '../../core'; import { Cluster, KubernetesVersion } from '../lib/'; import { renderAmazonLinuxUserData } from '../lib/user-data'; -/* eslint-disable max-len */ - describe('user data', () => { test('default user data', () => { // GIVEN diff --git a/packages/aws-cdk-lib/aws-eks/test/util.ts b/packages/aws-cdk-lib/aws-eks/test/util.ts index 98b7e27ab1a68..37602d04116b3 100644 --- a/packages/aws-cdk-lib/aws-eks/test/util.ts +++ b/packages/aws-cdk-lib/aws-eks/test/util.ts @@ -1,4 +1,3 @@ -import { KubectlV31Layer } from '@aws-cdk/lambda-layer-kubectl-v31'; import * as ec2 from '../../aws-ec2'; import { App, Stack } from '../../core'; import { Cluster, FargateCluster, ClusterProps, KubernetesVersion } from '../lib'; @@ -35,7 +34,7 @@ export interface testFixtureClusterOptions { * @param options - Additional options for the test fixture cluster. * @returns An object containing the stack, app, and the created cluster. */ -export function testFixtureCluster(props: Omit = {}, region: string = DEFAULT_REGION, options?: testFixtureClusterOptions) { +export function testFixtureCluster(props: Omit, region: string = DEFAULT_REGION, options?: testFixtureClusterOptions) { const { stack, app } = testFixtureNoVpc(region); const clusterProps = { version: CLUSTER_VERSION, diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/load-balancer.test.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/load-balancer.test.ts index cf7c367bd8d75..de18e1d08881c 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/load-balancer.test.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/alb/load-balancer.test.ts @@ -568,7 +568,7 @@ describe('tests', () => { test('bucket with KMS throws validation error', () => { // GIVEN - const { stack, bucket, lb } = loggingSetup(true); + const { bucket, lb } = loggingSetup(true); // WHEN const logAccessLogFunctionTest = () => lb.logAccessLogs(bucket); @@ -904,7 +904,7 @@ describe('tests', () => { test('bucket with KMS throws validation error', () => { // GIVEN - const { stack, bucket, lb } = loggingSetup(true); + const { bucket, lb } = loggingSetup(true); // WHEN const logConnectionLogFunctionTest = () => lb.logConnectionLogs(bucket); diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/load-balancer.test.ts b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/load-balancer.test.ts index 6f71c9fa844c8..6ea18619108b9 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/load-balancer.test.ts +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/test/nlb/load-balancer.test.ts @@ -1186,7 +1186,7 @@ describe('tests', () => { const sg2 = new ec2.SecurityGroup(stack, 'SG2', { vpc }); // WHEN - const nlb = new elbv2.NetworkLoadBalancer(stack, 'LB', { + new elbv2.NetworkLoadBalancer(stack, 'LB', { vpc, internetFacing: true, securityGroups: [sg1, sg2], @@ -1220,7 +1220,7 @@ describe('tests', () => { const vpc = new ec2.Vpc(stack, 'Stack'); // WHEN - const nlb = new elbv2.NetworkLoadBalancer(stack, 'LB', { + new elbv2.NetworkLoadBalancer(stack, 'LB', { vpc, internetFacing: true, securityGroups: [], @@ -1241,7 +1241,7 @@ describe('tests', () => { const vpc = new ec2.Vpc(stack, 'Stack'); // WHEN - const nlb = new elbv2.NetworkLoadBalancer(stack, 'LB', { + new elbv2.NetworkLoadBalancer(stack, 'LB', { vpc, internetFacing: true, disableSecurityGroups: true, @@ -1262,7 +1262,7 @@ describe('tests', () => { const vpc = new ec2.Vpc(stack, 'Stack'); // WHEN - const nlb = new elbv2.NetworkLoadBalancer(stack, 'LB', { + new elbv2.NetworkLoadBalancer(stack, 'LB', { vpc, internetFacing: true, disableSecurityGroups: false, diff --git a/packages/aws-cdk-lib/aws-elasticsearch/test/domain.test.ts b/packages/aws-cdk-lib/aws-elasticsearch/test/domain.test.ts index 1b4e4691a93c1..bca6ffb2ff618 100644 --- a/packages/aws-cdk-lib/aws-elasticsearch/test/domain.test.ts +++ b/packages/aws-cdk-lib/aws-elasticsearch/test/domain.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable jest/expect-expect */ + import { testDeprecated } from '@aws-cdk/cdk-build-tools'; import { Match, Template } from '../../assertions'; import * as acm from '../../aws-certificatemanager'; diff --git a/packages/aws-cdk-lib/aws-events-targets/test/ecs/event-rule-target.test.ts b/packages/aws-cdk-lib/aws-events-targets/test/ecs/event-rule-target.test.ts index b383ecace3e1e..e300b3d855838 100644 --- a/packages/aws-cdk-lib/aws-events-targets/test/ecs/event-rule-target.test.ts +++ b/packages/aws-cdk-lib/aws-events-targets/test/ecs/event-rule-target.test.ts @@ -1263,7 +1263,7 @@ test('it can override all possible ecs task properties via the input property', })); // THEN - const template = Template.fromStack(stack); + Template.fromStack(stack); debugger; Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', { Targets: [ diff --git a/packages/aws-cdk-lib/aws-events-targets/test/sqs/sqs.test.ts b/packages/aws-cdk-lib/aws-events-targets/test/sqs/sqs.test.ts index 4bdd8f633e6a5..3f78664ad5dea 100644 --- a/packages/aws-cdk-lib/aws-events-targets/test/sqs/sqs.test.ts +++ b/packages/aws-cdk-lib/aws-events-targets/test/sqs/sqs.test.ts @@ -2,8 +2,7 @@ import { Match, Template } from '../../../assertions'; import * as events from '../../../aws-events'; import * as kms from '../../../aws-kms'; import * as sqs from '../../../aws-sqs'; -import * as ssm from '../../../aws-ssm'; -import { App, CustomResource, Duration, Stack } from '../../../core'; +import { App, Duration, Stack } from '../../../core'; import * as cxapi from '../../../cx-api'; import * as targets from '../../lib'; diff --git a/packages/aws-cdk-lib/aws-events/test/archive.test.ts b/packages/aws-cdk-lib/aws-events/test/archive.test.ts index 0378d2266f81b..b7fe3fb8d5f4a 100644 --- a/packages/aws-cdk-lib/aws-events/test/archive.test.ts +++ b/packages/aws-cdk-lib/aws-events/test/archive.test.ts @@ -1,6 +1,5 @@ import { Template } from '../../assertions'; -import * as iam from '../../aws-iam'; import * as kms from '../../aws-kms'; import { Duration, Stack } from '../../core'; @@ -107,7 +106,7 @@ describe('archive', () => { const key = new kms.Key(stack, 'Key'); // WHEN - const archive = new Archive(stack, 'Archive', { + new Archive(stack, 'Archive', { kmsKey: key, sourceEventBus: eventBus, eventPattern: { @@ -193,7 +192,7 @@ describe('archive', () => { const eventBus = new EventBus(stack, 'Bus'); // WHEN - const archive = new Archive(stack, 'Archive', { + new Archive(stack, 'Archive', { sourceEventBus: eventBus, eventPattern: { source: ['test'], diff --git a/packages/aws-cdk-lib/aws-events/test/event-bus.grant.test.ts b/packages/aws-cdk-lib/aws-events/test/event-bus.grant.test.ts index c0a07431080e9..958909ea44e56 100644 --- a/packages/aws-cdk-lib/aws-events/test/event-bus.grant.test.ts +++ b/packages/aws-cdk-lib/aws-events/test/event-bus.grant.test.ts @@ -1,6 +1,6 @@ import { Annotations, Template, Match } from '../../assertions'; import * as iam from '../../aws-iam'; -import { App, Stack, Token } from '../../core'; +import { App, Stack } from '../../core'; import * as cxapi from '../../cx-api'; import { EventBus } from '../lib'; diff --git a/packages/aws-cdk-lib/aws-events/test/event-bus.test.ts b/packages/aws-cdk-lib/aws-events/test/event-bus.test.ts index 98ecedda80b4f..bb0b6c41ce34c 100644 --- a/packages/aws-cdk-lib/aws-events/test/event-bus.test.ts +++ b/packages/aws-cdk-lib/aws-events/test/event-bus.test.ts @@ -700,7 +700,7 @@ describe('event bus', () => { const key = new kms.Key(stack, 'Key'); // WHEN - const eventBus = new EventBus(stack, 'Bus', { + new EventBus(stack, 'Bus', { kmsKey: key, }); diff --git a/packages/aws-cdk-lib/aws-events/test/rule.test.ts b/packages/aws-cdk-lib/aws-events/test/rule.test.ts index e25471388e82e..046cbcac7d073 100644 --- a/packages/aws-cdk-lib/aws-events/test/rule.test.ts +++ b/packages/aws-cdk-lib/aws-events/test/rule.test.ts @@ -76,7 +76,7 @@ describe('rule', () => { const app = new cdk.App(); const stack = new cdk.Stack(app); const resource = new Construct(stack, 'Resource'); - const rule = new Rule(stack, 'MyRule', { + new Rule(stack, 'MyRule', { schedule: Schedule.rate(cdk.Duration.minutes(10)), targets: [ new SomeTarget('T1', resource), @@ -1220,7 +1220,6 @@ describe('rule', () => { }); class SomeTarget implements IRuleTarget { - // eslint-disable-next-line @cdklabs/no-core-construct public constructor(private readonly id?: string, private readonly resource?: IConstruct) { } diff --git a/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts b/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts index a06d550c56a9a..f8dc3322b4ba9 100644 --- a/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts +++ b/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts @@ -230,7 +230,7 @@ test('create accelerator with IpAddresses and IpAddressType', () => { const { stack } = testFixture(); // WHEN - const acc = new ga.Accelerator(stack, 'Accelerator', { + new ga.Accelerator(stack, 'Accelerator', { ipAddresses: [ '1.1.1.1', '2.2.2.2', diff --git a/packages/aws-cdk-lib/aws-iam/test/immutable-role.test.ts b/packages/aws-cdk-lib/aws-iam/test/immutable-role.test.ts index 094ec63d07d5b..7b653a305a988 100644 --- a/packages/aws-cdk-lib/aws-iam/test/immutable-role.test.ts +++ b/packages/aws-cdk-lib/aws-iam/test/immutable-role.test.ts @@ -102,9 +102,9 @@ describe('ImmutableRole', () => { }); test('ignores calls to addManagedPolicy', () => { - mutableRole.addManagedPolicy({ managedPolicyArn: 'Arn1' }); + mutableRole.addManagedPolicy({ managedPolicyArn: 'Arn1' } as any); - immutableRole.addManagedPolicy({ managedPolicyArn: 'Arn2' }); + immutableRole.addManagedPolicy({ managedPolicyArn: 'Arn2' } as any); Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { 'ManagedPolicyArns': [ diff --git a/packages/aws-cdk-lib/aws-iam/test/organization-principal.test.ts b/packages/aws-cdk-lib/aws-iam/test/organization-principal.test.ts index 7d0b39a76ae98..08c0f333c776e 100644 --- a/packages/aws-cdk-lib/aws-iam/test/organization-principal.test.ts +++ b/packages/aws-cdk-lib/aws-iam/test/organization-principal.test.ts @@ -1,12 +1,9 @@ -import { Annotations, Stack } from '../../core'; +import { Stack } from '../../core'; import * as cdk from '../../core'; import * as iam from '../lib'; describe('OrganizationPrincipal', () => { test('accepts valid organization ID', () => { - // GIVEN - const stack = new Stack(); - // WHEN / THEN expect(() => { new iam.OrganizationPrincipal('o-1234567890'); @@ -19,9 +16,6 @@ describe('OrganizationPrincipal', () => { ['too short', 'o-short'], ['too long', 'o-thisnameistoooooooooooooooooolong'], ])('throws error for non-compliant organization ID format: %s', (_, invalidId) => { - // GIVEN - const stack = new Stack(); - // WHEN / THEN expect(() => { new iam.OrganizationPrincipal(invalidId); @@ -30,7 +24,6 @@ describe('OrganizationPrincipal', () => { test('allows token as organization ID without validation', () => { // GIVEN - const stack = new Stack(); const orgIdToken = cdk.Token.asString({ Ref: 'OrgId' }); // WHEN / THEN diff --git a/packages/aws-cdk-lib/aws-iam/test/permissions-boundary.test.ts b/packages/aws-cdk-lib/aws-iam/test/permissions-boundary.test.ts index 5b76409ccea05..ac1996cabdeb0 100644 --- a/packages/aws-cdk-lib/aws-iam/test/permissions-boundary.test.ts +++ b/packages/aws-cdk-lib/aws-iam/test/permissions-boundary.test.ts @@ -200,7 +200,7 @@ test.each([ // WHEN iam.PermissionsBoundary.of(role).apply({ managedPolicyArn: 'OVERRIDDEN', - }); + } as any); // THEN Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { diff --git a/packages/aws-cdk-lib/aws-iam/test/principals.test.ts b/packages/aws-cdk-lib/aws-iam/test/principals.test.ts index 1b67bc843c64f..93f5efce5d821 100644 --- a/packages/aws-cdk-lib/aws-iam/test/principals.test.ts +++ b/packages/aws-cdk-lib/aws-iam/test/principals.test.ts @@ -1,6 +1,5 @@ import { Template } from '../../assertions'; import { App, CfnOutput, Stack } from '../../core'; -import * as cxapi from '../../cx-api'; import * as iam from '../lib'; import { ServicePrincipal } from '../lib'; diff --git a/packages/aws-cdk-lib/aws-iam/test/role.from-lookup.test.ts b/packages/aws-cdk-lib/aws-iam/test/role.from-lookup.test.ts index e84df896ff42a..06949a85b40ea 100644 --- a/packages/aws-cdk-lib/aws-iam/test/role.from-lookup.test.ts +++ b/packages/aws-cdk-lib/aws-iam/test/role.from-lookup.test.ts @@ -1,5 +1,5 @@ import * as cxschema from '../../cloud-assembly-schema'; -import { CfnParameter, ContextProvider, Stack, Token } from '../../core'; +import { CfnParameter, ContextProvider, Stack } from '../../core'; import * as iam from '../lib'; /* eslint-disable */ @@ -8,7 +8,7 @@ describe('Role from lookup', () => { // GIVEN const resultObjs = [ { - 'Arn': 'arn:aws:iam::123456789012:role/MyExistingRole', + 'Arn': 'arn:aws:iam::123456789012:role/MyExistingRole', }, ]; const value = { diff --git a/packages/aws-cdk-lib/aws-iam/test/role.test.ts b/packages/aws-cdk-lib/aws-iam/test/role.test.ts index 5069ad77312d4..5d14629daf058 100644 --- a/packages/aws-cdk-lib/aws-iam/test/role.test.ts +++ b/packages/aws-cdk-lib/aws-iam/test/role.test.ts @@ -537,10 +537,10 @@ describe('IAM role', () => { const role = new Role(stack, 'MyRole', { assumedBy: new ServicePrincipal('test.service'), - managedPolicies: [{ managedPolicyArn: 'managed1' }, { managedPolicyArn: 'managed2' }], + managedPolicies: [{ managedPolicyArn: 'managed1' } as any, { managedPolicyArn: 'managed2' } as any], }); - role.addManagedPolicy({ managedPolicyArn: 'managed3' }); + role.addManagedPolicy({ managedPolicyArn: 'managed3' } as any); Template.fromStack(stack).templateMatches({ Resources: { 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 7dc46cf8a0e11..aadb45daf7f2a 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,7 +105,6 @@ 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-kms/test/key.test.ts b/packages/aws-cdk-lib/aws-kms/test/key.test.ts index 490698569aa2f..0831eff5f3f32 100644 --- a/packages/aws-cdk-lib/aws-kms/test/key.test.ts +++ b/packages/aws-cdk-lib/aws-kms/test/key.test.ts @@ -1124,7 +1124,6 @@ describe('fromCfnKey()', () => { }); describe('addToResourcePolicy allowNoOp and there is no policy', () => { - // eslint-disable-next-line jest/expect-expect test('succeed if set to true (default)', () => { const stack = new cdk.Stack(); const key = kms.Key.fromKeyArn(stack, 'Imported', diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka-dlq.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka-dlq.test.ts index 739859994ef52..13a4849223b33 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka-dlq.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka-dlq.test.ts @@ -1,4 +1,3 @@ -import { Template } from '../../assertions'; import * as cdk from '../../core'; import * as sources from '../lib'; @@ -47,7 +46,6 @@ describe('KafkaDlq', () => { }); test('appends token as is without validation or prefix', () => { - const stack = new cdk.Stack(); const token = cdk.Fn.ref('MyTopicParameter'); const dlq = new sources.KafkaDlq(token); diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka.test.ts index 0ff219db48854..6c2ebac17b248 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kafka.test.ts @@ -603,7 +603,7 @@ describe('KafkaEventSource', () => { const clusterArn = 'some-arn'; const kafkaTopic = 'some-topic'; const bucket = Bucket.fromBucketName(stack, 'BucketByName', 'my-bucket'); - const s3OnFailureDestination = new sources.S3OnFailureDestination(bucket); + new sources.S3OnFailureDestination(bucket); testLambdaFunction.addEventSource(new sources.ManagedKafkaEventSource({ clusterArn, @@ -2790,7 +2790,7 @@ describe('backwards compatibility', () => { test('no breaking changes to existing API surface', () => { // GIVEN const stack = new cdk.Stack(); - const fn = new TestFunction(stack, 'Fn'); + new TestFunction(stack, 'Fn'); const clusterArn = 'some-arn'; const kafkaTopic = 'some-topic'; @@ -3027,7 +3027,7 @@ describe('KafkaDlq CloudFormation Template Generation', () => { stringEquals: lambda.FilterRule.isEqual('test'), }), ], - })); + } as any)); // THEN - Verify all properties coexist properly const template = Template.fromStack(stack); @@ -3118,7 +3118,7 @@ describe('template synthesis with various configurations', () => { test('CDK synthesis with complex topic names', () => { // GIVEN const stack = new cdk.Stack(); - const fn = new TestFunction(stack, 'Fn'); + new TestFunction(stack, 'Fn'); const clusterArn = 'arn:aws:kafka:us-east-1:123456789012:cluster/test-cluster'; const kafkaTopic = 'test-topic'; @@ -3229,7 +3229,7 @@ describe('template synthesis with various configurations', () => { numericEquals: lambda.FilterRule.isEqual(42), }), ], - })); + } as any)); // THEN - Should synthesize without errors and include all properties expect(() => Template.fromStack(stack)).not.toThrow(); 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 c212ea49ae20f..1cedebd09d7b3 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,4 +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 4260327a10cb5..b9ef163f57645 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,4 +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-nodejs/test/package-installation.test.ts b/packages/aws-cdk-lib/aws-lambda-nodejs/test/package-installation.test.ts index ce30fdb0bb148..1a7b46c4904aa 100644 --- a/packages/aws-cdk-lib/aws-lambda-nodejs/test/package-installation.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-nodejs/test/package-installation.test.ts @@ -2,7 +2,7 @@ import * as child_process from 'child_process'; import { PackageInstallation } from '../lib/package-installation'; import * as util from '../lib/util'; -// eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-extraneous-dependencies +// eslint-disable-next-line @typescript-eslint/no-require-imports const version = require('esbuild/package.json').version; test('detects local version', () => { diff --git a/packages/aws-cdk-lib/aws-lambda-nodejs/test/util.test.ts b/packages/aws-cdk-lib/aws-lambda-nodejs/test/util.test.ts index f7d3c5381bad2..da744a3c6dd34 100644 --- a/packages/aws-cdk-lib/aws-lambda-nodejs/test/util.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-nodejs/test/util.test.ts @@ -169,7 +169,7 @@ describe('extractDependencies', () => { path.join(__dirname, 'testpackage.json'), ['typescript'], )).toEqual({ - // eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-extraneous-dependencies + // eslint-disable-next-line @typescript-eslint/no-require-imports typescript: require('typescript/package.json').version, }); }); diff --git a/packages/aws-cdk-lib/aws-lambda/test/code.test.ts b/packages/aws-cdk-lib/aws-lambda/test/code.test.ts index 56ce19cd15c0a..742a400175675 100644 --- a/packages/aws-cdk-lib/aws-lambda/test/code.test.ts +++ b/packages/aws-cdk-lib/aws-lambda/test/code.test.ts @@ -35,7 +35,7 @@ describe('code', () => { test('fails if command is empty', () => { // GIVEN - const command = []; + const command = new Array(); // THEN expect(() => lambda.Code.fromCustomCommand('', command)).toThrow('command must contain at least one argument. For example, ["node", "buildFile.js"].'); diff --git a/packages/aws-cdk-lib/aws-lambda/test/function.test.ts b/packages/aws-cdk-lib/aws-lambda/test/function.test.ts index e7a2fd2a2aa25..a1a200edd3549 100644 --- a/packages/aws-cdk-lib/aws-lambda/test/function.test.ts +++ b/packages/aws-cdk-lib/aws-lambda/test/function.test.ts @@ -81,7 +81,6 @@ describe('function', () => { Version: '2012-10-17', }, ManagedPolicyArns: - // eslint-disable-next-line max-len [{ 'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':iam::aws:policy/service-role/AWSLambdaBasicExecutionRole']] }], }); Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { @@ -149,7 +148,6 @@ describe('function', () => { Version: '2012-10-17', }, ManagedPolicyArns: - // eslint-disable-next-line max-len [{ 'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':iam::aws:policy/service-role/AWSLambdaBasicExecutionRole']] }], }); @@ -2071,7 +2069,7 @@ describe('function', () => { let bindCalled = false; class MockApiEventSource implements lambda.IEventSource { - bind(target: lambda.IFunction): void { + bind(_target: lambda.IFunction): void { bindCalled = true; } } @@ -2095,7 +2093,7 @@ describe('function', () => { }); class MockSqsEventSource implements lambda.IEventSource { - bind(target: lambda.IFunction): void {} + bind(_target: lambda.IFunction): void {} } Object.defineProperty(MockSqsEventSource, 'name', { value: 'SqsEventSource' }); diff --git a/packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts b/packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts index 1d1e7cca5918d..ad00fa52ced62 100644 --- a/packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts +++ b/packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts @@ -1,5 +1,5 @@ import { Construct } from 'constructs'; -import { Annotations, Template, Match } from '../../assertions'; +import { Template } from '../../assertions'; import * as iam from '../../aws-iam'; import * as kms from '../../aws-kms'; import { Bucket } from '../../aws-s3'; diff --git a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts index f58e64414ff54..268efac472ca4 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable jest/expect-expect */ import each from 'jest-each'; import { Match, Template } from '../../assertions'; import * as acm from '../../aws-certificatemanager'; @@ -10,7 +9,7 @@ import * as logs from '../../aws-logs'; import * as route53 from '../../aws-route53'; import { App, Stack, Duration, SecretValue, CfnParameter, Token } from '../../core'; import * as cxapi from '../../cx-api'; -import { Domain, DomainProps, EngineVersion, IpAddressType, NodeOptions, TLSSecurityPolicy } from '../lib'; +import { Domain, DomainProps, EngineVersion, IpAddressType, NodeOptions, NodeType, TLSSecurityPolicy } from '../lib'; let app: App; let stack: Stack; @@ -2759,7 +2758,7 @@ function testMetric( each(testedOpenSearchVersions).test('can configure coordinator nodes with nodeOptions', (engineVersion) => { const coordinatorConfig: NodeOptions = { - nodeType: 'coordinator', + nodeType: NodeType.COORDINATOR, nodeConfig: { enabled: true, type: 'm5.large.search', @@ -2767,7 +2766,7 @@ each(testedOpenSearchVersions).test('can configure coordinator nodes with nodeOp }, }; - const domain = new Domain(stack, 'Domain', { + new Domain(stack, 'Domain', { version: engineVersion, capacity: { nodeOptions: [coordinatorConfig], @@ -2794,7 +2793,7 @@ each(testedOpenSearchVersions).test('throws when coordinator node instance type version: engineVersion, capacity: { nodeOptions: [{ - nodeType: 'coordinator' as const, + nodeType: NodeType.COORDINATOR, nodeConfig: { enabled: true, type: 'm5.large', @@ -2811,7 +2810,7 @@ each(testedOpenSearchVersions).test('throws when coordinator node count is less version: engineVersion, capacity: { nodeOptions: [{ - nodeType: 'coordinator' as const, + nodeType: NodeType.COORDINATOR, nodeConfig: { enabled: true, count: 0, @@ -2824,11 +2823,11 @@ each(testedOpenSearchVersions).test('throws when coordinator node count is less }); each(testedOpenSearchVersions).test('can disable coordinator nodes', (engineVersion) => { - const domain = new Domain(stack, 'Domain', { + new Domain(stack, 'Domain', { version: engineVersion, capacity: { nodeOptions: [{ - nodeType: 'coordinator' as const, + nodeType: NodeType.COORDINATOR, nodeConfig: { enabled: false, }, diff --git a/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts b/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts index 9f13b4c6bbbd9..988a07d8f8f7d 100644 --- a/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts +++ b/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts @@ -13,7 +13,7 @@ import { AURORA_CLUSTER_CHANGE_SCOPE_OF_INSTANCE_PARAMETER_GROUP_WITH_EACH_PARAMETERS, } from '../../cx-api'; import { - AuroraEngineVersion, AuroraMysqlEngineVersion, AuroraPostgresEngineVersion, CfnDBCluster, Credentials, DatabaseCluster, + AuroraMysqlEngineVersion, AuroraPostgresEngineVersion, CfnDBCluster, Credentials, DatabaseCluster, DatabaseClusterEngine, DatabaseClusterFromSnapshot, ParameterGroup, PerformanceInsightRetention, SubnetGroup, DatabaseSecret, DatabaseInstanceEngine, SqlServerEngineVersion, SnapshotCredentials, InstanceUpdateBehaviour, NetworkType, ClusterInstance, CaCertificate, IClusterEngine, diff --git a/packages/aws-cdk-lib/aws-rds/test/instance.from-lookup.test.ts b/packages/aws-cdk-lib/aws-rds/test/instance.from-lookup.test.ts index dd38df6fd4463..68bbf32d60a22 100644 --- a/packages/aws-cdk-lib/aws-rds/test/instance.from-lookup.test.ts +++ b/packages/aws-cdk-lib/aws-rds/test/instance.from-lookup.test.ts @@ -1,4 +1,4 @@ -import { Match, Template } from '../../assertions'; +import { Template } from '../../assertions'; import * as ec2 from '../../aws-ec2'; import * as cxschema from '../../cloud-assembly-schema'; import { ContextProvider, Stack } from '../../core'; @@ -222,37 +222,37 @@ describe('DatabaseInstanceBase connections', () => { ]; const value = { value: resultObjs }; const mock = jest.spyOn(ContextProvider, 'getValue').mockReturnValue(value); - + // WHEN const stack = new Stack(undefined, undefined, { env: { region: 'us-east-1', account: '123456789012' } }); - + const securityGroup = ec2.SecurityGroup.fromSecurityGroupId(stack, 'TestSG', 'sg-test'); - + const instance = rds.DatabaseInstance.fromLookup(stack, 'MyInstance', { instanceIdentifier: 'instance-1', }); - + instance.connections.allowDefaultPortFrom(securityGroup, 'Allow from test SG'); - + // THEN Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroupIngress', { IpProtocol: 'tcp', - FromPort: 5432, - ToPort: 5432, + FromPort: 5432, + ToPort: 5432, Description: 'Allow from test SG', SourceSecurityGroupId: 'sg-test', GroupId: 'sg-1' }); - + Template.fromStack(stack).hasResourceProperties('AWS::EC2::SecurityGroupIngress', { IpProtocol: 'tcp', - FromPort: 5432, - ToPort: 5432, + FromPort: 5432, + ToPort: 5432, Description: 'Allow from test SG', SourceSecurityGroupId: 'sg-test', GroupId: 'sg-2' }); - + mock.mockRestore(); }); }); diff --git a/packages/aws-cdk-lib/aws-rds/test/instance.test.ts b/packages/aws-cdk-lib/aws-rds/test/instance.test.ts index b9ce6e3da141e..2fc51f7640b05 100644 --- a/packages/aws-cdk-lib/aws-rds/test/instance.test.ts +++ b/packages/aws-cdk-lib/aws-rds/test/instance.test.ts @@ -1404,7 +1404,6 @@ describe('instance', () => { }); test('createGrant - creates IAM policy for instance replica when the USE_CORRECT_VALUE_FOR_INSTANCE_RESOURCE_ID_PROPERTY feature flag is enabled', () => { - const cloudwatchTraceLog = 'trace'; const app = new cdk.App({ context: { [cxapi.USE_CORRECT_VALUE_FOR_INSTANCE_RESOURCE_ID_PROPERTY]: true } }); stack = new cdk.Stack(app); vpc = new ec2.Vpc( stack, 'VPC' ); @@ -1467,7 +1466,6 @@ describe('instance', () => { }); test('createGrant - creates IAM policy for instance replica when the USE_CORRECT_VALUE_FOR_INSTANCE_RESOURCE_ID_PROPERTY feature flag is disabled by default', () => { - const cloudwatchTraceLog = 'trace'; const app = new cdk.App(); stack = new cdk.Stack(app); vpc = new ec2.Vpc( stack, 'VPC' ); @@ -2398,7 +2396,7 @@ describe('instance', () => { // WHEN new rds.DatabaseInstanceFromSnapshot(stack, 'Database', { snapshotIdentifier: 'my-snapshot', - engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_4_5 }), + engine, vpc, engineLifecycleSupport: rds.EngineLifecycleSupport.OPEN_SOURCE_RDS_EXTENDED_SUPPORT_DISABLED, }); diff --git a/packages/aws-cdk-lib/aws-route53/test/hosted-zone.test.ts b/packages/aws-cdk-lib/aws-route53/test/hosted-zone.test.ts index 8106e4b274dac..ceb0f872d691d 100644 --- a/packages/aws-cdk-lib/aws-route53/test/hosted-zone.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/hosted-zone.test.ts @@ -305,7 +305,7 @@ test('grantDelegation on L1s', () => { }); // WHEN - HostedZoneGrants.fromHostedZone(zone).delegation(role); + HostedZoneGrants.fromHostedZone(zone as any).delegation(role); // THEN const template = Template.fromStack(stack); diff --git a/packages/aws-cdk-lib/aws-route53/test/key-signing-key.test.ts b/packages/aws-cdk-lib/aws-route53/test/key-signing-key.test.ts index 1cb819b8710f4..6c5d441d36b6a 100644 --- a/packages/aws-cdk-lib/aws-route53/test/key-signing-key.test.ts +++ b/packages/aws-cdk-lib/aws-route53/test/key-signing-key.test.ts @@ -1,4 +1,3 @@ -import { testDeprecated } from '@aws-cdk/cdk-build-tools'; import { Match, Template } from '../../assertions'; import * as kms from '../../aws-kms'; import * as cdk from '../../core'; diff --git a/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts b/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts index ab277251f10dc..0460ef05f6879 100644 --- a/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts +++ b/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts @@ -10,7 +10,6 @@ import * as s3 from '../../aws-s3'; import * as sns from '../../aws-sns'; import * as ssm from '../../aws-ssm'; import * as cdk from '../../core'; -import { Token } from '../../core'; import { UnscopedValidationError } from '../../core/lib/errors'; import * as cxapi from '../../cx-api'; import * as s3deploy from '../lib'; diff --git a/packages/aws-cdk-lib/aws-s3-deployment/test/content.test.ts b/packages/aws-cdk-lib/aws-s3-deployment/test/content.test.ts index bd239b866d30b..7c0f5533ded2a 100644 --- a/packages/aws-cdk-lib/aws-s3-deployment/test/content.test.ts +++ b/packages/aws-cdk-lib/aws-s3-deployment/test/content.test.ts @@ -2,14 +2,13 @@ import { Vpc } from '../../aws-ec2'; import * as elbv2 from '../../aws-elasticloadbalancingv2'; import * as lambda from '../../aws-lambda'; import * as s3 from '../../aws-s3'; -import { IResolvable, Lazy, Stack, Token, Tokenization } from '../../core'; +import { Lazy, Stack, Tokenization } from '../../core'; import { Source } from '../lib'; import { renderData } from '../lib/render-data'; const expectEqualIfResolved = (stack: Stack, a: any, b: any) => expect(stack.resolve(a)).toStrictEqual(stack.resolve(b)); test('simple string', () => { - const stack = new Stack(); expect(renderData('foo')).toStrictEqual({ markers: {}, text: 'foo', @@ -89,7 +88,6 @@ test('markers are returned in the source config', () => { }); test('lazy string is not resolved', () => { - const stack = new Stack(); const token = Lazy.string({ produce: () => 'resolved!' }); expect(renderData(token)).toStrictEqual({ @@ -101,7 +99,6 @@ test('lazy string is not resolved', () => { }); test('lazy within a string is not resolved', () => { - const stack = new Stack(); const token = Lazy.string({ produce: () => 'resolved!' }); expect(renderData(`hello, ${token}`)).toStrictEqual({ @@ -113,7 +110,6 @@ test('lazy within a string is not resolved', () => { }); test('renderData can render empty string data', () => { - const stack = new Stack(); expect(renderData('')).toStrictEqual({ markers: {}, text: '', diff --git a/packages/aws-cdk-lib/aws-s3-notifications/test/notifications.test.ts b/packages/aws-cdk-lib/aws-s3-notifications/test/notifications.test.ts index 1eea5d3e0c44c..a0e7363fc0770 100644 --- a/packages/aws-cdk-lib/aws-s3-notifications/test/notifications.test.ts +++ b/packages/aws-cdk-lib/aws-s3-notifications/test/notifications.test.ts @@ -4,7 +4,6 @@ import * as sns from '../../aws-sns'; import * as cdk from '../../core'; import * as s3n from '../lib'; -/* eslint-disable max-len */ /* eslint-disable @stylistic/quote-props */ test('bucket without notifications', () => { diff --git a/packages/aws-cdk-lib/aws-s3-notifications/test/sns.test.ts b/packages/aws-cdk-lib/aws-s3-notifications/test/sns.test.ts index 838204cb263ca..699a060c2cfca 100644 --- a/packages/aws-cdk-lib/aws-s3-notifications/test/sns.test.ts +++ b/packages/aws-cdk-lib/aws-s3-notifications/test/sns.test.ts @@ -1,4 +1,4 @@ -import { Annotations, Template } from '../../assertions'; +import { Template } from '../../assertions'; import * as kms from '../../aws-kms'; import * as s3 from '../../aws-s3'; import * as sns from '../../aws-sns'; diff --git a/packages/aws-cdk-lib/aws-s3/test/bucket-policy.test.ts b/packages/aws-cdk-lib/aws-s3/test/bucket-policy.test.ts index 206b36c3b8a12..dbce38fc0d82e 100644 --- a/packages/aws-cdk-lib/aws-s3/test/bucket-policy.test.ts +++ b/packages/aws-cdk-lib/aws-s3/test/bucket-policy.test.ts @@ -1,6 +1,6 @@ import { Template } from '../../assertions'; import { AnyPrincipal, PolicyStatement } from '../../aws-iam'; -import { RemovalPolicy, Stack, App } from '../../core'; +import { RemovalPolicy, Stack } from '../../core'; import * as s3 from '../lib'; import { CfnBucketPolicy } from '../lib'; diff --git a/packages/aws-cdk-lib/aws-s3/test/bucket.test.ts b/packages/aws-cdk-lib/aws-s3/test/bucket.test.ts index c4df92a826f3f..4072746116927 100644 --- a/packages/aws-cdk-lib/aws-s3/test/bucket.test.ts +++ b/packages/aws-cdk-lib/aws-s3/test/bucket.test.ts @@ -6,11 +6,9 @@ import * as kms from '../../aws-kms'; import * as cdk from '../../core'; import * as cxapi from '../../cx-api'; import * as s3 from '../lib'; -import { ReplicationTimeValue } from '../lib/bucket'; // to make it easy to copy & paste from output: /* eslint-disable @stylistic/quote-props */ -/* eslint-disable no-console */ describe('bucket', () => { test('default bucket', () => { @@ -4441,7 +4439,7 @@ describe('bucket', () => { const app = new cdk.App(); const stack = new cdk.Stack(app, 'stack'); const dstBucket = new s3.Bucket(stack, 'DstBucket'); - const dstBucketNoEncryption = new s3.Bucket(stack, 'DstBucketNoEncryption'); + new s3.Bucket(stack, 'DstBucketNoEncryption'); const replicationRole = new iam.Role(stack, 'ReplicationRole', { assumedBy: new iam.ServicePrincipal('s3.amazonaws.com'), }); @@ -5166,7 +5164,7 @@ describe('bucket', () => { ], }); const stack = new cdk.Stack(app, 'MyStack', {}); - const b1 = new s3.Bucket(stack, 'my-bucket-1', {}); + new s3.Bucket(stack, 'my-bucket-1', {}); const template = Template.fromStack(stack).toJSON(); // WHEN - no Injector, but props @@ -5181,7 +5179,7 @@ describe('bucket', () => { lifecycleRules: [], removalPolicy: cdk.RemovalPolicy.RETAIN, }); - const b2 = new s3.Bucket(stack2, 'my-bucket-1', { + new s3.Bucket(stack2, 'my-bucket-1', { accessControl: undefined, blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, encryption: s3.BucketEncryption.KMS, @@ -5205,13 +5203,13 @@ describe('bucket', () => { ], }); const stack = new cdk.Stack(app, 'MyStack', {}); - const b1 = new s3.Bucket(stack, 'my-bucket-1', {}); + new s3.Bucket(stack, 'my-bucket-1', {}); const template = Template.fromStack(stack).toJSON(); // WHEN - no Injector, but props const app2 = new cdk.App({}); const stack2 = new cdk.Stack(app2, 'MyStack', {}); - const b2 = new s3.Bucket(stack2, 'my-bucket-1', { + new s3.Bucket(stack2, 'my-bucket-1', { blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, enforceSSL: true, }); diff --git a/packages/aws-cdk-lib/aws-s3/test/notification.test.ts b/packages/aws-cdk-lib/aws-s3/test/notification.test.ts index 0422a7a4b0fcf..d7974c6db4ffa 100644 --- a/packages/aws-cdk-lib/aws-s3/test/notification.test.ts +++ b/packages/aws-cdk-lib/aws-s3/test/notification.test.ts @@ -1,6 +1,5 @@ import { Match, Template, Annotations } from '../../assertions'; import * as iam from '../../aws-iam'; -import * as lambda from '../../aws-lambda'; import * as cdk from '../../core'; import * as cxapi from '../../cx-api'; import * as s3 from '../lib'; diff --git a/packages/aws-cdk-lib/aws-s3/test/rules.test.ts b/packages/aws-cdk-lib/aws-s3/test/rules.test.ts index 170b587c01d1d..34cff50f29341 100644 --- a/packages/aws-cdk-lib/aws-s3/test/rules.test.ts +++ b/packages/aws-cdk-lib/aws-s3/test/rules.test.ts @@ -1,5 +1,5 @@ import { Template } from '../../assertions'; -import { App, Duration, Stack } from '../../core'; +import { Duration, Stack } from '../../core'; import { Bucket, StorageClass } from '../lib'; describe('rules', () => { diff --git a/packages/aws-cdk-lib/aws-sns/test/subscription.test.ts b/packages/aws-cdk-lib/aws-sns/test/subscription.test.ts index b9de3740b10e9..53a16349377e3 100644 --- a/packages/aws-cdk-lib/aws-sns/test/subscription.test.ts +++ b/packages/aws-cdk-lib/aws-sns/test/subscription.test.ts @@ -538,7 +538,7 @@ describe('Subscription', () => { }, }, }, - ]; + ] as const; delayTestCases.forEach(({ prop, invalidDeliveryPolicy }) => { const invalidValue = invalidDeliveryPolicy.healthyRetryPolicy[prop]; diff --git a/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts b/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts index 422961806ad79..dbe7cdc0c12bf 100644 --- a/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts +++ b/packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable max-len */ import { testDeprecated } from '@aws-cdk/cdk-build-tools'; import { Template, Annotations } from '../../assertions'; diff --git a/packages/aws-cdk-lib/aws-ssm/test/util.test.ts b/packages/aws-cdk-lib/aws-ssm/test/util.test.ts index c59705e4cee0c..e1348284bfb0f 100644 --- a/packages/aws-cdk-lib/aws-ssm/test/util.test.ts +++ b/packages/aws-cdk-lib/aws-ssm/test/util.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable max-len */ import { Stack, Token } from '../../core'; import { arnForParameterName } from '../lib/util'; diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/athena/start-query-execution.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/athena/start-query-execution.test.ts index 940b9ab1ce015..7af9f19fe6ad4 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/athena/start-query-execution.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/athena/start-query-execution.test.ts @@ -393,7 +393,7 @@ describe('Start Query Execution', () => { expect(() => { // WHEN - const task = new AthenaStartQueryExecution(stack, 'Query', { + new AthenaStartQueryExecution(stack, 'Query', { queryString: 'CREATE DATABASE ?', clientRequestToken: 'unique-client-request-token', queryExecutionContext: { @@ -419,7 +419,7 @@ describe('Start Query Execution', () => { expect(() => { // WHEN - const task = new AthenaStartQueryExecution(stack, 'Query', { + new AthenaStartQueryExecution(stack, 'Query', { queryString: 'CREATE DATABASE ?', clientRequestToken: 'unique-client-request-token', queryExecutionContext: { @@ -445,7 +445,7 @@ describe('Start Query Execution', () => { expect(() => { // WHEN - const task = new AthenaStartQueryExecution(stack, 'Query', { + new AthenaStartQueryExecution(stack, 'Query', { queryString: 'CREATE DATABASE ?', clientRequestToken: 'unique-client-request-token', queryExecutionContext: { diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/bedrock/invoke-model.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/bedrock/invoke-model.test.ts index e67d62f963a6f..6c67bf225c32c 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/bedrock/invoke-model.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/bedrock/invoke-model.test.ts @@ -922,7 +922,7 @@ describe('Invoke Model', () => { expect(() => { // WHEN - const task = new BedrockInvokeModel(stack, 'Invoke', { + new BedrockInvokeModel(stack, 'Invoke', { model, body: sfn.TaskInput.fromObject( { diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/dynamodb/get-item.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/dynamodb/get-item.test.ts index a446b0ff427a4..027e624292726 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/dynamodb/get-item.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/dynamodb/get-item.test.ts @@ -145,7 +145,7 @@ test('supports tokens', () => { }, End: true, Parameters: { - /* eslint-disable @stylistic/quote-props */ + Key: { SOME_KEY: { 'S.$': '$.partitionKey' }, OTHER_KEY: { 'N.$': '$.sortKey' }, diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emr/emr-create-cluster.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emr/emr-create-cluster.test.ts index 58789240f6964..1de5469085830 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emr/emr-create-cluster.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emr/emr-create-cluster.test.ts @@ -2,7 +2,7 @@ import { Template } from '../../../assertions'; import * as iam from '../../../aws-iam'; import * as sfn from '../../../aws-stepfunctions'; import * as cdk from '../../../core'; -// eslint-disable-next-line import/no-extraneous-dependencies + import { ENABLE_EMR_SERVICE_POLICY_V2 } from '../../../cx-api'; import { EmrCreateCluster } from '../../lib'; diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emrcontainers/start-job-run.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emrcontainers/start-job-run.test.ts index c549793c15c0a..5ce1661034906 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emrcontainers/start-job-run.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/emrcontainers/start-job-run.test.ts @@ -1,6 +1,5 @@ import { Template } from '../../../assertions'; import * as iam from '../../../aws-iam'; -import * as lambda from '../../../aws-lambda'; import * as logs from '../../../aws-logs'; import * as s3 from '../../../aws-s3'; import * as sfn from '../../../aws-stepfunctions'; diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/http/invoke.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/http/invoke.test.ts index 63b8c62f3de47..0bddfe54ca78b 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/http/invoke.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/http/invoke.test.ts @@ -1,4 +1,4 @@ -import { Match, Template } from '../../../assertions'; +import { Template } from '../../../assertions'; import * as events from '../../../aws-events'; import * as sfn from '../../../aws-stepfunctions'; import * as cdk from '../../../core'; diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/mediaconvert/create-job.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/mediaconvert/create-job.test.ts index da922c85cccea..9fda54245130b 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/mediaconvert/create-job.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/mediaconvert/create-job.test.ts @@ -129,7 +129,7 @@ describe('MediaConvert Create Job', () => { test('Fails on Unsupported Integration Pattern', () => { expect(() => { // WHEN - const task = new MediaConvertCreateJob(stack, 'MediaConvertCreateJob', { + new MediaConvertCreateJob(stack, 'MediaConvertCreateJob', { integrationPattern: sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN, createJobRequest: { Settings: { @@ -145,7 +145,7 @@ describe('MediaConvert Create Job', () => { test('Fails on role not specified', () => { expect(() => { // WHEN - const task = new MediaConvertCreateJob(stack, 'MediaConvertCreateJob', { + new MediaConvertCreateJob(stack, 'MediaConvertCreateJob', { createJobRequest: { Settings: { OutputGroups: [], @@ -160,7 +160,7 @@ describe('MediaConvert Create Job', () => { test('Fails on settings not specified', () => { expect(() => { // WHEN - const task = new MediaConvertCreateJob(stack, 'MediaConvertCreateJob', { + new MediaConvertCreateJob(stack, 'MediaConvertCreateJob', { createJobRequest: { Role: 'arn:aws:iam::123456789012:role/MediaConvertRole', }, diff --git a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts index 77bd3ac43bf7c..4bad09fb64402 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts @@ -1132,7 +1132,7 @@ describe('Distributed Map State', () => { // GIVEN const stack = new cdk.Stack(); stack.node.setContext(STEPFUNCTIONS_USE_DISTRIBUTED_MAP_RESULT_WRITER_V2, feature); - const writerBucket = new s3.Bucket(stack, 'TestBucket'); + new s3.Bucket(stack, 'TestBucket'); // WHEN const map = new stepfunctions.DistributedMap(stack, 'Map State', { maxConcurrency: 1, diff --git a/packages/aws-cdk-lib/aws-stepfunctions/test/private/json-path.test.ts b/packages/aws-cdk-lib/aws-stepfunctions/test/private/json-path.test.ts index 66a98efd13e82..6310e0ccb90c8 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/test/private/json-path.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/test/private/json-path.test.ts @@ -1,4 +1,4 @@ -import { Token, Tokenization, UnscopedValidationError } from '../../../core'; +import { IResolvable, IResolveContext, Token, UnscopedValidationError } from '../../../core'; import { JsonPath } from '../../lib'; import { jsonPathFromAny, jsonPathString, JsonPathToken, renderInExpression } from '../../lib/private/json-path'; diff --git a/packages/aws-cdk-lib/aws-stepfunctions/test/state-machine.test.ts b/packages/aws-cdk-lib/aws-stepfunctions/test/state-machine.test.ts index 76c46e8e6268e..80eb6c7c0f031 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/test/state-machine.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/test/state-machine.test.ts @@ -1404,7 +1404,7 @@ describe('State Machine', () => { encryptionConfiguration: new sfn.CustomerManagedEncryptionConfiguration(activityKey), }); - const stateMachine = new sfn.StateMachine(stack, 'MyStateMachine', { + new sfn.StateMachine(stack, 'MyStateMachine', { stateMachineName: 'MyStateMachine', definitionBody: sfn.DefinitionBody.fromChainable(sfn.Chain.start(new task.StepFunctionsInvokeActivity(stack, 'Activity', { activity: activity, diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 11254f5d4ce59..a5816b38809cf 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -1072,7 +1072,7 @@ describe('artifact encryption test', () => { const stack = new Stack(); // WHEN - const canary = new synthetics.Canary(stack, 'Canary', { + new synthetics.Canary(stack, 'Canary', { test: synthetics.Test.custom({ handler: 'index.handler', code: synthetics.Code.fromInline(` 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 6172d7430e4d7..fe00a4ad0f30b 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/code.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/code.test.ts @@ -1,4 +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/aws-xray/test/xray.test.ts b/packages/aws-cdk-lib/aws-xray/test/xray.test.ts index 6f0769c8edaee..7f23fa313713c 100644 --- a/packages/aws-cdk-lib/aws-xray/test/xray.test.ts +++ b/packages/aws-cdk-lib/aws-xray/test/xray.test.ts @@ -1,11 +1,7 @@ -import { Match, Template } from '../../assertions'; -import * as iam from '../../aws-iam'; -import * as kms from '../../aws-kms'; -import { CfnParameter, Duration, Stack, App, Token, Tags } from '../../core'; +import { Template } from '../../assertions'; +import { Stack, Tags } from '../../core'; import * as xray from '../lib'; -/* eslint-disable @stylistic/quote-props */ - test('able to add tags to XRay CfnGroup', () => { const stack = new Stack(); new xray.CfnGroup(stack, 'Group', { diff --git a/packages/aws-cdk-lib/cloudformation-include/test/serverless-transform.test.ts b/packages/aws-cdk-lib/cloudformation-include/test/serverless-transform.test.ts index 2c42d44f56234..64b8203183af8 100644 --- a/packages/aws-cdk-lib/cloudformation-include/test/serverless-transform.test.ts +++ b/packages/aws-cdk-lib/cloudformation-include/test/serverless-transform.test.ts @@ -6,9 +6,6 @@ import * as cxapi from '../../cx-api'; import * as inc from '../lib'; import * as futils from '../lib/file-utils'; -/* eslint-disable @stylistic/quote-props */ -/* eslint-disable quotes */ - describe('CDK Include for templates with SAM transform', () => { let stack: core.Stack; diff --git a/packages/aws-cdk-lib/cloudformation-include/test/valid-templates.test.ts b/packages/aws-cdk-lib/cloudformation-include/test/valid-templates.test.ts index 2d867b7564a46..14f54503f72aa 100644 --- a/packages/aws-cdk-lib/cloudformation-include/test/valid-templates.test.ts +++ b/packages/aws-cdk-lib/cloudformation-include/test/valid-templates.test.ts @@ -737,14 +737,14 @@ describe('CDK Include', () => { }); test('preserves unknown policy attributes', () => { - const cfnTemplate = includeTestTemplate(stack, 'non-existent-policy-attribute.json'); + includeTestTemplate(stack, 'non-existent-policy-attribute.json'); Template.fromStack(stack).templateMatches( loadTestFileToJsObject('non-existent-policy-attribute.json'), ); }); test('correctly handles string arrays in policy attributes', () => { - const cfnTemplate = includeTestTemplate(stack, 'string-arrays-in-policy.json'); + includeTestTemplate(stack, 'string-arrays-in-policy.json'); Template.fromStack(stack).templateMatches( loadTestFileToJsObject('string-arrays-in-policy.json'), ); diff --git a/packages/aws-cdk-lib/core/test/arn.test.ts b/packages/aws-cdk-lib/core/test/arn.test.ts index 0d35b136eb104..53c6ab56ec2d0 100644 --- a/packages/aws-cdk-lib/core/test/arn.test.ts +++ b/packages/aws-cdk-lib/core/test/arn.test.ts @@ -247,9 +247,8 @@ describe('arn', () => { expect(parsed.sep).toEqual('/'); - // eslint-disable-next-line max-len expect(stack.resolve(parsed.resource)).toEqual({ 'Fn::Select': [0, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', theToken] }] }] }] }); - // eslint-disable-next-line max-len + expect(stack.resolve(parsed.resourceName)).toEqual({ 'Fn::Select': [1, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', theToken] }] }] }] }); }); diff --git a/packages/aws-cdk-lib/core/test/aspect.prop.test.ts b/packages/aws-cdk-lib/core/test/aspect.prop.test.ts index 79d0325bbb7a6..e7f9624ea0661 100644 --- a/packages/aws-cdk-lib/core/test/aspect.prop.test.ts +++ b/packages/aws-cdk-lib/core/test/aspect.prop.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @cdklabs/no-throw-default-error */ import { Construct, IConstruct } from 'constructs'; import * as fc from 'fast-check'; import * as fs from 'fs-extra'; @@ -188,7 +189,7 @@ function afterSynth(block: (x: PrettyApp) => void, aspectStabilization: boolean) let asm; try { asm = app.cdkApp.synth({ aspectStabilization }); - } catch (error) { + } catch (error: any) { if (error.message.includes('Cannot invoke Aspect')) { return; } @@ -236,18 +237,6 @@ function forEveryVisitPair(log: AspectActionLog, block: (a: AspectVisitWithIndex } } -function arraysEqual(arr1: T[], arr2: T[]): boolean { - if (arr1.length !== arr2.length) { - return false; - } - - return arr1.every((value, index) => value === arr2[index]); -} - -function arraysEqualUnordered(arr1: T[], arr2: T[]): boolean { - return arr1.length === arr2.length && new Set(arr1).size === new Set(arr2).size; -} - /** * Given an AspectVisitLog, returns a map of Constructs with a list of all Aspects that * visited the construct. @@ -474,7 +463,7 @@ class PrettyApp { ].join(' ')); prefixes.push(' '); - construct.node.children.forEach((child, i) => { + construct.node.children.forEach((child) => { recurse(child); }); prefixes.pop(); @@ -564,7 +553,7 @@ function buildApplication(appFac: AppFactory, appls: TestAspectApplication[]): P const state: ExecutionState = { actionLog: [], }; - tree[EXECUTIONSTATE_SYM] = state; // Stick this somewhere the aspects can find it + (tree as any)[EXECUTIONSTATE_SYM] = state; // Stick this somewhere the aspects can find it for (const app of appls) { const ctrs = app.constructPaths.map((p) => findConstructDeep(tree, p)); @@ -712,7 +701,7 @@ abstract class TracingAspect implements IAspect { } protected executionState(node: IConstruct): ExecutionState { - return node.node.root[EXECUTIONSTATE_SYM]; + return (node.node.root as any)[EXECUTIONSTATE_SYM]; } visit(node: IConstruct): void { diff --git a/packages/aws-cdk-lib/core/test/aspect.test.ts b/packages/aws-cdk-lib/core/test/aspect.test.ts index dd05e4373790c..a3831a8f0ce4e 100644 --- a/packages/aws-cdk-lib/core/test/aspect.test.ts +++ b/packages/aws-cdk-lib/core/test/aspect.test.ts @@ -129,7 +129,7 @@ describe('aspect', () => { test('Aspects applied without priority get the default priority value', () => { const app = new App(); const root = new MyConstruct(app, 'Construct'); - const child = new MyConstruct(root, 'ChildConstruct'); + new MyConstruct(root, 'ChildConstruct'); // WHEN - adding an Aspect without priority specified Aspects.of(root).add(new MyAspect()); @@ -142,7 +142,7 @@ describe('aspect', () => { test('Can override Aspect priority', () => { const app = new App(); const root = new MyConstruct(app, 'Construct'); - const child = new MyConstruct(root, 'ChildConstruct'); + new MyConstruct(root, 'ChildConstruct'); // WHEN - adding an Aspect without priority specified and resetting it. Aspects.of(root).add(new MyAspect()); @@ -158,7 +158,7 @@ describe('aspect', () => { const stack = new Stack(app, 'My-Stack'); // GIVEN - Bucket with versioning disabled - const bucket = new Bucket(stack, 'my-bucket', { + new Bucket(stack, 'my-bucket', { versioned: false, }); @@ -178,7 +178,7 @@ describe('aspect', () => { const stack = new Stack(app, 'My-Stack'); // GIVEN - Bucket with versioning disabled - const bucket = new Bucket(stack, 'my-bucket', { + new Bucket(stack, 'my-bucket', { bucketName: 'my-original-bucket', versioned: false, }); @@ -197,7 +197,7 @@ describe('aspect', () => { const stack = new Stack(app, 'My-Stack'); // GIVEN - Bucket with versioning disabled - const bucket = new Bucket(stack, 'my-bucket', { + new Bucket(stack, 'my-bucket', { bucketName: 'my-original-bucket', versioned: false, }); @@ -220,7 +220,7 @@ describe('aspect', () => { const stack = new Stack(app, 'My-Stack'); // GIVEN - Bucket with versioning disabled - const bucket = new Bucket(stack, 'my-bucket', { + new Bucket(stack, 'my-bucket', { bucketName: 'my-original-bucket', versioned: false, }); diff --git a/packages/aws-cdk-lib/core/test/cloudformation-json.test.ts b/packages/aws-cdk-lib/core/test/cloudformation-json.test.ts index ec817b115b4af..bba92eb8ac37b 100644 --- a/packages/aws-cdk-lib/core/test/cloudformation-json.test.ts +++ b/packages/aws-cdk-lib/core/test/cloudformation-json.test.ts @@ -1,4 +1,3 @@ -import { Construct } from 'constructs'; import { evaluateCFN } from './evaluate-cfn'; import { App, Aws, CfnOutput, CfnResource, Fn, IPostProcessor, IResolvable, IResolveContext, Lazy, Stack, Token } from '../lib'; import { Intrinsic } from '../lib/private/intrinsic'; diff --git a/packages/aws-cdk-lib/core/test/construct.test.ts b/packages/aws-cdk-lib/core/test/construct.test.ts index 554be0db1de62..c33e2113da92a 100644 --- a/packages/aws-cdk-lib/core/test/construct.test.ts +++ b/packages/aws-cdk-lib/core/test/construct.test.ts @@ -5,8 +5,6 @@ import * as cxschema from '../../cloud-assembly-schema'; import { App, Names } from '../lib'; import { Annotations } from '../lib/annotations'; -/* eslint-disable @typescript-eslint/naming-convention */ - describe('construct', () => { test('the "Root" construct is a special construct which can be used as the root of the tree', () => { const root = new Root(); @@ -135,7 +133,6 @@ describe('construct', () => { expect(t.child1_1_1.node.tryGetContext('ctx2')).toEqual('hello'); }); - // eslint-disable-next-line max-len test('construct.setContext(k,v) sets context at some level and construct.getContext(key) will return the lowermost value defined in the stack', () => { const root = new Root(); const highChild = new Construct(root, 'highChild'); @@ -291,7 +288,6 @@ describe('construct', () => { expect(root.node.children.length).toBeGreaterThanOrEqual(4); }); - // eslint-disable-next-line max-len test('construct.validate() can be implemented to perform validation, ConstructNode.validate(construct.node) will return all errors from the subtree (DFS)', () => { class MyConstruct extends Construct { constructor(scope: Construct, id: string) { diff --git a/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts b/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts index 04484d7d17616..e088a54c313d9 100644 --- a/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts +++ b/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts @@ -1,9 +1,10 @@ +/* eslint-disable @cdklabs/no-throw-default-error */ import * as fs from 'fs'; import * as path from 'path'; import { Construct } from 'constructs'; import { Template } from '../../../assertions'; import * as cxapi from '../../../cx-api'; -import { App, AssetStaging, CustomResourceProvider, DockerImageAssetLocation, DockerImageAssetSource, Duration, FileAssetLocation, FileAssetSource, ISynthesisSession, Size, Stack, CfnResource, determineLatestNodeRuntimeName, CustomResourceProviderBase, CustomResourceProviderBaseProps, CustomResourceProviderOptions, CustomResourceProviderRuntime } from '../../lib'; +import { App, AssetStaging, CustomResourceProvider, DockerImageAssetLocation, DockerImageAssetSource, Duration, FileAssetLocation, FileAssetSource, ISynthesisSession, Size, Stack, CfnResource, determineLatestNodeRuntimeName, CustomResourceProviderBase, CustomResourceProviderOptions, CustomResourceProviderRuntime } from '../../lib'; import { CUSTOMIZE_ROLES_CONTEXT_KEY } from '../../lib/helpers-internal'; import { toCloudFormation } from '../util'; @@ -178,7 +179,6 @@ describe('custom resource provider', () => { // it up from the output. const staging = stack.node.tryFindChild('Custom:MyResourceTypeCustomResourceProvider')?.node.tryFindChild('Staging') as AssetStaging; const assetHash = staging.assetHash; - const sourcePath = staging.sourcePath; const paramNames = Object.keys(cfn.Parameters); const bucketParam = paramNames[0]; const keyParam = paramNames[1]; diff --git a/packages/aws-cdk-lib/core/test/metadata-resource.test.ts b/packages/aws-cdk-lib/core/test/metadata-resource.test.ts index 829de9e1c826e..718b34f444db2 100644 --- a/packages/aws-cdk-lib/core/test/metadata-resource.test.ts +++ b/packages/aws-cdk-lib/core/test/metadata-resource.test.ts @@ -1,7 +1,7 @@ import * as zlib from 'zlib'; import { Construct } from 'constructs'; import { ENABLE_ADDITIONAL_METADATA_COLLECTION } from '../../cx-api'; -import { App, Stack, IPolicyValidationPluginBeta1, IPolicyValidationContextBeta1, Stage, PolicyValidationPluginReportBeta1, FeatureFlags, Duration } from '../lib'; +import { App, Stack, IPolicyValidationPluginBeta1, IPolicyValidationContextBeta1, Stage, PolicyValidationPluginReportBeta1 } from '../lib'; import { formatAnalytics, parseAnalytics } from '../lib/private/metadata-resource'; import { ConstructInfo } from '../lib/private/runtime-info'; diff --git a/packages/aws-cdk-lib/core/test/metadata.test.ts b/packages/aws-cdk-lib/core/test/metadata.test.ts index 5d2877812efa2..e100ef99b1061 100644 --- a/packages/aws-cdk-lib/core/test/metadata.test.ts +++ b/packages/aws-cdk-lib/core/test/metadata.test.ts @@ -196,7 +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', @@ -215,7 +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/core/test/prop-injectors.test.ts b/packages/aws-cdk-lib/core/test/prop-injectors.test.ts index cf10d47a63a31..83ddf91bdd295 100644 --- a/packages/aws-cdk-lib/core/test/prop-injectors.test.ts +++ b/packages/aws-cdk-lib/core/test/prop-injectors.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @cdklabs/no-throw-default-error */ import { Construct } from 'constructs'; import { Annotations, Resource, Stack, Stage } from '../lib'; import { App } from '../lib/app'; @@ -28,7 +29,7 @@ interface TestConstructProps { class TestConstruct extends Resource { public static readonly PROPERTY_INJECTION_ID: string = 'aws-cdk-lib.core.TestConstruct'; - constructor(scope: Construct, id: string, props: TestConstructProps = {}) { + constructor(scope: Construct, id: string, _props: TestConstructProps = {}) { super(scope, id); } } @@ -37,7 +38,7 @@ class TestConstruct extends Resource { class TestConstruct2 extends Resource { public static readonly PROPERTY_INJECTION_ID: string = 'aws-cdk-lib.core.TestConstruct2'; - constructor(scope: Construct, id: string, props: TestConstructProps = {}) { + constructor(scope: Construct, id: string, _props: TestConstructProps = {}) { super(scope, id); } } @@ -86,7 +87,7 @@ class ErrorPropsInjector implements IPropertyInjector { this.constructUniqueId = TestConstruct.PROPERTY_INJECTION_ID; } - inject(originalProps: any, context: InjectionContext): any { + inject(originalProps: any, _context: InjectionContext): any { if (originalProps.prop1 === 'veryBadValue') { throw new Error('prop1 has veryBadValue'); } @@ -388,7 +389,7 @@ describe('TestConstruct Injector', () => { ], }); const stack = new Stack(app, 'MyStack', {}); - const mock = jest.spyOn(Annotations.prototype, 'addWarningV2').mockImplementation(); + jest.spyOn(Annotations.prototype, 'addWarningV2').mockImplementation(); expect(() => { // WHEN @@ -425,7 +426,7 @@ describe('Test Warning', () => { ], }); const stack = new Stack(app, 'MyStack', {}); - const mock = jest.spyOn(Annotations.prototype, 'addWarningV2').mockImplementation(); + jest.spyOn(Annotations.prototype, 'addWarningV2').mockImplementation(); expect(() => { // WHEN diff --git a/packages/aws-cdk-lib/core/test/removal-policies.test.ts b/packages/aws-cdk-lib/core/test/removal-policies.test.ts index c79b29eefdead..d406f162a8e6d 100644 --- a/packages/aws-cdk-lib/core/test/removal-policies.test.ts +++ b/packages/aws-cdk-lib/core/test/removal-policies.test.ts @@ -1,6 +1,5 @@ import { Construct } from 'constructs'; -import { getWarnings } from './util'; -import { App, CfnResource, Stack } from '../lib'; +import { CfnResource, Stack } from '../lib'; import { synthesize } from '../lib/private/synthesis'; import { RemovalPolicies, MissingRemovalPolicies } from '../lib/removal-policies'; import { RemovalPolicy } from '../lib/removal-policy'; diff --git a/packages/aws-cdk-lib/core/test/resource.test.ts b/packages/aws-cdk-lib/core/test/resource.test.ts index 6f98a88739d8b..0f0989d07f763 100644 --- a/packages/aws-cdk-lib/core/test/resource.test.ts +++ b/packages/aws-cdk-lib/core/test/resource.test.ts @@ -196,7 +196,7 @@ describe('resource', () => { autoScalingCreationPolicy: { minSuccessfulInstancesPercent: 10 }, startFleet: true, }; - // eslint-disable-next-line max-len + r1.cfnOptions.updatePolicy = { autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false }, autoScalingReplacingUpdate: { willReplace: true }, diff --git a/packages/aws-cdk-lib/core/test/stack-synthesizers/all-synthesizers.test.ts b/packages/aws-cdk-lib/core/test/stack-synthesizers/all-synthesizers.test.ts index 9eaa8181f4fc9..27e2c9415a39b 100644 --- a/packages/aws-cdk-lib/core/test/stack-synthesizers/all-synthesizers.test.ts +++ b/packages/aws-cdk-lib/core/test/stack-synthesizers/all-synthesizers.test.ts @@ -1,6 +1,6 @@ import { FileAssetPackaging } from '@aws-cdk/cloud-assembly-schema'; import { getAssetManifest, readAssetManifest } from './_helpers'; -import { Aws, CliCredentialsStackSynthesizer, LegacyStackSynthesizer } from '../../lib'; +import { Aws, CliCredentialsStackSynthesizer } from '../../lib'; import { App } from '../../lib/app'; import { Stack } from '../../lib/stack'; import { DefaultStackSynthesizer } from '../../lib/stack-synthesizers/default-synthesizer'; diff --git a/packages/aws-cdk-lib/core/test/stack-synthesizers/bootstrapless-synthesizer.test.ts b/packages/aws-cdk-lib/core/test/stack-synthesizers/bootstrapless-synthesizer.test.ts index 17986d2a25e27..40ced77c91099 100644 --- a/packages/aws-cdk-lib/core/test/stack-synthesizers/bootstrapless-synthesizer.test.ts +++ b/packages/aws-cdk-lib/core/test/stack-synthesizers/bootstrapless-synthesizer.test.ts @@ -53,7 +53,7 @@ describe('BootstraplessSynthesizer', () => { // GIVEN const qualifier = 'custom-qualifier'; const app = new App(); - const stack = new Stack(app, 'Stack', { + new Stack(app, 'Stack', { synthesizer: new BootstraplessSynthesizer({ qualifier, }), diff --git a/packages/aws-cdk-lib/core/test/stack-synthesizers/new-style-synthesis.test.ts b/packages/aws-cdk-lib/core/test/stack-synthesizers/new-style-synthesis.test.ts index 5cd3e5fff30fe..6a4c9ef0db3e6 100644 --- a/packages/aws-cdk-lib/core/test/stack-synthesizers/new-style-synthesis.test.ts +++ b/packages/aws-cdk-lib/core/test/stack-synthesizers/new-style-synthesis.test.ts @@ -2,7 +2,7 @@ import * as fs from 'fs'; import * as cxschema from '../../../cloud-assembly-schema'; import { ArtifactType } from '../../../cloud-assembly-schema'; import * as cxapi from '../../../cx-api'; -import { App, Aws, CfnResource, ContextProvider, DefaultStackSynthesizer, FileAssetPackaging, Stack, NestedStack, DockerImageAssetLocation, DockerImageAssetSource, FileAssetLocation, FileAssetSource, SynthesizeStackArtifactOptions } from '../../lib'; +import { App, Aws, CfnResource, ContextProvider, DefaultStackSynthesizer, FileAssetPackaging, Stack, NestedStack } from '../../lib'; import { ISynthesisSession } from '../../lib/stack-synthesizers/types'; import { evaluateCFN } from '../evaluate-cfn'; import { getAssetManifest, isAssetManifest, readAssetManifest } from './_helpers'; diff --git a/packages/aws-cdk-lib/core/test/stack.test.ts b/packages/aws-cdk-lib/core/test/stack.test.ts index b62953519c0c5..315e6d9ae902f 100644 --- a/packages/aws-cdk-lib/core/test/stack.test.ts +++ b/packages/aws-cdk-lib/core/test/stack.test.ts @@ -15,11 +15,8 @@ import { Aspects, Stage, TagManager, - Resource, TagType, - ITaggable, ITaggableV2, - Token, } from '../lib'; import { Intrinsic } from '../lib/private/intrinsic'; import { resolveReferences } from '../lib/private/refs'; @@ -1836,7 +1833,6 @@ describe('stack', () => { expect(() => { app.synth(); - // eslint-disable-next-line max-len }).toThrow("'Stack1' depends on 'Stack2' (Stack1 -> Stack2.AWS::AccountId). Adding this dependency (Stack2 -> Stack1.AWS::AccountId) would create a cyclic reference."); }); @@ -2256,7 +2252,7 @@ describe('stack', () => { stackTraces: false, }); - const stack = new Stack(app, 'stack1', { + new Stack(app, 'stack1', { tags: { foo: Lazy.string({ produce: () => 'lazy' }), }, diff --git a/packages/aws-cdk-lib/core/test/staging.test.ts b/packages/aws-cdk-lib/core/test/staging.test.ts index d365d850858c6..e018f311174c2 100644 --- a/packages/aws-cdk-lib/core/test/staging.test.ts +++ b/packages/aws-cdk-lib/core/test/staging.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @cdklabs/no-throw-default-error */ import { spawnSync, execSync } from 'child_process'; import * as os from 'os'; import * as path from 'path'; diff --git a/packages/aws-cdk-lib/core/test/tokens.test.ts b/packages/aws-cdk-lib/core/test/tokens.test.ts index 748b90b7dd99a..4f626a40eca36 100644 --- a/packages/aws-cdk-lib/core/test/tokens.test.ts +++ b/packages/aws-cdk-lib/core/test/tokens.test.ts @@ -110,7 +110,6 @@ describe('tokens', () => { expect(resolve({ not_a_token: { resolve: 12 } })).toEqual({ not_a_token: { resolve: 12 } }); }); - // eslint-disable-next-line max-len test('if a resolvable object inherits from a class that is also resolvable, the "constructor" function will not get in the way (uses Object.keys instead of "for in")', () => { expect(resolve({ prop: new DataType() })).toEqual({ prop: { foo: 12, goo: 'hello' } }); }); diff --git a/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/external-id.test.ts b/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/external-id.test.ts index a1cdcad7a0812..986aa59145b37 100644 --- a/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/external-id.test.ts +++ b/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/external-id.test.ts @@ -1,5 +1,5 @@ import { Match, Template } from '../../../assertions'; -import { Role, ServicePrincipal, PolicyStatement } from '../../../aws-iam'; +import { Role, ServicePrincipal } from '../../../aws-iam'; import { Stack } from '../../../core'; import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from '../../lib'; diff --git a/packages/aws-cdk-lib/custom-resources/test/provider-framework/mocks.ts b/packages/aws-cdk-lib/custom-resources/test/provider-framework/mocks.ts index 7d8ba44a7ca39..bfe057afd13cd 100644 --- a/packages/aws-cdk-lib/custom-resources/test/provider-framework/mocks.ts +++ b/packages/aws-cdk-lib/custom-resources/test/provider-framework/mocks.ts @@ -1,3 +1,5 @@ +/* eslint-disable @cdklabs/no-throw-default-error */ +import { OutgoingHttpHeaders } from 'http'; import * as https from 'https'; import { parse as urlparse } from 'url'; import { InvocationResponse, InvokeCommandInput } from '@aws-sdk/client-lambda'; @@ -38,8 +40,8 @@ export async function httpRequestMock(options: https.RequestOptions, body: strin expect(options.path).toEqual(responseUrl.path); expect(options.hostname).toEqual(responseUrl.hostname); const headers = options.headers || {}; - expect(headers['content-length']).toEqual(body.length); - expect(headers['content-type']).toStrictEqual(''); + expect((headers as OutgoingHttpHeaders)['content-length']).toEqual(body.length); + expect((headers as OutgoingHttpHeaders)['content-type']).toStrictEqual(''); cfnResponse = JSON.parse(body); if (!cfnResponse) { throw new Error('unexpected'); } diff --git a/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts b/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts index d6c22bf69e368..692a0c7bbbd73 100644 --- a/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts +++ b/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts @@ -368,7 +368,7 @@ test('Log level are set to FATAL by default', () => { test('uses loggingFormat instead of deprecated logFormat', () => { // GIVEN // Spy on console.warn to check for deprecation warnings - // eslint-disable-next-line no-console + const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => { }); const stack = new Stack(); diff --git a/packages/aws-cdk-lib/custom-resources/test/provider-framework/runtime.test.ts b/packages/aws-cdk-lib/custom-resources/test/provider-framework/runtime.test.ts index 22359d06a83aa..a45538c2eab6f 100644 --- a/packages/aws-cdk-lib/custom-resources/test/provider-framework/runtime.test.ts +++ b/packages/aws-cdk-lib/custom-resources/test/provider-framework/runtime.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable max-len */ + /* eslint-disable no-console */ /* eslint-disable @typescript-eslint/no-require-imports */ import mocks = require('./mocks'); diff --git a/packages/aws-cdk-lib/cx-api/test/cloud-assembly.test.ts b/packages/aws-cdk-lib/cx-api/test/cloud-assembly.test.ts index 8fc2dcc000100..2f6c698acc808 100644 --- a/packages/aws-cdk-lib/cx-api/test/cloud-assembly.test.ts +++ b/packages/aws-cdk-lib/cx-api/test/cloud-assembly.test.ts @@ -119,7 +119,7 @@ testDeprecated('stack artifacts can specify an explicit stack name that is diffe test('getStackByName fails if there are multiple stacks with the same name', () => { const assembly = new CloudAssembly(path.join(FIXTURES, 'multiple-stacks-same-name')); - // eslint-disable-next-line max-len + expect(() => assembly.getStackByName('the-physical-name-of-the-stack')).toThrow(/There are multiple stacks with the stack name \"the-physical-name-of-the-stack\" \(stack1\,stack2\)\. Use \"getStackArtifact\(id\)\" instead/); }); diff --git a/packages/aws-cdk-lib/eslint-suppressions.json b/packages/aws-cdk-lib/eslint-suppressions.json new file mode 100644 index 0000000000000..587013f58ced4 --- /dev/null +++ b/packages/aws-cdk-lib/eslint-suppressions.json @@ -0,0 +1,177 @@ +{ + "assertions/test/match.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 2 + } + }, + "assertions/test/template.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 2 + } + }, + "aws-apigateway/test/authorizers/integ.request-authorizer.handler/index.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-apigateway/test/authorizers/integ.token-authorizer.handler/index.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-codebuild/test/codebuild.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-codebuild/test/project.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 2 + } + }, + "aws-codepipeline-actions/test/cloudformation/pipeline-actions.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 11 + } + }, + "aws-ec2/test/cfn-init.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 2 + } + }, + "aws-ecr-assets/test/build-image-cache.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-ecr-assets/test/custom-synthesis.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-ecr-assets/test/tarball-asset.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-eks/test/alb-controller.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-eks/test/bucket-pinger/bucket-pinger.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-events-targets/test/codepipeline/pipeline.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-iam/test/managed-policy.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-iam/test/policy.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "aws-lambda-nodejs/test/bundling.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "core/test/context.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "core/test/evaluate-cfn.ts": { + "@cdklabs/no-throw-default-error": { + "count": 7 + } + }, + "core/test/logical-id.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "core/test/stack-synthesizers/_helpers.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "core/test/stack-synthesizers/clicreds-synthesis.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "core/test/tokens.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 2 + } + }, + "core/test/validation/validation.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "custom-resources/test/provider-framework/outbound.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 9 + } + }, + "custom-resources/test/provider-framework/runtime.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 4 + } + }, + "custom-resources/test/provider-framework/util.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "pipelines/test/blueprint/helpers-internal/pipeline-graph.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 5 + } + }, + "pipelines/test/blueprint/helpers-internal/util.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "pipelines/test/codepipeline/codepipeline.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 2 + } + }, + "pipelines/test/compliance/assets.test.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "pipelines/test/testhelpers/matchers.ts": { + "@cdklabs/no-throw-default-error": { + "count": 1 + } + }, + "pipelines/test/testhelpers/test-app.ts": { + "@cdklabs/no-throw-default-error": { + "count": 2 + } + }, + "scripts/submodules/index.ts": { + "@cdklabs/no-throw-default-error": { + "count": 3 + } + }, + "scripts/verify-imports-resolve-same.ts": { + "@cdklabs/no-throw-default-error": { + "count": 5 + } + } +} \ No newline at end of file diff --git a/packages/aws-cdk-lib/eslint.config.mjs b/packages/aws-cdk-lib/eslint.config.mjs index 648f74cfa2a84..4768f99cf22aa 100644 --- a/packages/aws-cdk-lib/eslint.config.mjs +++ b/packages/aws-cdk-lib/eslint.config.mjs @@ -1,3 +1,4 @@ import { makeConfig } from '@aws-cdk/eslint-config'; +// We have 2 different projects in this directory with different sets of files. export default makeConfig('tsconfig.json'); diff --git a/packages/aws-cdk-lib/jest.config.js b/packages/aws-cdk-lib/jest.config.js index 861dd4bb1731a..99433b2aae415 100644 --- a/packages/aws-cdk-lib/jest.config.js +++ b/packages/aws-cdk-lib/jest.config.js @@ -1,13 +1,16 @@ +// @ts-check const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); +const ext = require('@aws-cdk/cdk-build-tools/config/ext'); /** @type {import('ts-jest').JestConfigWithTsJest} */ -module.exports = { +const config = { ...baseConfig, // Different than usual testMatch: [ - '/**/test/**/?(*.)+(test).ts', + `/**/test/**/?(*.)+(test).${ext}`, ], + coveragePathIgnorePatterns: ['\\.generated\\.[jt]s$', '/.*/test/', '.warnings.jsii.js$', '/node_modules/'], // Massive parallellism leads to common timeouts @@ -20,5 +23,7 @@ module.exports = { }, }, - testEnvironment: './testhelpers/jest-bufferedconsole.ts', + testEnvironment: `./testhelpers/jest-bufferedconsole.${ext}`, }; + +module.exports = config; diff --git a/packages/aws-cdk-lib/package.json b/packages/aws-cdk-lib/package.json index e7a1836f53c45..58d896d98a20a 100644 --- a/packages/aws-cdk-lib/package.json +++ b/packages/aws-cdk-lib/package.json @@ -12,10 +12,10 @@ "stability": "stable", "maturity": "stable", "scripts": { - "gen": "ts-node -P tsconfig.dev.json scripts/gen.ts", + "gen": "ts-node scripts/gen.ts", "build": "env NODE_OPTIONS=\"--max-old-space-size=8192\" cdk-build", "lint": "env NODE_OPTIONS=\"--max-old-space-size=8192\" cdk-lint", - "test": "jest", + "test": "scripts/maybe-compile-tests.sh && jest", "package": "cdk-package", "pkglint": "pkglint -f", "build+test": "yarn build && yarn test", @@ -26,13 +26,13 @@ "rosetta:extract": "yarn --silent jsii-rosetta extract", "build+extract": "yarn build && yarn rosetta:extract", "build+test+extract": "yarn build+test && yarn rosetta:extract", - "on-bump": "ts-node -P tsconfig.dev.json ./cx-api/build-tools/update-vnext.ts && ts-node -P tsconfig.dev.json ./cx-api/build-tools/flag-report" + "on-bump": "ts-node ./cx-api/build-tools/update-vnext.ts && ts-node ./cx-api/build-tools/flag-report" }, "cdk-build": { "stripDeprecated": true, "compressAssembly": true, "pre": [ - "ts-node -P tsconfig.dev.json region-info/build-tools/generate-static-data.ts", + "ts-node region-info/build-tools/generate-static-data.ts", "(rm -rf core/test/fs/fixtures && cd core/test/fs && tar -xzf fixtures.tar.gz)", "(rm -rf assets/test/fs/fixtures && cd assets/test/fs && tar -xzvf fixtures.tar.gz)", "./scripts/airlift-custom-resource-handlers.sh" diff --git a/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-graph.test.ts b/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-graph.test.ts index b8d4dc53957af..3d3877a51af6e 100644 --- a/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-graph.test.ts +++ b/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-graph.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable import/no-extraneous-dependencies */ + import * as cdkp from '../../../lib'; import { ManualApprovalStep, Step } from '../../../lib'; import { Graph, GraphNode, PipelineGraph } from '../../../lib/helpers-internal'; diff --git a/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-queries.test.ts b/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-queries.test.ts index 5dbac7be9dc72..3c7d995cbe45b 100644 --- a/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-queries.test.ts +++ b/packages/aws-cdk-lib/pipelines/test/blueprint/helpers-internal/pipeline-queries.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable import/no-extraneous-dependencies */ + import * as cdkp from '../../../lib'; import { PipelineQueries } from '../../../lib/helpers-internal/pipeline-queries'; import { AppWithOutput, TestApp } from '../../testhelpers/test-app'; diff --git a/packages/aws-cdk-lib/pipelines/test/compliance/basic-behavior.test.ts b/packages/aws-cdk-lib/pipelines/test/compliance/basic-behavior.test.ts index 87af884173374..86e574fb93dc5 100644 --- a/packages/aws-cdk-lib/pipelines/test/compliance/basic-behavior.test.ts +++ b/packages/aws-cdk-lib/pipelines/test/compliance/basic-behavior.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable import/no-extraneous-dependencies */ + import * as fs from 'fs'; import * as path from 'path'; import { Construct } from 'constructs'; diff --git a/packages/aws-cdk-lib/pipelines/test/compliance/environments.test.ts b/packages/aws-cdk-lib/pipelines/test/compliance/environments.test.ts index 47176cae93edf..436ff14e6663a 100644 --- a/packages/aws-cdk-lib/pipelines/test/compliance/environments.test.ts +++ b/packages/aws-cdk-lib/pipelines/test/compliance/environments.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable import/no-extraneous-dependencies */ + import { Match, Template } from '../../../assertions'; import { Stack } from '../../../core'; import { OneStackApp, PIPELINE_ENV, TestApp, ModernTestGitHubNpmPipeline, stringLike } from '../testhelpers'; diff --git a/packages/aws-cdk-lib/pipelines/test/compliance/self-mutation.test.ts b/packages/aws-cdk-lib/pipelines/test/compliance/self-mutation.test.ts index 7533535de9287..27e5c47836e0a 100644 --- a/packages/aws-cdk-lib/pipelines/test/compliance/self-mutation.test.ts +++ b/packages/aws-cdk-lib/pipelines/test/compliance/self-mutation.test.ts @@ -1,7 +1,5 @@ -/* eslint-disable import/no-extraneous-dependencies */ import { Match, Template } from '../../../assertions'; import * as cb from '../../../aws-codebuild'; -import * as cp from '../../../aws-codepipeline'; import { Stack, Stage } from '../../../core'; import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image'; import { PIPELINE_ENV, TestApp, ModernTestGitHubNpmPipeline } from '../testhelpers'; diff --git a/packages/aws-cdk-lib/pipelines/test/compliance/synths.test.ts b/packages/aws-cdk-lib/pipelines/test/compliance/synths.test.ts index 5ff3552327e4e..a51531a76e596 100644 --- a/packages/aws-cdk-lib/pipelines/test/compliance/synths.test.ts +++ b/packages/aws-cdk-lib/pipelines/test/compliance/synths.test.ts @@ -13,8 +13,6 @@ import { PIPELINE_ENV, TestApp, ModernTestGitHubNpmPipeline, ModernTestGitHubNpm let app: TestApp; let pipelineStack: Stack; -let sourceArtifact: codepipeline.Artifact; -let cloudAssemblyArtifact: codepipeline.Artifact; // Must be unique across all test files, but preferably also consistent const OUTDIR = 'testcdk0.out'; @@ -22,8 +20,6 @@ const OUTDIR = 'testcdk0.out'; beforeEach(() => { app = new TestApp({ outdir: OUTDIR }); pipelineStack = new Stack(app, 'PipelineStack', { env: PIPELINE_ENV }); - sourceArtifact = new codepipeline.Artifact(); - cloudAssemblyArtifact = new codepipeline.Artifact('CloudAsm'); }); afterEach(() => { diff --git a/packages/aws-cdk-lib/pipelines/test/compliance/validations.test.ts b/packages/aws-cdk-lib/pipelines/test/compliance/validations.test.ts index 9c42a66f7b9a4..a3b0b68c54abd 100644 --- a/packages/aws-cdk-lib/pipelines/test/compliance/validations.test.ts +++ b/packages/aws-cdk-lib/pipelines/test/compliance/validations.test.ts @@ -1,4 +1,4 @@ -/* eslint-disable import/no-extraneous-dependencies */ + import { Capture, Match, Template } from '../../../assertions'; import * as codebuild from '../../../aws-codebuild'; import * as codepipeline from '../../../aws-codepipeline'; diff --git a/packages/aws-cdk-lib/pipelines/test/testhelpers/compliance.ts b/packages/aws-cdk-lib/pipelines/test/testhelpers/compliance.ts deleted file mode 100644 index 0ebaefde304f2..0000000000000 --- a/packages/aws-cdk-lib/pipelines/test/testhelpers/compliance.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { describeDeprecated } from '@aws-cdk/cdk-build-tools'; - -interface SkippedSuite { - modern(reason?: string): void; -} - -interface Suite { - readonly doesNotApply: SkippedSuite; - - modern(fn: () => void): void; - - additional(description: string, fn: () => void): void; -} diff --git a/packages/aws-cdk-lib/pipelines/test/testhelpers/index.ts b/packages/aws-cdk-lib/pipelines/test/testhelpers/index.ts index 88e875cc75817..de4654ae887b4 100644 --- a/packages/aws-cdk-lib/pipelines/test/testhelpers/index.ts +++ b/packages/aws-cdk-lib/pipelines/test/testhelpers/index.ts @@ -1,4 +1,3 @@ -export * from './compliance'; export * from './modern-pipeline'; export * from './test-app'; export * from './matchers'; diff --git a/packages/aws-cdk-lib/pipelines/test/testhelpers/modern-pipeline.ts b/packages/aws-cdk-lib/pipelines/test/testhelpers/modern-pipeline.ts index fc85e92c76344..d84294cc387cb 100644 --- a/packages/aws-cdk-lib/pipelines/test/testhelpers/modern-pipeline.ts +++ b/packages/aws-cdk-lib/pipelines/test/testhelpers/modern-pipeline.ts @@ -1,4 +1,4 @@ -/* eslint-disable import/no-extraneous-dependencies */ + import { Construct } from 'constructs'; import * as cdkp from '../../lib'; diff --git a/packages/aws-cdk-lib/scripts/maybe-compile-tests.sh b/packages/aws-cdk-lib/scripts/maybe-compile-tests.sh new file mode 100755 index 0000000000000..cb351d27fb68c --- /dev/null +++ b/packages/aws-cdk-lib/scripts/maybe-compile-tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -eu + +ci=false +case "${CI:-false}" in + "1" | "true" | "yes") ci=true;; +esac + + +# Compile tests if we're running in CI +if ${ci}; then + npx tsc -b tsconfig.json +fi diff --git a/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts b/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts index 99b8ca286a1e2..17d9f11a8e000 100644 --- a/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts +++ b/packages/aws-cdk-lib/scripts/verify-imports-resolve-same.ts @@ -15,7 +15,6 @@ import * as os from 'os'; import * as path from 'path'; import * as fs from 'fs-extra'; -// eslint-disable-next-line import/no-extraneous-dependencies import * as ts from 'typescript'; async function main() { @@ -136,7 +135,6 @@ export const STANDARD_COMPILER_OPTIONS: ts.CompilerOptions = { }; main().catch((e) => { - // eslint-disable-next-line no-console console.error(e); process.exitCode = 1; }); diff --git a/packages/aws-cdk-lib/tsconfig.json b/packages/aws-cdk-lib/tsconfig.json index 4653637b9cee5..6fb0d00bca1e7 100644 --- a/packages/aws-cdk-lib/tsconfig.json +++ b/packages/aws-cdk-lib/tsconfig.json @@ -1,41 +1,15 @@ { + "$": "A tsconfig for all files, for the benefit of the VSCode plugin; necessary because we can't convince the plugin to load anything other than tsconfig.json upwards of the file we are editing, and all tests aren't in a single test/ subdirectory.b", + "extends": "./tsconfig.options.json", "compilerOptions": { - "declarationMap": false, - "inlineSourceMap": true, - "inlineSources": true, - "alwaysStrict": true, - "declaration": true, - "incremental": true, - "lib": [ - "es2022" - ], - "module": "commonjs", - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "stripInternal": true, - "target": "es2022", - "composite": true, - "esModuleInterop": false, - "isolatedModules": true, - "tsBuildInfoFile": "tsconfig.tsbuildinfo" + "tsBuildInfoFile": "tsconfig.tsbuildinfo", + "stripInternal": true }, "include": [ "**/*.ts" ], "exclude": [ "node_modules", - "scripts", - "**/test/**/*.ts", "**/*.d.ts" ], "references": [ diff --git a/packages/aws-cdk-lib/tsconfig.dev.json b/packages/aws-cdk-lib/tsconfig.options.json similarity index 52% rename from packages/aws-cdk-lib/tsconfig.dev.json rename to packages/aws-cdk-lib/tsconfig.options.json index ff45670a5c753..767a4c47cf313 100644 --- a/packages/aws-cdk-lib/tsconfig.dev.json +++ b/packages/aws-cdk-lib/tsconfig.options.json @@ -1,17 +1,16 @@ { - "$": "Config file for ts-node", - "ts-node": { - "preferTsExts": true - }, "compilerOptions": { + "declarationMap": false, + "inlineSourceMap": true, + "inlineSources": true, "alwaysStrict": true, - "experimentalDecorators": true, + "declaration": true, "incremental": true, "lib": [ - "es2022", - "dom" + "es2022" ], - "module": "CommonJS", + "module": "commonjs", + "noEmitOnError": true, "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "noImplicitReturns": true, @@ -24,17 +23,9 @@ "strictNullChecks": true, "strictPropertyInitialization": true, "stripInternal": false, - "target": "ES2022", - "composite": false, - "isolatedModules": true, - "tsBuildInfoFile": "tsconfig.dev.tsbuildinfo" - }, - "include": [ - "**/*.ts" - ], - "exclude": [ - "node_modules", - ".types-compat", - "**/*.d.ts" - ] + "target": "es2022", + "composite": true, + "esModuleInterop": false, + "isolatedModules": true + } } diff --git a/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts b/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts index 0507b33126ff2..9975ba1284abc 100644 --- a/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts +++ b/tools/@aws-cdk/cdk-build-tools/bin/cdk-build.ts @@ -46,12 +46,12 @@ async function main() { if (options.pre) { const commands = options.pre.join(' && '); - await shell([commands], { timers, env }); + await shell([commands], { timers, env, traceName: `pre,${options.currentPackageName}` }); } const gen = genScript(); if (args.gen && gen) { - await shell([gen], { timers, env }); + await shell([gen], { timers, env, traceName: `gen,${options.currentPackageName}` }); } const overrides: CompilerOverrides = { eslint: args.eslint, jsii: args.jsii, tsc: args.tsc }; @@ -62,7 +62,7 @@ async function main() { if (options.post) { const commands = options.post.join(' && '); - await shell([commands], { timers, env }); + await shell([commands], { timers, env, traceName: `post,${options.currentPackageName}` }); } } diff --git a/tools/@aws-cdk/cdk-build-tools/bin/cdk-test.ts b/tools/@aws-cdk/cdk-build-tools/bin/cdk-test.ts index 09d0cf359e309..15154bca22860 100644 --- a/tools/@aws-cdk/cdk-build-tools/bin/cdk-test.ts +++ b/tools/@aws-cdk/cdk-build-tools/bin/cdk-test.ts @@ -47,12 +47,18 @@ async function main() { const testFiles = await unitTestFiles(); if (testFiles.length > 0) { - await shell([args.jest], unitTestOptions); + await shell([args.jest], { + ...unitTestOptions, + traceName: `jest,${options.currentPackageName}`, + }); } // Run integration test if the package has integ test files if (await hasIntegTests()) { - await shell(['integ-runner'], defaultShellOptions); + await shell(['integ-runner'], { + ...defaultShellOptions, + traceName: `integ-runner,${options.currentPackageName}`, + }); } } diff --git a/tools/@aws-cdk/cdk-build-tools/config/ext.js b/tools/@aws-cdk/cdk-build-tools/config/ext.js new file mode 100644 index 0000000000000..620fec7a7ff13 --- /dev/null +++ b/tools/@aws-cdk/cdk-build-tools/config/ext.js @@ -0,0 +1,12 @@ +// In a separate file because this logic needs to be shared between files +// +// On developer boxes we want to run the .ts files directly for quickest +// iteration (save -> run), but on CI machines we want to run the compiled +// JavaScript for highest throughput. + +const isCi = !!process.env.CI || !!process.env.CODEBUILD_BUILD_ID; + +const thisPackageName = require(`${process.cwd()}/package.json`).name; +const isExceptedPackage = ['@aws-cdk/custom-resource-handlers'].includes(thisPackageName); + +module.exports = isCi && !isExceptedPackage ? 'js' : 'ts'; \ No newline at end of file diff --git a/tools/@aws-cdk/cdk-build-tools/config/jest.config.js b/tools/@aws-cdk/cdk-build-tools/config/jest.config.js index 0c47026702afe..ed813f4f653a9 100644 --- a/tools/@aws-cdk/cdk-build-tools/config/jest.config.js +++ b/tools/@aws-cdk/cdk-build-tools/config/jest.config.js @@ -1,28 +1,38 @@ +// @ts-check +// Crazy stuff! +// +// On developer boxes we want to run the .ts files directly for quickest +// iteration (save -> run), but on CI machines we want to run the compiled +// JavaScript for highest throughput. +const ext = require('./ext'); + const thisPackagesPackageJson = require(`${process.cwd()}/package.json`); const setupFilesAfterEnv = []; -if ('aws-cdk-lib' in thisPackagesPackageJson.devDependencies ?? {}) { +if ('aws-cdk-lib' in (thisPackagesPackageJson.devDependencies ?? {})) { // If we depend on aws-cdk-lib, use the provided autoclean hook setupFilesAfterEnv.push('aws-cdk-lib/testhelpers/jest-autoclean'); } else if (thisPackagesPackageJson.name === 'aws-cdk-lib') { // If we *ARE* aws-cdk-lib, use the hook in a slightly different way - setupFilesAfterEnv.push('./testhelpers/jest-autoclean.ts'); + setupFilesAfterEnv.push(`./testhelpers/jest-autoclean.${ext}`); } -module.exports = { +// @ts-check +/** @type {import('jest').Config} */ +const config = { // The preset deals with preferring TS over JS moduleFileExtensions: [ // .ts first to prefer a ts over a js if present 'ts', 'js', ], - testMatch: ['/test/**/?(*.)+(test).ts'], + testMatch: [`/test/**/?(*.)+(test).${ext}`], // Transform TypeScript using ts-jest. Use of this preset still requires the depending - // package to depend on `ts-jest` directly. + // package to depend on `ts-jest` directly. We need to use `babel-jest` on .js files to + // make sure `jest.mock` calls are hoisted to the top of every test file. transform: { - '^.+\\.tsx?$': [ - 'ts-jest' - ], + "\\.jsx?$": ["babel-jest", {}], + '^.+\\.tsx?$': ['ts-jest', { tsConfig: 'tsconfig.json' }], }, // Jest is resource greedy so this shouldn't be more than 50% maxWorkers: '50%', @@ -42,5 +52,12 @@ module.exports = { coveragePathIgnorePatterns: ['\\.generated\\.[jt]s$', '/test/', '.warnings.jsii.js$', '/node_modules/'], reporters: ['default', ['jest-junit', { suiteName: 'jest tests', outputDirectory: 'coverage' }]], + // A consequence of doing this is that snapshots files are always named after + // the currently executing file, which will be different for .ts and .js + // extensions, so we need to do some more work to redirect always to .ts + snapshotResolver: `${__dirname}/snapshot-resolver.js`, + setupFilesAfterEnv, }; + +module.exports = config; \ No newline at end of file diff --git a/tools/@aws-cdk/cdk-build-tools/config/snapshot-resolver.js b/tools/@aws-cdk/cdk-build-tools/config/snapshot-resolver.js new file mode 100644 index 0000000000000..7c6061e2918ed --- /dev/null +++ b/tools/@aws-cdk/cdk-build-tools/config/snapshot-resolver.js @@ -0,0 +1,20 @@ +const path = require('path'); +const ext = require('./ext'); + +const dotext = `.${ext}`; + +module.exports = { + // resolves from test to snapshot path + resolveSnapshotPath: (testPath, snapshotExtension) => { + return `${path.dirname(testPath)}/__snapshots__/${path.basename(testPath, dotext)}.ts${snapshotExtension}`; + }, + + // resolves from snapshot to test path + resolveTestPath: (snapshotFilePath, snapshotExtension) => { + const testDir = path.dirname(path.dirname(snapshotFilePath)); + return `${testDir}/${path.basename(snapshotFilePath, `.ts${snapshotExtension}`)}${dotext}`; + }, + + // Example test path, used for preflight consistency check of the implementation above + testPathForConsistencyCheck: `test/apple.test.${dotext}`, +}; \ No newline at end of file diff --git a/tools/@aws-cdk/cdk-build-tools/lib/compile.ts b/tools/@aws-cdk/cdk-build-tools/lib/compile.ts index 173fea93685b5..ae7e974bd42c0 100644 --- a/tools/@aws-cdk/cdk-build-tools/lib/compile.ts +++ b/tools/@aws-cdk/cdk-build-tools/lib/compile.ts @@ -1,3 +1,4 @@ +import * as path from 'path'; import { makeExecutable, shell } from './os'; import { CDKBuildOptions, CompilerOverrides, currentPackageJson, packageCompiler } from './package-info'; import { Timers } from './timer'; @@ -7,7 +8,10 @@ import { Timers } from './timer'; */ export async function compileCurrentPackage(options: CDKBuildOptions, timers: Timers, compilers: CompilerOverrides = {}): Promise { const env = options.env; - await shell(packageCompiler(compilers, options), { timers, env }); + const compiler = packageCompiler(compilers, options); + + let compilerName = path.basename(compiler[0]); + await shell(compiler, { timers, env, traceName: `${compilerName},${options.currentPackageName}` }); // Find files in bin/ that look like they should be executable, and make them so. const scripts = currentPackageJson().bin || {}; diff --git a/tools/@aws-cdk/cdk-build-tools/lib/lint.ts b/tools/@aws-cdk/cdk-build-tools/lib/lint.ts index 972b522099de6..71a77c45af903 100644 --- a/tools/@aws-cdk/cdk-build-tools/lib/lint.ts +++ b/tools/@aws-cdk/cdk-build-tools/lib/lint.ts @@ -23,14 +23,14 @@ export async function lintCurrentPackage( await shell([ eslintPath, ...fixOption, - ], { timers, env }); + ], { timers, env, traceName: `eslint,${options.currentPackageName}` }); } if (!options.pkglint?.disable) { await shell([ 'pkglint', ...fixOption, - ], { timers, env }); + ], { timers, env, traceName: `pkglint,${options.currentPackageName}` }); } if (await fs.pathExists('README.md')) { @@ -45,5 +45,5 @@ export async function lintCurrentPackage( ], { timers }); } - await shell([path.join(__dirname, '..', 'bin', 'cdk-awslint')], { timers, env }); + await shell([path.join(__dirname, '..', 'bin', 'cdk-awslint')], { timers, env, traceName: `awslint,${options.currentPackageName}` }); } diff --git a/tools/@aws-cdk/cdk-build-tools/lib/os.ts b/tools/@aws-cdk/cdk-build-tools/lib/os.ts index 2af5c1ac08376..83f42b96379fd 100644 --- a/tools/@aws-cdk/cdk-build-tools/lib/os.ts +++ b/tools/@aws-cdk/cdk-build-tools/lib/os.ts @@ -1,5 +1,6 @@ import * as child_process from 'child_process'; import * as fs from 'fs'; +import * as path from 'path'; import * as util from 'util'; import * as chalk from 'chalk'; import { Timers } from './timer'; @@ -7,6 +8,7 @@ import { Timers } from './timer'; interface ShellOptions { timers?: Timers; env?: child_process.SpawnOptions['env']; + traceName?: string; } /** @@ -15,9 +17,24 @@ interface ShellOptions { * Is platform-aware, handles errors nicely. */ export async function shell(command: string[], options: ShellOptions = {}): Promise { - const [cmd, ...args] = command; + let [cmd, ...args] = command; + + const timeFile = '.time.tmp'; + + // Try to trace memory usage with /usr/bin/time if we're tracing + if (options.traceName && process.platform === 'darwin') { + args.unshift('-l', '-o', timeFile, cmd); + cmd = '/usr/bin/time'; + } + if (options.traceName && process.platform === 'linux') { + args.unshift('-v', '-o', timeFile, cmd); + cmd = '/usr/bin/time'; + } + const timer = (options.timers || new Timers()).start(cmd); + const startTime = new Date(); + await makeShellScriptExecutable(cmd); // yarn exec runs the provided command with the correct environment for the workspace. @@ -38,6 +55,7 @@ export async function shell(command: string[], options: ShellOptions = {}): Prom return new Promise((resolve, reject) => { const stdout = new Array(); + const stderr = new Array(); child.stdout!.on('data', chunk => { process.stdout.write(chunk); @@ -45,6 +63,7 @@ export async function shell(command: string[], options: ShellOptions = {}): Prom }); child.stderr!.on('data', chunk => { + stderr.push(chunk); process.stderr.write(makeRed(chunk.toString())); }); @@ -52,6 +71,31 @@ export async function shell(command: string[], options: ShellOptions = {}): Prom child.once('exit', code => { timer.end(); + const endTime = new Date(); + + if (options.traceName) { + // The end of stderr contains the timing measurements + const timing = fs.readFileSync(timeFile, 'utf-8'); + let maxMemMB = 0; + + if (options.traceName && process.platform === 'darwin') { + const f = timing.match(/(\d+) maximum resident set size/); // Bytes + if (f) { + maxMemMB = Number(f[1]) / (1024 * 1024); + } + } + if (options.traceName && process.platform === 'linux') { + const f = timing.match(/Maximum resident set size \(kbytes\): (\d+)/); // kbytes + if (f) { + maxMemMB = Number(f[1]) / 1024; + } + } + + fs.unlinkSync(timeFile); + + writeTrace(options.traceName, startTime, endTime, maxMemMB); + } + if (code === 0) { resolve(Buffer.concat(stdout).toString('utf-8')); } else { @@ -173,3 +217,43 @@ async function isShellScript(script: string): Promise { return buffer.equals(Buffer.from('#!')); } + +/** + * Write a trace file. + * + * We write each to a different file to avoid race conditions appending to a shared file + * in parallel processes. + */ +function writeTrace(name: string, start: Date, end: Date, maxMemMB: number) { + const lernaJson = findUp('lerna.json'); + if (!lernaJson) { + return; + } + const dir = path.join(path.dirname(lernaJson), '.traces'); + fs.mkdirSync(dir, { recursive: true }); + + fs.writeFileSync( + path.join(dir, `${slugify(name)}.csv`), + `"${name}",${start.getTime() / 1000},${end.getTime() / 1000},${maxMemMB}`, + ); +} + +export function findUp(name: string, directory: string = process.cwd()): string | undefined { + const absoluteDirectory = path.resolve(directory); + + const file = path.join(directory, name); + if (fs.existsSync(file)) { + return file; + } + + const { root } = path.parse(absoluteDirectory); + if (absoluteDirectory == root) { + return undefined; + } + + return findUp(name, path.dirname(absoluteDirectory)); +} + +function slugify(x: string): string { + return x.replace(/[^a-zA-Z0-9]/g, '-'); +} diff --git a/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts b/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts index afcb0781a93cd..0a458e0021c4f 100644 --- a/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts +++ b/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts @@ -21,14 +21,23 @@ export function cdkBuildOptions(): CDKBuildOptions { // now it's easiest to just read them from the package JSON. // Our package directories are littered with .json files enough // already. - return currentPackageJson()['cdk-build'] || {}; + const pj = currentPackageJson(); + + return { + ...pj['cdk-build'], + currentPackageName: pj.name, + }; } /** * Return the cdk-package options */ export function cdkPackageOptions(): CDKPackageOptions { - return currentPackageJson()['cdk-package'] || {}; + const pj = currentPackageJson(); + return { + ...pj['cdk-package'], + currentPackageName: pj.name, + }; } /** @@ -121,6 +130,8 @@ export function genScript(): string | undefined { } export interface CDKBuildOptions { + currentPackageName: string; + /** * What CloudFormation scope to generate resources for, if any */ @@ -185,6 +196,8 @@ export interface CDKBuildOptions { } export interface CDKPackageOptions { + currentPackageName: string; + /** * Optional commands (formatted as a list of strings, which will be joined together with the && operator) to run before packaging */ diff --git a/tools/@aws-cdk/integration-test-deployment/test/integration-test-deployment.test.ts b/tools/@aws-cdk/integration-test-deployment/test/integration-test-deployment.test.ts index 020a2fc4cdd78..3c89615c5d466 100644 --- a/tools/@aws-cdk/integration-test-deployment/test/integration-test-deployment.test.ts +++ b/tools/@aws-cdk/integration-test-deployment/test/integration-test-deployment.test.ts @@ -1,4 +1,3 @@ -import { describe, expect, jest, test, beforeEach, beforeAll } from '@jest/globals'; import { AtmosphereAllocationMock } from './atmosphere-mock'; import { gitDiffMock } from './git-mock'; import { AtmosphereAllocation } from '../lib/atmosphere'; diff --git a/tools/@aws-cdk/integration-test-deployment/test/updated-integration-test-detection.test.ts b/tools/@aws-cdk/integration-test-deployment/test/updated-integration-test-detection.test.ts index f04eccb264e46..d0f9e9d9b741a 100644 --- a/tools/@aws-cdk/integration-test-deployment/test/updated-integration-test-detection.test.ts +++ b/tools/@aws-cdk/integration-test-deployment/test/updated-integration-test-detection.test.ts @@ -1,4 +1,3 @@ -import { describe, expect, jest, test } from '@jest/globals'; import { expectedChangedSnapshots } from './git-diff-expected-changed-snapshots'; import { gitDiffMock } from './git-mock'; import * as utils from '../lib/utils'; diff --git a/tools/@aws-cdk/integration-test-deployment/tsconfig.json b/tools/@aws-cdk/integration-test-deployment/tsconfig.json index b36f4affc9ed1..d33b744193e1c 100644 --- a/tools/@aws-cdk/integration-test-deployment/tsconfig.json +++ b/tools/@aws-cdk/integration-test-deployment/tsconfig.json @@ -17,7 +17,7 @@ "isolatedModules": true, "incremental": true, "moduleResolution": "node", - "types": ["node"], + "types": ["node", "jest"], "outDir": "." }, "include": ["**/*.ts"], diff --git a/tools/@aws-cdk/project-sync/test/issue-sync.test.ts b/tools/@aws-cdk/project-sync/test/issue-sync.test.ts index ea1af3c1f85cd..b723cb2fafd84 100644 --- a/tools/@aws-cdk/project-sync/test/issue-sync.test.ts +++ b/tools/@aws-cdk/project-sync/test/issue-sync.test.ts @@ -1,4 +1,3 @@ -import { describe, test, expect, jest, beforeEach } from '@jest/globals'; import * as issueSync from '../lib/issue-sync.js'; import { GithubMock } from './github-mock.js'; import { Github } from '../lib/github.js'; diff --git a/tools/@aws-cdk/project-sync/test/pr-sync.test.ts b/tools/@aws-cdk/project-sync/test/pr-sync.test.ts index 717712cced548..e5447bc8c4a83 100644 --- a/tools/@aws-cdk/project-sync/test/pr-sync.test.ts +++ b/tools/@aws-cdk/project-sync/test/pr-sync.test.ts @@ -1,4 +1,3 @@ -import { describe, test, expect, jest, beforeEach } from '@jest/globals'; import * as prSync from '../lib/pr-sync.js'; import { GithubMock } from './github-mock.js'; import { Github } from '../lib/github.js'; diff --git a/tools/@aws-cdk/project-sync/tsconfig.json b/tools/@aws-cdk/project-sync/tsconfig.json index 07bd78d234c3c..8f42bac11b303 100644 --- a/tools/@aws-cdk/project-sync/tsconfig.json +++ b/tools/@aws-cdk/project-sync/tsconfig.json @@ -17,7 +17,7 @@ "isolatedModules": true, "incremental": true, "moduleResolution": "node", - "types": ["node"] + "types": ["node", "jest"] }, "include": ["**/*.ts"], "exclude": ["**/*.d.ts"]