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
{{ message }}
Repository navigation
Template string failing with Cannot read property 'range' of null #10904
If you come across this issue from search engine, see below for the solution:
uninstall babel-eslint
install @babel/eslint-parser
replace babel-eslint by @babel/eslint-parser in your ESLint config
if you use eslint-plugin-babel, do 4.a - 4.c, otherwise skip it
4.a uninstall eslint-plugin-babel
4.b install @babel/eslint-plugin
4.c replace "babel" or "eslint-plugin-babel" to "@babel"
Reacted by GroverTB, Sebastian K, Igor Novozhilov, askart, Githoniel, Alexander Popov, Danny Fritz, Johan, Stefanie L., Niels NTG Poldervaart and 37 more
Reacted by Jeff Margolis, Harsh Maisheri, Paulius Zaranka and Christopher Wiles
Reacted by Boris D. Teoharov, Rémi Vincent, Harsh Maisheri, Paulius Zaranka, Christopher Wiles, noorzaie, Junior S.O Mariano and Sergey Podgorny
Hey @yitomok! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."
Thanks @LexSwed, It seems that was the problem in my case as well. I needed to run yarn-deduplicate yarn.lock after installing @babel/[email protected] to get it to work.
Reacted by Harrison Kamau, Ev Haus and Magdalena Strzoda
Came here from eslint/eslint#13394. Could someone give me brief instructions on how to handle this fix, please?
I'm aware of FOSS requiring some interest and time to spent to work with. I know it's about shared efforts. However, right now I'd like to use ESLint to check my own FOSS code. I have a basic understanding on what babel is and when to use it, but I don't know all the relations between all that babel-packages mentioned in this thread and how they are integrated with ESLint. Currently I'm quite little interested in studying those internals to get babel-eslint working as a parser in ESLint again. So, is there any easy way to fix that linked issue when trying to add babel-eslint to ESLint?
Have to selectively disable ESLint rules to skirt the problem, like so:
"template-curly-spacing" : "off"
or ESLint still blows up with:
TypeError: Cannot read property 'value' of null
Occurred while linting [redacted]
at checkSpacingBefore ([redacted]\node_modules\eslint\lib\rules\template-curly-spacing.js:52:24)
at TemplateElement ([redacted]\node_modules\eslint\lib\rules\template-curly-spacing.js:136:17)
at [redacted]\node_modules\eslint\lib\linter\safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit ([redacted]\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
at NodeEventGenerator.applySelector ([redacted]\node_modules\eslint\lib\linter\node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors ([redacted]\node_modules\eslint\lib\linter\node-event-generator.js:283:22)
at NodeEventGenerator.enterNode ([redacted]\node_modules\eslint\lib\linter\node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode ([redacted]\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:711:23)
at [redacted]\node_modules\eslint\lib\linter\linter.js:952:32
Here, inside template-curly-spacing the sourceCode.getFirstToken call ends up returning null:
Looks like this is STILL the problem with a wrong version of @babel/types being used.
After a thorough wipe and reinstall of all things @babel (as npm dedup was deduping to the WRONG version) it does work.
I though the whole idea of having the eslint parser go into the mono repo was to maintain it together with Babel and prevent exactly that shitty issue?
Reacted by Tang Chuan-Wei, mk, Alexander Romanov, Stig Johan Berggren, Anton Mokrushin, Hiroki Osame, Chris Joe, Zach Bialecki, Dennis Al Baihaqi Walangadi, Christopher Wiles and 6 more
Activity
babel-bot commentedon Dec 21, 2019
Hey @yitomok! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."
kaicataldo commentedon Dec 23, 2019
I think this should be fixed by #10828, but will have to verify.
kaicataldo commentedon Dec 23, 2019
Added to #10752 so I don't forget to verify this when I start going through rules.
Fixed issue with dependency latest version breaking build [ref](babel…
jlchereau commentedon Mar 30, 2020
The following does not trigger the 'range' of null error:
but the following does:
kaicataldo commentedon Mar 30, 2020
What version are you using?
jlchereau commentedon Mar 31, 2020
Hey @kaicataldo,
rjgotten commentedon Apr 7, 2020
@kaicataldo
For what it's worth - I'm also having this problem with the
template-curly-spacingthrowing on a dynamic import.Relevant packages:
(NOTE: Problem actually occurs with
babel-eslintversions 10.0.3; 10.1.0 as well as the 11.0.0-beta2 under its@next. Checked all of them.)Unlisted dependencies confirmed fully de-duped:
Downgrade babel-eslint
tmcdos commentedon May 4, 2020
I am experiencing this problem when I lint code like this (string templates without any interpolation inside):
Downgrade babel-eslint
kaicataldo commentedon May 14, 2020
This should be fixed in the latest v11 prerelease (and will be included in the next major release, which will be under a new package name).
brettz9 commentedon May 16, 2020
Regarding the "latest v11 prerelease", I guess you mean the next such release, @kaicataldo, as npm is showing the latest release for
babel-eslintas 11.0.0-beta.2 from 5 months ago (and https://www.npmjs.com/package/@babel/eslint-parser shows nothing yet)?githoniel commentedon Jun 5, 2020
when will this release? use 8.x babel-eslint will result in other bugs...
12 remaining items
geopamplona commentedon Aug 11, 2020
How should fix, upgrading packages??
or Should wait some new release?
I upgrade to @babel/[email protected] but I still have these problem.
Thanks !
lebaz20 commentedon Aug 12, 2020
Thanks @LexSwed, It seems that was the problem in my case as well. I needed to run
yarn-deduplicate yarn.lockafter installing@babel/[email protected]to get it to work.soletan commentedon Sep 13, 2020
Came here from eslint/eslint#13394. Could someone give me brief instructions on how to handle this fix, please?
I'm aware of FOSS requiring some interest and time to spent to work with. I know it's about shared efforts. However, right now I'd like to use ESLint to check my own FOSS code. I have a basic understanding on what babel is and when to use it, but I don't know all the relations between all that babel-packages mentioned in this thread and how they are integrated with ESLint. Currently I'm quite little interested in studying those internals to get babel-eslint working as a parser in ESLint again. So, is there any easy way to fix that linked issue when trying to add babel-eslint to ESLint?
cdoublev commentedon Sep 13, 2020
Try switching to
@babel/eslint-parser.https://babeljs.io/blog/2020/07/13/the-state-of-babel-eslint
soletan commentedon Sep 14, 2020
I found this minimum configuration helpful (with unrelated or too specific pieces removed):
package.json
{ "name": "your-project", "devDependencies": { "@babel/core": "^7.11.6", "@babel/eslint-parser": "^7.11.5", "@babel/eslint-plugin": "^7.11.5", "@babel/preset-env": "^7.11.5", "eslint": "^7.9.0" } }.babelrc (required)
{ "presets": [ [ "@babel/env", { "targets": { "edge": "17", "firefox": "60", "chrome": "67", "safari": "11.1" }, "useBuiltIns": "usage", "corejs": "3.6.4" } ] ] }.eslintrc
{ "plugins": [ "@babel" ], "extends": [ "your-preferred-ruleset-here" ], "parser": "@babel/eslint-parser", }Replace babel-eslint with @babel/eslint-parser as recommended in babe…
rjgotten commentedon Nov 19, 2020
FYI; This is still broken.
package versions
[email protected]
@babel/[email protected]
Have to selectively disable ESLint rules to skirt the problem, like so:
or ESLint still blows up with:
Here, inside
template-curly-spacingthesourceCode.getFirstTokencall ends up returningnull:[EDIT]
Looks like this is STILL the problem with a wrong version of
@babel/typesbeing used.After a thorough wipe and reinstall of all things
@babel(asnpm dedupwas deduping to the WRONG version) it does work.I though the whole idea of having the eslint parser go into the mono repo was to maintain it together with Babel and prevent exactly that shitty issue?
jiandandkl commentedon Jan 26, 2021
use @babel/eslint-parser, because

chore(deps): babel-eslint ➡ @babel/eslint-parser
chore: upgrade babel eslint-parser
chore: upgrade babel eslint-parser