Eslint-plugin-react: jsx-fragments: self closing <React.Fragment /> breaking eslint "Cannot read property 'range' of null"

Created on 3 Jan 2019  路  2Comments  路  Source: yannickcr/eslint-plugin-react

Hi there, stumbled into linter-crashing bug.
Error caused when processing a self closing fragment: <React.Fragment /> crashes eslint.

Without going into whether <React.Fragment /> is really needed, it shouldn't break eslint and especially with no indication from the error that this was the cause, I had to search file by file to find it.

TypeError: Cannot read property 'range' of null
    at replaceNode (/node_modules/eslint-plugin-react/lib/rules/jsx-fragments.js:18:34)
    at Object.fix (/node_modules/eslint-plugin-react/lib/rules/jsx-fragments.js:74:18)
    at normalizeFixes (/node_modules/eslint/lib/report-translator.js:176:28)
    at args (/node_modules/eslint/lib/report-translator.js:278:18)
    at Object.report (/node_modules/eslint/lib/linter.js:830:41)
    at Program:exit.jsxElements.forEach.node (/node_modules/eslint-plugin-react/lib/rules/jsx-fragments.js:169:23)
    at Array.forEach (<anonymous>)
    at Program:exit (/node_modules/eslint-plugin-react/lib/rules/jsx-fragments.js:158:21)
    at listeners.(anonymous function).forEach.listener (/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
error Command failed with exit code 2.
bug help wanted

Most helpful comment

Sorry about that, I鈥檒l take a look.

All 2 comments

Change <React.Fragment /> to <></> that will let you run the eslint task

Sorry about that, I鈥檒l take a look.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gpeal picture gpeal  路  3Comments

Arcanemagus picture Arcanemagus  路  3Comments

isnifer picture isnifer  路  3Comments

inian picture inian  路  3Comments

otakustay picture otakustay  路  3Comments