Validate syntaxes
Hi!
Properties and selector syntaxes make use of lower-level syntaxes.
Unless they are "basic" types (that has their own page on MDN), these lower-level syntax are defined in syntaxes.json (and so on, recursively)
It is fastidious and error-prone to be sure not to forget one of these lower-level syntaxes definition. It is also complex for the reviewers to spot them.
We should write a test, run by ci that detect this.
I have long wanted to add syntax validation using CSSTree into test script. Currently CSSTree supports CSS Values and Units module grammar. However some syntaxes (e.g. selectors, at-rules etc) has extended grammar (i.e. uses tokens that are not defined by V&U module) and can't be parsed by CSSTree at the moment. There are two options:
- improve CSSTree to be able process all the syntaxes, but that's need a time – don't know when it happen
- add a validation but use a blacklist for a
badsyntaxes – that's not an ideal solution, but most syntaxes can be validated right now
What do you think? Are there other options how to do this?
I think this would be great, and had been wondering the same thing. My preference would be your second option. Even simpler, could we just validate properties (and their dependent syntax)? Just that would be really useful.