props-name-convention
ℹ️ This rule is not included in the recommended rules.
Forces the Props(interface) name of the Construct class to follow the form ${ConstructName}Props.
Where ${ConstructName} is the name of the Construct class.
Following a consistent naming pattern clarifies the relationship between Construct and its Props(interface), improving code maintainability and ease of understanding.
(This rule applies only to classes that extends from Construct.)
🔧 How to use
js
// eslint.config.mjs
export default defineConfig([
{
// ... some configs
rules: {
"awscdk/props-name-convention": "error",
},
},
]);✅ Correct Example
ts
import { Construct } from "constructs";
import { IBucket } from "aws-cdk-lib/aws-s3";
// ✅ Props(interface) name follows the format of `${ConstructName}Props`
interface MyConstructProps {
readonly bucket?: IBucket;
}
class MyConstruct extends Construct {
constructor(scope: Construct, id: string, props: MyConstructProps) {
super(scope, id);
}
}❌ Incorrect Example
ts
import { Construct } from "constructs";
import { IBucket } from "aws-cdk-lib/aws-s3";
// ❌ Props(interface) name must follow the ${ConstructName}Props format
interface Props {
readonly bucket?: string;
}
class MyConstruct extends Construct {
constructor(scope: Construct, id: string, props: Props) {
super(scope, id);
}
}