From 2827543154ba3c39f317b4f47e40d5528d892383 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Tue, 27 Aug 2019 07:09:12 +0200 Subject: [PATCH] Improve overrides documentation (#6416) Refs. #6415. --- docs/configuration.md | 15 ++++++++++++++- .../version-stable/configuration.md | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 14cbbe67..ab7621c7 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -61,7 +61,9 @@ singleQuote = true ## Configuration Overrides -Prettier borrows eslint's [override format](http://eslint.org/docs/user-guide/configuring#example-configuration). This allows you to apply configuration to specific files. +Overrides let you have different configuration for certain file extensions, folders and specific files. + +Prettier borrows ESLint’s [override format](http://eslint.org/docs/user-guide/configuring#example-configuration). JSON: @@ -74,6 +76,12 @@ JSON: "options": { "semi": true } + }, + { + "files": ["*.html", "legacy/**/*.js"], + "options": { + "tabWidth": 4 + } } ] } @@ -87,6 +95,11 @@ overrides: - files: "*.test.js" options: semi: true + - files: + - "*.html" + - "legacy/**/*.js" + options: + tabWidth: 4 ``` `files` is required for each override, and may be a string or array of strings. `excludeFiles` may be optionally provided to exclude files for a given rule, and may also be a string or array of strings. diff --git a/website/versioned_docs/version-stable/configuration.md b/website/versioned_docs/version-stable/configuration.md index d90b00d1..07f20a0c 100644 --- a/website/versioned_docs/version-stable/configuration.md +++ b/website/versioned_docs/version-stable/configuration.md @@ -62,7 +62,9 @@ singleQuote = true ## Configuration Overrides -Prettier borrows eslint's [override format](http://eslint.org/docs/user-guide/configuring#example-configuration). This allows you to apply configuration to specific files. +Overrides let you have different configuration for certain file extensions, folders and specific files. + +Prettier borrows ESLint’s [override format](http://eslint.org/docs/user-guide/configuring#example-configuration). JSON: @@ -75,6 +77,12 @@ JSON: "options": { "semi": true } + }, + { + "files": ["*.html", "legacy/**/*.js"], + "options": { + "tabWidth": 4 + } } ] } @@ -88,6 +96,11 @@ overrides: - files: "*.test.js" options: semi: true + - files: + - "*.html" + - "legacy/**/*.js" + options: + tabWidth: 4 ``` `files` is required for each override, and may be a string or array of strings. `excludeFiles` may be optionally provided to exclude files for a given rule, and may also be a string or array of strings.