Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] jsx-no-literals: Avoid crashing on valueless boolean props #3823

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

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

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

## [7.36.0] - 2024.09.12
Expand Down
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