require-props-default-doc β
βΉοΈ This rule is not included in the recommended rules.
This rule requires a documentation comment including a @default JSDoc tag for optional properties defined in a Construct's Props interface, to indicate their default behavior.
The names of such Props interfaces typically follow a format like XxxxProps (e.g., MyConstructProps, MyStackProps).
Note: This rule does not apply to regular class properties or properties within general interfaces not intended as Construct Props.
π§ How to use β
js
// eslint.config.mjs
export default defineConfig([
{
// ... some configs
rules: {
"cdk/require-props-default-doc": "error",
},
},
]);β Correct Example β
ts
import { IBucket } from "aws-cdk-lib/aws-s3";
interface MyConstructProps {
// β
JSDoc comment including a `@default` tag for the optional property.
/**
* @default - No S3 bucket is associated.
*/
readonly bucket?: IBucket;
}
// β
This rule does not apply to general interfaces that are not Construct Props.
interface Config {
readonly bucket?: IBucket;
}β Incorrect Example β
ts
import { IBucket } from "aws-cdk-lib/aws-s3";
interface MyConstructProps {
// β No JSDoc comment for the optional property.
readonly bucket?: IBucket;
}ts
import { IBucket } from "aws-cdk-lib/aws-s3";
interface MyConstructProps {
// β JSDoc comment exists, but the `@default` tag is missing.
/** Some description without default value. */
readonly bucket?: IBucket;
}