@@ -189,12 +189,12 @@ constructLinter.add({
189
189
190
190
constructLinter . add ( {
191
191
code : 'props-no-unions' ,
192
- message : 'props should not use TypeScript unions' ,
192
+ message : 'props must not use TypeScript unions' ,
193
193
eval : e => {
194
194
if ( ! e . ctx . propsType ) { return ; }
195
195
if ( ! e . ctx . hasPropsArgument ) { return ; }
196
196
197
- // this rule only applies to L2 constructs
197
+ // this rule does not apply to L1 constructs
198
198
if ( CoreTypes . isCfnResource ( e . ctx . classType ) ) { return ; }
199
199
200
200
for ( const property of e . ctx . propsType . ownProperties ) {
@@ -205,12 +205,12 @@ constructLinter.add({
205
205
206
206
constructLinter . add ( {
207
207
code : 'props-no-arn-refs' ,
208
- message : 'props should use strong types instead of attributes. props should not have "arn" suffix' ,
208
+ message : 'props must use strong types instead of attributes. props should not have "arn" suffix' ,
209
209
eval : e => {
210
210
if ( ! e . ctx . propsType ) { return ; }
211
211
if ( ! e . ctx . hasPropsArgument ) { return ; }
212
212
213
- // this rule only applies to L2 constructs
213
+ // this rule does not apply to L1 constructs
214
214
if ( CoreTypes . isCfnResource ( e . ctx . classType ) ) { return ; }
215
215
216
216
for ( const property of e . ctx . propsType . ownProperties ) {
@@ -221,12 +221,12 @@ constructLinter.add({
221
221
222
222
constructLinter . add ( {
223
223
code : 'props-no-tokens' ,
224
- message : 'props should not use the "Token" type' ,
224
+ message : 'props must not use the "Token" type' ,
225
225
eval : e => {
226
226
if ( ! e . ctx . propsType ) { return ; }
227
227
if ( ! e . ctx . hasPropsArgument ) { return ; }
228
228
229
- // this rule only applies to L2 constructs
229
+ // this rule does not apply to L1 constructs
230
230
if ( CoreTypes . isCfnResource ( e . ctx . classType ) ) { return ; }
231
231
232
232
for ( const property of e . ctx . propsType . allProperties ) {
@@ -242,12 +242,12 @@ constructLinter.add({
242
242
243
243
constructLinter . add ( {
244
244
code : 'props-no-cfn-types' ,
245
- message : 'props should not expose L1 types (types which start with "Cfn")' ,
245
+ message : 'props must not expose L1 types (types which start with "Cfn")' ,
246
246
eval : e => {
247
247
if ( ! e . ctx . propsType ) { return ; }
248
248
if ( ! e . ctx . hasPropsArgument ) { return ; }
249
249
250
- // this rule only applies to L2 constructs
250
+ // this rule does not apply to L1 constructs
251
251
if ( CoreTypes . isCfnResource ( e . ctx . classType ) ) { return ; }
252
252
253
253
for ( const property of e . ctx . propsType . ownProperties ) {
@@ -263,17 +263,33 @@ constructLinter.add({
263
263
264
264
constructLinter . add ( {
265
265
code : 'props-default-doc' ,
266
- message : 'All optional props should have @default documentation' ,
266
+ message : 'All optional props must have @default documentation' ,
267
267
eval : e => {
268
268
if ( ! e . ctx . propsType ) { return ; }
269
269
if ( ! e . ctx . hasPropsArgument ) { return ; }
270
270
271
- // this rule only applies to L2 constructs
271
+ // this rule does not apply to L1 constructs
272
272
if ( CoreTypes . isCfnResource ( e . ctx . classType ) ) { return ; }
273
273
274
274
for ( const property of e . ctx . propsType . allProperties ) {
275
275
if ( ! property . optional ) { continue ; }
276
276
e . assert ( property . docs . docs . default !== undefined , `${ e . ctx . propsFqn } .${ property . name } ` ) ;
277
277
}
278
278
}
279
- } ) ;
279
+ } ) ;
280
+
281
+ constructLinter . add ( {
282
+ code : 'props-no-any' ,
283
+ message : 'props must not use Typescript "any" type' ,
284
+ eval : e => {
285
+ if ( ! e . ctx . propsType ) { return ; }
286
+ if ( ! e . ctx . hasPropsArgument ) { return ; }
287
+
288
+ // this rule does not apply to L1 constructs
289
+ if ( CoreTypes . isCfnResource ( e . ctx . classType ) ) { return ; }
290
+
291
+ for ( const property of e . ctx . propsType . ownProperties ) {
292
+ e . assert ( ! property . type . isAny , `${ e . ctx . propsFqn } .${ property . name } ` ) ;
293
+ }
294
+ }
295
+ } ) ;
0 commit comments