fix: include container-query type in patch output#1811
fix: include container-query type in patch output#1811bibixx wants to merge 2 commits intocsstools:mainfrom
Conversation
The patched container-condition and query-in-parens types reference <container-query>, but it was never included in the output. This is because both raw data sources define container-query identically, so diff_sets() excludes it. When consumed with a css-tree version that lacks container-query in its base grammar, fork() cannot resolve the reference and throws "Bad syntax reference". Added container-query to the manual compatibility patches (same pattern as dashed-ident and unicode-range-token) and a test verifying the type is present in the output.
|
Hi @bibixx, This PR description reads as if it was created with the assistance of an LLM.
Can you create a reproduction for the underlying issue? |
|
Hey, yes. Indeed the PR description was created with some help of an LLM. Sorry didn't know about that. But with the code itself I was thoroughly going through myself. I'll create repro in a moment. |
|
It does surface in a pretty specific dependencies combinations (which we have actually encountered in our project, and the fix for it will be to just update the stylelint to latest version) but this still seems like a bug in the Here's repro: https://github.com/bibixx/container-query-repro |
That is what I suspected :) We did add the peer dependency version constraint to better communicate this. So I guess we can close this? Keep in mind that an LLM will happily write fixes for non-issues and thereby waste time of (unpaid) OSS maintainers. I will gladly look into any issue and review any PR, but I won't even look at a diff produced (partially) by an LLM :) |
|
The logical issue is still there. It probably won't happen again but only now the code itself is actually correct. It could still happen in theory if the versions are misaligned. So I mean it's up to your discretion. You're the maintainer ;) |
|
A true fix would need to be done in package managers.
But maybe it is fine to make the peer dependency required? |
|
Okay, so the assumption (even though might not be always true, since, as you mentioned package managers aren't perfect) is that the users will always use the plugin version corresponding to the |
|
Yes, if you use it with a version that is outside the version constraint you will have issues and those will not (can't) be fixed. There is no way to have a correct syntax definition as a whole with mismatched versions. |
|
Got it. Closing then |
Problem
The patched
container-conditionandquery-in-parenstypes both reference<container-query>in their syntax, butcontainer-queryitself is never included indist/index.json.How this happened
In
b670b0cac(#1466), when the package was first created, css-tree didn't havecontainer-queryin its base grammar. It appeared in the diff astype: "added"and was correctly included in the output.In
a0880e31b(#1792), css-tree was updated to^3.2.1, which addedcontainer-queryto its base grammar. Since both sources now defined it identically,diff_sets()excluded it from the diff, and it was removed from the patches. Butcontainer-conditionandquery-in-parensstill reference<container-query>in their merged syntax — creating a dangling reference in the patch output.Why it crashes
In css-tree's base grammar,
container-conditionis defined as:The patch replaces this with the newer spec definition:
This new syntax references
<container-query>. Butcontainer-queryisn't in the patch output — because both css-tree and webref now define it with the exact same syntax, so the diff step sees no difference and excludes it. When consumed with a css-tree version whose base grammar doesn't includecontainer-query, there's no definition for it anywhere, and css-tree throws:This crashes tools like stylelint entirely (not a lint warning — an unhandled exception) when validating
@containerrules.Fix
Added
container-queryto the manual compatibility patches inapply-patches.mjs, following the existing pattern fordashed-identandunicode-range-token. This ensures the patch output is self-contained for the types it references.Also added a test that verifies
container-queryis present in the output and that@containerpreludes validate without error.