Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(eslint): enforce no extra semicolons #32724

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ export async function fetchPreviousVersion(token: string, options?: {
if (previousMVRelease) { return previousMVRelease; }

throw new Error(`Unable to find previous version given ${JSON.stringify(options)}`);
};
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/integ-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface TestContext {
readonly randomString: string;
readonly output: NodeJS.WritableStream;
log(s: string): void;
};
}

if (process.env.JEST_TEST_CONCURRENT === 'true') {
process.stderr.write('ℹ️ JEST_TEST_CONCURRENT is true: tests will run concurrently and filters have no effect!\n0');
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cloudformation-diff/lib/diff/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function deepEqual(lvalue: any, rvalue: any): boolean {
for (const key of keys) {
if (!rvalue.hasOwnProperty(key)) { return false; }
if (key === 'DependsOn') {
if (!dependsOnEqual(lvalue[key], rvalue[key])) { return false; };
if (!dependsOnEqual(lvalue[key], rvalue[key])) { return false; }
// check differences other than `DependsOn`
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/toolkit/lib/actions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ export class StackParameters {
*/
public static onlyExisting() {
return new StackParameters({}, true);
};
}

/**
* Use exactly these parameters and remove any other existing parameters from the stack.
*/
public static exactly(params: { [name: string]: string | undefined }) {
return new StackParameters(params, false);
};
}

/**
* Define additional parameters for the stack, while keeping existing parameters for unspecified values.
*/
public static withExisting(params: { [name: string]: string | undefined }) {
return new StackParameters(params, true);
};
}

public readonly parameters: Map<string, string | undefined>;
public readonly keepExistingParameters: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/assertions/lib/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class SerializedJson extends Matcher {
private readonly pattern: any,
) {
super();
};
}

public test(actual: any): MatchResult {
if (getType(actual) !== 'string') {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/assertions/lib/private/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function hasNoMessage(messages: Messages, constructPath: string, props: a
function redactTraces(match: any, redact: boolean = true): void {
if (redact && match.entry?.trace !== undefined) {
match.entry.trace = 'redacted';
};
}
}

function filterPath(section: { [key: string]: SynthesisMessage }, path: string): { [key: string]: SynthesisMessage } {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/assertions/test/annotations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class MyAspect implements IAspect {
this.info(node, 'this is an info');
}
}
};
}

protected warn(node: IConstruct, message: string): void {
// Use construct ID as suppression string, just to make it unique easily
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-apigatewayv2/lib/http/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class HttpRoute extends Resource implements IHttpRoute {
// path variable and all that follows with a wildcard.
if (path.length > 1000) {
throw new Error(`Path is too long: ${path}`);
};
}
const iamPath = path.replace(/\{.*?\}.*/, '*');

return `arn:${Aws.PARTITION}:execute-api:${this.env.region}:${this.env.account}:${this.httpApi.apiId}/${stage}/${iamHttpMethod}${iamPath}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface IMappingValue {
* Represents a Mapping Value.
*/
readonly value: string;
};
}

/**
* Represents a Mapping Value.
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-appmesh/lib/shared-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export abstract class LoggingFormat {
}

return new JsonLoggingFormat(jsonLoggingFormat);
};
}

/**
* Called when the Access Log Format is initialized. Can be used to enforce
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-appsync/lib/graphqlapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ export class GraphqlApi extends GraphqlApiBase {
public addSchemaDependency(construct: CfnResource): boolean {
if (this.schemaResource) {
construct.addDependency(this.schemaResource);
};
}
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-appsync/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface SchemaProps {
* existing file from disk.
*/
readonly filePath: string;
};
}

/**
* The Schema for a GraphQL Api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ export class EcsEc2ContainerDefinition extends EcsContainerDefinitionBase implem
privileged: this.privileged,
resourceRequirements: this._renderResourceRequirements(),
};
};
}

/**
* Add a ulimit to this container
Expand Down Expand Up @@ -1099,7 +1099,7 @@ export class EcsFargateContainerDefinition extends EcsContainerDefinitionBase im
}

return containerDef;
};
}
}

function createExecutionRole(scope: Construct, id: string, logging: boolean): iam.IRole {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ export class EksContainerDefinition extends Construct implements IEksContainerDe
},
}),
};
};
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class KeyAlgorithm {
* The name of the algorithm
*/
public readonly name: string,
) { };
) { }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class S3BucketOriginWithOAC extends S3BucketOrigin {
const result = key.addToResourcePolicy(oacKeyPolicyStatement);
return result;
}
};
}

class S3BucketOriginWithOAI extends S3BucketOrigin {
private readonly bucket: IBucket;
Expand All @@ -236,7 +236,7 @@ class S3BucketOriginWithOAI extends S3BucketOrigin {
this.originAccessIdentity = new cloudfront.OriginAccessIdentity(oaiScope, oaiId, {
comment: `Identity for ${options.originId}`,
});
};
}
// Used rather than `grantRead` because `grantRead` will grant overly-permissive policies.
// Only GetObject is needed to retrieve objects for the distribution.
// This also excludes KMS permissions; OAI only supports SSE-S3 for buckets.
Expand All @@ -260,4 +260,4 @@ class S3BucketOriginWithOAI extends S3BucketOrigin {
}
return { originAccessIdentity: `origin-access-identity/cloudfront/${this.originAccessIdentity.originAccessIdentityId}` };
}
};
}
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-cloudwatch/lib/alarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function assertSubmetricsCount(expr: MetricExpressionConfig) {
if (Object.keys(expr.usingMetrics).length > 10) {
// https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarms-on-metric-math-expressions
throw new Error('Alarms on math expressions cannot contain more than 10 individual metrics');
};
}
}

type Writeable<T> = { -readonly [P in keyof T]: T[P] };
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,14 @@ export class Metric implements IMetric {
dimsArray.map(key => {
if (dims[key] === undefined || dims[key] === null) {
throw new Error(`Dimension value of '${dims[key]}' is invalid`);
};
}
if (key.length < 1 || key.length > 255) {
throw new Error(`Dimension name must be at least 1 and no more than 255 characters; received ${key}`);
};
}

if (dims[key].length < 1 || dims[key].length > 255) {
throw new Error(`Dimension value must be at least 1 and no more than 255 characters; received ${dims[key]}`);
};
}
});

return dims;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-codebuild/lib/build-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,4 @@ function mergeDeep(lhs: any, rhs: any): any {
}

return rhs;
};
}
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,8 @@ export class Project extends ProjectBase {
if (!Token.isUnresolved(props.autoRetryLimit) && (props.autoRetryLimit !== undefined)) {
if (props.autoRetryLimit < 0 || props.autoRetryLimit > 10) {
throw new Error(`autoRetryLimit must be a value between 0 and 10, got ${props.autoRetryLimit}.`);
};
};
}
}

const resource = new CfnProject(this, 'Resource', {
description: props.description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('StackSetAction', () => {
template: cpactions.StackSetTemplate.fromArtifactPath(stack.sourceOutput.atPath('template.yaml')),
parameters: cpactions.StackSetParameters.fromArtifactPath(stack.sourceOutput.atPath('parameters.json')),
};
};
}

describe('self-managed mode', () => {
test('creates admin role if not specified', () => {
Expand Down Expand Up @@ -354,7 +354,7 @@ describe('StackInstancesAction', () => {
failureTolerancePercentage: 50,
maxAccountConcurrencyPercentage: 25,
};
};
}

test('simple', () => {
stack.deployStage.addAction(new cpactions.CloudFormationDeployStackInstancesAction({
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-codepipeline/test/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ function createPipelineWithSourceAndBuildStages(scope: Construct, pipelineName?:
},
],
});
};
}

interface CreatePipelineStackOptions {
readonly withFeatureFlag?: boolean;
Expand All @@ -1053,7 +1053,7 @@ function createPipelineStack(options: CreatePipelineStackOptions): PipelineStack
pipelineName: `Actual-Pipeline-${options.suffix}`.substring(0, 100),
pipelineId: options.pipelineId,
});
};
}

// Adding 2 stages with actions so pipeline validation will pass
function testPipelineSetup(pipeline: codepipeline.Pipeline, sourceActions?: codepipeline.IAction[], buildActions?: codepipeline.IAction[]) {
Expand Down
10 changes: 5 additions & 5 deletions packages/aws-cdk-lib/aws-codepipeline/test/triggers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ describe('triggers', () => {
},
}],
});
}).toThrow(/length of pushFilter for sourceAction with name 'CodeStarConnectionsSourceAction' must be less than or equal to 3, got 4/);;
}).toThrow(/length of pushFilter for sourceAction with name 'CodeStarConnectionsSourceAction' must be less than or equal to 3, got 4/);
});

test('throw if length of pullRequestFilter is greater than 3', () => {
Expand Down Expand Up @@ -855,7 +855,7 @@ describe('triggers', () => {
},
}],
});
}).toThrow(/length of pullRequestFilter for sourceAction with name 'CodeStarConnectionsSourceAction' must be less than or equal to 3, got 4/);;
}).toThrow(/length of pullRequestFilter for sourceAction with name 'CodeStarConnectionsSourceAction' must be less than or equal to 3, got 4/);
});

test('throw if both pushFilter and pullRequestFilter are specified', () => {
Expand All @@ -881,7 +881,7 @@ describe('triggers', () => {
},
}],
});
}).toThrow(/cannot specify both pushFilter and pullRequestFilter for the trigger with sourceAction with name 'CodeStarConnectionsSourceAction'/);;
}).toThrow(/cannot specify both pushFilter and pullRequestFilter for the trigger with sourceAction with name 'CodeStarConnectionsSourceAction'/);
});

test('throw if neither pushFilter nor pullRequestFilter are specified', () => {
Expand All @@ -895,7 +895,7 @@ describe('triggers', () => {
},
}],
});
}).toThrow(/must specify either pushFilter or pullRequestFilter for the trigger with sourceAction with name 'CodeStarConnectionsSourceAction'/);;
}).toThrow(/must specify either pushFilter or pullRequestFilter for the trigger with sourceAction with name 'CodeStarConnectionsSourceAction'/);
});

test('throw if both pushFilter and pullRequestFilter are empty arrays', () => {
Expand All @@ -911,7 +911,7 @@ describe('triggers', () => {
},
}],
});
}).toThrow(/must specify either pushFilter or pullRequestFilter for the trigger with sourceAction with name 'CodeStarConnectionsSourceAction'/);;
}).toThrow(/must specify either pushFilter or pullRequestFilter for the trigger with sourceAction with name 'CodeStarConnectionsSourceAction'/);
});

test('throw if provider of sourceAction is not \'CodeStarSourceConnection\'', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-cognito/lib/user-pool-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export class UserPoolClient extends Resource implements IUserPoolClient {
accessToken: props.accessTokenValidity ? 'minutes' : undefined,
refreshToken: props.refreshTokenValidity ? 'minutes' : undefined,
};
};
}

resource.idTokenValidity = props.idTokenValidity ? props.idTokenValidity.toMinutes() : undefined;
resource.refreshTokenValidity = props.refreshTokenValidity ? props.refreshTokenValidity.toMinutes() : undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-cognito/lib/user-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export enum FeaturePlan {
ESSENTIALS = 'ESSENTIALS',
/** Plus feature plan */
PLUS = 'PLUS',
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be no eslint rule regarding semicolons in interface definitions, but the overwhelming majority of interface definitions in this file do not have semicolons.
Therefore, we believe that this semicolon should also be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this modification is not needed, I'll remove it.


/**
* Props for the UserPool construct
Expand Down Expand Up @@ -927,7 +927,7 @@ export class UserPool extends UserPoolBase {

const userPoolId = arnParts.resourceName;
// ex) cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdefghi
const providerName = `cognito-idp.${arnParts.region}.${Stack.of(scope).urlSuffix}/${userPoolId}`;;
const providerName = `cognito-idp.${arnParts.region}.${Stack.of(scope).urlSuffix}/${userPoolId}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 There are 18 occurrences of ;; in the project at the moment. It would be nice to adjust the other 17 as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be similarly amazing to figure out why its happening and/or add a linter rule against it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lpizzinidev @kaizencc
added @stylistic/js/no-extra-semi rule.


class ImportedUserPool extends UserPoolBase {
public readonly userPoolArn = userPoolArn;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-config/lib/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export class CustomRule extends RuleNew {
principal: new iam.ServicePrincipal('config.amazonaws.com'),
sourceAccount: this.env.account,
});
};
}

