PackedPrettier 2.5.1.10

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global PackedPrettier --version 2.5.1.10                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local PackedPrettier --version 2.5.1.10                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=PackedPrettier&version=2.5.1.10                
nuke :add-package PackedPrettier --version 2.5.1.10                

PackedPrettier

The opinionated code formatter Prettier packed as dotnet tool.

What is prettier?

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

GitHub - prettier/prettier: Prettier is an opinionated code formatter.

It is written in javascript and requires node to run.

What is PackedPrettier?

PackedPrettier packs prettier in an executable for various platforms.

Including node.

You can install it using dotnet tool install, both as global and local tool.

Getting started

Installation

Install as local dotnet tool:

dotnet new tool-manifest # if PackedPrettier is your first tool
dotnet tool install PackedPrettier # will take a few seconds

How to use

In the terminal:

dotnet pprettier --help

❗ The command is named pprettier for brevity and internally prettier is executed.

In Visual Studio

  1. Install RunOnSave: A Visual Studio extension that can run commands on files when they're saved.

  2. Create a .onsaveconfig with this content:

    [*.{js,jsx,ts,tsx,css,less,scss,vue,json,gql,md}]
    command = dotnet
    arguments = pprettier --write "{file}"
    

When you save a file in VS, prettier will reformat it

Plugins

By default, two plugins are included (always the latest version at time of compilation of prettier):

They aren't used by default. You need to tell prettier where to find them.

Because the plugins are part of the packed prettier binary, the files are stored in a virtual filesystem and a special lookup path needs to be used:

dotnet pprettier --write <file path> --plugin=<NodeModulesPath>/@prettier/plugin-xml

Example with test.xml:

dotnet pprettier --write test.xml --plugin=<NodeModulesPath>/@prettier/plugin-xml
Plugin File types Lookup Path
prettier-plugin-sh shellscript, Dockerfile, gitignore, dotenv and many more! <NodeModulesPath>/prettier-plugin-sh
@prettier/plugin-xml xml <NodeModulesPath>/@prettier/plugin-xml

Custom .onsaveconfig entries

[*.{xml,csproj,xaml}]
command = dotnet
arguments = pprettier --write "{file}" --plugin "<NodeModulesPath>/@prettier/plugin-xml"

[*.sh]
command = dotnet
arguments = pprettier --write "{file}" --plugin "<NodeModulesPath>/prettier-plugin-sh"

What about C# files (.cs)?

There is a (sort of) port of prettier that supports cs files:

Checkout belav/csharpier: an opinionated code formatter for c#. and install it as dotnet tool. Then add this to your .onsaveconfig file:

[*.cs]
command = dotnet
arguments = csharpier "{file}"

Supported Platforms of PackedPrettier

prettier is compiled for

  • Windows x64

  • Linux x64

and the loader requires

  • .Net Standard 2.1

  • .Net 5

  • .Net 6

Found a bug? Have a suggestion?

Please create an issue.

Pull requests are always welcome 😍

License

This software is released under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
3.2.5.13 6,380 2/10/2024
2.8.8.211 3,179 4/24/2023
2.8.7.181 1,235 3/25/2023
2.8.6.178 772 3/22/2023
2.8.5.177 752 3/21/2023
2.8.4.137 3,304 2/9/2023
2.8.3.112 1,098 1/15/2023
2.8.2.105 880 1/8/2023
2.8.1.100-alpha1 634 12/16/2022
2.7.1.14 2,616 7/3/2022
2.6.2.14 1,964 5/14/2022
2.6.2.11 1,792 5/11/2022
2.5.1.10 3,363 1/22/2022
2.5.1.9 1,452 1/22/2022
2.5.1.8 1,460 1/22/2022