Reputation: 133
Our team uses both VSCode and WebStorm for development, so need to create a same code formatting style for both IDEs.
Upvotes: 13
Views: 10209
Reputation: 2723
Follow these steps in WebStorm :
yarn add --dev --exact prettier
yarn prettier . --write
npm install --save-dev eslint-config-prettier
Go to File | New Projects Setup | Settings for New Projects. In the dialog that opens, go to Languages & Frameworks | JavaScript | Prettier.
Use the Run on 'Reformat Code' action and On save checkboxes to specify the actions that will trigger Prettier.
Your code formatting in WebStorm closely resembles that of VS Code.
eslintrc: Add "prettier" to the "extends" array in your .eslintrc.* file. Make sure to put it last, so it gets the chance to override other configs.
{
"extends": [
"some-other-config-you-use",
"prettier"
]
}
Configure Prettier to run on save or on reformat in new projects
That solution worked perfectly for me.
Upvotes: 0
Reputation: 4957
You can use editorconfig. It's a format for describing code style supported by many editors including WebStorm and VS Code.
Upvotes: 0