Pug must not contain any attribute concatenation.
//- Invalid
a(href='text ' + title) Link
//- Invalid under `'aggressive'`
a(href=text + title) Link
a(href=num1 + num2) Link
Pug must not contain any attribute interpolation operators.
//- Invalid
a(href='text #{title}') Link
//- Valid
a(href='text \#{title}') Link
a(href='text \\#{title}') Link
Attribute interpolation has already been removed from Pug v2. This rule helps transition from legacy "Jade" v1 code bases to Pug, but does not serve any real purpose in real world if Pug v2 is used.
Pug must not contain template strings in attributes. true
only fails when
the attribute is a template string; 'all'
fails when template strings are
used at all.
//- Invalid
a(href=`https://${site}`) Link
//- Valid
a(href=getLink(`https://${site}`)) Link
//- Invalid
a(href=getLink(`https://${site}`)) Link
Pug must not contain any block expansion operators.
//- Invalid
p: strong text
table: tr: td text
Prefer class literals over class
attributes with static values.
//- Invalid
span(class='foo')
//- Valid
span.foo
All attribute blocks must be written before any class literals.
//- Invalid
input.class(type='text')
//- Valid
input(type='text').class
All ID literals must be written before any class literals.
//- Invalid
input.class#id(type='text')
//- Valid
input#id.class(type='text')
Pug must not contain any class literals.
//- Invalid
.class
//- Valid
div(class='class')
Attribute blocks must not contain any duplicates. And if an ID literal is present an ID attribute must not be used. Ignores class attributes.
//- Invalid
div(a='a' a='b')
#id(id='id')
//- Valid
div(class='a', class='b')
.class(class='class')
Pug must not contain any HTML text.
//- Invalid
<strong>html text</strong>
p this is <strong>html</strong> text
Prefer ID literals over id
attributes with static values.
//- Invalid
span(id='foo')
//- Valid
span#id
All attribute blocks must be written before any ID literals.
//- Invalid
input#id(type='text')
//- Valid
input(type='text')#id
Pug must not contain any ID literals.
//- Invalid
#id
//- Valid
div(id='id')
The Pug template must not contain legacy mixin call.
//- Invalid
mixin myMixin(arg)
//- Valid mixin call
+myMixin(arg)
//- Valid mixin call with block attached
+myMixin(arg)
p Hey
//- Valid mixin definition
mixin myMixin(arg)
p Hey
Pug must not contain multiple blank lines in a row.
//- Invalid
div
div
//- Valid
div
div
No code operators (-
/=
/!=
) should be followed by any spaces.
//- Invalid
p= 'This code is <escaped>'
p!= 'This code is <strong>not</strong> escaped'
//- Valid
p='This code is <escaped>'
p!='This code is <strong>not</strong> escaped'
No unbuffered code operators (-
) should be followed by any spaces.
//- Invalid
- var a = 'This is code'
//- Valid
-var a = 'This is code'
Disallows space after opening attribute bracket and before closing.
//- Invalid
input( type='text' name='name' value='value' )
//- Valid
input(type='text' name='name' value='value')
Pug must not contain any of the attributes specified.
//- Invalid
span(a='a')
div(B='b')
img
tags must not contain any of the attributes specified.
//- Invalid
img(title='title')
Pug must not contain any of the tags specified.
//- Invalid
b Bold text
i Italic text
Pug must not contain any string concatenation.
//- Invalid
h1= title + 'text'
//- Invalid under `'aggressive'`
h1= title + text
Pug must not contain any string interpolation operators.
//- Invalid
h1 #{title} text
Pug must not contain any tag interpolation operators.
//- Invalid
| #[strong html] text
p #[strong html] text
Pug must not contain template strings. true
only fails when a template
string is used directly; 'all'
fails when template strings are used at
all.
//- Invalid
h1= `${title} text`
//- Valid
h1= translate(`${title} text`)
//- Invalid
h1= translate(`${title} text`)
Lines in Pug file must not contain useless spaces at the end.
Lines in Pug file must not exceed the specified length.
Pug files should be at most the number of lines specified.
All class literals must be written before any attribute blocks.
//- Invalid
input(type='text').class
//- Valid
input.class(type='text')
All class literals must be written before any ID literals.
//- Invalid
input#id.class(type='text')
//- Valid
input.class#id(type='text')
All ID literals must be written before any attribute blocks.
//- Invalid
input(type='text')#id
//- Valid
input#id(type='text')
All files must end with a line feed.
All attributes must be written in lower case. Files with doctype xml
are ignored.
//- Invalid
div(Class='class')
//- Valid
div(class='class')
All tags must be written in lower case. Files with doctype xml
are ignored.
//- Invalid
Div(class='class')
//- Valid
div(class='class')
All code operators (-
/=
/!=
) must be immediately followed by a single space.
//- Invalid
p='This code is <escaped>'
p!= 'This code is <strong>not</strong> escaped'
//- Valid
p= 'This code is <escaped>'
p!= 'This code is <strong>not</strong> escaped'
All unbuffered code operators (-
) must be immediately followed by a single space.
//- Invalid
-var a = 'This is code'
//- Valid
- var a = 'This is code'
Requires space after opening attribute bracket and before closing.
//- Invalid
input(type='text' name='name' value='value')
//- Valid
input( type='text' name='name' value='value' )
img
tags must contain all of the attributes specified.
//- Invalid
img(src='src')
//- Valid
img(src='src' alt='alt')
Requires the use of ===
and !==
instead of ==
and !=
.
//- Invalid
if true == false
if true != false
//- Valid
if true === false
if true !== false
All attribute values must be enclosed in single quotes.
//- Invalid
input(type="text" name="name" value="value")
//- Valid
input(type='text' name='name' value='value')
All attribute values must be enclosed in quote marks match the first quote mark encountered in the source code.
- All attributes must be immediately followed by a comma and then a space.
- All attributes must be on the same line.
//- Invalid
input(type='text' name='name' value='value')
div
input(type='text'
, name='name'
, value='value'
)
//- Valid
input(type='text', name='name', value='value')
- All attributes that are on the same line must be immediately followed by a space.
- All attributes that are on different lines must be preceded by two spaces.
//- Invalid
input(type='text', name='name', value='value')
div
input(type='text'
, name='name'
, value='value'
)
//- Valid
input(type='text' name='name' value='value')
div
input(type='text'
name='name'
value='value'
)
Checks that Pug does not contain any unnecessary div
tags.
//- Invalid
div.class
div#id
div.class(class='class')
//- Valid
.class
#id
.class(class='class')
Pug template must use proper file extensions with inclusion and inheritance
(.pug
).
//- Invalid
include a
include a.jade
extends a
extends a.txt
extends a.jade
//- Valid
include a.txt
include a.pug
extends a.pug
Indentation must be consistently two spaces.
//- Invalid
div
<TAB>div
//- Valid
div
<SPACE><SPACE>div
Indentation must be consistently tabs.
//- Invalid
div
<SPACE><SPACE>div
//- Valid
div
<TAB>div
All line break characters must match.
//- Invalid
div(class='class')<CRLF>
.button
//- Valid
div(class='class')<LF>
.button
Checks that Pug does not contain any
unnecessary self closing tags.
Files with doctype xml
are ignored.
//- Invalid
area/
link/
//- Valid
area
link
foo/
doctype xml
area/
Validate the use of template string in Pug templates.
The option can either be an array or true
. If it is an array, it can
contain the following strings. If it is true
signifies all of the
following subrules are enabled.
//- Invalid
h1= `${title}`
//- Valid
h1= title
//- Invalid
h1= `title`
//- Valid
h1= 'title'
//- Invalid
h1= `title` + `text`
h1= `title` + variable
//- Valid
h1= `titletext`
h1= `title${variable}`