pascal-case-construct-id β
β
Using recommended in an ESLint configuration enables this rule.
π§ Some problems reported by this rule are automatically fixable by the --fix ESLint command line option
This rule enforces writing Construct IDs in PascalCase.
Enforcing a consistent naming convention helps developers manage logical IDs more easily, and as a result, helps reduce the risk of unintentional logical ID collisions.
(This rule applies only to classes that extends from Construct or Stack.)
π§ How to use β
js
// eslint.config.mjs
export default defineConfig([
{
// ... some configs
rules: {
"cdk/pascal-case-construct-id": "error",
},
},
]);β Correct Example β
ts
import { Bucket } from "aws-cdk-lib/aws-s3";
// β
Can use PascalCase
const bucket = new Bucket(this, "MyBucket");β Incorrect Example β
ts
import { Bucket } from "aws-cdk-lib/aws-s3";
// β Shouldn't use camelCase
const bucket = new Bucket(this, "myBucket");
// β Shouldn't use snake_case
const bucket = new Bucket(this, "my_bucket");
// β Shouldn't use kebab-case
const bucket = new Bucket(this, "my-bucket");