Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate attribute separator not working properly #149

Open
jlaamanen opened this issue Apr 12, 2018 · 1 comment · May be fixed by #150
Open

Validate attribute separator not working properly #149

jlaamanen opened this issue Apr 12, 2018 · 1 comment · May be fixed by #150

Comments

@jlaamanen
Copy link

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 after a-b it, but it works the other way round (a-b before a).

For example, given the lint rule:

{
  "validateAttributeSeparator": {
    "separator": " ",
    "multiLineSeparator": "\n  "
  }
}

...and the following pug code:

div(a a-b="foo")

...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:

div(a-b="foo" a)
div(a-a="foo" a)

The same bug occurs in multiline attributes.

pug-lint version used: 2.5.0

jlaamanen pushed a commit to jlaamanen/pug-lint that referenced this issue Apr 12, 2018
jlaamanen pushed a commit to jlaamanen/pug-lint that referenced this issue Apr 12, 2018
@Max-0n
Copy link

Max-0n commented Jan 21, 2019

Same problem. Fix that please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants