-
Notifications
You must be signed in to change notification settings - Fork 677
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
New: Add hint to check if inline CSS styles are used #4161
Conversation
b959e62
to
62414c4
Compare
Thanks @bolah2009 for your PR!!! I like the idea of this hint, but we need to be careful, because it can report a lot of false positives. The attribute IMO, this is a good hint to have, but the severity has to be changed for |
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.
Just a few comments
Thanks for the review @sarvaje 🙂
I agree that the severity can be changed, I will change it to For the configuration aspect, if it's not added to the |
@sarvaje I changed the severity from Thanks! 😊 |
If I remember correctly, these files should be modify in a separate PR to enable the hint. @antross am I right?
I have been thinking about this and I think it makes a lot of sense when you are developing, so you don't add any inline styles to your source code, so maybe we can increase the severity for the |
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.
Thanks again for the PR @bolah2009! Sorry for the slow response over the holidays.
Given the potential for false-positives, even during development, I'm hesitant to add this to any of our default configurations, though I think it could be a great hint for people to opt-in to when they want it.
Out of curiosity, are you aware of any external blogs or other resources discussing why this should be a recommendation? I don't see this as blocking unless we decide to add the hint to a default configuration, but it'd be great to reference a few sources in the README if we can.
@antross Thanks for the review! Yes, I am aware of external source discussing why this should be a recommendation. Some are:
About false positives, I think many of the good use cases are generating them with JavaScript, wouldn’t it be ok to have it in @antross Should I add those links? |
@antross Should I add the link to the readme? |
Yes, I think the first link (from nomensa.com) would be a helpful additional resource to reference. I think the second can be left out as it doesn't add much to the first.
As far as I know, reporting use of the My main concern is reporting use of the |
@bolah2009 to be clear I think we can still keep both checks in this hint. If we want to get
The second change would enable analyzing only raw source (as opposed to the live DOM) which would avoid false-positives on With those two changes I think we should be able to turn this hint on by default in all configurations. |
I have made the following changes you suggested:
Thanks for the suggestion. 🙂 |
Thanks @bolah2009 for the updates! I particularly appreciate your thoroughness in getting the new option plumbed through, including updating the README and tests. @sarvaje any further comments? This looks ready-to-merge to me. Then we can do a follow-up PR to update the default configurations. |
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.
LGTM!!
I just have one question :)
@bolah2009 thanks for putting together this hint and for working with us to iron out the details! 🎉 If you'd like to take a stab at a follow-up PR to add this to the default configurations, see #4079 for a recent example. |
Thanks @antross. I will open a PR to add it to the default configuration. |
@bolah2009 yeah, we don't have an auto-publish step set up currently (though we've talked about adding one). We're planning to run another release within the next couple of weeks, but in the meantime you should be able to use this hint with the CLI or VS Code Extension by saving its built output locally and pointing to the local path in your |
Okay, thanks 😊 |
Pull request checklist
Make sure you:
For non-trivial changes, please make sure you also:
Short description of the change(s)
This PR adds a new hint that checks if the HTML is using inline CSS styles.
Why is this important?
What does the hint check?
This hint checks if the HTML is using inline CSS styles.
Examples of inline CSS styles
<div style="color: blue;"></div>
<style></style>
It checks that no element has the attribute
style
. It also checks that no internal styles<style>
is used.Full details in the readme.