require-jsdoc â
âšī¸ This rule is not included in the recommended rule.
This rule requires JSDoc comments for Construct's Props interface properties and Construct public properties.
Adding JSDoc comments to properties clarifies what each property represents, improving code maintainability and understandability.
đ§ How to use â
js
// eslint.config.mjs
export default defineConfig([
{
// ... some configs
rules: {
"cdk/require-jsdoc": "error",
},
},
]);
â Correct Example â
ts
import { IBucket } from "aws-cdk-lib/aws-s3";
interface MyConstructProps {
// â
JSDoc comment for interface property
/** S3 bucket to be specified for the resource */
readonly bucket: IBucket;
}
ts
import { Construct } from "constructs";
import { IBucket } from "aws-cdk-lib/aws-s3";
class MyConstruct extends Construct {
// â
JSDoc comment for public property
/** The S3 bucket created by this construct */
public readonly bucket: IBucket;
// â
This rule does not apply to non-public properties
private readonly bucketName: string;
}
â Incorrect Example â
ts
import { IBucket } from "aws-cdk-lib/aws-s3";
interface MyConstructProps {
// â Must write JSDoc comment
readonly bucket: IBucket;
}
ts
import { Construct } from "constructs";
import { IBucket } from "aws-cdk-lib/aws-s3";
class MyConstruct extends Construct {
// â Must write JSDoc comment
public readonly bucket: IBucket;
}