Skip to content

Commit 99e15e1

Browse files
reosarevokljharb
authored andcommitted
[Fix] jsx-no-literals: Avoid crashing on valueless boolean props
b8217ed removed the node.value check leading to this crashing on any valueless boolean prop such as <Component isWhatever /> This just readds the check.
1 parent a09083b commit 99e15e1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
88

99
### Fixed
1010
* [`no-is-mounted`]: fix logic in method name check ([#3821][] @Mathias-S)
11+
* [`jsx-no-literals`]: Avoid crashing on valueless boolean props ([#3823][] @reosarevok)
1112

13+
[#3823]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3823
1214
[#3821]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3821
1315

1416
## [7.36.0] - 2024.09.12

lib/rules/jsx-no-literals.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,9 @@ module.exports = {
503503
},
504504

505505
JSXAttribute(node) {
506-
const isLiteralString = node.value.type === 'Literal'
506+
const isLiteralString = node.value && node.value.type === 'Literal'
507507
&& typeof node.value.value === 'string';
508-
const isStringLiteral = node.value.type === 'StringLiteral';
508+
const isStringLiteral = node.value && node.value.type === 'StringLiteral';
509509

510510
if (isLiteralString || isStringLiteral) {
511511
const resolvedConfig = getOverrideConfig(node) || config;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy