Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    动力小车
    @Stevens1995
    can anyone explain to me what the Node means in this example?
    sjmik
    @sjmik
    Hi, I didn't see one here (https://prettier.io/docs/en/options.html), but is there a way to make prettier output code that looks more like this:
    image.png
    Instead of this:
    image.png
    Jed Fox
    @j-f1
    There isn’t one.
    sjmik
    @sjmik
    Ah, okay, thanks
    Ryan Carniato
    @ryansolid
    Hey, I wrote a JS UI library(https://github.com/ryansolid/solid) that gets incredible performance based on a different approach to change management and templating. It uses JSX (or Tagged Template Literals) but relies on syntax to call out reactive expressions. It currently uses parenthesis to do so (as it is succinct and this plays well with TypeScript). Of course, Prettier strips this out. I've looked at previous issues, but I see no configuration to "preserve parens" or "ignore JSX". I'm unsure if even a custom parser helps here. Any suggestions that doesn't involve putting in //prettier-ignore in every file?
    Jed Fox
    @j-f1
    There isn’t an option for that, but you could change your library to, for example, use a function call instead:
    import { createState, onCleanup, $ } from 'solid-js'
    
    const CountingComponent = () => {
      const [state, setState] = createState({counter: 0});
    
      const interval = setInterval(() =>
        setState({counter: state.counter + 1})
      , 1000);
    
      onCleanup(() => clearInterval(interval));
    
      return <div>{$(state.counter)}</div>;
    }
    Ryan Carniato
    @ryansolid
    I see.. yeah it's just a compiler indicator. So I could compile out the function. Just seeing if there were other options less obtrusive to Typescript.
    I had similar issues with html tagged literals where I don't have the benefit of precompilation. Thanks for the information.
    Marc Immediato
    @marcimmediato
    when i try to install prettier globally i get a ton of node-gyp errors (slightly truncated version: https://pastebin.com/asKVNVUJ) any idea why?
    Jed Fox
    @j-f1
    What Node version are you using?
    Marc Immediato
    @marcimmediato
    12.8.0
    installed with brew
    Marc Immediato
    @marcimmediato
    seems like reinstalling yarn fixed the issue

    now i'm running into a different error with prettier. whenever i save a file in VS Code, it seems that prettier doesn't actually format my code and instead gives the following error:

    Failed to load plugin 'react-hooks' declared in 'CLIOptions'/path/to/react/app/src/test.js:: Cannot find module 'eslint-plugin-react-hooks'
    Require stack:
    - /__placeholder__.js

    But I'm not using hooks at all so i'm not sure why this plugin would even need to be loaded

    Marc Immediato
    @marcimmediato
    It looks like possibly an eslint issue but it shows up in the prettier console and Prettier shows an X next to it in my editor
    Jed Fox
    @j-f1
    Seems like an ESLint issue. Are you using prettier-eslint?
    Marc Immediato
    @marcimmediato
    this will sound stupid, but how do i know? i haven't done react/js in a while and i just am getting back into it
    i created the app with create-react-app
    Jed Fox
    @j-f1
    It’s usually a setting in your editor’s Prettier package.
    Marc Immediato
    @marcimmediato
    i'm on vs code and have these settings
    "prettier.singleQuote": true,
      "javascript.format.enable": false,
      "prettier.eslintIntegration": true,
      "prettier.tslintIntegration": false,
      "prettier.stylelintIntegration": true,
      "editor.formatOnSave": true,
      "prettier.disableLanguages": [
        "markdown"
      ],
    is the eslintIntegration what you're referring to?
    Jed Fox
    @j-f1
    Yep, that’s it.
    Marc Immediato
    @marcimmediato
    so that means i have an eslint config somewhere that probably is trying to include that plugin?
    Jed Fox
    @j-f1
    I believe the built in create-react-app ESLint config includes that plugin.
    Marc Immediato
    @marcimmediato
    thanks, i'll take a look at CRA
    at the CRA eslint config*
    Domingo Perez III
    @dperez3

    Hello. Question about Prettier and Markdown ToC. While adding a partial ToC to my README, I discovered that something somehow completed the rest and I think it was Prettier. A pleasant surprise!

    But I would like to know, can Prettier do this?

    Thanks in advance!

    Jed Fox
    @j-f1
    I don’t think Prettier does that. Maybe you have an editor plugin installed?
    Domingo Perez III
    @dperez3

    Ok, I have this and must have accidentally invoked it
    https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one

    Also, I think I just found what I need to get Prettier to do it...
    https://prettier.io/docs/en/related-projects.html#misc + https://github.com/DavidWells/markdown-magic#toc

    Erwann Mest
    @kud
    Hey
    I've got a little problem with prettier and eslint-disable
    I've got this render() { // eslint-disable-line max-lines-per-function, complexity
    but prettier transforms this into
    render() {
      // eslint-disable-line max-lines-per-function, complexity
    which breaks the feature of disabling some rules in eslint
    is there any way not to do that only for eslint comments?
    cheers
    Benjamin Modayil
    @benjaminmodayil
    If I have an explicit rule for line wrapping in the Prettier Config for the VSCode extension, but I don't have the explicit rule in my .prettierrc file, does the VSCode extension config rule for line wrapping get applied despite nothing being explicit in the .prettierrc file?
    FlyRocketDrones
    @FlyRocketDrones
    Hello, does anyone know how to make prettier add ; at the end of lines where it should go.. like if I have line like let abc = "dada" then add ; next to it...
    Ryan Zimmerman
    @RyanZim
    @FlyRocketDrones If you have the semi option set to true (which it is by default), prettier will add the semis
    FlyRocketDrones
    @FlyRocketDrones
    Thank you
    Jakob Guddas
    @jguddas
    is there a way to run prettier only on a single line of code?
    Jakob Guddas
    @jguddas
    thanks, i will definitely take a look at that
    Stephen
    @stephepush
    Hi all, anyone using sublime to work on react projects? What plugins do you use?