Skip to content

Commit

Permalink
chore(awslint): fix nested submodule L1 type not recognized as L1 (#2…
Browse files Browse the repository at this point in the history
…7273)

Previously a type from a submodule with a FQN like `aws_service.CfnTheResource.SubType` was not identified as an L1 type, and subjected to stricter L2 rules.

Fixes failing integration tests in https://github.com/cdklabs/awscdk-service-spec

E.g. https://github.com/cdklabs/awscdk-service-spec/actions/runs/6293221129/job/17097529390

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain authored Sep 25, 2023
1 parent 4ade7dc commit b3bbc7f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/awslint/lib/rules/core-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export class CoreTypes {
* Return true if the given interface type is a CFN class or prop type
*/
public static isCfnType(interfaceType: reflect.Type) {
return interfaceType.name.startsWith('Cfn') || (interfaceType.namespace && interfaceType.namespace.startsWith('Cfn'));
return interfaceType.name.startsWith('Cfn')
|| (interfaceType.namespace && interfaceType.namespace.startsWith('Cfn'))
// aws_service.CfnTheResource.SubType
|| (interfaceType.namespace && interfaceType.namespace.split('.', 2).at(1)?.startsWith('Cfn'));
}

/**
Expand Down

0 comments on commit b3bbc7f

Please sign in to comment.