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: Prettier is consolidating mixin objects to single-line #324

Closed
ekfuhrmann opened this issue Jan 3, 2022 · 5 comments · May be fixed by #288
Closed

Bug: Prettier is consolidating mixin objects to single-line #324

ekfuhrmann opened this issue Jan 3, 2022 · 5 comments · May be fixed by #288
Labels
type: duplicate This issue or pull request already exists

Comments

@ekfuhrmann
Copy link

Info

Tool Version
Plugin v1.19.0
Prettier v2.2.1
Framework none
Node 14.17.5
OS win

Prettier config

{
  "semi": true,
  "trailingComma": "es5",
  "singleQuote": true,
  "printWidth": 80,
  "tabWidth": 2,
  "endOfLine": "auto"
}

Input

mixin section-intro(content)
  section.section.section--intro(data-chameleon='black')
    .wrapper
      .section__header
        if content.subhead
          p.section__subhead.enter.enter--bottom!= content.subhead
        p.section__heading.enter.enter--bottom.enter--delay-1!= content.heading

      .section__row
        each column in content.content
          .section__column
            .section__content.enter.enter--bottom.enter--delay-2
              p.section__content-subhead!= column.subhead
              each paragraph in column.text
                p.section__content-text!= paragraph

        if content.image
          img.section__image.enter.enter--bottom.enter--delay-3(src=`/${relativeRoot}assets/images/work/${content.image}`, alt='')

      if block
        block

+section-intro({
  subhead: 'Introduction',
  heading: 'Helping candidates and employers connect through a streamlined platform, all while ensuring no one is left out. ',
  content: [
    {
      subhead: 'The Problem',
      text: ['Employers are eager to higher a diverse workforce, but struggle to manage the daunting process to access talent that meets their needs. Underrepresented job seekers often go unnoticed or worse, get passed up based on existing market biases. ']
    },
    {
      subhead: 'The Solution',
      text: ['Create a network that prioritizes inclusivity and transparency by uniting job seekers with employers based on their common strengths.  For employers and admins, use thoughtful automation to encourage autonomy.']
    }
  ]
})

Output or Error

+section-intro({ subhead: 'Introduction', heading: 'Helping candidates and employers connect through a streamlined platform, all while ensuring no one is left out. ', content: [ { subhead: 'The Problem', text: ['Employers are eager to higher a diverse workforce, but struggle to manage the daunting process to access talent that meets their needs. Underrepresented job seekers often go unnoticed or worse, get passed up based on existing market biases. '] }, { subhead: 'The Solution', text: ['Create a network that prioritizes inclusivity and transparency by uniting job seekers with employers based on their common strengths. For employers and admins, use thoughtful automation to encourage autonomy.'] } ] })

Expected Output

+section-intro({
  subhead: 'Introduction',
  heading: 'Helping candidates and employers connect through a streamlined platform, all while ensuring no one is left out. ',
  content: [
    {
      subhead: 'The Problem',
      text: ['Employers are eager to higher a diverse workforce, but struggle to manage the daunting process to access talent that meets their needs. Underrepresented job seekers often go unnoticed or worse, get passed up based on existing market biases. ']
    },
    {
      subhead: 'The Solution',
      text: ['Create a network that prioritizes inclusivity and transparency by uniting job seekers with employers based on their common strengths.  For employers and admins, use thoughtful automation to encourage autonomy.']
    }
  ]
})

Additional Context

@Shinigami92 Shinigami92 linked a pull request Jan 3, 2022 that will close this issue
@Shinigami92
Copy link
Member

I already tried to format this, but it's very hard and error-prone 😕
Theoretically args can be anything, it could be json, or a comma separated list of args that contains e.g. also json as one arg, and I cannot find out where a comma of param args is or a json comma is.
So to totally fix this, we would need to have this feature: pugjs/pug#3214

I will also close this issue due to duplicate to #66

@Shinigami92 Shinigami92 added the type: duplicate This issue or pull request already exists label Jan 3, 2022
@ekfuhrmann
Copy link
Author

Oh gosh, I forgot I created that issue... 🤦. I did a search ahead of time and just didn't do a good enough job, sorry about the duplicate, though I am happy that this example may be more useful.

Thanks again for everything.

@Shinigami92
Copy link
Member

Sadly pug is kinda really dead in maintenance 😭
They didn't even response in anyway to my request
Beside that, I think this is VERY hard to implement and maybe it's easier for now to find a workaround like to extract the json content to a var/let/const and pass it as arg
That way it gets formatted, I think

@ekfuhrmann
Copy link
Author

yeah, that's fair. I have a rather large legacy project that just was not formatted that way and I dread the thought of going back through and reconfiguring it. I'll most likely just avoid using puglint for that older project so as to not have to deal with it, but on other projects I'll use the var pattern to work around it.

Here's to hoping Pug begins to get maintained again one day, in the meantime I really do appreciate all that you do for the community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants