Add `at-rule-no-invalid-required-descriptors`
What is the problem you're trying to solve?
Some at-rules have rules around required descriptors.
For example, from the @property spec:
@propertyrules require a syntax and inherits descriptor; if either are missing, the entire rule is invalid and must be ignored. The initial-value descriptor is optional only if the syntax is the universal syntax definition, otherwise the descriptor is required; if it’s missing, the entire rule is invalid and must be ignored.
And from the Fonts spec:
@font-palette-valuesrules require a font-family descriptor; if it is missing, the@font-palette-valuesrule is invalid and must be ignored entirely.
Catching @property mistakes would be particularly useful for people as the popularity of @property increases.
Example:
@font-face {
src: url(foo.woff);
}
2:2 error Unexpected missing descriptor "font-family" for at-rule "font-face"
What solution would you like to see?
A new rule to catch missing descriptors for at-rules.
- Name:
at-rule-no-missing-descriptors - Description: Disallow missing descriptors for at-rules.
- Message:
Unexpected missing descriptor(s) "$descriptors" for at-rule "$atRule" - Primary option:
true - Category: Avoid errors > Missing
- Included in sharable configs?: Yes, recommended
- Expanded description: Certain descriptors are required for at-rules. For example,
@property...
The rule would be complementary to at-rule-property-required-list. For example, only src and font-family are required in the specs for @font-face, but someone may also want to enforce other descriptors like font-display.
In addition to the three at-rules mentioned above. There is @counter-style and its descriptors:
symbolsThis descriptor is required if thesystemdescriptor is set tocyclic,numeric,alphabetic,symbolic, orfixed.additive-symbolsThis descriptor is required if thesystemdescriptor is set toadditive.
So, in total, four at-rules have required descriptors. Two are straight-up requires:
-
@font-face-srcandfont-family -
@font-palette-values-font-family
And two have requirements based on other descriptors or their values:
-
@property -
@counter-style
Category: Avoid errors > Missing
I think it should be under 2 categories: Missing and Invalid. i.e. the at-rule is invalid because one or more descriptors are missing
Name:
at-rule-no-missing-descriptors
I am not sure about the name.
It doesn't convey that the missing descriptors are specific.
What about at-rule-no-missing-mandatory-descriptors or at-rule-no-missing-required-descriptors?
i.e. the at-rule is invalid because one or more descriptors are missing
Good catch. Let's go with at-rule-no-invalid-required-descriptors.
- Name:
at-rule-no-invalid-required-descriptors - Description: Disallow invalid at-rules without required descriptors.
- Message:
Unexpected invalid at-rule "$atRule" without required descriptor(s) "$descriptors" - Primary option:
true - Category: Avoid errors > Invalid
- Included in sharable configs?: Yes, recommended
- Expanded description: Certain descriptors are required for at-rules. For example,
@property...
I'll label this rule as ready to implement as there are no objections. It ties in nicely with our efforts to help users write error-free at-rules.
Message:
Unexpected invalid at-rule "$atRule" without required descriptor(s) "$descriptors"
We can discuss in the upcoming PR whether it should match at-rule-property-required-list's message format or not.
e.g. Expected descriptor(s) "${descriptors}" for at-rule "${atRule}"
This issue is older than one month. Please ask before opening a pull request, as it may no longer be relevant.
@jeddy3 is it still relevant?
Yes, it remains relevant and would be helpful to users.
Looking at the issue again with fresh eyes, let's go with:
- Name:
at-rule-no-missing-required-descriptors - Description: Disallow missing required descriptors for at-rules.
- Message:
Unexpected missing descriptor(s) "{descriptors}" for "${atRule}" - Primary option:
true - Category: Avoid errors > Missing
- Included in sharable configs?: Yes, recommended
- Expanded description: Certain descriptors are required for at-rules. For example,
@property...
working on this...