---
title: "prettier/prettier"
description: "Require code to be formatted the way Prettier prints it"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "prettier"
aliases: []
kind: "layout"
category: null
default: "off"
fixable: "yes"
typeAware: false
deprecated: false
---

This rule compares each file with what Prettier prints and reports every place where they differ. Formatting problems then show up next to your lint problems, in the terminal and in the editor.

It's the rule from `eslint-plugin-prettier`, for projects with an ESLint config that loads that package. Bun has it built in. It compares the file with the output of `bun fmt`, which matches Prettier 3.9, so it never starts Prettier.

If Bun can't guarantee the same output as your Prettier, the package's rule runs in JavaScript with your installed Prettier, and a note says why. That happens, for example, with a Prettier version other than 3.9 or a Prettier plugin that `bun fmt` doesn't have.

`--fix` formats the file.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"prettier/prettier" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"root": true, "packages": {"prettier": "3.9.9", "eslint-plugin-prettier": "5.5.6"}, "count": 1} */}
```js
const user = {name:'Ada'}
```

The message says what to change. In it, `·` is a space, `⏎` is a line break, and `↹` is a tab:

```txt
Replace `name:'Ada'}` with `·name:·"Ada"·};`
```

Not reported:

{/* good {"root": true, "packages": {"prettier": "3.9.9", "eslint-plugin-prettier": "5.5.6"}} */}
```js
const user = { name: "Ada" };
```

To change the style, use a `.prettierrc` or an `.editorconfig`. Prettier and `bun fmt` read them too.

{/* file ".prettierrc" */}
```json .prettierrc
{ "singleQuote": true, "semi": false }
```

{/* good {"root": true, "packages": {"prettier": "3.9.9", "eslint-plugin-prettier": "5.5.6"}} */}
```js
const user = { name: 'Ada' }
```

To skip files, list them in a `.prettierignore` in the directory where you run `bun lint`.

## Options

The first option is an object of Prettier options, with the same names as in a `.prettierrc`. They override your config files.

{/* skip */}
```js eslint.config.js
import prettier from "eslint-plugin-prettier";

export default [
  {
    plugins: { prettier },
    rules: {
      "prettier/prettier": ["error", { singleQuote: true }],
    },
  },
];
```

{/* bad {"root": true, "packages": {"prettier": "3.9.9", "eslint-plugin-prettier": "5.5.6"}, "options": [{"singleQuote": true}]} */}
```js
const user = { name: "Ada" };
```

The second option is an object with these keys:

| Option | Default | What it does |
| --- | --- | --- |
| `usePrettierrc` | `true` | Read `.prettierrc` and `.editorconfig`. |
| `fileInfoOptions` | `{}` | `ignorePath` names the ignore file or files to read instead of `.prettierignore`. `withNodeModules: true` also checks files in `node_modules`. |

## When not to use it

This rule needs `eslint-plugin-prettier` and Prettier in `node_modules`. Without them, use `bun/format`. It has the same options and messages, and it checks files against `bun fmt`.

If `bun fmt --check` or `prettier --check` already runs in CI, this rule does the same work a second time.
