I am stealing an example of an existing custom rule for this as exact use cases vary, however, the foundation of checking tags for the presence of x attribute on y tag remains the same. I think this would be an incredibly valuable template to have because there are plenty of cases where making sure x attribute is in y tag would prevent lots of issues from cropping up. It also seems like it would be relatively easy to implement since it’s the inverse of an existing template.
This rule checks that the specified attributes ARE present in HTML tags.
Expected attribute list of:
< a href=“blah .com” > ← Noncompliant; name attribute is not used in “a” tag.
< a href=“blah .com” name=“Blah link” > ← Compliant ; name attribute is used in “a” tag.
attributes Comma-separated list of tag.attributes that are expected. E.G. a.name expects a “name” attribute in an “a” tag.
Type: Bug ← Severity determined by use case, could be info/low/med/high/crit depending on how critical the attribute’s presence is in the tag.