Skip to content

Commit 152bea4

Browse files
author
Ethan Cohen
committed
[fix] - Edit heading-has-content to check correctly for undefined.
1 parent e4768ef commit 152bea4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/rules/heading-has-content.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ module.exports = context => ({
4242
child.openingElement.attributes
4343
);
4444
case 'JSXExpressionContainer':
45-
return child.expression.type === 'Identifier' && child.expression.name !== 'undefined';
45+
if (child.expression.type === 'Identifier') {
46+
return child.expression.name !== 'undefined';
47+
}
48+
return true;
4649
default:
4750
return false;
4851
}

tests/src/rules/heading-has-content.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ruleTester.run('heading-has-content', rule, {
4040
{ code: '<h6>123</h6>', parserOptions },
4141
{ code: '<h1><Bar /></h1>', parserOptions },
4242
{ code: '<h1>{foo}</h1>', parserOptions },
43+
{ code: '<h1>{foo.bar}</h1>', parserOptions },
4344
],
4445
invalid: [
4546
{ code: '<h1 />', errors: [expectedError], parserOptions },

0 commit comments

Comments
 (0)