Skip to content

Commit

Permalink
Avoid crashing on valueless boolean props
Browse files Browse the repository at this point in the history
b8217ed removed the node.value check
leading to this crashing on any valueless boolean prop such as
<Component isWhatever />

This just readds the check.
  • Loading branch information
reosarevok authored Sep 12, 2024
1 parent 1df23d2 commit 14f8435
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules/jsx-no-literals.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ module.exports = {
},

JSXAttribute(node) {
const isLiteralString = node.value.type === 'Literal'
const isLiteralString = node.value && node.value.type === 'Literal'
&& typeof node.value.value === 'string';
const isStringLiteral = node.value.type === 'StringLiteral';
const isStringLiteral = node.value && node.value.type === 'StringLiteral';

if (isLiteralString || isStringLiteral) {
const resolvedConfig = getOverrideConfig(node) || config;
Expand Down

0 comments on commit 14f8435

Please sign in to comment.