diff --git a/lib/rules/jsx-max-depth.js b/lib/rules/jsx-max-depth.js index b5b3723733..3c9ab3894f 100644 --- a/lib/rules/jsx-max-depth.js +++ b/lib/rules/jsx-max-depth.js @@ -103,12 +103,12 @@ module.exports = { } function checkDescendant(baseDepth, children) { + baseDepth++; children.forEach(node => { if (!hasJSX(node)) { return; } - baseDepth++; if (baseDepth > maxDepth) { report(node, baseDepth); } else if (!isLeaf(node)) { diff --git a/tests/lib/rules/jsx-max-depth.js b/tests/lib/rules/jsx-max-depth.js index 0b2ceb1a9c..85dd2cd95b 100644 --- a/tests/lib/rules/jsx-max-depth.js +++ b/tests/lib/rules/jsx-max-depth.js @@ -61,6 +61,19 @@ ruleTester.run('jsx-max-depth', rule, { }, { code: 'const foo = (x) =>