Skip to content
A Visual Studio extension
C#
Branch: master
Clone or download

Latest commit

tommck and madskristensen Fixed 2 bugs related to #6 (#25)
Fixed error throw when saving a non-supported file type
Fixed throw when the current cursor position is greater that the resulting reformatted file length
Latest commit 2b0cb0b Sep 9, 2018

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add project files. Feb 14, 2017
art Updated readme.md Feb 15, 2017
src Fixed 2 bugs related to #6 (#25) Sep 9, 2018
.editorconfig Update .editorconfig (#23) Aug 20, 2018
.gitattributes Add project files. Feb 14, 2017
.gitignore Add project files. Feb 14, 2017
CHANGELOG.md Adding Format On Save Option (#6) (#24) Sep 6, 2018
JavaScriptPrettier.sln Add project files. Feb 14, 2017
LICENSE Add project files. Feb 14, 2017
README.md update readme to mention local prettier capability (#22) Jul 25, 2018
appveyor.yml Fixed build script Apr 13, 2017

README.md

JavaScript Prettier

Build status

Download this extension from the Marketplace or get the CI build.


Prettier is an opinionated JavaScript formatter inspired by refmt with advanced support for language features from ES2017, JSX, TypeScript and Flow. It removes all original styling and ensures that all outputted JavaScript conforms to a consistent style.

See the change log for changes and road map.

Features

Prettify

This extension calls the prettier node module behind the scenes to format any JavaScript document to its standards.

For example, take the following code:

foo(arg1, arg2, arg3, arg4);

That looks like the right way to format it. However, we've all run into this situation:

foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());

Suddenly our previous format for calling function breaks down because this is too long. What you would probably do is this instead:

foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne()
);

Invoke the command from the context menu in the JavaScript editor.

Context Menu

FAQ

Updating from 1.1 to 2.0

Depending on your Visual Studio Configuration, you might experience that 2.0's output differs from the one you got with 1.1.
Most likely it is the tab size that has been changed from 4 spaces to 2. Please read the configuration section below on details how to get 4 spaces as tabsize.

Configuration

It is quite easy to setup Prettier to format alittle bit different. Like having 4 spaces instead of 2 spaces. The easiest way is to create a .prettierrc in your project root. Here is an example containing the two most common settings that people want to change: tabWidth is how many spaces it uses for indentation, and printWidth is how long a line can be before it breaks down:

  {
    "tabWidth": 4,
    "printWidth": 100
  }

Read more about the configuration file here

Can it use my bundled version of prettier?

Yes, the plugin will search for a locally installed prettier version before falling back to its own version.

Contribute

Check out the contribution guidelines if you want to contribute to this project.

For cloning and building this project yourself, make sure to install the Extensibility Tools 2015 extension for Visual Studio which enables some features used by this project.

License

Apache 2.0

You can’t perform that action at this time.