diff --git a/tools/awslint/lib/rules/construct.ts b/tools/awslint/lib/rules/construct.ts index d1b50276dde9c..de6926a0bd53e 100644 --- a/tools/awslint/lib/rules/construct.ts +++ b/tools/awslint/lib/rules/construct.ts @@ -211,4 +211,20 @@ constructLinter.add({ e.assert(!property.type.unionOfTypes, `${e.ctx.propsFqn}.${property.name}`); } } +}); + +constructLinter.add({ + code: 'props-no-arn-refs', + message: 'props should use strong types instead of attributes. props should not have "arn" suffix', + eval: e => { + if (!e.ctx.propsType) { return; } + if (!e.ctx.hasPropsArgument) { return; } + + // this rule only applies to L2 constructs + if (e.ctx.classType.name.startsWith('Cfn')) { return; } + + for (const property of e.ctx.propsType.ownProperties) { + e.assert(!property.name.toLowerCase().endsWith('arn'), `${e.ctx.propsFqn}.${property.name}`); + } + } }); \ No newline at end of file