-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(awslint): new rules for reference interfaces #27790
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
6fc8b10
to
e6f6804
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
ebbaa51
to
fade49e
Compare
e.assert(resourceInterface.extends(interfaceBase), resourceInterface.fqn); | ||
}, | ||
}); | ||
|
||
/* | ||
// This rule is the worst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sure is!
`If this is intentional, add "${EXCLUDE_ANNOTATION_REF_VIA_INTERFACE}" to element's jsdoc`, | ||
eval: e => { | ||
eval: (e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule hasn't changed. I just refactored the code used to visit spec nodes to be reusable.
const EXCLUDE_ANNOTATION_REF_VIA_INTERFACE = | ||
'[disable-awslint:ref-via-interface]'; | ||
|
||
const EXCLUDE_ANNOTATION_REF_VIA_REF_INTERFACE = | ||
'[disable-awslint:ref-via-ref-interface]'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered wrapping them both into a single rule, but found it too confusing and complicated.
Now we have two rules:
ref-via-interface
guarantees that we are not expecting concrete instances of constructsref-via-ref-interface
guarantees that we preferICfnWhatever
reference interfaces overIWhatever
interfaces
Generally looks good to me - did you see what impact this had on the lint times? |
I'll check that. |
fade49e
to
b43e155
Compare
Adds about 5s to awslint. Deeming this as acceptable. I am working on some speed-ups for the linter. |
Introducing two new rules, and immediately accepting all current violations.
resource-interface-extends-resource-ref
- all resources interfaces likeIBucket
must also implement the reference interface, e.g.ICfnBucket
ref-via-ref-interface
- all APIs should accept the reference interfaceICfnBucket
over the resource interfaceIBucket
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license