data icon indicating copy to clipboard operation
data copied to clipboard

Validate syntaxes

Open teoli2003 opened this issue 7 years ago • 2 comments

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.

teoli2003 avatar Feb 07 '18 07:02 teoli2003

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 bad syntaxes – 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?

lahmatiy avatar Feb 07 '18 10:02 lahmatiy

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.

wbamberg avatar Apr 10 '18 05:04 wbamberg