by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Elliot
    @raisonon
    Is Prettier extension for VS Code using PSR-12 formatting for PHP code? Thanks in advance
    Emmanuel Medina
    @emmanuel_mg__twitter
    Hi is there a guide to install @prettier-ruby plugin to work with VS-Code prettier extension?
    Jan Opravil
    @opravil-jan

    Hello. I'm new to prettier and I run to the problem with formatting my async / await functions. In eslint configuration I have this rule dissabled have rule space-before-function-paren but still prettier is formatting the code incorrectly.
    Expected formating:

    test('Refresh token', async() {
          const response = await chakram.post(`/v2/sso/refresh`, {
            refreshToken
          })
    
          Joi.assert(response.body, validators.responsePostRefresh)
        })

    Given:

    test('Refresh token', async () {
          const response = await chakram.post(`/v2/sso/refresh`, {
            refreshToken
          })
    
          Joi.assert(response.body, validators.responsePostRefresh)
        })

    Can you help me to not have space between async and brackets. What Am I missing?

    Jed Fox
    @j-f1
    Can you make an example in the playground so I can better see the issue @opravil-jan? https://prettier.io/playground
    Brad Cantrell
    @maxirater
    People who use Dart are very bothered by the 2-space indent enforced by dartfmt which automatically formats Dart and would like the option to be able to configure how Dart indent spacing is formatted. Im wondering if the Prettier plugin will ever support Dart since its very similar to Javascript. Here is a thread on github discussing this issue: Dart-Code/Dart-Code#914
    Jed Fox
    @j-f1
    If someone finds a JS parser for Dart and writes a printer for it, we’ll be happy to add it to our list of plugins. However I don’t think we plan to add support for Dart by default at this time.
    Andreas Opferkuch
    @s-h-a-d-o-w
    I recently started using prettier v2 and stumbled across this issue: https://prettier.io/docs/en/options.html#end-of-line
    Maybe I'm just too dense but I've been working with Windows, Mac and Linux for years now, frequently on the same code bases and never had an issue with line endings. Except for the rare cases when people thought that it's a good idea to use forced line ending settings that clashed with git's autocrlf. Which is exactly what happened to me now.
    git on Windows by default installs with autocrlf (unless this was changed recently too), so why oh why would you introduce conflicts with this only to protect from maybe 2% of Windows users who have their git settings wrong?
    Andreas Opferkuch
    @s-h-a-d-o-w
    (I do realize that this can be overridden, I just think that the default setting should harmonize with git's default and would appreciate an explanation for why I'm wrong about that.)
    Andreas Opferkuch
    @s-h-a-d-o-w
    Thanks but that just again describes the 2% case I mentioned and ignores the fact that now, millions of Windows users have to change their git configs to avoid seeing prettier errors on everything that they just cloned. As well as their IDE configs, since obviously some of them default to CRLF on Windows for good reason.
    Andreas Opferkuch
    @s-h-a-d-o-w
    In case other confused/frustrated Windows developers end up here - this is a more substantial explanation for the "why oh why" 😉 prettier/prettier#5320
    Clarence "Sparr" Risher
    @sparr
    is there a way to disable just one part or rule of prettier for a particular piece of code, short of turning it off entirely with // prettier-ignore ?
    Ryan Zimmerman
    @RyanZim
    @sparr No
    Tino Groteloh
    @Tinoooo
    Hi there. Is there a possibility for somebody to have a second look on prettier/eslint-plugin-prettier#94 ? I've been trying the whole day to fix that problem for me. No success :(
    Thomas Jay Rush
    @tjayrush
    Hi. Love your tool, but I'm curious if this is open source. How can you support such an excellent tool? Is there a 'for-purchase' version with some additional feature? I'd pay.
    Ryan Zimmerman
    @RyanZim
    @tjayrush AFAIK, there isn't a paid version, however, donations are appreciated: https://opencollective.com/prettier
    (BTW, I'm not a member of the team, just an active community member)
    Jed Fox
    @j-f1
    @tjayrush For companies, there’s Tidelift which is a paid support plan for a bunch of npm packages.
    Chiawen Chen
    @golopot
    Hi, I am developing a prettier plug-in for SQL. And I am having difficulty understanding how comments are handled. I am reading the source of estree printer as an examplar. I suppose there should be codes that attach comments to ast nodes, also there should be codes that print leading and trailing comments attached to nodes. But I cannot find these said codes. Can you help me with an outline about how comments are handled?
    Egor Gorbachev
    @kubk
    Hi all, is there a list of popular recognizible open source projects using Prettier? I want to convince my colleague to switch to Prettier 😈
    Ryan Zimmerman
    @RyanZim
    Lean Junio
    @leanjunio
    image.png
    Hey guys, does anybody know why prettier formats these two constructors differently on ts?
    Chiawen Chen
    @golopot
    Prettier tries to fit it in one line when possible. The left example when fit in one line will exceed the configured maximum width, therefore it is broke into multiple lines.
    Ben Schley
    @bschley
    Hello, how I can install the official prettier-php plugin for the prettier plugin for visual studio code? I read the documentation but I had no luck to get it running :/
    I have prettier in visual studio code installed but not the plugin in the plugin. I talk from (https://github.com/prettier/plugin-php)
    Eric Nemchik
    @nemchik

    i've come across something i don't love about prettier formatting in html (and other markup languages like xml or any using <tags>).

    I start with one long line like this

    <q-btn v-if="this.multifactorEnabled === false" name="multifactorEnabled" @click="enablesMfa">Enable MFA</q-btn>

    prettier wraps that like so

    <q-btn v-if="this.multifactorEnabled === false" name="multifactorEnabled" @click="enablesMfa"
      >Enable MFA</q-btn
    >

    but this is hideous. i reformat it to

    <q-btn v-if="this.multifactorEnabled === false" name="multifactorEnabled" @click="enablesMfa">
      Enable MFA
    </q-btn>

    and prettier is fine with this. is there some kind of option to adjust this behavior?

    The reason prettier works that way by default is that your manual reformat technically adds whitespace to the value inside the tag.
    Eric Nemchik
    @nemchik
    that makes sense. so using htmlWhitespaceSensitivity: "ignore" would accomplish what i want visually, but would be adding white space that could affect the output of the markup itself. (assuming ignore means what i think it means after reading. the docs don't really explain explicitly the difference between the 3 options - saying whitespace is ignored or not doesn't quite explain the effect, thus i had overlooked this option when searching the docs initially)
    Ryan Zimmerman
    @RyanZim
    Yep, ignore should do what you describe.
    Ghost
    @ghost~5ec7a467d73408ce4fe48f3d
    Hey 👋
    There is a neat feature request for WebStorm/PhpStorm for better code folding support. Prettier is formating long class names in a new line. But if the element is folded there is no way to see it in the IDE. If anyone got a JetBrains account and could maybe upvote for this feature request: https://youtrack.jetbrains.com/issue/WEB-45637
    It would mean alot for me. This would make prettier even better with JetBrains Products :)
    Javed Bartlett
    @javedbartlett
    image.png
    Hello!
    I was wondering if it were possible to have parens added around a block of multiline jsx with prettier?
    Every time I save my file it removes the parens and it's not lining up with my companies lint config
    Ryan Zimmerman
    @RyanZim
    prettier does not comply with arbitrary lint configs. If you must comply with an external config, you might look into prettier-eslint, to let eslint re-add the parens.
    Manuel Mendez
    @mmlb
    hey all, I went looking in the docs and github issues and couldn't find the answer to my quesion: how can I configure prettier to sort json object by keys?
    I've got a markdown file with what was a one line json blob wrapped in "```json", and prettier reflowed to many lines ( :+1: ) but it would be nice to also sort the keys.
    I saw an issue about package.json but I'm looking for more generic json sorting.
    also maybe yaml too
    hmm looks like prettier does not do the json reflow in the ```json within markdown, looks like I did that manually
    Gregorio Setti
    @desmondhume

    Hi! I'm using prettier on some markdown files, but it seems to ignore errors inside the yaml front matter.
    The prettier playground show the error correctly but not my local setup (they have the same versions and options):

    Prettier 2.0.5
    Playground link

    --parser mdx

    Input:

    ---
    title: test: 1
    ---
    
    # Test 1

    Output:

    SyntaxError: Nested mappings are not allowed in compact mappings (1:8)
    > 1 | title: test: 1
        |        ^^^^^^^
    any idea?
    Jed Fox
    @j-f1
    Prettier just ignores invalid syntax in embedded languages because we can never be positive that you intended to embed something of a different language. However on the playground we throw errors, probably for debugging purposes.
    Gregorio Setti
    @desmondhume
    got it :thumbsup: I guess I'll be able to hook a remark plugin to check it maybe :thought_balloon:
    G. Richard Bellamy
    @rbellamy
    When trying to work with the XML plugin (https://github.com/prettier/plugin-xml) using Typescript, I get a compilation error:
    return prettier.format(
          dom.serialize(),
          {
            printWidth: options.printWidth,
            tabWidth: options.tabWidth,
            parser: "xml"
          });
    TS2322: Type 'xml' is not assignable to type '"babel" | "babel-flow" | "babel-ts" | "flow" | "typescript" | "css"...