Skip to content

Commit

Permalink
Clarify Prettier defaulting behavior (#616)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
devinrhode2 and sindresorhus authored Oct 7, 2021
1 parent 6d39d10 commit eefd88a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,23 @@ Default: `false`

Format code with [Prettier](https://github.com/prettier/prettier).

The [Prettier options](https://prettier.io/docs/en/options.html) will be read from the [Prettier config](https://prettier.io/docs/en/configuration.html) and if **not set** will be determined as follow:
[Prettier options](https://prettier.io/docs/en/options.html) will be based on your [Prettier config](https://prettier.io/docs/en/configuration.html). XO will then **merge** your options with its own defaults:
- [semi](https://prettier.io/docs/en/options.html#semicolons): based on [semicolon](#semicolon) option
- [useTabs](https://prettier.io/docs/en/options.html#tabs): based on [space](#space) option
- [tabWidth](https://prettier.io/docs/en/options.html#tab-width): based on [space](#space) option
- [trailingComma](https://prettier.io/docs/en/options.html#trailing-commas): `all`
- [singleQuote](https://prettier.io/docs/en/options.html#quotes): `true`
- [bracketSpacing](https://prettier.io/docs/en/options.html#bracket-spacing): `false`
- [bracketSameLine](https://prettier.io/docs/en/options.html#bracket-line): `false`

To stick with Prettier's defaults, add this to your Prettier config:

```js
module.exports = {
trailingComma: 'es5',
singleQuote: false,
bracketSpacing: true,
};
```

If contradicting options are set for both Prettier and XO an error will be thrown.

Expand Down

0 comments on commit eefd88a

Please sign in to comment.