-
Notifications
You must be signed in to change notification settings - Fork 402
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
feat: Restrict usage of attributes in stylesheets #316
Conversation
Benchmark resultsBase commit: lwc-engine-benchmark
|
|
||
export const GLOBAL_ATTRIBUTE_SET: Set<string> = new Set([ | ||
'role', | ||
'accesskey', |
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.
creating css rules based on accesskey
seems wrong. /cc @stefsullrew
'lang', | ||
'slot', | ||
'spellcheck', | ||
'style', |
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.
creating css rules based on style
attribute seems wrong. /cc @stefsullrew
'spellcheck', | ||
'style', | ||
'tabindex', | ||
'title', |
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.
creating css rules based on title
attribute seems wrong because this is supposed to be internationalized while the css doesn't. /cc @stefsullrew
]); | ||
|
||
export const HTML_ATTRIBUTES_REVERSE_LOOKUP: { [attr: string]: string[] } = { | ||
'xlink:href': [ |
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.
@stefsullrew can you also help us to review this list to ban anything that we consider a bad practice when writing component's css.
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 is good stuff. Remember, these rules are not arbitrary rules, they have a purpose, the purpose is to prevent people from doing the wrong thing or trip over by silly mistakes. So, I think we need to be more vigilant on what we will allow and what we will not allow rather than stick to the tee on the spec.
I agree with you Caridy, but in this case, it's not a compiler concern. The compiler takes care of making sure the code runs as expected, the linter, on the other hand, make sure the code is compliant with the best practices. We have been striving so far to find the right balance, and when we doubted we went down the restrict path. Here we want to prevent the code to compile even if the runtime execution will be correct. |
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.
Ok @pmdartus, I'm fine with that. Let's make sure that we have an issue open to track that linter work, and we can have the discussion about what to restrict there.
Details
This PR restricts the usage of attributes in the stylesheet:
Fix #261
Does this PR introduce a breaking change?
If yes, please describe the impact and migration path for existing applications:
Components won't compile if they already use attribute selectors in their stylesheet.