diff --git a/docs/configuration.md b/docs/configuration.md index ca89213f0c21..74eb0f4f4eb7 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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` diff --git a/docs/options.md b/docs/options.md index 80faff1e6a3b..a24f7f4e5462 100644 --- a/docs/options.md +++ b/docs/options.md @@ -27,6 +27,8 @@ Specify the line length that the printer will wrap on. | ------- | --------------------- | ------------------- | | `80` | `--print-width ` | `printWidth: ` | +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 @@ -37,6 +39,8 @@ Specify the number of spaces per indentation-level. | ------- | ------------------- | ----------------- | | `2` | `--tab-width ` | `tabWidth: ` | +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. @@ -45,6 +49,8 @@ Indent lines with tabs instead of spaces. | ------- | ------------ | ----------------- | | `false` | `--use-tabs` | `useTabs: ` | +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 @@ -425,6 +431,8 @@ Valid options: | ------- | ----------------------------------------------------------- | ---------------------------------------------------------- | | `"lf"` | --end-of-line | endOfLine: "" | +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_