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

Bug: pugAttributeSeparator='as-needed' breaks quotes of the preceding attribute value #255

Closed
2 of 7 tasks
lukaromih opened this issue Jul 9, 2021 · 4 comments · Fixed by #256
Closed
2 of 7 tasks
Labels
type: bug Functionality that does not work as intended/expected

Comments

@lukaromih
Copy link

lukaromih commented Jul 9, 2021

Plugin Version

v1.16.0

Prettier Version

v2.3.2

Which frameworks are affected?

  • none
  • vue
  • angular
  • svelte

Node Version

v10.19.0

Which operating systems have you used?

  • Linux
  • macOS
  • Windows

Prettier config

overrides:
  - files: "*.pug"
    options:
      semi: false
      singleQuote: true
      trailingComma: none
      arrowParens: avoid
      pugAttributeSeparator: as-needed

Input

doctype html
html
  head
    title= title
    link(rel='stylesheet' , href='/stylesheets/style.css')
  body
    block content

Output or Error

doctype html
html
  head
    title= title
    link(rel="stylesheet" href='/stylesheets/style.css')
  body
    block content

Expected Output

doctype html
html
  head
    title= title
    link(rel='stylesheet' href='/stylesheets/style.css')
  body
    block content

Additional Context

When using the option pugAttributeSeparator: as-needed, the pugin breaks quotes around attribute values, which are followed by atleast one space before comma and the following attribute key/value pair.
This can seen in the 5th line of my example:

link(rel='stylesheet' , href='/stylesheets/style.css')

will get rewritten by the plugin as:

link(rel="stylesheet" href='/stylesheets/style.css')

When I rerun it the 2nd time, it ends up correctly, as:

link(rel='stylesheet' href='/stylesheets/style.css')

With more than 2 attributes, it only breaks the ones which have atleast one space before the comma and the following attributes, but correctly sets up the attribues, which are immediately followed by a comma.

Without the singleQuote: true option, it will break the quotes to the single quotes. Put simply, it always breaks the quotes since it applies exactly the opposite of what you have set.

@Shinigami92 Shinigami92 added the type: bug Functionality that does not work as intended/expected label Jul 9, 2021
@Shinigami92
Copy link
Member

I think I know this issue, but was too lazy to fix it, cause nobody reported it... Until now... Now I think I have to finally fix it 😅
How dare you 🤣
I will work tomorrow on this 👍

@Shinigami92
Copy link
Member

@lukaromih Please test out v1.16.1-0.

@lukaromih
Copy link
Author

Well, that was fast and the fix definitely works. Thanks!

Would you recommend that I update the dependent projects with version v1.16.1-0 (how stable is it?) or wait for the next patch/minor version?

As far as I'm concerned, this issue has been resolved 👍👏

@Shinigami92
Copy link
Member

v1.16.1-0 could potentially be exactly what v1.16.1 will be 🙂
I just wanted to be safe and I will try it on next working-day on my companies project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants