TypeScript false-positives for AWS CDK IaC

TypeScript + AWS CDK.
Code example:

new CfnOutput(this, 'test', {});

This is for the TypeScript rule: Objects should not be created to be dropped immediately without being used:

It is perfectly fine to just define it and not assign it or use it as this define Infrastructure as Code component.

Hello Radek,

Thank you for your message.

Given the example you shared, I do understand that’s how the API of AWS CDK is supposed to be used. Still, we consider that creating a new object just for the sake of side effects and not using the resulting instance afterwards is a bad practice (or a bad design) as it is rightfully explained by the rule description.

Coming back to your problem, I think it would makes sense for you to disable the rule to avoid these false-positives.

Hope this helps,
Yassin

Hi Yassin,

Indeed, I have disabled the rule with an undocumented method - see my comment here:

It would be great to add this to the official docs.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.