From 9d3955adddc6e922e4a0714f3be0b9d0ba968d42 Mon Sep 17 00:00:00 2001 From: Joshua Stiefer Date: Fri, 4 Jan 2019 07:34:58 -0700 Subject: [PATCH] Prevent crash of jsx-indent rule --- lib/rules/jsx-indent.js | 2 +- tests/lib/rules/jsx-indent.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js index b79f724cba..2076704ad1 100644 --- a/lib/rules/jsx-indent.js +++ b/lib/rules/jsx-indent.js @@ -253,7 +253,7 @@ module.exports = { } function handleAttribute(node) { - if (!checkAttributes || node.value.type !== 'JSXExpressionContainer') { + if (!checkAttributes || (!node.value || node.value.type !== 'JSXExpressionContainer')) { return; } const nameIndent = getNodeIndent(node.name); diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js index 75584a32bf..43d6a80a70 100644 --- a/tests/lib/rules/jsx-indent.js +++ b/tests/lib/rules/jsx-indent.js @@ -820,6 +820,18 @@ const Component = () => ( ); `, options: ['tab', {checkAttributes: false}] + }, { + code: ` + function Foo() { + return ( + + ); + } + `, + options: [2, {checkAttributes: true}] }], invalid: [{