dprint is a pluggable, configurable code formatting platform written in Rust. It aims to unify all your code formatters in one tool.
Features
Global Configuration File
dprint now supports a global configuration file that can be used when not in a project. (#1040)
Initialize a global config:
dprint init --global
# or
dprint config init --globalThe global config location is customizable via the DPRINT_CONFIG_DIR environment variable, but by default is stored in (this reflects the update that was published in 0.51.1 after feedback):
- Linux/Mac:
~/.config/dprint/dprint.jsonc(or$XDG_CONFIG_HOME/dprint/dprint.jsonc)- Note: On Mac it will respect
$HOME/Library/Application Support/dprint/dprint.jsoncif it exists
- Note: On Mac it will respect
- Windows:
%APPDATA%\dprint\dprint.jsonc
Note: You can edit the config by running dprint config edit --global
Use global config for formatting:
Once setup, the global configuration will be used by default when there's no dprint configuration file in the current directory tree; however, to prevent accidentally formatting such directories, a prompt is shown when calling dprint fmt:
> dprint fmt
Warning You're not in a dprint project. Format '/home/david' anyway? (Y/n) █
Hint: Specify the directory to bypass this prompt in the future (ex. `dprint fmt .`)
As the hint states, you can bypass the confirmation prompt by providing the current directory:
> dprint fmt .
Formatted 1 file.
To format files using only the global configuration and ignore local configuration files use:
dprint fmt --config-discovery=globalManage global config:
# Add plugins to global config
dprint config add --global
# Update global config
dprint config update --global
# Edit global config
dprint config edit --globalFull docs: https://dprint.dev/global-config/
Improved dprint check Output
When files are not formatted, dprint check now suggests running dprint fmt to fix them, making it clearer for new users contributing to your projects what to do next. (#1056)
Found 3 not formatted files. Run dprint fmt to fix.
dprint check --fail-fast
Stops checking files and exit on the first file that isn't formatted. This is useful when you want even faster feedback. (#1054)
dprint check --fail-fastNote: When using --log-level=silent, --fail-fast is now enabled by default.
Breaking Changes
-
dprint config updateis now non-recursive by default - The command now only updates the configuration file in the current directory by default, rather than updating all config files in descendant directories. Use--recursive(or-r) to update configuration files recursively. (#1053)# Update only the current config (new default) dprint config update # Update current config and all descendant configs dprint config update --recursive
Other Changes
- Added
updateUrltoeditor-infocommand output (#1027)
New Plugins
Another announcement is dprint now has an Oxc (JS/TS) and Mago (PHP) plugins:
dprint config add oxc- https://github.com/dprint/dprint-plugin-oxcdprint config add mago- https://github.com/dprint/dprint-plugin-mago
Install
Run dprint upgrade or see https://dprint.dev/install/
Checksums
| Artifact | SHA-256 Checksum |
|---|---|
| dprint-x86_64-apple-darwin.zip | 1fa152f36a4aa519fa9f233f49f2fb54cc063c77d40ba9f4fc54ea77a4068e0b |
| dprint-aarch64-apple-darwin.zip | f3fb85da6b10011835f3b5a14faf11d03594b4b3b32602ae2b45418794c5039b |
| dprint-x86_64-pc-windows-msvc.zip | fe6c0be73c4fa8a77672bf4271b019d767fabdd0b8cc10df2fd9842399e19e7e |
| dprint-x86_64-pc-windows-msvc-installer.exe | 8bbb3a89960f12c6f9e2f53de44cee7ae72ccc89e90ff1213e6b5f8bb49c3ca1 |
| dprint-x86_64-unknown-linux-gnu.zip | ee5ff0865c461ef6d3023a491f2ee5c1c63c833a15fb3c42fdb2ef835b1c7072 |
| dprint-x86_64-unknown-linux-musl.zip | 9a8b8ad3429a1ae5733e2c237b313c8650626cc48cf972927e7c3fc651eb6ba2 |
| dprint-aarch64-unknown-linux-gnu.zip | 5169106061f04805aa089cdd0a73fb913cfda3bc70038546abf4283992db19bd |
| dprint-aarch64-unknown-linux-musl.zip | bb56d7ac441c905c33f77114c450337e54a263a0ce449da23a0f03b2778368d8 |
| dprint-riscv64gc-unknown-linux-gnu.zip | 5d20460a263e858bd28b61be2ddec12277863c8f29ddc4591c18105ec3d2ab0c |
| dprint-loongarch64-unknown-linux-gnu.zip | 5f7c6fbdf735231c5319298c9302c93931b14c824f25837505308ac5e53f2573 |
| dprint-loongarch64-unknown-linux-musl.zip | 516e712f47ba2fcb9a1f389176d32334d0dce86a26e207002ec4dddc2f10ddf8 |