diff --git a/src/rules/jsxWrapMultilineRule.ts b/src/rules/jsxWrapMultilineRule.ts index ebc8af6..f7464c5 100644 --- a/src/rules/jsxWrapMultilineRule.ts +++ b/src/rules/jsxWrapMultilineRule.ts @@ -51,9 +51,8 @@ class JsxWrapMultilineWalker extends Lint.AbstractWalker { const cb = (node: ts.Node): void => { if (isJsxElement(node) || isJsxSelfClosingElement(node) || isJsxFragment(node)) { this.checkNode(node, sourceFile); - } else { - return ts.forEachChild(node, cb); } + return ts.forEachChild(node, cb); }; return ts.forEachChild(sourceFile, cb); diff --git a/test/rules/jsx-wrap-multiline/test.tsx.lint b/test/rules/jsx-wrap-multiline/test.tsx.lint index 511ee61..1a87123 100644 --- a/test/rules/jsx-wrap-multiline/test.tsx.lint +++ b/test/rules/jsx-wrap-multiline/test.tsx.lint @@ -21,7 +21,7 @@ const badMultiline =
; -~~~~~~ [Multiline JSX elements must be wrapped in parentheses] +~~~~~~ [FAILURE_NOT_WRAPPED] const goodSelfClosingMultiline = (
; -~~ [Multiline JSX elements must be wrapped in parentheses] +~~ [FAILURE_NOT_WRAPPED] const badWrappedWithoutNewLines = (
{children}
); - ~ [New line required before close parenthesis when wrapping multiline JSX elements] + ~ [FAILURE_MISSING_NEW_LINE_BEFORE_CLOSE] const badWrappedWithoutNewLineAtOpen = (
{children} @@ -61,7 +61,7 @@ const badWrappedWithoutNewLineAtClose = ( > {children}
); - ~ [New line required before close parenthesis when wrapping multiline JSX elements] + ~ [FAILURE_MISSING_NEW_LINE_BEFORE_CLOSE] const goodSingleLineWrappedWithoutNewLines = (
{children}
); @@ -82,7 +82,7 @@ const badNestedElements =
/> ~~~~~~~
; -~~~~~~ [Multiline JSX elements must be wrapped in parentheses] +~~~~~~ [FAILURE_NOT_WRAPPED] const goodFunctionWrap = mount(
~~~~~~~~~~~ ; -~~~ [Multiline JSX elements must be wrapped in parentheses] +~~~ [FAILURE_NOT_WRAPPED] shallowRender( @@ -127,3 +127,60 @@ shallowRender( ); + +const myCondition = true; +const component = () => ( +
+ Some Text + + {myCondition &&
+ ~~~~~ + Some Text. +~~~~~~~~~~~~~~~~~~~~~~ +
} +~~~~~~~~~~~~~~ [FAILURE_NOT_WRAPPED] + + {myCondition && (
+ ~ [FAILURE_MISSING_NEW_LINE_AFTER_OPEN] + Some Text. +
)} + ~ [FAILURE_MISSING_NEW_LINE_BEFORE_CLOSE] + + {myCondition && ( +
+ Some Text. +
+ )} + + {myCondition + ?
+ ~~~~~ + Some Text. +~~~~~~~~~~~~~~~~~~~~~~~~~~ +
+~~~~~~~~~~~~~~~~~~ [FAILURE_NOT_WRAPPED] + :
+ ~~~~~ + Some Text. +~~~~~~~~~~~~~~~~~~~~~~~~~~ +
+~~~~~~~~~~~~~~~~~~ [FAILURE_NOT_WRAPPED] + } + + {myCondition + ? ( +
+ Some Text. +
+ ) : ( +
+ Some Text. +
+ ) + } +
+); + +[FAILURE_NOT_WRAPPED]: Multiline JSX elements must be wrapped in parentheses +[FAILURE_MISSING_NEW_LINE_AFTER_OPEN]: New line required after open parenthesis when wrapping multiline JSX elements +[FAILURE_MISSING_NEW_LINE_BEFORE_CLOSE]: New line required before close parenthesis when wrapping multiline JSX elements