diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js
index fa81f8f673..ca9e82b3c5 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(node) {
+ if (!node.parent) {
+ return;
+ }
+
+ const openingIndent = getNodeIndent(node);
+ const 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..834522da2a 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
+ }, {
+ code: [
+ 'function App() {',
+ ' return ',
+ ' ',
+ ' ;',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions
}],
invalid: [{
@@ -1038,7 +1058,10 @@ const Component = () => (
'}'
].join('\n'),
options: [2],
- 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() {',
@@ -1055,7 +1078,10 @@ const Component = () => (
'}'
].join('\n'),
options: [2],
- errors: [{message: 'Expected indentation of 2 space characters but found 4.'}]
+ errors: [
+ {message: 'Expected indentation of 2 space characters but found 4.'},
+ {message: 'Expected indentation of 2 space characters but found 4.'}
+ ]
}, {
code: [
'function App() {',
@@ -1883,5 +1909,27 @@ const Component = () => (
errors: [
{message: 'Expected indentation of 8 space characters but found 4.'}
]
+ }, {
+ code: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ' );',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions,
+ errors: [{message: 'Expected indentation of 2 space characters but found 4.'}]
+ }, {
+ code: [
+ 'function App() {',
+ ' return (',
+ ' ',
+ ');',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions,
+ errors: [{message: 'Expected indentation of 2 space characters but found 0.'}]
}]
});