Adapter for tidy for use as a formatting plugin in dprint. tidy formats in Prettier's style, and this plugin uses it for:
- HTML (and MJML), Vue and Handlebars
- CSS, SCSS and Less
- JSON, JSONC and JSON5
- YAML, TOML, XML (and SVG) and INI (and gitconfig)
- GraphQL
- Markdown
- Dockerfiles
- JavaScript, TypeScript and JSX
Code embedded in a file (ex. a <script> in HTML, or a code block in Markdown) is formatted by tidy too, when tidy knows its language.
Then in your project's directory with a dprint.json file, run:
dprint add tidyNote: You do not need tidy installed as dprint will run it from the .wasm file in a sandboxed environment.
tidy formats languages that other dprint plugins also format (ex. TypeScript, JSON and Markdown). When two plugins format the same file, the one listed first in the plugins array formats it. To leave a language to another plugin, turn it off here with "<section>.enabled": false (ex. "markdown.enabled": false).
To add configuration, specify a "tidy" key in your dprint.json:
The options and their defaults are the ones a tidy.json has. The options of a language section are written with the section first and a dot (ex. "js.semi": false), or in an object named after the section, as in a tidy.json (ex. "js": { "semi": false }). An option every language has, like width or quote, can also be set for one section only (ex. "markdown.width": 120).
dprint's global lineWidth, indentWidth, useTabs and newLineKind are used as tidy's width, indent, tabs and eol when they're set, and tidy's defaults otherwise. With "newLineKind": "auto", a file keeps the line endings it has.
Each section has an enabled option, which is true by default: html, vue, handlebars, css, json, yaml, toml, xml, markdown, dockerfile, ini, graphql and js.
A file with a syntax error is reported as an error rather than formatted, and range formatting isn't supported.
For an overview of the config, see https://github.com/dprint/dprint-plugin-tidy/blob/main/deployment/schema.json
- JS Formatter - Browser/Deno and Node
- npm package
This repo automatically upgrades to the latest version of tidy once a day. You can check which version of tidy is being used by looking at the tidy entry in the Cargo.toml file in this repo:
https://github.com/dprint/dprint-plugin-tidy/blob/main/Cargo.toml
At the moment, the version of this plugin does not reflect the version of tidy.
This project is licensed under the MIT License - see the LICENSE file for details. tidy is licensed under the MIT License as well.
{ "tidy": { "width": 100, "quote": "single", "js.semi": false, "markdown.wrap": "always", "toml.enabled": false, }, "plugins": [ // ...etc... ], }