From 859d12aac6ba62bfe9a304a450c8a3a676ab0ef1 Mon Sep 17 00:00:00 2001 From: Plusb Preco Date: Tue, 16 May 2017 16:52:50 +0900 Subject: [PATCH] Improve documents Clarify options and examples Add missing changes Apply suggestion Merge remote-tracking branch 'preco21/docs-improvement' into docs-improvement --- docs/rules/jsx-first-prop-new-line.md | 5 +- docs/rules/jsx-wrap-multilines.md | 87 ++++++++++++++++++++++++--- 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/docs/rules/jsx-first-prop-new-line.md b/docs/rules/jsx-first-prop-new-line.md index dd3bcd3644..770a4f5b91 100644 --- a/docs/rules/jsx-first-prop-new-line.md +++ b/docs/rules/jsx-first-prop-new-line.md @@ -6,11 +6,12 @@ Ensure correct position of the first property. ## Rule Details -This rule checks whether the first property of all JSX elements is correctly placed. There are three possible configurations: +This rule checks whether the first property of all JSX elements is correctly placed. There are the possible configurations: + * `always`: The first property should always be placed on a new line. * `never` : The first property should never be placed on a new line, e.g. should always be on the same line as the Component opening tag. * `multiline`: The first property should always be placed on a new line when the JSX tag takes up multiple lines. -* `multiline-multiprop`: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties. `default` +* `multiline-multiprop`: The first property should always be placed on a new line if the JSX tag takes up multiple lines and there are multiple properties. This is the `default` value. The following patterns are considered warnings when configured `"always"`: diff --git a/docs/rules/jsx-wrap-multilines.md b/docs/rules/jsx-wrap-multilines.md index a3f24c4d35..f1d8124002 100644 --- a/docs/rules/jsx-wrap-multilines.md +++ b/docs/rules/jsx-wrap-multilines.md @@ -1,11 +1,20 @@ # Prevent missing parentheses around multiline JSX (jsx-wrap-multilines) -Wrapping multiline JSX in parentheses can improve readability and/or convenience. It optionally takes a second parameter in the form of an object, containing places to apply the rule. By default, `"declaration"`, `"assignment"`, `"return"`, and `"arrow"` syntax is checked, but these can be explicitly disabled. Any syntax type missing in the object will follow the default behavior (become enabled). +Wrapping multiline JSX in parentheses can improve readability and/or convenience. **Fixable:** This rule is automatically fixable using the `--fix` flag on the command line. ## Rule Details +This rule optionally takes a second parameter in the form of an object, containing places to apply the rule. By default, all the syntax listed below will be checked, but these can be explicitly disabled. Any syntax type missing in the object will follow the default behavior (become enabled). + +There are the possible syntax available: + +* `declaration` +* `assignment` +* `return` +* `arrow` + The following patterns are considered warnings: ```jsx @@ -32,20 +41,80 @@ var Hello = createReactClass({ ); } }); +``` + +The following patterns are considered warnings when configured `{declaration: true}`. + +```jsx +var hello =
+

Hello

+
; +``` -// When [1, {declaration: false}] +The following patterns are not considered warnings when configured `{declaration: true}`. + +```jsx +var hello = ( +
+

Hello

+
+); +``` + +The following patterns are considered warnings when configured `{assignment: true}`. + +```jsx var hello; hello =

Hello

-
+; +``` -// When [1, {declaration: true, assignment: false, return: true}] -var world =
-

World

-
+The following patterns are not considered warnings when configured `{assignment: true}`. -// When [1, {arrow: false}] +```jsx +var hello; +hello = ( +
+

Hello

+
+); +``` +The following patterns are considered warnings when configured `{return: true}`. + +```jsx +function hello() { + return
+

Hello

+
; +} +``` + +The following patterns are not considered warnings when configured `{return: true}`. + +```jsx +function hello() { + return ( +
+

Hello

+
+ ); +} +``` +The following patterns are considered warnings when configured `{arrow: true}`. + +```jsx var hello = () =>

World

-
+; +``` + +The following patterns are not considered warnings when configured `{arrow: true}`. + +```jsx +var hello = () => ( +
+

World

+
+); ```