Linter: Implement html-no-style-attributes and html-no-style-elements rules#1539
Open
markokajzer wants to merge 2 commits intomarcoroth:mainfrom
Open
Linter: Implement html-no-style-attributes and html-no-style-elements rules#1539markokajzer wants to merge 2 commits intomarcoroth:mainfrom
html-no-style-attributes and html-no-style-elements rules#1539markokajzer wants to merge 2 commits intomarcoroth:mainfrom
Conversation
marcoroth
reviewed
Mar 30, 2026
Owner
marcoroth
left a comment
There was a problem hiding this comment.
Thank you for working on this @markokajzer! 🙏🏼
Similar to #1536 (review), I think we also want to rename this rule to have a html-* prefix and have it split up to two rules, something like:
html-no-style-attributes: nostyle=""html-no-style-elements: no<style>...</style>
27b8088 to
19465be
Compare
erb-disallow-inline-styleshtml-no-style-attributes and html-no-style-elements rules
19465be to
87fcbc9
Compare
Contributor
Author
|
changes:
i can separate into two PRs 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #162
Rule:
html-no-style-attributesDescription
Disallow the use of inline
styleattributes on HTML elements. All styling should be applied via external stylesheets or class-based styling.Rationale
Inline
styleattributes make templates harder to maintain, promote duplication, and prevent adoption of strict CSP policies (style-src 'self'). Using CSS classes and external stylesheets improves maintainability and security.Rule:
html-no-style-elementsDescription
Disallow the use of inline
<style>tags in HTML templates. All styling should be applied via external stylesheets.Rationale
Inline
<style>tags make templates harder to maintain, promote duplication, and prevent adoption of strict CSP policies (style-src 'self'). Centralizing styles via external stylesheets improves maintainability and security.This rule enforces:
<style>tags embedded directly in templates.styletags generated viacontent_tagortaghelpers.