Format Code ActionRun eslint extension after the prettier extension in VS Code. Or the other way around, whatever way you want. Installation
Install through VS Code extensions: Visual Studio Code Market Place: Format Code Action Or install from within VS Code: Launch VS Code Quick Open (Ctrl+P or cmd+P), paste the following command, and press enter.
Or on the command line:
UsageDisable
This runs 'Format Document' with the default formatter (in this case prettier). Or for specific lanuage only:
This would run prettier by default, but for javascript files would run prettier and then eslint. If you want to reverse the order then just reverse the array. Format Modified (EXPERIMENTAL)Alternatively you may want to format only the modified part of the file, in that case use
This is experimentally supported right now, if you face any problems please report them at: https://github.com/rohit-gohri/vscode-format-code-action/issues/5 MotivationI created this so I could use prettier and eslint together in the editor, in a specific order (eslint after prettier). Earlier prettier was setup to run on save and eslint as a codeAction with:
This would often lead to prettier being run after eslint and eslint errors still being present. Since the March 2020 (v1.44) update, VS Code allows setting The extension uses the Read More on my blog: How to get ESlint and Prettier to play nicely in VS Code? VS Code API
|