Skip to content

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.


🔧 How to use

ts
// oxlint.config.ts
export default defineConfig({
  // ... some configs
  rules: {
    "awscdk/pascal-case-construct-id": "error",
  },
});
js
// eslint.config.mjs
export default defineConfig({
  // ... some configs
  rules: {
    "awscdk/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");