stylelint: Fix `function-no-unknown` false negatives for functions in at-rule preludes
What minimal example or steps are needed to reproduce the bug?
@container scroll-state() {}
@container style() {}
What minimal configuration is needed to reproduce the bug?
{
"rules": {
"function-no-unknown": true
}
}
How did you run Stylelint?
What did you expect to happen?
Unexpected unknown function "scroll-state"
Unexpected unknown function "style"
Do you have a proposal to fix the bug?
Support
@container@supportsfont-format()font-tech()selector()
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18 (18 by maintainers)
In another way, we may add
container-query-no-invalidlikemedia-query-no-invalid.I think it is very hard to avoid overlap here with other rules, but maybe this is fine?
I would also expect
function-no-unknownto check at-rules, while at the same time I like more specific and specialized rules likemedia-query-no-invalidanddeclaration-property-value-no-unknown. Both kinds of rules have value and can coexist imho.I think that a specialized rule will always give better feedback because it should be able to determine if a function exists and if it is used correctly in a given context.
While
function-no-unknowncan only give superficial feedback about if a function is known. We could have some conditions to only make some functions valid in some places but it has to be more specific than only looking at the at-rule name.Some more complex cases:
@import supports(<everything here, including selector()>) layer(...) scope(:is(foo)) (width: calc(...))@container (width: calc(...))(only math functions)@container style(--foo: rgb(...))(any value related functions)Thanks for the info. Since some functions are already supported in at-rules, adding at-rule support to
function-no-unknownmay be possible.The implementation might be as follows:
Are there other points we missed? If not, we could go forward.
There are 3 more AFAIK:
font-format()font-tech()selector()see https://developer.mozilla.org/en-US/docs/Web/CSS/@supports#function_syntax
style()is not really experimental at this point. cf https://caniuse.com/css-container-queries-styleI agree for
scroll-state()though.