Closed lb- closed 2 years ago
This recently came up when reviewing a PR - see comment - https://github.com/wagtail/wagtail/pull/8671#discussion_r897822527
Makes sense to me!
I’m not 100% convinced data-
attributes don’t have a place in stylesheets, but in my mind if they did have a place it’d only be in a few specific cases – so I quite like the idea of outright enforcing they aren’t used ever.
If we did this, I think we could use selector-attribute-disallowed-list? "selector-attribute-name-disallowed-list": ["/^data-/"],
Thanks Thibaud. selector-attribute-name-disallowed-list
is way better! Don't know what I was thinking haha.
Overview
Proposed solution
Add
'selector-max-attribute': [0, { ignoreAttributes: ['/^(?!data-).*/'] }],
- which only blocks the use ofdata-*
attributes when applying styles to components.All other usage should still be allowed, such as
hidden
,aria-hidden
,disabled
,type
etc.Additional details
Issues in Wagtail Core
The following 11 issues will be flagged in Wagtail core if this rule is applied.
data-tabs-animate
on the tabs can be resolved by using classes instead (or just drop this feature as it is unused)tippy
styles - probably would be left as is and this rule would be ignored in the overrides folder as we have no control over these components