Prettier formatter for Visual Studio CodeVS Code package to format your JavaScript / TypeScript / CSS using Prettier. ChangeLog
InstallationInstall through VS Code extensions. Search for Visual Studio Code Market Place: Prettier - Code formatter Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
⚠ A word of warning-if you have any other code formatting extensions installed such as for example hugely popular UsageUsing Command Palette (CMD/CTRL + Shift + P)
Custom keybindingsIf you don't like the defaults, you can rebind Format On SaveRespects You can turn on format-on-save on a per-language basis by scoping the setting:
VSCode ESLint and TSLint Integration
SettingsPrettier's SettingsSettings will be read from (listed by priority):
Or if no prettier configuration file exist
prettier.printWidth (default: 80)Fit code within this line limit prettier.tabWidth (default: 2)Number of spaces it should use per tab prettier.singleQuote (default: false)If true, will use single instead of double quotes prettier.trailingComma (default: 'none')Controls the printing of trailing commas wherever possible. Valid options:
prettier.bracketSpacing (default: true)Controls the printing of spaces inside object literals prettier.jsxBracketSameLine (default: false)If true, puts the prettier.parser (default: 'babylon') - JavaScript onlyWhich parser to use. Valid options are 'flow' and 'babylon'. prettier.semi (default: true)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) prettier.useTabs (default: false)If true, indent lines with tabs prettier.proseWrap (default: 'preserve')(Markdown) wrap prose over multiple lines. prettier.arrowParens (default: 'avoid')Include parentheses around a sole arrow function parameter prettier.jsxSingleQuote (default: false)Use single quotes instead of double quotes in JSX. prettier.htmlWhitespaceSensitivity (default: 'css')Specify the global whitespace sensitivity for HTML files. Learn more here prettier.endOfLine (default: 'auto')Specify the end of line used by prettier. Learn more here VSCode specific settingsThese settings are specific to VSCode and need to be set in the VSCode settings file. See the documentation for how to do that. prettier.eslintIntegration (default: false) - JavaScript and TypeScript onlyUse prettier-eslint instead of prettier. Other settings will only be fallbacks in case they could not be inferred from ESLint rules. prettier.tslintIntegration (default: false) - JavaScript and TypeScript onlyUse prettier-tslint instead of prettier. Other settings will only be fallbacks in case they could not be inferred from TSLint rules. prettier.stylelintIntegration (default: false) - CSS, SCSS and LESS onlyUse prettier-stylelint instead of prettier. Other settings will only be fallbacks in case they could not be inferred from stylelint rules. prettier.requireConfig (default: false)Require a 'prettierconfig' to format prettier.ignorePath (default: .prettierignore)Supply the path to an ignore file such as prettier.disableLanguages (default: ["vue"])A list of languages IDs to disable this extension on. Restart required. Note: Disabling a language enabled in a parent folder will prevent formatting instead of letting any other formatter to run Prettier resolutionThis 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. ContributeFeel free to open issues or PRs! Running extension
Running testsTests open a VSCode instance and load
OR Without having an instance VSCode running (or it won't start)
|