Skip to content

no-construct-stack-suffix

✅ Using recommended in an ESLint configuration enables this rule.

This rule is to disallow using the Construct or Stack suffix in construct IDs and stack IDs.
(This rule applies only to classes that extends from Construct or Stack.)

If the Construct ID includes "Construct," the issues that should be stopped in the CDK world will leak into the CloudFormation template and the AWS world, so not good.(the same for Stack ID )

✅ Correct Example

ts
import { Construct } from "constructs";
import { Bucket } from "aws-cdk-lib/aws-s3";

export class MyConstruct extends Construct {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    // ✅ When the suffix "Construct" is not added, it is permitted.
    const bucket = new Bucket(this, "MyBucket");
  }
}

❌ Incorrect Example

ts
import { Construct } from "constructs";
import { Bucket } from "aws-cdk-lib/aws-s3";

export class MyConstruct extends Construct {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    // ❌ Shouldn't use the suffix "Construct"
    const bucket = new Bucket(this, "BucketConstruct");
  }
}