PackedPrettier 2.6.2.14
See the version list below for details.
dotnet tool install --global PackedPrettier --version 2.6.2.14
dotnet new tool-manifest
dotnet tool install --local PackedPrettier --version 2.6.2.14
#tool dotnet:?package=PackedPrettier&version=2.6.2.14
nuke :add-package PackedPrettier --version 2.6.2.14
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
pprettierfor brevity and internallyprettieris executed.
In Visual Studio
Install RunOnSave: A Visual Studio extension that can run commands on files when they're saved.
Create a
.onsaveconfigwith 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.
For Windows that's C:\snapshot\node_modules and /snapshot/node_modules for unix systems.
So if you want to load prettier/plugin-xml, then you need to write:
dotnet pprettier --write <file path> --plugin=/snapshot/node_modules/@prettier/plugin-xml
To make this portable, PackedPrettier will replace <NodeModulesPath> at runtime with the correct path:
dotnet pprettier --write <file path> --plugin=<NodeModulesPath>/@prettier/plugin-xml
This will work on any operating system.
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,appxmanifest,props,wapproj}]
command = dotnet
arguments = pprettier --write "{file}" --plugin "<NodeModulesPath>/@prettier/plugin-xml" --parser "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 either
.Net Core 3.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 | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 is compatible. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.5.13 | 16,681 | 2/10/2024 |
| 2.8.8.211 | 3,479 | 4/24/2023 |
| 2.8.7.181 | 1,393 | 3/25/2023 |
| 2.8.6.178 | 914 | 3/22/2023 |
| 2.8.5.177 | 891 | 3/21/2023 |
| 2.8.4.137 | 3,469 | 2/9/2023 |
| 2.8.3.112 | 1,256 | 1/15/2023 |
| 2.8.2.105 | 1,038 | 1/8/2023 |
| 2.8.1.100-alpha1 | 767 | 12/16/2022 |
| 2.7.1.14 | 2,909 | 7/3/2022 |
| 2.6.2.14 | 2,177 | 5/14/2022 |
| 2.6.2.11 | 2,105 | 5/11/2022 |
| 2.5.1.10 | 3,827 | 1/22/2022 |
| 2.5.1.9 | 1,640 | 1/22/2022 |
| 2.5.1.8 | 1,662 | 1/22/2022 |