stylelint: Fix `declaration-property-value-no-unknown` false negatives for `position-try-options`
What minimal example or steps are needed to reproduce the bug?
a {
position-try: foo;
position-try-fallbacks: foo;
position-try-options: foo;
position-try-order: foo;
}
What minimal configuration is needed to reproduce the bug?
{
"rules": { "declaration-property-value-no-unknown": true }
}
How did you run Stylelint?
What did you expect to happen?
Unexpected unknown value "foo" for property "position-try-options"
What actually happened?
✅ No problems!
Resources
mdn/browser-compat-data#23651 w3c/csswg-drafts#10395 https://caniuse.com/?search=position-try
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 16 (16 by maintainers)
I think it would be better if Stylelint doesn’t have its own opinion on what is valid syntax.
What is or isn’t syntactically valid should be defined by the CSSWG, not by Stylelint.
The data source for what is valid should be something actively maintained by the W3C and CSSWG, not Stylelint. (i.e.
mdn-dataand@webref/css)mdn-dataandcsstreeare already really conservative and both have editorial escape hatches to preserve non-standard properties or values in their data sets. (@webref/cssdoes not have such escape hatches because it simply scrapes specs)mdn-dataandcsstreedecided not to preserveposition-try-options. I don’t think Stylelint should swim against the current here.(You could open an issue upstream with either
csstreeormdn-datato request that they preserveposition-try-optionsas valid.)Having a clear policy that any data issues are upstream issues would be best in my opinion. Anyone who disagrees with the data can still file an upstream issue 😃
I think there is a very large difference between wanting to compensate for
csstreemoving to slowly and marking currently invalid CSS as valid because it was present in 3 browser versions of a single vendor as an experimental feature.Users want to know when they write something that is invalid and
position-try-optionstoday is invalid CSS.Edit:
also important to keep in mind that users can use configuration commands and the plugin options to extend the known syntaxes.
So the very rare users that want to write
position-try-optionsaren’t blocked on this.I am also against removing this rule, but I am trying to balance various nuances and needs 😃 If I were part of the original discussion I would have been fully in favor of adding it and I still am today.
I think this rule is incredibly valuable.
I don’t think it should be controversial to say that there are limits to how much workload we should volunteer to take on.
Open source is a gift, we don’t owe anything to anyone. That a rule was once created does not mean that we need to keep maintaining it. This doesn’t mean that I don’t care about Stylelint users or the quality and future of Stylelint. It only means that we don’t owe anyone our time, focus, …
Even if some are willing to do more work now, we need a long term commitment for efforts like these. I am concerned that the commitment required to do this rule right is beyond what is healthy for Stylelint.
I am not saying that I want this rule removed.
I am only saying that we should discuss this if my effort proves to be unsuccessful. I also want us to be careful with the amount of work we volunteer to do.
The challenge with this rule is that the CSS syntax is a very large, hand written, cyclic graph.
Any change can affect many other types, including itself when it is cyclic definition.
Mutating this by hand, without proper tests, is error prone:
Mutating this by hand is hard to maintain:
The CSSWG does not really consider these syntax definitions as part of their “API surface”. So they often rewrite these drastically. Removing and introducing dozens of new definitions.
Any change is also potentially a breaking change for users. If a type is altered or removed but users are using these same types in their own overrides, then we are breaking their config.
I am making slow progress here: https://github.com/csstools/postcss-plugins/pull/1466
Things I haven’t started yet:
atruledescriptors and their syntaxDoes seem to work ok:
With each update to
@webref/cssthe build script will remove outdated patch entries and insert new template patch entries. These patch entries need to be manually resolved.A patch entry looks like this:
The entire setup focusses heavily on creating a process that makes it possible to understand what changes, which definitions are affected and if resolved patches are actually valid.
If anyone is willing to contribute I will gladly explain more and setup an example. There are more than 700 patches still to resolve so plenty todo 😅
I am currently estimating that this will take me about 2-3 months to complete.
Small status update on https://github.com/csstools/postcss-plugins/pull/1466
Properties and types are done and can be seen here: https://github.com/csstools/postcss-plugins/blob/a02ec16572375dbf1c211d157d765a76c74d1359/packages/css-syntax-patches-for-csstree/dist/index.json
Starting work on atrule descriptors next.
@romainmenke’s thought makes sense to me.
I don’t think Stylelint should actively support removed or deprecated CSS features unless they don’t widely impact many people.
I disagree. We ought to support all properties that were implemented at one point by a browser. i.e. Chrome/Edge 125–127 and Opera 111
Since it’s not yet a policy it can be discussed but this issue shouldn’t be closed.
In light of this announcement, I am not gonna set the status to ready to implement right away.