Skip to content

Commit

Permalink
docs: add docs for editorconfig to configuration and options (#11883)
Browse files Browse the repository at this point in the history
  • Loading branch information
midgleyc committed Nov 30, 2021
1 parent e17404e commit 2160e11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/configuration.md
Expand Up @@ -173,3 +173,12 @@ You can also switch to the `flow` parser instead of the default `babel` for .js
## Configuration Schema

If you’d like a JSON schema to validate your configuration, one is available here: http://json.schemastore.org/prettierrc.

## EditorConfig

If `options.editorconfig` is `true` and an [`.editorconfig` file](https://editorconfig.org/) is in your project, Prettier will parse it and convert its properties to the corresponding Prettier configuration. This configuration will be overridden by `.prettierrc`, etc. Currently, the following EditorConfig properties are supported:

- `end_of_line`
- `indent_style`
- `indent_size`/`tab_width`
- `max_line_length`
8 changes: 8 additions & 0 deletions docs/options.md
Expand Up @@ -27,6 +27,8 @@ Specify the line length that the printer will wrap on.
| ------- | --------------------- | ------------------- |
| `80` | `--print-width <int>` | `printWidth: <int>` |

Setting `max_line_length` in an [`.editorconfig` file](https://editorconfig.org/) will configure Prettier’s print width, unless overridden.

(If you don’t want line wrapping when formatting Markdown, you can set the [Prose Wrap](#prose-wrap) option to disable it.)

## Tab Width
Expand All @@ -37,6 +39,8 @@ Specify the number of spaces per indentation-level.
| ------- | ------------------- | ----------------- |
| `2` | `--tab-width <int>` | `tabWidth: <int>` |

Setting `indent_size` or `tab_width` in an [`.editorconfig` file](https://editorconfig.org/) will configure Prettier’s tab width, unless overridden.

## Tabs

Indent lines with tabs instead of spaces.
Expand All @@ -45,6 +49,8 @@ Indent lines with tabs instead of spaces.
| ------- | ------------ | ----------------- |
| `false` | `--use-tabs` | `useTabs: <bool>` |

Setting `indent_style` in an [`.editorconfig` file](https://editorconfig.org/) will configure Prettier’s tab usage, unless overridden.

(Tabs will be used for _indentation_ but Prettier uses spaces to _align_ things, such as in ternaries.)

## Semicolons
Expand Down Expand Up @@ -425,6 +431,8 @@ Valid options:
| ------- | ----------------------------------------------------------- | ---------------------------------------------------------- |
| `"lf"` | <code>--end-of-line <lf&#124;crlf&#124;cr&#124;auto></code> | <code>endOfLine: "<lf&#124;crlf&#124;cr&#124;auto>"</code> |

Setting `end_of_line` in an [`.editorconfig` file](https://editorconfig.org/) will configure Prettier’s end of line usage, unless overridden.

## Embedded Language Formatting

_First available in v2.1.0_
Expand Down

0 comments on commit 2160e11

Please sign in to comment.