Diagnostics
The lexer and parser never stop at the first problem: they report it and carry on, so one run lists everything. compile throws the errors as one ZamnError, the CLI prints them, and parse and lex return them alongside the result.
Every diagnostic has a code, a severity, a message, a range and often a hint. The severity is error or warning:
- an error means the template can't be compiled:
compilethrows, andzamn --validatefails; - a warning points at something that compiles but probably isn't what you meant:
compilereturns it inwarnings, and the CLI prints it aswarning[CODE]without failing.
In ESLint the codes are prefixed with zamn/ (zamn/JS_EXPRESSION): errors are reported by vue-zamn/no-parsing-error, and the MISLEADING_INDENTATION warning by vue-zamn/no-misleading-indentation.
Statements and values
UNSUPPORTED_SYNTAX
A statement zamn doesn't have. The hint says what to write instead.
JS_EXPRESSION
An attribute value, or what follows it, is JavaScript: href=url + "/x", title=`${x}`, class=['a', 'b'], data-x={ a: 1 }, or a style={...} that can't be read as CSS. Quote the value, or in Vue use a binding (:href="url + '/x'").
a(href=base + "/docs") DocsBlocks
UNCLOSED_BRACE
A { with no }.
section {
p Never closedUNMATCHED_BRACE
A } with no { to close.
p Text
}UNESCAPED_BRACE
A { in text that is neither a block nor a {{ }} mustache. Write \{ for a literal brace, and \} for its partner, which would otherwise close the block. See Braces in text.
p Objects look like { a: 1 }MISLEADING_INDENTATION
A warning: a statement is indented deeper than the statement before it in the same block, and that statement left no block open. It looks like a child, but indentation means nothing, so it is a sibling. Put it inside the braces, or indent it as a sibling. The first line of a block, continued attribute lists, |{ } text, script and style content and comments are exempt.
p Some text
b bold<p>Some text</p>
<b>bold</b>Text
UNEXPECTED_TEXT
Something zamn can't read, such as a statement that starts with {{ or #{ (start text with |), or text straight after the ) of the attributes (write a space first).
p {
{{ greeting }}
}UNCLOSED_INTERPOLATION
A {{ in text with no }} before the text ends.
p Hello {{ user.nameUNCLOSED_COMMENT
A /* or /*! with no */.
/* draft
p HelloScripts and styles
UNCLOSED_RAW
A script or style whose content has no /script or /style line after it. It is reported at the opening line, with the hint "end it with /script on its own line". See Scripts and styles.
script
go()UNMATCHED_CLOSE
A /tag line that ends nothing: after a script with src, which has no content and needs no /script, or for a tag other than script and style.
script(src="/app.js")
/scriptElements
INVALID_CLASS_NAME
A . that isn't followed by a class name, or a name with no letter or _ in it (.5). See Classes and ids for what a name may hold, and use class="..." for anything else.
p.5 FiveINVALID_ID
A # after a tag with no id after it.
p# TextSELF_CLOSING_CONTENT
A void element (img, br, input, …) has content.
img(src="/a.png") {
span Caption
}MISSING_EXPANSION
A : (block expansion) with nothing after it: li: followed by the end of the line.
MISSING_EXPRESSION
A = with no expression after it.
p=MISSING_DOCTYPE
A doctype with nothing after it. Write doctype html, or leave the line out.
doctypeAttributes
DUPLICATE_ATTRIBUTE
The same attribute twice on one element, id set by both #id and id="..." included. class may repeat: the values are merged.
a(href="/a" href="/b")INVALID_ATTRIBUTE_VALUE
An unquoted value holds a character HTML doesn't allow there: whitespace, ", ', `, =, < or >. The hint: put the value in quotes.
a(href=/search?q=zamn) SearchMISSING_ATTRIBUTE_VALUE
A = with no value after it.
a(href=) LinkNO_END_BRACKET
The ( of an attribute list never closes.
a(href="/" DocsOther
UNEXPECTED_TOKEN
The parser met a token it didn't expect where it was. You shouldn't normally see this one: the lexer reports most problems first. If you do, please open an issue with the template.
Removed codes
INVALID_INDENTATION, INCONSISTENT_INDENTATION and UNEXPECTED_INDENT went with nesting by indentation: indentation means nothing now, and the only diagnostic about it is the MISLEADING_INDENTATION warning.
