Skip to content

[FEATURE] Add support for checking if attribute values are valid #382

@reteps

Description

@reteps

Is your feature request related to a problem? Please describe.

I have code like this:

<element attr="bar"></element>
<element attr="foo"></element>

And I know that the valid set of attributes for element is [bar, baz]. Emitting a warning on an invalid attribute would be great! Since this seems tricky to do for HTML attributes by default, I would propose a rule that lets you configure this set per attribute and element (perhaps if elements is not present, it applies to all elements).

validAttrs: {
attr: { values: ["bar", "foo"], elements: ["element"] }
}

One edge case to be aware of is that if the attribute value contains a templating expression, it should be ignored.

<element attr="{{ dynamic_val }}"></element>

Thank you so much for this plugin!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions