Prettier/VSCode Eslint weird format/syntax breaking bug

I had similar issues using ESLint and Prettier together in VS Code. After trying dozens of ways, the following configuration works for me.

ESLint and Prettier are installed globally on my machine.

I am using these extensions:

https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

My .eslintrc.json file looks like this:

{
"env": {
    "browser": true,
    "commonjs": true,
    "es6": true
},
"extends": ["eslint:recommended"],
"parserOptions": {
    "sourceType": "module"
},
"rules": {
    "indent": ["error", 4],
    "quotes": ["error", "single"],
    "semi": ["error", "always"],
    "no-console": "off"
}

}

In your VS Code, please go to Preference > Settings > User Settings and add the following lines:

"editor.formatOnSave": true,
"prettier.tabWidth": 4,
"prettier.eslintIntegration": true,
"prettier.stylelintIntegration": true

I am not using eslint-config-prettier or eslint-plugin-prettier and everything works fine for me.

Important: Please make sure you do not have any other automatic formatter (other than Prettier) extension installed.


When using VSCode, Prettier and ESLint the same time you may have different conflicting rules.

Setting rules manually in VSCode and ESLint may have no effect, but try to do that first. Also, Prettier settings may be saved in its own config file - .prettierrc or some like that.

If no effect, then check these:

  1. In dev dependencies is proper version installed [eslint-config-prettier][1]

    If you've used React/Vue/other-3d-party tool or source, you have to check that you're use NOT @vue/eslint-config-prettier version (see package.json and lock files)

  2. In eslintrc file there is extends: ['prettier']. Same as the previous check there no library depended version specified.


For me the issue was that the Beautify extension performed the formatting in .js files, and it didn't know how to handle JSX syntax.

The solution was to prevent Beautify from formatting Javascript files.

In order to do so you need to add the following setting to your User Settings in VSCode (reachable using ctrl+shift+p and selecting Preferences: Open User Settings):

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