VS Code package to format your Javascript / Typescript / CSS using Prettier.
Install through VS Code extensions. Search for Prettier - JavaScript formatter
Visual Studio Code Market Place: Prettier - JavaScript formatter
Can also be installed using
ext install prettier-vscode
1. CMD + Shift + P -> Format Document
OR
1. Select the text you want to Prettify
2. CMD + Shift + P -> Format Selection
Respects editor.formatOnSave
setting.
Settings will be read from:
- File system, first matching file in
package.json
-prettier
key.prettierrc
.prettier.config.js
- VSCode prettier's settings, described below
- VSCode prettier's default settings
Fit code within this line limit
Number of spaces it should use per tab
If true, will use single instead of double quotes
Controls the printing of trailing commas wherever possible. Valid options:
- "none" - No trailing commas
- "es5" - Trailing commas where valid in ES5 (objects, arrays, etc)
- "all" - Trailing commas wherever possible (function arguments)
Controls the printing of spaces inside object literals
If true, puts the >
of a multi-line jsx element at the end of the last line instead of being alone on the next line
Which parser to use. Valid options are 'flow' and 'babylon'.
Whether to add a semicolon at the end of every line (semi: true), or only at the beginning of lines that may introduce ASI failures (semi: false)
If true, indent lines with tabs
Use prettier-eslint instead of prettier. Other settings will only be fallbacks in case they could not be inferred from eslint rules.
Advanced feature. Use this to opt in / out prettier on various language ids. Restart required.
Use parser babylon
or flow
depending on prettier.parser
for given language ids.
Use with care.
Advanced feature. Use this to opt in / out prettier on various language ids. Restart required.
Use parser typescript
for given language ids.
Use with care.
Advanced feature. Use this to opt in / out prettier on various language ids. Restart required.
Use parser postcss
for given language ids.
Use with care.
Advanced feature. Use this to opt in / out prettier on various language ids. Restart required.
Use parser json
for given language ids.
Use with care.
Advanced feature. Use this to opt in / out prettier on various language ids. Restart required.
Use parser graphql
for given language ids.
Use with care.
This extension will use prettier from your project's local dependencies. Should prettier not be installed locally with your project's dependencies, a copy will be bundled with the extension.
This is my first Visual Studio Extension so I probably made some terrible choices. Feel free to open issues or PRs!