Skip to content

Commit 9408c46

Browse files
msluthersalilagrawal
authored andcommitted
Fix issue where lint would crash trying to evaluate a function without the expected node ancestry (#3)
1 parent aaef73d commit 9408c46

File tree

3 files changed

+1099
-1062
lines changed

3 files changed

+1099
-1062
lines changed

lib/util/findNodes.js

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function findFormattedMessageAttrNode(node, attrName) {
2626
if (
2727
node.type === 'JSXIdentifier'
2828
&& node.name === 'FormattedMessage'
29+
&& node.parent
2930
&& node.parent.type === 'JSXOpeningElement'
3031
) {
3132
return node.parent.attributes.find(a => a.name && a.name.name === attrName);
@@ -42,6 +43,10 @@ function findFormattedMessageAttrNode(node, attrName) {
4243
function findAttrNodeInDefineMessages(node, attrName) {
4344
if (node.type === 'Property'
4445
&& node.key.name === attrName
46+
&& node.parent
47+
&& node.parent.parent
48+
&& node.parent.parent.parent
49+
&& node.parent.parent.parent.parent
4550
&& node.parent.parent.parent.parent.type === 'CallExpression'
4651
&& node.parent.parent.parent.parent.callee.name === 'defineMessages'
4752
) {

0 commit comments

Comments
 (0)