Skip to main content

DprintConfig

Struct DprintConfig 

Source
pub struct DprintConfig {
Show 15 fields pub schema: Option<String>, pub incremental: Option<bool>, pub extends: Option<Extends>, pub line_width: Option<u32>, pub indent_width: Option<u32>, pub use_tabs: Option<bool>, pub new_line_kind: Option<NewLineKind>, pub includes: Option<Vec<String>>, pub excludes: Option<Vec<String>>, pub plugins: Option<Vec<String>>, pub typescript: Option<TypeScriptConfig>, pub json: Option<JsonConfig>, pub toml: Option<TomlConfig>, pub markdown: Option<MarkdownConfig>, pub plugin_configs: BTreeMap<String, PluginConfig>,
}
Expand description

dprint configuration file (dprint.json / .dprint.json).

Configuration for the dprint code formatter. The config file is typically named dprint.json, .dprint.json, dprint.jsonc, or .dprint.jsonc and placed at the root of your project.

Global formatting options (lineWidth, indentWidth, useTabs, newLineKind) apply as defaults to all plugins but can be overridden in per-plugin configuration sections.

Plugin-specific configuration is placed at the top level, keyed by the plugin name:

{
  "lineWidth": 80,
  "typescript": {
    "quoteStyle": "preferSingle"
  },
  "json": {
    "indentWidth": 2
  },
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.93.3.wasm",
    "https://plugins.dprint.dev/json-0.19.4.wasm"
  ]
}

Fields§

§schema: Option<String>

The JSON schema URL for editor validation and autocompletion.

The dprint VS Code extension automatically constructs a composite schema based on the installed plugins, so you usually don’t need to set this manually.

§incremental: Option<bool>

Only format files that have changed since the last formatting run.

When true (the default), dprint tracks which files have been formatted and skips unchanged files on subsequent runs. Set to false to always reformat all matched files.

Can also be toggled via the --incremental / --incremental=false CLI flag.

§extends: Option<Extends>

One or more configuration files to extend.

Can be a single path/URL or an array of paths/URLs. Properties from extended configs are merged, with the current file taking precedence. Earlier entries in an array take priority over later ones.

Supports the ${configDir} variable (resolves to the directory of the current config file) and ${originConfigDir} (resolves to the directory of the original/root config file).

When extending remote configs (URLs), includes and non-Wasm plugins entries are ignored for security.

§line_width: Option<u32>

The maximum line width the formatter tries to stay under.

The formatter may exceed this width in certain cases where breaking the line would produce worse output. This is a global default that individual plugins can override in their configuration sections.

§indent_width: Option<u32>

The number of characters for each indent level.

When useTabs is true, this controls the visual width of each tab character. When useTabs is false, this is the number of spaces inserted per indent level. This is a global default that individual plugins can override in their configuration sections.

§use_tabs: Option<bool>

Whether to use tabs (true) or spaces (false) for indentation.

This is a global default that individual plugins can override in their configuration sections.

§new_line_kind: Option<NewLineKind>

The newline character style to use when formatting.

This is a global default that individual plugins can override in their configuration sections.

§includes: Option<Vec<String>>

Glob patterns for files to include in formatting.

When specified, only files matching at least one of these patterns are formatted. When omitted, all files matched by installed plugins are formatted (respecting excludes).

Uses gitignore-style glob syntax.

§excludes: Option<Vec<String>>

Glob patterns for files or directories to exclude from formatting.

Uses gitignore-style glob syntax. Files already ignored by .gitignore are excluded automatically. Prefix a pattern with ! to un-exclude files that were previously excluded.

§plugins: Option<Vec<String>>

Plugin URLs or local file paths.

Each entry is a URL to a WebAssembly plugin (.wasm) or a local file path. The order determines precedence when multiple plugins can handle the same file extension — the first matching plugin wins.

Can also be specified via the --plugins CLI flag.

§typescript: Option<TypeScriptConfig>

TypeScript / JavaScript plugin configuration.

See: https://dprint.dev/plugins/typescript/config/

§json: Option<JsonConfig>

JSON plugin configuration.

See: https://dprint.dev/plugins/json/config/

§toml: Option<TomlConfig>

TOML plugin configuration.

See: https://dprint.dev/plugins/toml/config/

§markdown: Option<MarkdownConfig>

Markdown plugin configuration.

See: https://dprint.dev/plugins/markdown/config/

§plugin_configs: BTreeMap<String, PluginConfig>

Configuration for plugins not covered by the typed fields above.

Trait Implementations§

Source§

impl Clone for DprintConfig

Source§

fn clone(&self) -> DprintConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DprintConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DprintConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for DprintConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for DprintConfig

Source§

fn eq(&self, other: &DprintConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DprintConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DprintConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,