diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js
index fa81f8f673..1f4500a1d7 100644
--- a/lib/rules/jsx-indent.js
+++ b/lib/rules/jsx-indent.js
@@ -352,6 +352,18 @@ module.exports = {
}
const parentNodeIndent = getNodeIndent(node.parent);
checkNodesIndent(node, parentNodeIndent + indentSize);
+ },
+ ReturnStatement: function(node) {
+ if (!node.parent) {
+ return;
+ }
+
+ var openingIndent = getNodeIndent(node);
+ var closingIndent = getNodeIndent(node, true);
+
+ if (closingIndent !== openingIndent) {
+ report(node, openingIndent, closingIndent);
+ }
}
};
}
diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js
index af01578abc..432edcb51c 100644
--- a/tests/lib/rules/jsx-indent.js
+++ b/tests/lib/rules/jsx-indent.js
@@ -956,6 +956,26 @@ const Component = () => (
}
`,
options: [2, {indentLogicalExpressions: true}]
+ }, {
+ code: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ' );',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions: parserOptions
+ }, {
+ code: [
+ 'function App() {',
+ ' return ',
+ ' ',
+ ' ;',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions: parserOptions
}],
invalid: [{
@@ -1056,6 +1076,50 @@ const Component = () => (
].join('\n'),
options: [2],
errors: [{message: 'Expected indentation of 2 space characters but found 4.'}]
+ }, {
+ code: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ' );',
+ '}'
+ ].join('\n'),
+ output: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ' ',
+ ' ',
+ ' );',
+ '}'
+ ].join('\n'),
+ options: [2],
+ errors: [{
+ line: 5,
+ message: 'Expected indentation of 4 space characters but found 6.'
+ }]
+ }, {
+ code: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ' );',
+ '}'
+ ].join('\n'),
+ output: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ' ',
+ ' ',
+ ' );',
+ '}'
+ ].join('\n'),
+ options: [2],
+ errors: [{
+ line: 5,
+ message: 'Expected indentation of 4 space characters but found 6.'
+ }]
}, {
code: [
'function App() {',
@@ -1883,5 +1947,27 @@ const Component = () => (
errors: [
{message: 'Expected indentation of 8 space characters but found 4.'}
]
+ }, {
+ code: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ' );',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions: parserOptions,
+ errors: [{message: 'Expected indentation of 2 space characters but found 4.'}]
+ }, {
+ code: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ');',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions: parserOptions,
+ errors: [{message: 'Expected indentation of 2 space characters but found 0.'}]
}]
});