question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breaking up HTML tags in JSX upon save

See original GitHub issue

Hey guys, I’ve been using prettier for about 6 months now and never had an issue. but I recently updated VSCode and I ran into this problem today with it breaking out my HTML tags in my JSX and spacing it all wildly. Example follows: Before save:

return (
    <div className="input-group mb-3">
      <div className="input-group-prepend">
        <span className="input-group-text">
          <i className={icon} />
        </span>
    </div>
    <input
      className={classnames("form-control form-control-lg", {
        "is-invalid": error
      })}
      placeholder={placeholder}
      name={name}
      value={value}
      onChange={onChange}
    />
      {error && <div className="invalid-feedback">{error}</div>}
    </div>
  );
}; 

After save

return ( <
      div className = "input-group mb-3" >
      <
      div className = "input-group-prepend" >
      <
      span className = "input-group-text" >
      <
      i className = {
        icon
      }
      /> <
      /span> <
      /div> <
      input className = {
        classnames("form-control form-control-lg", {
          "is-invalid": error
        })
      }
      placeholder = {
        placeholder
      }
      name = {
        name
      }
      value = {
        value
      }
      onChange = {
        onChange
      }
      /> {
        error && < div className = "invalid-feedback" > {
            error
          } < /div>} <
          /div>
      );
    }; 

I can provide additional info if needed. Such as my settings, etc.

UPDATE 6/4/18: Resolved by disabling Beautify, which was causing issues with Prettier.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:64
  • Comments:28 (1 by maintainers)

github_iconTop GitHub Comments

62reactions
sonbuiGFDcommented, May 17, 2018

@jtbandes Thank you so much 👍 FYI: it conflicts with beautify so we add:

"beautify.ignore": [
        "**/*.js",
        "**/*.jsx"
    ]

and it fixed =))

28reactions
ctrlplusbcommented, May 15, 2018

Oh, thank the heavens, the linked issue at jsbeautify solved it for me. Disabled the Beautify plugin on my vscode and all is well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code - breaking up HTML tags in JSX on save - Dirask
VS Code - breaking up HTML tags in JSX on save · 1. Go to File -> Preferences -> Settings, · 2. Search...
Read more >
VS Code beautify break tags in react html - Stack Overflow
Save this question. Show activity on this post. Question is how can i change beautify settings to not transfer tags to a new...
Read more >
Introducing JSX - React
This funny tag syntax is neither a string nor HTML. It is called JSX, and it is a syntax extension to JavaScript. We...
Read more >
HTML Programming with Visual Studio Code
Tag elements are automatically closed when > of the opening tag is typed. HTML Close1. The matching closing tag is inserted when /...
Read more >
HTML pre tag - W3Schools
The <pre> tag defines preformatted text. Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found