props-name-convention
ℹ️ このルールは recommended ルールには含まれていません。
CDK Construct クラスの Props (interface) 名が ${ConstructName}Props の形式に従うことを強制します。
(ここでの ${ConstructName} は Construct のクラス名を示します)
一貫した命名パターンに従うことで、Construct とその Props (interface) の関係が明確になり、コードの保守性と理解のしやすさが向上します。
🔧 使用方法
js
// eslint.config.mjs
export default defineConfig([
{
// ... some configs
rules: {
"awscdk/props-name-convention": "error",
},
},
]);✅ 適切な例
ts
import { Construct } from "constructs";
import { IBucket } from "aws-cdk-lib/aws-s3";
// ✅ Props (interface) 名が `${ConstructName}Props` の形式に従っている
interface MyConstructProps {
readonly bucket?: IBucket;
}
class MyConstruct extends Construct {
constructor(scope: Construct, id: string, props: MyConstructProps) {
super(scope, id);
}
}❌ 不適切な例
ts
import { Construct } from "constructs";
import { IBucket } from "aws-cdk-lib/aws-s3";
// ❌ Props (interface) 名が `${ConstructName}Props` の形式に従っていない
interface Props {
readonly bucket?: IBucket;
}
class MyConstruct extends Construct {
constructor(scope: Construct, id: string, props: Props) {
super(scope, id);
}
}