From 7863a5c9f1ee79d1f6f287473534b0063aaee1a4 Mon Sep 17 00:00:00 2001 From: Roy Sutton Date: Mon, 20 Feb 2017 23:14:41 -0800 Subject: [PATCH] Fix jsx-indent single line jsx Also adds test --- lib/rules/jsx-indent.js | 2 +- tests/lib/rules/jsx-indent.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index 773e979de1..f6ed3ac5a1 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -325,7 +325,7 @@ module.exports = { checkNodesIndent(node, parentNodeIndent + indentSize); }, Literal: function(node) { - if (!node.parent || node.parent.type !== 'JSXElement') { + if (!node.parent || node.parent.type !== 'JSXElement' || node.loc.start.line === node.parent.loc.start.line) { return; } var parentElementIndent = getOpeningElementIndent(node.parent.openingElement); diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js index 737fdf45b2..960a1009c0 100644 --- a/tests/lib/rules/jsx-indent.js +++ b/tests/lib/rules/jsx-indent.js @@ -451,6 +451,14 @@ ruleTester.run('jsx-indent', rule, { ].join('\n'), options: [2], parserOptions: parserOptions + }, { + code: [ + 'function foo() {', + ' Text', + '}' + ].join('\n'), + options: [2], + parserOptions: parserOptions }], invalid: [{