eslint-plugin-prettier-doc
Version:
ESLint rules for Prettier Doc.
88 lines (59 loc) • 1.66 kB
Markdown
> ESLint rules for [Prettier Doc](https://github.com/prettier/prettier/blob/main/commands.md).
```bash
yarn add eslint-plugin-prettier-doc --dev
```
Add `prettier-doc` to the `plugins` and `extends` sections of your `.eslintrc` configuration file.
```json
{
"extends": ["plugin:prettier-doc/recommended"]
}
```
> `concat(…)` has been [deprecated](https://github.com/prettier/prettier/pull/9733), use `array` instead.
This rule is fixable.
**Please disable this rule before fixing `no-nested-concat`, and `no-single-doc-concat`, they both relay on checking `concat(…)` call**
```js
// Fail
const doc = concat(['prettier', line, '(', line, ')'])
```
```js
// Pass
const doc = ['prettier', line, '(', line, ')']
```
> The second argument (flatContents) for `ifBreak(…)` should omitted when it's empty.
This rule is fixable.
```js
// Fail
const comma = ifBreak(',', '')
```
```js
// Pass
const comma = ifBreak(',')
```
> Nested `concat(…)` should be flatted.
This rule is fixable.
```js
// Fail
const doc = concat(['prettier', concat([line, '(', line, ')'])])
```
```js
// Pass
const doc = concat(['prettier', line, '(', line, ')'])
```
> Single `Doc` should use directly.
This rule is fixable.
```js
// Fail
const doc = concat(['prettier()'])
```
```js
// Pass
const doc = 'prettier()'
```