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

validateAttributeSeparator multiLineSeparator doesn't support variable indenting #157

Open
GPetrites opened this issue Oct 26, 2018 · 1 comment

Comments

@GPetrites
Copy link

GPetrites commented Oct 26, 2018

This rule is probably the most important for us. When you use Angular you eventually learn that Pug doesn't recognize the Angular binding attributes correctly unless you separate them with a comma. Missing a comma has bitten us numerous times.

currently when you configure the rule using:

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

The pug is only considered valid if the white space on the second line matches EXACTLY the white space included in the rule. As I have it above, there are two spaces after the newline so the rule only passed if the pug looks like:

div(
    aaa="111",
  bbb="222"
)

Note that there are exactly two spaces before the 'bbb' attribute. If I add or remove a space, the rule reports it as an error.

If I replace the spaces with tabs in both the rule and the pug, I get the same results. The number of tabs in the rule must match exactly the number of tabs in the pug.

As a result, it's not possible to create a rule that allows the following pug to be recognized as valid:

div(
    aaa="aaa",
    bbb="bbb"
)
    div(
        aaa="aaa",
        bbb="bbb"
    )
        div(
            aaa="aaa",
            bbb="bbb"
        )

In order to be usable, the multiLineSeparator needs to support various levels of indenting on the following line.

@adrienverge
Copy link
Contributor

I just did a test and confirm what you experience. A new option would be great, for instance:

"validateAttributeSeparator": {
    "separator": ", ",
    "allowMultiLine": true  # `allowMultiLine` and `multiLineSeparator` should be mutually exclusive
}

Contributions are welcome!

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

No branches or pull requests

2 participants