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
Add selector-attribute-name-disallowed-list #4915
Comments
selector-attribute-allowed-list
and selector-attribute-disallowed-list
rules
@gbhasha Thanks for the request and for using the template.
That's fascinating. I can imagine why they'd want to do that; if you're already using attribute selectors for things like Incidentally, it's possible to enforce that approach using: {
"selector-max-id": 0,
"selector-max-class": 0
} Anyhow, you want to enforce the opposite and, as you said, that's not currently possible with stylelint.
Yes, I agree. I suggest we go with I assume you'll use
I've labelled the issue as ready to implement. Please consider contributing if you have time. There are steps on how to add a new rule in the Developer guide. You'll want to use the |
Hi @jeddy3! I'd like to implement this rule as my first contribution. |
@rletsin That's great! I'll mark issue as |
Should this issue be closed now that #4992 is merged? BTW there is a legitimate use of an attribute selector for IDs: so that it doesn't use the higher specifity for IDs. (but better use classes everywhere :-) ). |
Yes.
Oh wow, I hadn't considered specificity. Neat trick. |
The developers on my team use class and id attributes in attribute selectors instead of using id selector or classname selector. This adds complexity and inconsistent coding style.
To fix the above mentioned problem, having this linting rule would definitely help.
example use case:
selector-attribute-disallowed-list: ['class', 'id']
should throw error for below selectors....
div[class*='some-thing']
div[id~='some-thing']
The text was updated successfully, but these errors were encountered: