Skip to content

Commit

Permalink
Merge pull request #1081 from webOS101/jsx-indent-fix
Browse files Browse the repository at this point in the history
Fix jsx-indent single line jsx
  • Loading branch information
ljharb authored Feb 21, 2017
2 parents 22f3638 + 7863a5c commit c45ab86
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 c45ab86

Please sign in to comment.