Skip to content

Commit

Permalink
Merge c65bfd7 into 82b3aa9
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbuck committed Jun 4, 2016
2 parents 82b3aa9 + c65bfd7 commit 630cc87
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 5 deletions.
12 changes: 12 additions & 0 deletions lib/rules/jsx-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ module.exports = function(context) {
}
var peerElementIndent = getNodeIndent(node.parent.openingElement);
checkNodesIndent(node, peerElementIndent);
},
ReturnStatement: function(node) {
if (!node.parent) {
return;
}

var openingIndent = getNodeIndent(node);
var closingIndent = getNodeIndent(node, true);

if (closingIndent !== openingIndent) {
report(node, openingIndent, closingIndent);
}
}
};

Expand Down
57 changes: 52 additions & 5 deletions tests/lib/rules/jsx-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ ruleTester.run('jsx-indent', rule, {
].join('\n'),
options: [2],
parserOptions: parserOptions
}, {
code: [
'function App() {',
' return (',
' <App />',
' );',
'}'
].join('\n'),
options: [2],
parserOptions: parserOptions
}, {
code: [
'function App() {',
' return <App>',
' <Foo />',
' </App>;',
'}'
].join('\n'),
options: [2],
parserOptions: parserOptions
}],

invalid: [{
Expand Down Expand Up @@ -137,18 +157,23 @@ ruleTester.run('jsx-indent', rule, {
].join('\n'),
options: [2],
parserOptions: parserOptions,
errors: [{message: 'Expected indentation of 2 space characters but found 9.'}]
errors: [
{message: 'Expected indentation of 2 space characters but found 9.'},
{message: 'Expected indentation of 2 space characters but found 9.'}
]
}, {
code: [
'function App() {',
' return (<App>',
' <Foo />',
' </App>);',
' return (',
' <App>',
' <Foo />',
' </App>',
' );',
'}'
].join('\n'),
options: [2],
parserOptions: parserOptions,
errors: [{message: 'Expected indentation of 2 space characters but found 4.'}]
errors: [{message: 'Expected indentation of 4 space characters but found 6.'}]
}, {
code: [
'function App() {',
Expand All @@ -162,5 +187,27 @@ ruleTester.run('jsx-indent', rule, {
options: [2],
parserOptions: parserOptions,
errors: [{message: 'Expected indentation of 4 space characters but found 0.'}]
}, {
code: [
'function App() {',
' return (',
' <App />',
' );',
'}'
].join('\n'),
options: [2],
parserOptions: parserOptions,
errors: [{message: 'Expected indentation of 2 space characters but found 4.'}]
}, {
code: [
'function App() {',
' return (',
' <App />',
');',
'}'
].join('\n'),
options: [2],
parserOptions: parserOptions,
errors: [{message: 'Expected indentation of 2 space characters but found 0.'}]
}]
});

0 comments on commit 630cc87

Please sign in to comment.