Template string failing with Cannot read property 'range' of null
See original GitHub issueIt throws error when dynamic import, template literal inline and rule template-curly-spacing
as follow:
Tested on:
babel-eslint@10.0.3
(with @babel/parser@7.7.7
)
eslint@6.7.2
Sample code:
import(`${'package.json'}`)
.eslintrc.json
{
"parser": "babel-eslint",
"rules": {
"template-curly-spacing": ["error", "never"]
}
}
The problem is coming from @babel/parser@7.7.7
, which added ImportExpression
.
_Originally posted by @yitomok in https://github.com/babel/babel-eslint/issues/799#issuecomment-567598343_
Edits by @JLHwung
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 uninstalleslint-plugin-babel
4.b install@babel/eslint-plugin
4.c replace"babel"
or"eslint-plugin-babel"
to"@babel"
- The working ESLint config should look like https://github.com/babel/babel/issues/10904#issuecomment-691827355
Issue Analytics
- State:
- Created 4 years ago
- Reactions:60
- Comments:28 (7 by maintainers)
Top Results From Across the Web
Template string failing with Cannot read property 'range' of null
jsx I have template strings, it blows up with this error. TypeError: Cannot read property 'range' of null. This is my current list...
Read more >eslint error cannot read property 'range' of null - Stack Overflow
My solution was to use yarn instead of npm. Has solved the problem for the time being. node-modules · eslint.
Read more >ESLint: Cannot read property 'value' of null Occurred while ...
when dealing template string came out such error :ESLint: Cannot read property 'value' of null Occurred while linting /path/to/file.js:43.
Read more >eslint/eslint - Gitter
I am having an issue with ESLint while deploying my react app to Heroku. I am getting this error "Oops! Something went wrong!...
Read more >estlint -Cannot read property 'range' of null - 简书
编程风格要统一编程风格这个东西,说实在的对于刚加入团队的新成员来说还是很难让人完全适应的。因为每人的编程风格都不.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FYI; This is still broken.
package versions eslint@7.13.0 @babel/eslint-parser@7.12.1
Have to selectively disable ESLint rules to skirt the problem, like so:
or ESLint still blows up with:
Here, inside
template-curly-spacing
thesourceCode.getFirstToken
call ends up returningnull
:[EDIT]
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
(asnpm 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?
Fixed in
@babel/eslint-parser@7.11.3
.