# eslint-plugin-format

> Format various languages with formatters in ESLint

Latest version **2.0.1** (published 2026-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-format
pnpm add eslint-plugin-format
yarn add eslint-plugin-format
bun add eslint-plugin-format
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2026-02-25 |
| First published | 2023-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 200 |
| Author | Anthony Fu |
| Maintainers | antfu |
| Keywords | eslint, eslint-plugin, formatters, prettier, dprint, oxfmt |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-format
- Repository: https://github.com/antfu/eslint-plugin-format
- Homepage: https://github.com/antfu/eslint-plugin-format#readme
- Issues: https://github.com/antfu/eslint-plugin-format/issues
- Funding: https://github.com/sponsors/antfu
- npm.io page: https://npm.io/package/eslint-plugin-format

## Dependencies (9)

- [ohash](https://npm.io/package/ohash.md) ^2.0.11
- [oxfmt](https://npm.io/package/oxfmt.md) ^0.35.0
- [synckit](https://npm.io/package/synckit.md) ^0.11.12
- [prettier](https://npm.io/package/prettier.md) ^3.8.1
- [@dprint/toml](https://npm.io/package/@dprint/toml.md) ^0.7.0
- [@dprint/markdown](https://npm.io/package/@dprint/markdown.md) ^0.21.1
- [@dprint/formatter](https://npm.io/package/@dprint/formatter.md) ^0.5.1
- [eslint-parser-plain](https://npm.io/package/eslint-parser-plain.md) ^0.1.1
- [eslint-formatting-reporter](https://npm.io/package/eslint-formatting-reporter.md) ^0.0.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
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2026-02-25
- 2.0.0 — 2026-02-24
- 1.5.0 — 2026-02-24
- 1.4.0 — 2026-02-07
- 1.3.1 — 2026-01-14
- 1.3.0 — 2026-01-13
- 1.2.0 — 2026-01-06
- 1.1.0 — 2025-12-04
- 1.0.2 — 2025-09-19
- 1.0.1 — 2025-01-08
- 1.0.0 — 2025-01-08
- 0.1.3 — 2024-11-30
- 0.1.2 — 2024-06-15
- 0.1.1 — 2024-04-17
- 0.1.0 — 2023-12-05
- … 2 more at https://npm.io/package/eslint-plugin-format/versions

## README

# eslint-plugin-format

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]

Format various languages with formatters in ESLint. Supports [Prettier](https://prettier.io/), [dprint](https://dprint.dev/) and [oxfmt](https://oxc.rs/docs/guide/usage/formatter). Side-effects-free and fully configurable.

## Usages

### Install

```bash
npm i -D eslint-plugin-format
```

### Configure

This plugin does not do language detection or reading configure files, you need to specify the language for each file type you want to format along with other formatting options. We recommend using [ESLint's Flat Config format](https://eslint.org/docs/latest/use/configure/configuration-files-new).

```ts
// eslint.config.js
import format from 'eslint-plugin-format'

export default [
  // ...other flat configs

  // use Prettier to format CSS
  {
    files: ['**/*.css'],
    languageOptions: {
      parser: format.parserPlain,
    },
    plugins: {
      format,
    },
    rules: {
      'format/prettier': ['error', { parser: 'css', tabWidth: 2 }],
    },
  },

  // use dprint to format TOML
  {
    files: ['**/*.toml'],
    languageOptions: {
      parser: format.parserPlain,
    },
    plugins: {
      format,
    },
    rules: {
      'format/dprint': ['error', { language: 'toml', languageOptions: { indentWidth: 2 } }],
    },
  },

  // use oxfmt to format JavaScript/TypeScript with TailwindCSS classnames sorting
  {
    files: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'],
    languageOptions: {
      parser: format.parserPlain,
    },
    plugins: {
      format,
    },
    rules: {
      'format/oxfmt': ['error', { sortTailwindcss: {} }],
    },
  },

  // use dprint to format HTML and CSS in style tags
  {
    files: ['**/*.html'],
    languageOptions: {
      parser: format.parserPlain,
    },
    plugins: {
      format,
    },
    rules: {
      'format/dprint': ['error', {
        plugins: [
          {
            plugin: 'node_modules/dprint-plugin-malva/plugin.wasm',
            options: {},
          },
          {
            plugin: 'node_modules/dprint-plugin-markup/plugin.wasm',
            options: {
              scriptIndent: true,
              styleIndent: true,
            },
          },
        ],
        useTabs: false,
        indentWidth: 2,
      }],
    },
  },
]
```

## Rules

### `format/prettier`

Use Prettier to format files.

#### Options

- `parser` (required) - the language to format, [Supported languages](https://prettier.io/docs/en/options.html#parser)
- The rest options are passed as Prettier options

### `format/dprint`

Use dprint to format files.

#### Options

Either:
- `language` (required) - the language to format, or can be a filepath or URL to the WASM binary. [Supported languages](https://dprint.dev/plugins/)
- `languageOptions` - the options for the language
- The rest options are passed as dprint's general options

Or:
- `plugins` (required) - Array of plugins, defined as an object containing `plugin` (same as `language` above) and `options`, which is the same as `languageOptions` above.
- The rest of the options are passed as dprint's general options

### `format/oxfmt`

Use oxfmt to format files.

#### Options

- File type is inferred from the linted filename extension.
- The options are passed directly to oxfmt's [`format()` API](https://oxc.rs/docs/guide/usage/formatter).

## Sponsors

<p align="center">
  <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
    <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg' alt='Sponsors' />
  </a>
</p>

## FAQ

### What's the difference between this and `eslint-plugin-prettier`?

While this plugin provides Prettier as one of the formatters, the main difference is that `eslint-plugin-prettier` is much more opinionated toward the Prettier CLI ecosystem. While this plugin only treats Prettier as the side-effects-free formatter and gives you full control in ESLint.

## Credits

Thanks to the existing works for references and inspiration.

- [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier)
- [eslint-plugin-dprint-integration](https://github.com/so1ve/eslint-plugin-dprint-integration)

## License

[MIT](./LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu)

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/eslint-plugin-format?style=flat&colorA=080f12&colorB=1fa669
[npm-version-href]: https://npmjs.com/package/eslint-plugin-format
[npm-downloads-src]: https://img.shields.io/npm/dm/eslint-plugin-format?style=flat&colorA=080f12&colorB=1fa669
[npm-downloads-href]: https://npmjs.com/package/eslint-plugin-format
[bundle-src]: https://img.shields.io/bundlephobia/minzip/eslint-plugin-format?style=flat&colorA=080f12&colorB=1fa669&label=minzip
[bundle-href]: https://bundlephobia.com/result?p=eslint-plugin-format
[license-src]: https://img.shields.io/github/license/antfu/eslint-plugin-format.svg?style=flat&colorA=080f12&colorB=1fa669
[license-href]: https://github.com/antfu/eslint-plugin-format/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
[jsdocs-href]: https://www.jsdocs.io/package/eslint-plugin-format

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