Closed charlespwd closed 1 year ago
Right now, the LiquidHTML parser has default "fall through" cases for liquidTagOpen and liquidTag.
LiquidHTML
liquidTagOpen
liquidTag
That is, we used to do something like this:
liquidTag = | liquidTagAssign | liquidTagEcho | ... | liquidTagBaseCase
i.e., try the strict rule and, if that fails, parse the .markup as a string.
.markup
> toLiquidHTMLAST(`{% echo var %}`, { mode: 'tolerant' }) [ { type: 'LiquidTag', name: 'echo', markup: { type: 'VariableLookup', expression: {/* ... /*} lookups: [], }, } ] > toLiquidHTMLAST(`{% echo var } error! { %}`, { mode: 'tolerant' }) [ { type: 'LiquidTag', name: 'echo', markup: 'var } error! {', // this is a string } ]
With { mode: 'strict' }, we'll throw errors instead of accepting that kind of crappy Liquid.
{ mode: 'strict' }
> toLiquidHTMLAST(`{% echo var } error! { %}`, { mode: 'strict' }) LiquidHTMLParsingError: Expected "%}", "-%}", "}}", "-}}", a space, "|", ".", or "["
Nothing in prettier-plugin-liquid; but, in theme-check-js, this should be enough to power the LiquidSyntaxError check.
LiquidSyntaxError
In this PR
What this means
Right now, the
LiquidHTML
parser has default "fall through" cases forliquidTagOpen
andliquidTag
.That is, we used to do something like this:
i.e., try the strict rule and, if that fails, parse the
.markup
as a string.With
{ mode: 'strict' }
, we'll throw errors instead of accepting that kind of crappy Liquid.Consequences
Nothing in prettier-plugin-liquid; but, in theme-check-js, this should be enough to power the
LiquidSyntaxError
check.