There seems to be a bug with validateAttributeSeparator when attributes are named in a specific way. If one attribute is named e.g. a, there cannot be an attribute named after a-b it, but it works the other way round (a-b before a).
...the linter fails with Invalid attribute separator found, pointing at the dash in a-b. Interestingly, with the same lint rule, the following pug code with an attribute named a-a:
div(a a-a="foo")
...fails with error:
TypeError: Cannot read property 'line' of undefined
at lib/rules/validate-attribute-separator.js:9:4527
at lib/pug-file.js:9:18727
at Array.forEach (<anonymous>)
at PugFile.iterateTokensByFilter (lib/pug-file.js:9:18624)
at PugFile.iterateTokensByType (lib/pug-file.js:9:18937)
at module.exports.lint (lib/rules/validate-attribute-separator.js:9:2008)
at lib/linter.js:9:8270
at Array.forEach (<anonymous>)
at Linter._checkFile (lib/linter.js:9:8092)
at Linter.checkString (lib/linter.js:9:3918)
at Linter.checkFile (lib/linter.js:9:2741)
...
When the attributes are re-ordered, the pug code is linted without errors:
Hello!
There seems to be a bug with
validateAttributeSeparator
when attributes are named in a specific way. If one attribute is named e.g.a
, there cannot be an attribute named aftera-b
it, but it works the other way round (a-b
beforea
).For example, given the lint rule:
...and the following pug code:
...the linter fails with
Invalid attribute separator found
, pointing at the dash ina-b
. Interestingly, with the same lint rule, the following pug code with an attribute nameda-a
:...fails with error:
When the attributes are re-ordered, the pug code is linted without errors:
The same bug occurs in multiline attributes.
pug-lint
version used: 2.5.0