From efa1723ff9fd31a6b4b1945845dc6db4246746e1 Mon Sep 17 00:00:00 2001 From: Pete Gleeson Date: Wed, 14 Mar 2018 17:12:04 +1100 Subject: [PATCH] adds more examples to the import/extensions rule docs --- docs/rules/extensions.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/rules/extensions.md b/docs/rules/extensions.md index e520ef5b5..e2b68e950 100644 --- a/docs/rules/extensions.md +++ b/docs/rules/extensions.md @@ -8,9 +8,33 @@ In order to provide a consistent use of file extensions across your code base, t This rule either takes one string option, one object option, or a string and an object option. If it is the string `"never"` (the default value), then the rule forbids the use for any extension. If it is the string `"always"`, then the rule enforces the use of extensions for all import statements. If it is the string `"ignorePackages"`, then the rule enforces the use of extensions for all import statements except package imports. -By providing an object you can configure each extension separately, so for example `{ "js": "always", "json": "never" }` would always enforce the use of the `.js` extension but never allow the use of the `.json` extension. +```json +"import/extensions": [, "never" | "always" | "ignorePackages"] +``` + +By providing an object you can configure each extension separately. + +```json +"import/extensions": [, { + : "never" | "always" | "ignorePackages" +}] +``` + + For example `{ "js": "always", "json": "never" }` would always enforce the use of the `.js` extension but never allow the use of the `.json` extension. + +By providing both a string and an object, the string will set the default setting for all extensions, and the object can be used to set granular overrides for specific extensions. + +```json +"import/extensions": [ + , + "never" | "always" | "ignorePackages", + { + : "never" | "always" | "ignorePackages" + } +] +``` -By providing both a string and an object, the string will set the default setting for all extensions, and the object can be used to set granular overrides for specific extensions. For example, `[, "never", { "svg": "always" }]` would require that all extensions are omitted, except for "svg". +For example, `["error", "never", { "svg": "always" }]` would require that all extensions are omitted, except for "svg". ### Exception @@ -110,7 +134,7 @@ import express from 'express'; ``` -The following patterns are not considered problems when configuration set to `[ 'always', {ignorePackages: true} ]`: +The following patterns are not considered problems when configuration set to `['error', 'always', {ignorePackages: true} ]`: ```js import Component from './Component.jsx';