PackedPrettier 3.2.5.13
dotnet tool install --global PackedPrettier --version 3.2.5.13
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local PackedPrettier --version 3.2.5.13
#tool dotnet:?package=PackedPrettier&version=3.2.5.13
nuke :add-package PackedPrettier --version 3.2.5.13
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
:
- If you haven't used any other dotnet tools yet, create a tool manifest first:
dotnet new tool-manifest
- Install PackedPrettier
dotnet tool install PackedPrettier
How to use
In the terminal:
dotnet pprettier --help
❗ The command is named
pprettier
for brevity and internallyprettier
is executed.
In Visual Studio
Install RunOnSave: A Visual Studio extension that can run commands on files when they're saved.
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
Migration from v2 to v3
Prettier has migrated to es modules. This means that the prettier
package is no longer compatible with pkg
and PackedPrettier
v2. Previously the pkg
package has been used to pack prettier
into an executable. This is no longer possible. The new version of PackedPrettier
uses a different approach to pack prettier
into an executable: deno
. deno
compiles prettier
into an single executable. This executable is then used by the PackedPrettier
loader to run prettier
in the same way as before.
Deno does not allow to import modules at runtime, see https://github.com/denoland/deno/issues/8655 for details.
That means but plugins and javascript config files (for example prettier.config.js
) are not supported anymore.
If this is a showstopper for you, please open an issue and we can discuss a solution. A potential solution could be to use bun
to pack prettier
. But bun
has no stable release for windows yet.
I still consider the windows build of PackedPrettier
as experimental. If you encounter any issues, please open an issue.
Restrictions
Compared to run prettier
with node
there are some restrictions:
- Plugins are not supported (see https://github.com/denoland/deno/issues/8655 for details)
- Javascript config files (for example
prettier.config.js
) are not supported - All restrictions of
deno
apply
This is because deno
does not allow to import modules at runtime.
If this is a showstopper for you, please open an issue and we can discuss a solution. A potential solution could be to use bun
to pack prettier
. But bun
has no stable release for windows yet.
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 6
.Net 7
.Net 8
❗ Support for .NET Core 3.1 and .NET 5 has been dropped because they are out of support.
Mac OS support
This is not possible because executable has to be signed (with either an adhoc signature) or an Apple Developer ID.
Checkout the official pkg
readme for historical details. The same restrictions apply to deno
, too.
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 | 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 is compatible. 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. |
This package has no dependencies.
Version | Downloads | Last updated |
---|---|---|
3.2.5.13 | 7,235 | 2/10/2024 |
2.8.8.211 | 3,239 | 4/24/2023 |
2.8.7.181 | 1,255 | 3/25/2023 |
2.8.6.178 | 788 | 3/22/2023 |
2.8.5.177 | 765 | 3/21/2023 |
2.8.4.137 | 3,321 | 2/9/2023 |
2.8.3.112 | 1,115 | 1/15/2023 |
2.8.2.105 | 890 | 1/8/2023 |
2.8.1.100-alpha1 | 635 | 12/16/2022 |
2.7.1.14 | 2,638 | 7/3/2022 |
2.6.2.14 | 1,989 | 5/14/2022 |
2.6.2.11 | 1,820 | 5/11/2022 |
2.5.1.10 | 3,398 | 1/22/2022 |
2.5.1.9 | 1,469 | 1/22/2022 |
2.5.1.8 | 1,477 | 1/22/2022 |