if (props.lambdaFunction.role) {
props.lambdaFunction.role.addManagedPolicy(
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/aws-ec2/lib/launch-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export enum CpuCredits {
* @see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-unlimited-mode.html
*/
UNLIMITED = 'unlimited',
};
}

/**
* Provides the options for specifying the instance initiated shutdown behavior.
Expand All @@ -66,7 +66,7 @@ export enum InstanceInitiatedShutdownBehavior {
* The instance will be terminated when it initiates a shutdown.
*/
TERMINATE = 'terminate',
};
}

/**
* Interface for LaunchTemplate-like objects.
Expand Down Expand Up @@ -191,7 +191,7 @@ export interface LaunchTemplateSpotOptions {
* @default The default end date is 7 days from the current date.
*/
readonly validUntil?: Expiration;
};
}

/**
* The state of token usage for your instance metadata requests.
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/aws-ec2/lib/prefix-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ export class PrefixList extends PrefixListBase {
if (props?.prefixListName) {
if ( props.prefixListName.startsWith('com.amazonaws')) {
throw new Error('The name cannot start with \'com.amazonaws.\'');
};
}
if (props.prefixListName.length > 255 ) {
throw new Error('Lengths exceeding 255 characters cannot be set.');
};
};
}
}

this.prefixListName = this.physicalName;

Expand Down
Loading
Loading