Skip to content

Commit

Permalink
Fix jsx-indent single line jsx
Browse files Browse the repository at this point in the history
Also adds test
  • Loading branch information
Roy Sutton authored and omerzach committed Mar 21, 2017
1 parent 966532d commit b5a2ff4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent.js
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/jsx-indent.js
Expand Up @@ -451,6 +451,14 @@ ruleTester.run('jsx-indent', rule, {
].join('\n'),
options: [2],
parserOptions: parserOptions
}, {
code: [
'function foo() {',
' <span>Text</span>',
'}'
].join('\n'),
options: [2],
parserOptions: parserOptions
}],

invalid: [{
Expand Down

0 comments on commit b5a2ff4

Please sign in to comment.