# @ben_12/eslint-plugin-dprint

> An ESLint plugin that fixes code with dprint

Latest version **1.33.0** (published 2026-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ben_12/eslint-plugin-dprint
pnpm add @ben_12/eslint-plugin-dprint
yarn add @ben_12/eslint-plugin-dprint
bun add @ben_12/eslint-plugin-dprint
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.33.0 |
| Published | 2026-11-15 |
| First published | 2023-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18.0.0 |
| Dependencies | 4 |
| Unpacked size | 312.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4 |
| Author | Benoît Moreau |
| Maintainers | ben.12 |
| Keywords | eslint, eslintplugin, eslint-plugin, dprint, formatter |

## Links

- npm: https://www.npmjs.com/package/@ben_12/eslint-plugin-dprint
- Repository: https://github.com/ben12/eslint-plugin-dprint
- Homepage: https://eslint-plugin-dprint.ben12.eu
- Issues: https://github.com/ben12/eslint-plugin-dprint/issues
- npm.io page: https://npm.io/package/@ben_12/eslint-plugin-dprint

## Dependencies (4)

- [diff](https://npm.io/package/diff.md) ^9.0.0
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [jsonc-parser](https://npm.io/package/jsonc-parser.md) ^3.2.0
- [@dprint/formatter](https://npm.io/package/@dprint/formatter.md) ^0.6.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 1.33.0 (latest) — 2026-11-15
- 1.32.0 — 2026-11-15
- 1.31.0 — 2026-11-08
- 1.30.1 — 2026-11-01
- 1.30.0 — 2026-10-25
- 1.29.1 — 2026-10-18
- 1.29.0 — 2026-10-11
- 1.28.0 — 2026-10-04
- 1.27.1 — 2026-09-27
- 1.27.0 — 2026-09-20
- 1.26.0 — 2026-09-13
- 1.25.2 — 2026-09-06
- 1.25.1 — 2026-08-30
- 1.24.0 — 2026-08-23
- 1.23.0 — 2026-08-07
- … 87 more at https://npm.io/package/@ben_12/eslint-plugin-dprint/versions

## README

# eslint-plugin-dprint

[![GitHub](https://img.shields.io/github/license/ben12/eslint-plugin-dprint)](https://github.com/ben12/eslint-plugin-dprint/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/@ben_12/eslint-plugin-dprint.svg)](https://www.npmjs.com/package/@ben_12/eslint-plugin-dprint)
[![Downloads/month](https://img.shields.io/npm/dm/@ben_12/eslint-plugin-dprint.svg)](http://www.npmtrends.com/@ben_12/eslint-plugin-dprint)\
[![node-current](https://img.shields.io/node/v/%40ben_12%2Feslint-plugin-dprint)](https://nodejs.org)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/eslint)](https://www.npmjs.com/package/eslint)
[![install size](https://packagephobia.com/badge?p=@ben_12/eslint-plugin-dprint)](https://packagephobia.com/result?p=@ben_12/eslint-plugin-dprint)\
[![Build Status](https://github.com/ben12/eslint-plugin-dprint/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/ben12/eslint-plugin-dprint/actions)
[![codecov](https://codecov.io/gh/ben12/eslint-plugin-dprint/branch/master/graph/badge.svg)](https://codecov.io/gh/ben12/eslint-plugin-dprint)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ben12_eslint-plugin-dprint&metric=alert_status&branch=master)](https://sonarcloud.io/summary/new_code?id=ben12_eslint-plugin-dprint)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=ben12_eslint-plugin-dprint&metric=code_smells&branch=master)](https://sonarcloud.io/dashboard?id=ben12_eslint-plugin-dprint)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=ben12_eslint-plugin-dprint&metric=vulnerabilities&branch=master)](https://sonarcloud.io/dashboard?id=ben12_eslint-plugin-dprint)

> This is an updated fork of mysticatea/eslint-plugin-dprint.

The plugin that runs [dprint] to format code in ESLint.

## 💿 Installation

Use [npm] or a compatible tool.

```sh
$ npm install -D eslint @ben_12/eslint-plugin-dprint
```

Then install [dprint] plugin for the language to format.

```sh
$ npm install -D @dprint/dockerfile
$ npm install -D @dprint/json
$ npm install -D @dprint/markdown
$ npm install -D @dprint/sql
$ npm install -D @dprint/toml
$ npm install -D @dprint/typescript
$ npm install -D dprint-plugin-malva
$ npm install -D dprint-plugin-markup
$ npm install -D dprint-plugin-yaml
$ npm install -D dprint-plugin-graphql
```

[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/%40dprint%2Fdockerfile)](https://dprint.dev/plugins/dockerfile/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/%40dprint%2Fjson)](https://dprint.dev/plugins/json/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/%40dprint%2Fmarkdown)](https://dprint.dev/plugins/markdown/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/%40dprint%2Fsql)](https://dprint.dev/plugins/sql/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/%40dprint%2Ftoml)](https://dprint.dev/plugins/toml/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/%40dprint%2Ftypescript)](https://dprint.dev/plugins/typescript/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/dprint-plugin-malva)](https://dprint.dev/plugins/malva/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/dprint-plugin-markup)](https://dprint.dev/plugins/markup_fmt/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/dprint-plugin-yaml)](https://dprint.dev/plugins/pretty_yaml/)
[![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/dprint-plugin-graphql)](https://dprint.dev/plugins/pretty_graphql/)

## 📖 Usage

Write your ESLint configuration. For example with typescript code:

```mjs
import { defineConfig } from "eslint/config";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import dprint from "@ben_12/eslint-plugin-dprint";

module.exports = defineConfig([
  {
    files: ["**/*.ts", "**/*.js"],

    languageOptions: {
        parser: tsParser
    },

    plugins: {
        "@typescript-eslint": tsPlugin,
        "@ben_12/dprint": dprint,
    },

    rules: {
      ...tsPlugin.configs["eslint-recommended"].rules,
      ...tsPlugin.configs["recommended"].rules,
      ...tsPlugin.configs["strict"].rules,
      ...dprint.configs["typescript-recommended"].rules
      "@ben_12/dprint/typescript": [
        "error",
        {
          // Use dprint JSON configuration file (default: "dprint.json")
          // It may be created using `dprint init` command
          // See also https://dprint.dev/config/
          configFile: "dprint.json",
          config: {
            // The TypeScript configuration of dprint
            // See also https://dprint.dev/plugins/typescript/config/
          },
        },
      ],
    },
  },
]);
```

For legacy eslint (eslintrc configuration),

```js
module.exports = {
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@ben_12/dprint/typescript-recommended",
  ],
  rules: {
    "@ben_12/dprint/typescript": [
      "error",
      {
        // Use dprint JSON configuration file (default: "dprint.json")
        // It may be created using `dprint init` command
        // See also https://dprint.dev/config/
        configFile: "dprint.json",
        config: {
          // The TypeScript configuration of dprint
          // See also https://dprint.dev/plugins/typescript/config/
        },
      },
    ],
  },
};
```

Then run ESLint with `--fix`!

### Providing a pre-resolved formatter via `settings`

By default the plugin loads each dprint formatter at module-load time by doing a dynamic `require()`
of the corresponding peer package (`@dprint/typescript`, `dprint-plugin-yaml`, …). That works for
most setups, but it relies on the optional peer dependency being installed _and_ discoverable by
Node's resolver. Some bundlers and bundled config packages (anything that does static module-graph
analysis, e.g. [Packtory](https://github.com/lukas-bischof/packtory)) only follow real `import`
statements, so the dprint plugins never end up in the bundle. In that case the plugin logs
`Plugin not found: …` for every linted file and the rule silently becomes a no-op.

You can avoid this by passing a pre-resolved formatter through ESLint's `settings`. Settings are not
serialized or `structuredClone`d by ESLint, so they can carry runtime objects (modules, buffers,
pre-built formatters). When a formatter is provided this way, the plugin uses it directly and skips
the dynamic `require()` lookup (and the associated "Plugin not found" warning).

Accepted shapes for each formatter entry:

- an object with `getPath(): string` (the shape exported by `@dprint/typescript`, `@dprint/json`,
  `@dprint/markdown`, `@dprint/toml`, `@dprint/dockerfile`)
- an object with `getBuffer(): Buffer | Uint8Array` (legacy shape, previously used by some
  `@dprint/*` packages)
- a raw `Buffer` / `Uint8Array` / `ArrayBuffer` of the plugin's wasm bytes
- a pre-built `Formatter` returned by `@dprint/formatter`'s `createFromBuffer`

Example (flat config):

```mjs
import { defineConfig } from "eslint/config";
import dprint from "@ben_12/eslint-plugin-dprint";
import typescriptFormatter from "@dprint/typescript";

export default defineConfig([
  {
    files: ["**/*.ts"],
    plugins: { "@ben_12/dprint": dprint },
    settings: {
      "@ben_12/dprint": {
        formatters: {
          typescript: typescriptFormatter,
        },
      },
    },
    rules: {
      "@ben_12/dprint/typescript": ["error", { config: { /* dprint config */ } }],
    },
  },
]);
```

The settings key is the plugin namespace (`@ben_12/dprint`). Inside `formatters`, the key is the
rule name (`typescript`, `json`, `markdown`, `toml`, `dockerfile`, `malva`, `markup`, `yaml`,
`graphql`).

#### g-plane plugins (`yaml`, `malva`, `markup`, `graphql`)

The `@dprint/*` packages can be imported and passed straight through, as in the example above.
The g-plane packages (`dprint-plugin-yaml`, `dprint-plugin-malva`, `dprint-plugin-markup`,
`dprint-plugin-graphql`) have no JS entrypoint and ship only `plugin.wasm`, so callers have to
resolve and read the wasm file themselves and pass the result through `createFromBuffer` (or as
a raw `BufferSource`). Example for `dprint-plugin-graphql`:

```mjs
import { defineConfig } from "eslint/config";
import dprint from "@ben_12/eslint-plugin-dprint";
import { createFromBuffer } from "@dprint/formatter";
import fs from "node:fs";

const graphqlFormatter = createFromBuffer(
  fs.readFileSync(new URL(import.meta.resolve("dprint-plugin-graphql/plugin.wasm"))),
);

export default defineConfig([
  {
    files: ["**/*.graphql"],
    plugins: { "@ben_12/dprint": dprint },
    settings: {
      "@ben_12/dprint": {
        formatters: { graphql: graphqlFormatter },
      },
    },
    rules: {
      "@ben_12/dprint/graphql": ["error", { config: { /* dprint config */ } }],
    },
  },
]);
```

The same pattern (with the matching package and rule name) applies to `yaml`, `malva`, and
`markup`.

For unparsed eslint file like markdown or dockerfile, you can use [@ben_12/eslint-simple-parser](https://www.npmjs.com/package/@ben_12/eslint-simple-parser) as parser.

```mjs
import { defineConfig } from "eslint/config";
import dprint from "@ben_12/eslint-plugin-dprint";
import simpleParser from "@ben_12/eslint-simple-parser";

export default defineConfig([
  {
    files: ["**/*.md"],
    plugins: {
        "@ben_12/dprint": dprint,
    },
    languageOptions: {
        parser: simpleParser,
    },
    rules: dprint.configs["markdown-recommended"].rules,
  },
]);
```

### Available Rules

| Rule                        | Description                                        |
| :-------------------------- | :------------------------------------------------- |
| [@ben_12/dprint/dockerfile] | Format dockerfile code with [@dprint/dockerfile].  |
| [@ben_12/dprint/json]       | Format json code with [@dprint/json].              |
| [@ben_12/dprint/markdown]   | Format markdown code with [@dprint/markdown].      |
| [@ben_12/dprint/sql]        | Format sql code with [@dprint/sql].                |
| [@ben_12/dprint/toml]       | Format toml code with [@dprint/toml].              |
| [@ben_12/dprint/typescript] | Format typescript code with [@dprint/typescript].  |
| [@ben_12/dprint/malva]      | Format css/scss/less/sass code with [malva].       |
| [@ben_12/dprint/markup]     | Format HTML/Vue/Svelte/... code with [markup_fmt]. |
| [@ben_12/dprint/yaml]       | Format YAML code with [pretty_yaml].               |
| [@ben_12/dprint/graphql]    | Format GraphQL code with [pretty_graphql].         |

### Available Configs

| Config                                                    | Description                                                                                                                  |
| :-------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| [plugin:@ben_12/dprint/disable-typescript-conflict-rules] | Disable rules where are conflicted with the [@ben_12/dprint/typescript] rule.                                                |
| [plugin:@ben_12/dprint/dockerfile-recommended]            | Enable the [@ben_12/dprint/dockerfile] rule.                                                                                 |
| [plugin:@ben_12/dprint/json-recommended]                  | Enable the [@ben_12/dprint/json] rule.                                                                                       |
| [plugin:@ben_12/dprint/markdown-recommended]              | Enable the [@ben_12/dprint/markdown] rule.                                                                                   |
| [plugin:@ben_12/dprint/sql-recommended]                   | Enable the [@ben_12/dprint/sql] rule.                                                                                        |
| [plugin:@ben_12/dprint/toml-recommended]                  | Enable the [@ben_12/dprint/toml] rule.                                                                                       |
| [plugin:@ben_12/dprint/typescript-recommended]            | Enable the [@ben_12/dprint/typescript] rule along with the [plugin:@ben_12/dprint/disable-typescript-conflict-rules] preset. |
| [plugin:@ben_12/dprint/malva-recommended]                 | Enable the [@ben_12/dprint/malva] rule.                                                                                      |
| [plugin:@ben_12/dprint/markup-recommended]                | Enable the [@ben_12/dprint/markup] rule.                                                                                     |
| [plugin:@ben_12/dprint/yaml-recommended]                  | Enable the [@ben_12/dprint/yaml] rule.                                                                                       |
| [plugin:@ben_12/dprint/graphql-recommended]               | Enable the [@ben_12/dprint/graphql] rule.                                                                                    |

- Put the [plugin:@ben_12/dprint/recommended] or [plugin:@ben_12/dprint/disable-conflict-rules] config into the last of your `extends` list in order to ensure disabling conflict rules where came from other base configurations.

## 📰 Changelog

See [GitHub Releases](https://github.com/ben12/eslint-plugin-dprint/releases).

## ❤️ Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

### Development Tools

- `npm test` ... Run tests. It generates code coverage into `coverage` directory.
- `npm run watch` ... Run tests when files are edited.
- `npm version <patch|minor|major>` ... Bump a new version.

[dprint]: https://github.com/dprint/dprint
[@dprint/dockerfile]: https://github.com/dprint/dprint-plugin-dockerfile
[@dprint/json]: https://github.com/dprint/dprint-plugin-json
[@dprint/markdown]: https://github.com/dprint/dprint-plugin-markdown
[@dprint/sql]: https://github.com/dprint/dprint-plugin-sql
[@dprint/toml]: https://github.com/dprint/dprint-plugin-toml
[@dprint/typescript]: https://github.com/dprint/dprint-plugin-typescript
[malva]: https://github.com/g-plane/malva
[markup_fmt]: https://github.com/g-plane/markup_fmt
[pretty_yaml]: https://github.com/g-plane/pretty_yaml
[pretty_graphql]: https://github.com/g-plane/pretty_graphql
[npm]: https://www.npmjs.com/
[@ben_12/dprint/dockerfile]: docs/rules/dprint-dockerfile.md
[@ben_12/dprint/json]: docs/rules/dprint-json.md
[@ben_12/dprint/markdown]: docs/rules/dprint-markdown.md
[@ben_12/dprint/sql]: docs/rules/dprint-sql.md
[@ben_12/dprint/toml]: docs/rules/dprint-toml.md
[@ben_12/dprint/typescript]: docs/rules/dprint-typescript.md
[@ben_12/dprint/malva]: docs/rules/dprint-malva.md
[@ben_12/dprint/markup]: docs/rules/dprint-markup.md
[@ben_12/dprint/yaml]: docs/rules/dprint-yaml.md
[@ben_12/dprint/graphql]: docs/rules/dprint-graphql.md
[plugin:@ben_12/dprint/disable-typescript-conflict-rules]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/disable-typescript-conflict-rules.ts
[plugin:@ben_12/dprint/dockerfile-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L3
[plugin:@ben_12/dprint/json-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L10
[plugin:@ben_12/dprint/markdown-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L17
[plugin:@ben_12/dprint/sql-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L24
[plugin:@ben_12/dprint/toml-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L31
[plugin:@ben_12/dprint/typescript-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L39
[plugin:@ben_12/dprint/malva-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L46
[plugin:@ben_12/dprint/markup-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L53
[plugin:@ben_12/dprint/yaml-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L60
[plugin:@ben_12/dprint/graphql-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L67

---
_Source: https://npm.io/package/@ben_12/eslint-plugin-dprint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
