Skip to content

Commit

Permalink
chore: remove TSLint (#8946)
Browse files Browse the repository at this point in the history
On every build, we are basically compiling our code 3 times: once with
jsii, once with eslint and once with tslint. 

Between these, TSLint is deprecated, so why are we even doing this
anymore? Reduce build times by removing TSLint and migrating all the
rules we were getting from it to ESLint.

Also, with the current setup you need 2 plugins installed into your
IDE to get all linting errors reported as-you-type. Reduce to one
plugin.

This change makes `lerna run lint` run successfully, which was also not the case.

This change shaves 5 minutes (25%) off of the PR build (21 minutes down to 16 minutes).

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr committed Jul 10, 2020
1 parent 4943efe commit 16d2a48
Show file tree
Hide file tree
Showing 393 changed files with 903 additions and 836 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/lib/assertions/have-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class HaveResourceAssertion extends JestFriendlyAssertion<StackInspector>
}

public get description(): string {
// tslint:disable-next-line:max-line-length
// eslint-disable-next-line max-len
return `resource '${this.resourceType}' with ${JSON.stringify(this.matcher, undefined, 2)}`;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assert/lib/synth-utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import * as fs from 'fs';
import * as path from 'path';
import * as core from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';

export class SynthUtils {
public static synthesize(stack: core.Stack, options: core.SynthesisOptions = { }): cxapi.CloudFormationStackArtifact {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assert/test/have-output.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cxapi from '@aws-cdk/cx-api';
import { unlink, writeFileSync } from 'fs';
import { join } from 'path';
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cxapi from '@aws-cdk/cx-api';
import '../jest';

let templateFilePath: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assert/test/have-resource.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cxapi from '@aws-cdk/cx-api';
import { writeFileSync } from 'fs';
import { join } from 'path';
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cxapi from '@aws-cdk/cx-api';
import { ABSENT, arrayWith, exactValue, expect as cdkExpect, haveResource, haveResourceLike } from '../lib/index';

test('support resource with no properties', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class App extends Resource implements IApp, iam.IGrantable {
buildSpec: props.autoBranchCreation.buildSpec && props.autoBranchCreation.buildSpec.toBuildSpec(),
enableAutoBranchCreation: true,
enableAutoBuild: props.autoBranchCreation.autoBuild === undefined ? true : props.autoBranchCreation.autoBuild,
environmentVariables: Lazy.anyValue({ produce: () => renderEnvironmentVariables(this.autoBranchEnvironmentVariables )}, { omitEmptyArray: true }), // tslint:disable-line max-line-length
environmentVariables: Lazy.anyValue({ produce: () => renderEnvironmentVariables(this.autoBranchEnvironmentVariables )}, { omitEmptyArray: true }), // eslint-disable-line max-len
enablePullRequestPreview: props.autoBranchCreation.pullRequestPreview === undefined ? true : props.autoBranchCreation.pullRequestPreview,
pullRequestEnvironmentName: props.autoBranchCreation.pullRequestEnvironmentName,
stage: props.autoBranchCreation.stage,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2012-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Originally generated from the AWS CloudFormation Resource Specification. Now, hand managed.

// tslint:disable:max-line-length
/* eslint-disable max-len */

import * as cdk from '@aws-cdk/core';

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class Method extends Resource {
credentials = options.credentialsRole.roleArn;
} else if (options.credentialsPassthrough) {
// arn:aws:iam::*:user/*
// tslint:disable-next-line:max-line-length
// eslint-disable-next-line max-len
credentials = Stack.of(this).formatArn({ service: 'iam', region: '', account: '*', resource: 'user', sep: '/', resourceName: '*' });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:no-console
/* eslint-disable no-console */

export const handler = async (event: any, _context: any = {}): Promise<any> => {
const authToken: string = event.headers.Authorization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// !cdk-integ pragma:ignore-assets
import * as lambda from '@aws-cdk/aws-lambda';
import { App, Stack } from '@aws-cdk/core';
import * as path from 'path';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// !cdk-integ pragma:ignore-assets
import * as iam from '@aws-cdk/aws-iam';
import * as lambda from '@aws-cdk/aws-lambda';
import { App, Stack } from '@aws-cdk/core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:no-console
/* eslint-disable no-console */

export const handler = async (event: any, _context: any = {}): Promise<any> => {
const authToken: string = event.authorizationToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// !cdk-integ pragma:ignore-assets
import * as lambda from '@aws-cdk/aws-lambda';
import { App, Stack } from '@aws-cdk/core';
import * as path from 'path';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports.handler = async (evt: any) => {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error(JSON.stringify(evt, undefined, 2));
return {
statusCode: 200,
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-apigateway/test/integ.cors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// !cdk-integ pragma:ignore-assets
import * as lambda from '@aws-cdk/aws-lambda';
import { App, Construct, Stack, StackProps } from '@aws-cdk/core';
import * as path from 'path';
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-apigateway/test/test.domains.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// tslint:disable:object-literal-key-quotes
import { ABSENT, expect, haveResource } from '@aws-cdk/assert';
import * as acm from '@aws-cdk/aws-certificatemanager';
import { Stack } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as apigw from '../lib';

/* eslint-disable quote-props */

export = {
'can define either an EDGE or REGIONAL domain name'(test: Test) {
// GIVEN
Expand Down Expand Up @@ -365,7 +366,7 @@ export = {
});

const testStage = new apigw.Stage(stack, 'test-stage', {
deployment : testDeploy,
deployment: testDeploy,
});

// WHEN
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.lambda-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as cdk from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as apigw from '../lib';

// tslint:disable:object-literal-key-quotes
/* eslint-disable quote-props */

export = {
'LambdaRestApi defines a REST API with Lambda proxy integration'(test: Test) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Stack } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as apigw from '../lib';

// tslint:disable:object-literal-key-quotes
/* eslint-disable quote-props */

export = {
'ProxyResource defines a "{proxy+}" resource with ANY method'(test: Test) {
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-apigateway/test/test.restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { App, CfnElement, CfnResource, Stack } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as apigw from '../lib';

// tslint:disable:max-line-length
/* eslint-disable max-len */

export = {
'minimal setup'(test: Test) {
Expand Down Expand Up @@ -956,7 +956,7 @@ export = {
test.done();
},

'Import': {
Import: {
'fromRestApiId()'(test: Test) {
// GIVEN
const stack = new Stack();
Expand Down Expand Up @@ -995,7 +995,7 @@ export = {
},
},

'SpecRestApi': {
SpecRestApi: {
'add Methods and Resources'(test: Test) {
// GIVEN
const stack = new Stack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export = {
return steps.every(step => {
return reportFalse(intervals.find(interval => {
const acceptableLowerBounds = step.MetricIntervalLowerBound === -Infinity ? [undefined, 0] : [undefined, step.MetricIntervalLowerBound];
// tslint:disable-next-line:max-line-length
// eslint-disable-next-line max-len
const acceptableUpperBounds = step.MetricIntervalUpperBound === Infinity ? [undefined, Infinity] : [undefined, step.MetricIntervalUpperBound];

return (acceptableLowerBounds.includes(interval.lower) && acceptableUpperBounds.includes(interval.upper));
Expand Down Expand Up @@ -259,7 +259,7 @@ function apply<T, U>(x: T | undefined, f: (x: T) => U | undefined): U | undefine
*/
function reportFalse(cond: boolean, ...repr: any[]) {
if (!cond) {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error('PROPERTY FAILS ON:', ...repr);
}
return cond;
Expand Down
24 changes: 12 additions & 12 deletions packages/@aws-cdk/aws-autoscaling/test/auto-scaling-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as cdk from '@aws-cdk/core';
import { nodeunitShim, Test } from 'nodeunit-shim';
import * as autoscaling from '../lib';

// tslint:disable:object-literal-key-quotes
/* eslint-disable quote-props */

nodeunitShim({
'default fleet'(test: Test) {
Expand Down Expand Up @@ -1134,17 +1134,17 @@ nodeunitShim({

// THEN
expect(stack).to(haveResource('AWS::AutoScaling::AutoScalingGroup', {
NotificationConfigurations : [
NotificationConfigurations: [
{
TopicARN : { Ref : 'MyTopic86869434' },
NotificationTypes : [
TopicARN: { Ref: 'MyTopic86869434' },
NotificationTypes: [
'autoscaling:EC2_INSTANCE_LAUNCH_ERROR',
'autoscaling:EC2_INSTANCE_TERMINATE_ERROR',
],
},
{
TopicARN : { Ref : 'MyTopic86869434' },
NotificationTypes : [
TopicARN: { Ref: 'MyTopic86869434' },
NotificationTypes: [
'autoscaling:EC2_INSTANCE_TERMINATE',
],
},
Expand Down Expand Up @@ -1174,10 +1174,10 @@ nodeunitShim({

// THEN
expect(stack).to(haveResource('AWS::AutoScaling::AutoScalingGroup', {
NotificationConfigurations : [
NotificationConfigurations: [
{
TopicARN : { Ref : 'MyTopic86869434' },
NotificationTypes : [
TopicARN: { Ref: 'MyTopic86869434' },
NotificationTypes: [
'autoscaling:EC2_INSTANCE_LAUNCH',
'autoscaling:EC2_INSTANCE_LAUNCH_ERROR',
'autoscaling:EC2_INSTANCE_TERMINATE',
Expand Down Expand Up @@ -1206,10 +1206,10 @@ nodeunitShim({

// THEN
expect(stack).to(haveResource('AWS::AutoScaling::AutoScalingGroup', {
NotificationConfigurations : [
NotificationConfigurations: [
{
TopicARN : { Ref : 'MyTopic86869434' },
NotificationTypes : [
TopicARN: { Ref: 'MyTopic86869434' },
NotificationTypes: [
'autoscaling:EC2_INSTANCE_LAUNCH',
'autoscaling:EC2_INSTANCE_LAUNCH_ERROR',
'autoscaling:EC2_INSTANCE_TERMINATE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class TaskDefinition {
*
* @internal
*/
// tslint:disable-next-line: no-empty
public _linkContainer() {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('Batch Compute Evironment', () => {
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
hardwareType: ecs.AmiHardwareType.STANDARD,
}),
instanceRole: new iam.CfnInstanceProfile(stack, 'Instance-Profile', {
instanceRole: new iam.CfnInstanceProfile(stack, 'Instance-Profile', {
roles: [ new iam.Role(stack, 'Ecs-Instance-Role', {
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
managedPolicies: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"build": "echo No build",
"test": "jest",
"lint": "eslint lib",
"eslint": "eslint lib",
"build+test+package": "npm run build+test",
"build+test": "npm run build && npm test"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export enum ValidationMethod {
DNS = 'DNS',
}

// tslint:disable-next-line:max-line-length
// eslint-disable-next-line max-len
function renderDomainValidation(validation: CertificateValidation, domainNames: string[]): CfnCertificate.DomainValidationOptionProperty[] | undefined {
const domainValidation: CfnCertificate.DomainValidationOptionProperty[] = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file has been generated using ../suffixes/build-map.py
// tslint:disable:no-trailing-whitespace object-literal-key-quotes
/* eslint-disable quote-props */
export const publicSuffixes = {
'ac': {
'com': {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:no-console
/* eslint-disable no-console */

exports.handler = async (evt: any) => {
console.error(JSON.stringify(evt, undefined, 2));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable: no-console
/* eslint-disable no-console */

export function handler(event: any) {
console.log('I am a custom resource');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// !cdk-integ pragma:ignore-assets
/*
* Stack verification steps:
* - Deploy with `--no-clean`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// !cdk-integ pragma:ignore-assets
import * as lambda from '@aws-cdk/aws-lambda';
import { App, Construct, Stack } from '@aws-cdk/core';
import * as path from 'path';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as fs from 'fs';
import * as path from 'path';
import { expect, haveResource, matchTemplate, SynthUtils } from '@aws-cdk/assert';
import * as s3_assets from '@aws-cdk/aws-s3-assets';
import * as sns from '@aws-cdk/aws-sns';
import { App, CfnParameter, CfnResource, Construct, ContextProvider, Stack } from '@aws-cdk/core';
import * as fs from 'fs';
import { Test } from 'nodeunit';
import * as path from 'path';
import { NestedStack } from '../lib/nested-stack';

// tslint:disable:max-line-length
/* eslint-disable max-len */

export = {
'fails if defined as a root'(test: Test) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudformation/test/test.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as cdk from '@aws-cdk/core';
import { Test, testCase } from 'nodeunit';
import { CustomResource, CustomResourceProvider } from '../lib';

// tslint:disable:object-literal-key-quotes
/* eslint-disable quote-props */

export = testCase({
'custom resources honor removalPolicy': {
Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ export class GeoRestriction {
}
locations.forEach(location => {
if (!GeoRestriction.LOCATION_REGEX.test(location)) {
// eslint-disable-next-line max-len
throw new Error(`Invalid location format for location: ${location}, location should be two-letter and uppercase country ISO 3166-1-alpha-2 code`);
}
});
Expand Down Expand Up @@ -739,7 +740,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements IDistrib
httpVersion: props.httpVersion || HttpVersion.HTTP2,
priceClass: props.priceClass || PriceClass.PRICE_CLASS_100,
ipv6Enabled: (props.enableIpV6 !== undefined) ? props.enableIpV6 : true,
// tslint:disable-next-line:max-line-length
// eslint-disable-next-line max-len
customErrorResponses: props.errorConfigurations, // TODO: validation : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-customerrorresponse.html#cfn-cloudfront-distribution-customerrorresponse-errorcachingminttl
webAclId: props.webACLId,
};
Expand Down Expand Up @@ -883,7 +884,7 @@ export class CloudFrontWebDistribution extends cdk.Construct implements IDistrib
const validProtocols = this.VALID_SSL_PROTOCOLS[sslSupportMethod as SSLMethod];

if (validProtocols.indexOf(minimumProtocolVersion.toString()) === -1) {
// tslint:disable-next-line:max-line-length
// eslint-disable-next-line max-len
throw new Error(`${minimumProtocolVersion} is not compabtible with sslMethod ${sslSupportMethod}.\n\tValid Protocols are: ${validProtocols.join(', ')}`);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', {
s3OriginSource: {
s3BucketSource: sourceBucket,
},
behaviors : [ {isDefaultBehavior: true}],
behaviors: [ {isDefaultBehavior: true}],
},
],
geoRestriction: cloudfront.GeoRestriction.whitelist('US', 'UK'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', {
s3OriginSource: {
s3BucketSource: sourceBucket,
},
behaviors : [ {isDefaultBehavior: true}],
behaviors: [ {isDefaultBehavior: true}],
},
],
enableIpV6: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', {
s3OriginSource: {
s3BucketSource: sourceBucket,
},
behaviors : [ {isDefaultBehavior: true, lambdaFunctionAssociations: [{
behaviors: [ {isDefaultBehavior: true, lambdaFunctionAssociations: [{
eventType: cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
lambdaFunction: lambdaVersion,
}]}],
Expand Down

0 comments on commit 16d2a48

Please sign in to comment.