-
-
Notifications
You must be signed in to change notification settings - Fork 3
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 Rule: no-important #20
Comments
As with #19, a {
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "Declaration[important=true]",
"message": "!important annotations are not allowed."
},
]
}
} When using cascade layers, the
Fewer people will likely want to restrict this syntax as they adopt cascade layers. |
Yeah, I think we want to hold off on adding rules that simply disallow syntax because it can easily be covered by |
I was excited about that one but reading the comments makes me doubt now 😀. I believe @jeddy3's view on these is super interesting, I personally have 0 background on CSS linting so following your advice seems like the best idea to me! |
@jeddy3 is this true for keyframe https://stylelint.io/user-guide/rules/keyframe-declaration-no-important/ |
The
We added the How about?:
You could either limit the repurposed #23 to keyframe blocks (as a {
color: red !foo;
} (You may want to allow I think |
The core |
That's great! Thank you for pointing that out. In addition to restricting "no-restricted-syntax": [
"error",
{
"selector": "Declaration[important=true]",
"message": "!important annotations are not allowed."
},
] I was also able to replicate nearly all of Stylelint's From simple ones like {
selector: "Function[name=/\\b(var|rgb)\\b/]",
message: "var() and rgb() functions are not allowed",
} To pair matching ones like {
selector: "Declaration[property=/^animation/] Dimension[unit=s]",
message: "Use `ms` instead of `s` for animation durations"
}, Because ESQuery supports the {
selector: "FeatureRange:has(Identifier[name=width]) Dimension[unit!=rem]",
message: "Use `rem` units for the `width` feature"
}, Catching the use of @media screen and (10px < width <= 768px) {}
div {
container-type: inline-size;
div {
@container (width > 30px) {}
}
} The core Are there any other core ones that can be used with CSS? |
Rule details
Flag the use of !important
What type of rule is this?
Warns about a potential problem
Example code
Participation
Additional comments
Needing
!important
indicates there may be a larger underlying issue.The text was updated successfully, but these errors were encountered: