You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues and my issue is unique
My issue appears in the command-line and not only in the text editor
To pick up a draggable item, press the space bar.
While dragging, use the arrow keys to move the item.
Press space again to drop the item in its new position, or press escape to cancel.
Description Overview
If there is a boolean props in JSX, there is an exception thrown in processing this rule and eslint broke down.
<a isBoolean>test</a>
[Error - 15:46:51] TypeError: Cannot read properties of null (reading 'type')
Occurred while linting <file_name>
Rule: "react/jsx-no-literals"
at JSXAttribute (/node_modules/.pnpm/eslint-plugin-react@7.36.0_eslint@8.57.0/node_modules/eslint-plugin-react/lib/rules/jsx-no-literals.js:506:44)
at ruleErrorHandler (/node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/linter/linter.js:1076:28)
at /node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach ()
at Object.emit (/node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
changed the title [-][Bug]: If boolean props are in JSX, the latest update(7.36.0) throws exception[/-][+][Bug]: If boolean props are in JSX, the latest update(7.36.0) throws exception and breaks ESLINT[/+]on Sep 12, 2024
changed the title [-][Bug]: If boolean props are in JSX, the latest update(7.36.0) throws exception and breaks ESLINT[/-][+][Bug]: If boolean props are in JSX, the react/jsx-no-literals rule in latest update(7.36.0) throws exception and breaks ESLINT[/+]on Sep 12, 2024
// ...publicasyncinit(){for(constchunkofthis.chunks){// <------this is line 150awaitchunk.generateSha1Hash();}}// ...
where this.chunks is an array of objects.
If I comment out this method it will error in another (seemingly random) file with the same error message in the console as above:
functionready(fn: (event?: Event)=>void){if(document.readyState!=='loading')returnfn();document.addEventListener('DOMContentLoaded',fn);}ready(()=>{letelement;// <------ this line is where the error happens in the other filetry{localStorage.getItem(null);}catch(error){if(error.message==='The operation is insecure.'){element=document.getElementById('safari-with-blocked-cookies-message');}elsethrowerror;}if(!element)element=document.getElementById('unsupported-browser-message');if(!element)return;constclassList=element.classList;classList.add('fade','show');classList.remove('d-none');});
(this is the contents of the entire file)
eslint-plugin-react: "version": "7.37.2",
Here's the lines of eslint-plugin-react/lib/rules/jsx-no-literals.js:223:16
[Bug]: If boolean props are in JSX, the react/jsx-no-literals rule in latest update(7.36.0) throws exception and breaks ESLINT · Issue #3820 · jsx-eslint/eslint-plugin-react
Activity
[-][Bug]: If boolean props are in JSX, the latest update(7.36.0) throws exception[/-][+][Bug]: If boolean props are in JSX, the latest update(7.36.0) throws exception and breaks ESLINT[/+][-][Bug]: If boolean props are in JSX, the latest update(7.36.0) throws exception and breaks ESLINT[/-][+][Bug]: If boolean props are in JSX, the react/jsx-no-literals rule in latest update(7.36.0) throws exception and breaks ESLINT[/+]jsx-no-literals
: Avoid crashing on valueless boolean props #3823react/jsx-no-literals
crashes withCannot read properties of null (reading 'type')
#3822kai-dorschner-twinsity commentedon Sep 12, 2024
Can confirm, same here
kai-dorschner-twinsity commentedon Oct 18, 2024
For me it is still not solved unfortunately. The issue is marked as completed but as of
"eslint-plugin-react": "7.37.1"
it still appearsljharb commentedon Oct 18, 2024
@kai-dorschner-twinsity can you provide the code it’s crashing on?
kai-dorschner-twinsity commentedon Oct 25, 2024
Unfortunately not, it is corporate code. Let me check if I can extract a few meaningful lines out of it.
Edit:
this is the eslint rule:
this is what's been thrown in the command line:

This is the line 150:
where
this.chunks
is an array of objects.If I comment out this method it will error in another (seemingly random) file with the same error message in the console as above:
(this is the contents of the entire file)
eslint-plugin-react:
"version": "7.37.2",
Here's the lines of
eslint-plugin-react/lib/rules/jsx-no-literals.js:223:16
eslint-plugin-react/lib/rules/jsx-no-literals.js
Lines 216 to 233 in d1556a3