Home > Software design >  After save Javascript file in VScode, it changed all format [Solved]
After save Javascript file in VScode, it changed all format [Solved]

Time:03-18

[PROBLEM SOLVED] I found an extension named 'JS-CSS-HTML Formatter' in my extensions. I don't know when I install this extension. So, I decided to uninstall it, and everything back to normal!.

I am having a problem with my vscode that I hope someone can help me. When I try to save a javascript file, it changed all the formating. So, I have to change the language mode from Javascript to Javascript React to all of .js files to make it looks normal. Do you have any suggestions?

Before saving

   const FormComponent = () => {
  return (
    <div className="container">
      <h1>Hello </h1>
    </div>
  );
};

export default FormComponent;

After saving

const FormComponent = () => {
    return ( <
        div className = "container" >
        <
        h1 > Hello < /h1> <
        /div>
    );
};

export default FormComponent;

in settings.json

  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": false
  },

CodePudding user response:

You have set editor.formatOnSave to true

Change it to false as it formats the file on saving

  • Related