-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat: add no-invalid-at-rule-placement rule #171
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
base: main
Are you sure you want to change the base?
feat: add no-invalid-at-rule-placement rule #171
Conversation
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.
Nice and useful rule that plugs a gap, as CSSTree only detected misplaced declarations, e.g.:
--foo: bar; /* CSSTree parse error */
a { }
# no-invalid-at-rule-placement | ||
|
||
Disallow invalid placement of at-rules. | ||
|
||
## Background | ||
|
||
At-rules are CSS statements that instruct CSS how to behave. Some at-rules have strict placement requirements that must be followed for the stylesheet to work correctly. For example: |
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.
@charset
is no longer considered an at-rule even though it syntactically looks like one. There may be a more suitable name and wording in the documentation that better reflect this.
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.
If it's not an at-rule, then what is it? The spec is ridiculously worded:
https://drafts.csswg.org/css-syntax/#charset-rule
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.
According to MDN, it's not technically an at-rule but a specific byte sequence. However, I noticed it's referred to as an at-rule in no-invalid-at-rules as well. Should we add a clarifying note about this, or leave it as-is for now?
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.
Let's leave this as-is for now. We can always circle back and do doc updates later.
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. Would like another review before merging.
Prerequisites checklist
What is the purpose of this pull request?
This pull request introduces a new rule no-invalid-at-rule-placement that enforces correct placement of at-rules within stylesheets.
What changes did you make? (Give an overview)
Implemented the no-invalid-at-rule-placement rule, along with documentation and tests.
Related Issues
Fixes #163
Fixes #151
Is there anything you'd like reviewers to focus on?