-
Notifications
You must be signed in to change notification settings - Fork 263
bug: enum validation picks odd convention for members with digits #3208
Copy link
Copy link
Closed
Labels
bugThis issue is a bug.This issue is a bug.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.
Description
🐛 Bug Report
Affected Languages
-
TypeScriptorJavascript -
Python -
Java - .NET (
C#,F#, ...) -
Go
General Information
- JSII Version: (Not yet released as of this writing)
- Platform: N/A
What is the problem?
jsii enforces a kind of odd convention for enum names, and the error message does not reflect the actual validation. See the below:
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C5A" to "C5_A"
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C5AD" to "C5_A_D"
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C5D" to "C5_D"
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C5N" to "C5_N"
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C6G" to "C6_G"
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C6GD" to "C6_G_D"
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C6GN" to "C6_G_N"
error JSII8001: Enum members must be ALL_CAPS. Rename "aws-cdk-lib.aws_ec2.InstanceClass.C6I" to "C6_I"
It looks like
jsii/packages/jsii/lib/validator.ts
Line 90 in a2bf477
| if (member.name && member.name !== Case.constant(member.name)) { |
Case.constant() wants to introduce these underscores.
The above are live values in the aws-cdk, but they haven't been a problem to date because of #2782. However, I just tested the fix (#3207), and the CDK build fails due to the above. Given that our JS/TS users are able to use the values (e.g., C5A), we can't rename them, as it would be a breaking change. Instead, I propose we update the validation to support this case (likely replacing Case.constant with our own code and/or something else).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.