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?

https://stylelint.io/demo

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)

Most upvoted comments

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-data and @webref/css)

mdn-data and csstree are already really conservative and both have editorial escape hatches to preserve non-standard properties or values in their data sets. (@webref/css does not have such escape hatches because it simply scrapes specs)

mdn-data and csstree decided not to preserve position-try-options. I don’t think Stylelint should swim against the current here.

(You could open an issue upstream with either csstree or mdn-data to request that they preserve position-try-options as 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 csstree moving 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-options today 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-options aren’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:

  • you might break downstream definitions
  • you might subtly affect groupings
  • you might introduce a naming conflict

Mutating this by hand is hard to maintain:

  • you don’t get any signals about which overrides are outdated themselves
  • you don’t get any signals when upstream data includes your overrides or even newer syntax
  • you don’t get any signals when overrides break the cyclic graph structure
  • you don’t get any signals on naming conflicts
  • you don’t get any signals on orphaned types
  • you don’t get any signals on missing types

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:

  • atrule descriptors and their syntax
  • orphaned definition analysis
  • test coverage, fuzzzing, mutators
  • breaking change analysis

Does seem to work ok:

  • record dependencies between various specs and order them correctly
  • combining and overriding conflicting definitions across delta specs
  • generating and re-generating patches that need to be merged by hand
  • testing that syntax definitions are valid
  • testing sample bits of CSS against syntax definitions
  • parsing and validating various community CSS files (bootstrap, …)

With each update to @webref/css the 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:

	"ray()": {
		"type": "added",
		"syntax-before": "",
		"syntax-after": "ray( <angle> && <ray-size>? && contain? && [ at <position> ]? )",
		"comment": "Without the extra group the order seems to matter anyway, possibly a bug in css-tree or the syntax definition",
		"merged": "ray( [ <angle> && <ray-size>? && contain? && [ at <position> ]? ] )",
		"tests": {
			"passing": [
				{
					"property": "offset-path",
					"value": "ray(45deg)"
				},
				{
					"property": "offset-path",
					"value": "ray(200deg contain)"
				},
				{
					"property": "offset-path",
					"value": "ray(contain 200deg)"
				},
				{
					"property": "offset-path",
					"value": "ray(50deg closest-corner contain at 100px 20px)"
				},
				{
					"property": "offset-path",
					"value": "ray(50deg closest-corner contain)"
				}
			],
			"failing": [
				{
					"property": "offset-path",
					"value": "ray()"
				},
				{
					"property": "offset-path",
					"value": "ray(50deg closest-corner contain at)"
				},
				{
					"property": "offset-path",
					"value": "ray(50hz)"
				}
			]
		}
	},

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.

@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.