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 }}
This repository was archived by the owner on Aug 18, 2021. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 18, 2021. It is now read-only.
$ npx eslint .
Cannot read property 'range' of null
(node:44758) [ESLINT_LEGACY_OBJECT_REST_SPREAD] DeprecationWarning: The 'parserOptions.ecmaFeatures.experimentalObjectRestSpread' option is deprecated. Use 'parserOptions.ecmaVersion' instead. (found in "node_modules/eslint-config-airbnb-base/index.js")
> eslint . --cache --cache-file eslint-cache/eslintcache
Cannot read property 'range' of null
TypeError: Cannot read property 'range' of null
at SourceCode.getTokenBefore (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/token-store/index.js:303:18)
at checkSpacingBefore (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/rules/template-curly-spacing.js:52:42)
at TemplateElement (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/rules/template-curly-spacing.js:117:17)
at listeners.(anonymous function).forEach.listener (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/util/safe-emitter.js:45:58)
at Array.forEach (<anonymous>)
at Object.emit (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/util/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/util/node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/util/node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/util/node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode (/Users/craigbeck/dev/premise-frontend-v3/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
Also seeing similar error although we don't use decorators
TypeError: Cannot read property 'range' of null
at OffsetStorage.setDesiredOffset (/Users/dsizomin/Projects/RateFamily/frontend/node_modules/eslint/lib/rules/indent.js:335:45)
at TemplateLiteral.node.expressions.forEach (/Users/dsizomin/Projects/RateFamily/frontend/node_modules/eslint/lib/rules/indent.js:1341:29)
at Array.forEach (<anonymous>)
at Object.TemplateLiteral [as listener] (/Users/dsizomin/Projects/RateFamily/frontend/node_modules/eslint/lib/rules/indent.js:1333:34)
at Program:exit.listenerCallQueue.filter.forEach.nodeInfo (/Users/dsizomin/Projects/RateFamily/frontend/node_modules/eslint/lib/rules/indent.js:1529:55)
at Array.forEach (<anonymous>)
at Program:exit (/Users/dsizomin/Projects/RateFamily/frontend/node_modules/eslint/lib/rules/indent.js:1529:26)
at listeners.(anonymous function).forEach.listener (/Users/dsizomin/Projects/RateFamily/frontend/node_modules/eslint/lib/util/safe-emitter.js:45:58)
at Array.forEach (<anonymous>)
at Object.emit (/Users/dsizomin/Projects/RateFamily/frontend/node_modules/eslint/lib/util/safe-emitter.js:45:38)
For me the troublesome lines are the ones containing template literals. Commenting out those makes eslint work.
// TODO: Remove when is https://github.com/babel/babel-eslint/issues/530 fixed
rules : {
"template-curly-spacing" : "off",
indent : "off"
}
Reacted by debel27, katsuki takahashi, Valery, Esteban Trejos Quirós, Steve Wolfe, Ruslan, leancoderk, Michael Wheeler, mori-dev, Olivier Tassinari and 113 more
Reacted by Bohdan Balov (Mr. Balov), 宁缺, Peter Pak, Maja Isaković, Hyalen Neves Caldeira, Colby Fayock, Dmitrii Komalov, Sergey Vladimirov, erikqin, sailfish009 and 2 more
Reacted by stefan9541, Fábio Paiva, Bohdan Balov (Mr. Balov), Cisco Guillaume, Seanitzel(Sean Ray Dvir), Sebastian Galler, Peter Pak, Maja Isaković, Mickael Lac, Arif Dewi and 9 more
Reacted by Nelson Martell, Valentin Cocaud, Arthur Franco, Bartek Igielski and 5aava
Reacted by Welliton Gervickas, Kevin van Zonneveld, stefan9541, Petar Mihaylovski, Bohdan Balov (Mr. Balov), 宁缺, Sebastian Galler, Peter Pak, Maja Isaković, Mickael Lac and 12 more
Reacted by Bohdan Balov (Mr. Balov), Anastasios Selalmazidis, Peter Pak, Maja Isaković, Arif Dewi, Hyalen Neves Caldeira, Colby Fayock, Michael M. Q. Nguyen, 이재영(Jay Lee) and Christian Segovia
I encountered similar problem, finally I found that it's because of existence of 2 @babel/types.
babel-eslint changes data in @babel/types and assumes @babel/traverse would consume it. But as npm/yarn may create different @babel/types to avoid conflict, the change on @babel/types may not take affect on @babel/traverse.
FWIW, I'm getting the same error, with eslint 5.11.1 and npm 6.5.0. Switching to yarn fixes it, so from that perspective it seems like a dependency/determinicness issue. However, I want to keep using npm, and I also don't want to downgrade.
In my case at least the error is generated during handling of template literals within the indent rule. I can live with not checking indentation for template literals, so I've fixed it for now using the ignoredNodes option for the indent rule, roughly as follows:
Not sure how else I can be of help, except maybe reiterate @ljqx's suggestion of trying to normalize the @babel/types dep across babel and babel-eslint. I can't tell if npm is doing something wrong here or if yarn's more deterministic algorithm is hiding a flaw in the code.
Reacted by Shea Belsky, Ítalo Borges, Shimaguchi Tomoya, Adhitya Yosua Sanjaya Andaria, Ahsan Sher, zdy, Thaer, DaveJump, Samed Düzçay, Paulo Mogollón and 20 more
Reacted by Nazar Tokar, Adam Flaxman, Eliecer Chicott, Bongseok Choi, Soldeplata Saketos Candela, Per and 5aava
Reacted by Adhitya Yosua Sanjaya Andaria, Matt Bogen, Mike, Patrick Söllner, Jesús Otero and Soldeplata Saketos Candela
Reacted by Lorenzo Cavazzi, Luca Iaconelli, wendt88 and 5aava
Reacted by EmiyaYang
ghost added a commit that references this issue on Jan 8, 2019
I have the same issue. I'm not going to remove all template literals just for this upgrade since everything seems to still work with 8.2.6.
Have you resolved this question
@ldwqh0 could you attach complete error log in output channel?
In my case, I encountered similar log as @dsizomin
I solved it by remove yarn.lock, node_modules and run yarn install again (need to restart VS code): #530 (comment)
[Error - 11:55:33 AM] TypeError: Cannot read property 'range' of null
at OffsetStorage.setDesiredOffset (/home/laura/Documents/project/kid-guard-api/node_modules/eslint/lib/rules/indent.js:335:45)
at TemplateLiteral.node.expressions.forEach (/home/laura/Documents/project/kid-guard-api/node_modules/eslint/lib/rules/indent.js:1335:29)
at Array.forEach (<anonymous>)
at Object.TemplateLiteral [as listener] (/home/laura/Documents/project/kid-guard-api/node_modules/eslint/lib/rules/indent.js:1327:34)
at Program:exit.listenerCallQueue.filter.forEach.nodeInfo (/home/laura/Documents/project/kid-guard-api/node_modules/eslint/lib/rules/indent.js:1537:55)
at Array.forEach (<anonymous>)
at Program:exit (/home/laura/Documents/project/kid-guard-api/node_modules/eslint/lib/rules/indent.js:1537:26)
at listeners.(anonymous function).forEach.listener (/home/laura/Documents/project/kid-guard-api/node_modules/eslint/lib/util/safe-emitter.js:45:58)
at Array.forEach (<anonymous>)
at Object.emit (/home/laura/Documents/project/kid-guard-api/node_modules/eslint/lib/util/safe-emitter.js:45:38)
Reacted by Dallas Hall, Oleg, Herman Starikov, nanokind, Zz, Yusuf Sultan, Santiago Martí Olbrich, Desmoline Awa, mojabyte, Jake and 6 more
Reacted by Oleg, Desmoline Awa, Ed Estrela Dantas and Lord Grosse Jeanine
This problem popped up for me after running npm audit fix to clear some npm vulnerability warnings, which bumped my version of eslint from v5.8.0 to v5.13.0
Removing my package-lock.json and node_modules folder and running npm install worked to resolve this in my case.
eslint: v5.13.0
babel-eslint: v10.0.1
Reacted by Minh Nguyen, AlexKorzh, Brendan Miller, Steve Podell, UZHS, xz, Geovanni Perez, Hydra Jones, Paweł Kalinowski, Oleg Chulanovskyi and 28 more
Reacted by idmadj, David Devor, Ítalo Borges, Tekeste Gebreanenia, Ray Su, Alex Nainer, Chris Adkins, Brendan Miller, Steve Podell, Paweł Kalinowski and 11 more
Reacted by oceanz
Reacted by Tekeste Gebreanenia, Total Pave Inc., Paweł Kalinowski, John Reynolds, John Molakvoæ, Maxime Freschard, oceanz and Rodrigo D’Agostino
I fixed this issue by making sure I only have the one version of @babel/types:
npm list @babel/types
I targeted version 7.3.4 and some packages were using the newer 7.4.4. For those packages I reverted to an older version which used @babel/types@7.3.4. I did this without adding the dependency to package.json. An npm install is sufficient to update the package-lock.json.
Then I ran the dedupe command to ensure I had no duplicates of @babel/types, since having multiple copies of the same version will still cause issues.
npm dedupe @babel/types
You should then see that the npm list command shows a single @babel/types without "dedupe" and all others with it, indicating they're references. After this the linter ran just fine.
Reacted by Viet Tran, Werner Design, UZHS, yhls, James Pearce, Tonye Jack, theFreedomBanana, Ben Goerdt, joeyparis, Kessy Similien and 1 more
@lolmaus Actually for me it's the gitlab pipelines that fails because of eslint, everything works on local environment and on deploy server, so it's really weird , as @NicholasIoanJones said : Appeared out of nowhere.
Simply commenting out the import keyword fixes it.
I tried wrapping the problematic block with /* eslint-disable */ and /* eslint-enable */, but the dynamic import keyword's appearance breaks the engine.
I've never seen this error before from "just template literals", so if I had anything to contribute, it would be that the import keyword is related. When I remove that keyword but keep the template literal, it un-breaks ES Lint.
Reacted by Taraluktus, Nick Trefz, Nikolay Petkov, Adam Ryvola, Quentin De Smedt and WavinFlag
i'm using CRA (react-scripts@3.4.1), yarn and react-app-rewired@2.1.6 and this issue happens to me only transpiling the tests (yarn test) with import sentences using template literals such as this one:
import(`${path}`)
Neither of the commented solutions worked for me but using the patch of disabling the corresponding eslint rules. To me this is not a valid solution, but by the moment will use it.
I encountered similar problem, finally I found that it's because of existence of 2 @babel/types.
babel-eslint changes data in @babel/types and assumes @babel/traverse would consume it. But as npm/yarn may create different @babel/types to avoid conflict, the change on @babel/types may not take affect on @babel/traverse.
I fixed this issue by making sure I only have the one version of @babel/types:
npm list @babel/types
I targeted version 7.3.4 and some packages were using the newer 7.4.4. For those packages I reverted to an older version which used @babel/types@7.3.4. I did this without adding the dependency to package.json. An npm install is sufficient to update the package-lock.json.
Then I ran the dedupe command to ensure I had no duplicates of @babel/types, since having multiple copies of the same version will still cause issues.
npm dedupe @babel/types
You should then see that the npm list command shows a single @babel/types without "dedupe" and all others with it, indicating they're references. After this the linter ran just fine.
Activity
craigbeck commentedon Sep 4, 2018
Also seeing similar error although we don't use decorators
dsizomin commentedon Sep 7, 2018
Experiencing similar issue here.
For me the troublesome lines are the ones containing template literals. Commenting out those makes
eslintwork.krousseau-cs commentedon Sep 10, 2018
I have the same issue. I'm not going to remove all template literals just for this upgrade since everything seems to still work with 8.2.6.
ZackKnopp commentedon Sep 12, 2018
See: #530
What worked for me in .eslintrc:
ljqx commentedon Oct 16, 2018
I encountered similar problem, finally I found that it's because of existence of 2
@babel/types.babel-eslintchanges data in@babel/typesand assumes@babel/traversewould consume it. But as npm/yarn may create different@babel/typesto avoid conflict, the change on@babel/typesmay not take affect on@babel/traverse.So
Would work. But
won't work.
@hzoo , I think here it's better to pass in the
@babel/typesinstead of implicitly depending on same dependency which may not be true.ldwqh0 commentedon Oct 16, 2018
I have resolved this
add this config in my .eslintrc.js file
but the "Cannot read property 'range' of null" error can not be resolved
wait online
joepvl commentedon Jan 4, 2019
FWIW, I'm getting the same error, with eslint 5.11.1 and npm 6.5.0. Switching to yarn fixes it, so from that perspective it seems like a dependency/determinicness issue. However, I want to keep using npm, and I also don't want to downgrade.
In my case at least the error is generated during handling of template literals within the
indentrule. I can live with not checking indentation for template literals, so I've fixed it for now using theignoredNodesoption for theindentrule, roughly as follows:Not sure how else I can be of help, except maybe reiterate @ljqx's suggestion of trying to normalize the
@babel/typesdep acrossbabelandbabel-eslint. I can't tell if npm is doing something wrong here or if yarn's more deterministic algorithm is hiding a flaw in the code.fix(deps): bump internal packages to latest matching version via yarn…
aarongeorge commentedon Jan 14, 2019
I was having this issue myself using:
Using the following code words:
However if I change it to use a template literal with a placeholder:
I get the error: Cannot read property 'range' of null.
It seems to be an issue with using template literals that contain a placeholder as using:
I upgraded babel-eslint's package.json to the following and it fixes the issue:
Also @hzoo is there any reason as to why babel-eslint has babel-eslint as a devDependency?
lizuncong commentedon Jan 14, 2019
ldwqh0 commentedon Jan 14, 2019
It looks like this problem has been resolved !
I changed this .babelrc to babel.config.js in my project
package.json
{ "name": "element-seed", "version": "1.3.1", "description": "A Vue.js project", "author": "ldwqh0 <ldwqh0@outlook.com>", "private": true, "scripts": { "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "start": "npm run dev", "lint": "eslint --ext .js,.vue src", "build": "node build/build.js", "ts-compile": "tsc", "fix": "eslint --fix --ext .js,.vue src" }, "dependencies": { "@babel/polyfill": "^7.0.0", "animate.css": "^3.7.0", "animejs": "^2.2.0", "axios": "^0.18.0", "echarts": "^4.2.0-rc.2", "echarts-wordcloud": "^1.1.3", "element-datatables": "^0.2.3", "element-ui": "^2.4.7", "lodash": "^4.17.11", "qrcodejs2": "^0.0.2", "qs": "^6.5.1", "resize-detector": "^0.1.9", "vue": "^2.5.20", "vue-property-decorator": "^7.1.0", "vue-router": "^3.0.1", "vue2-uploader": "0.1.8", "vuex": "^3.0.1", "vuex-class": "^0.3.0", "wangeditor": "^3.1.1" }, "devDependencies": { "@babel/core": "^7.2.0", "@babel/plugin-proposal-class-properties": "^7.2.1", "@babel/plugin-proposal-decorators": "^7.2.0", "@babel/plugin-proposal-do-expressions": "^7.2.0", "@babel/plugin-proposal-export-default-from": "^7.2.0", "@babel/plugin-proposal-export-namespace-from": "^7.2.0", "@babel/plugin-proposal-function-sent": "^7.2.0", "@babel/plugin-proposal-json-strings": "^7.2.0", "@babel/plugin-proposal-logical-assignment-operators": "^7.2.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0", "@babel/plugin-proposal-numeric-separator": "^7.2.0", "@babel/plugin-proposal-object-rest-spread": "^7.2.0", "@babel/plugin-proposal-optional-chaining": "^7.2.0", "@babel/plugin-proposal-pipeline-operator": "^7.2.0", "@babel/plugin-proposal-throw-expressions": "^7.2.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-import-meta": "^7.2.0", "@babel/plugin-syntax-jsx": "^7.2.0", "@babel/plugin-transform-runtime": "^7.2.0", "@babel/preset-env": "^7.2.0", "@babel/runtime": "^7.2.0", "@types/node": "^10.12.12", "ajv": "^6.6.1", "autoprefixer": "^9.4.2", "babel-eslint": "^10.0.0", "babel-loader": "^8.0.4", "babel-plugin-component": "^1.1.1", "chalk": "^2.0.1", "copy-webpack-plugin": "^4.5.1", "css-loader": "^2.0.0", "eslint": "^5.10.0", "eslint-config-standard": "^12.0.0", "eslint-friendly-formatter": "^4.0.0", "eslint-loader": "^2.1.1", "eslint-plugin-html": "^5.0.0", "eslint-plugin-import": "^2.7.0", "eslint-plugin-node": "^8.0.0", "eslint-plugin-promise": "^4.0.0", "eslint-plugin-standard": "^4.0.0", "eslint-plugin-vue": "^5.0.0", "file-loader": "^3.0.0", "friendly-errors-webpack-plugin": "^1.6.0", "html-webpack-plugin": "^3.1.0", "less": "^3.8.0", "less-loader": "^4.1.0", "mini-css-extract-plugin": "^0.5.0", "mockjs": "^1.0.1-beta3", "node-notifier": "^5.1.0", "node-xlsx": "^0.12.1", "optimize-css-assets-webpack-plugin": "^5.0.0", "ora": "^3.0.0", "portfinder": "^1.0.20", "postcss-import": "^12.0.0", "postcss-loader": "^3.0.0", "postcss-url": "^8.0.0", "rimraf": "^2.6.0", "semver": "^5.3.0", "shelljs": "^0.8.0", "ts-node": "^7.0.1", "typescript": "^3.2.1", "uglifyjs-webpack-plugin": "^2.0.1", "url-loader": "^1.0.0", "vue-loader": "^15.4.0", "vue-style-loader": "^4.1.0", "vue-template-compiler": "^2.5.20", "webpack": "^4.27.1", "webpack-bundle-analyzer": "^3.0.2", "webpack-cli": "^3.1.1", "webpack-dev-server": "^3.1.0", "webpack-merge": "^4.1.0" }, "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" }, "browserslist": [ "> 1%", "last 2 versions", "not ie <= 8" ] }babel.config.js
There is no error in my project when use export module from '../file'
this is my test project
l443018 commentedon Jan 18, 2019
@ldwqh0 could you attach complete error log in output channel?
In my case, I encountered similar log as @dsizomin
I solved it by remove
yarn.lock,node_modulesand runyarn installagain (need to restart VS code): #530 (comment)dallashall-procore commentedon Feb 15, 2019
This problem popped up for me after running
npm audit fixto clear some npm vulnerability warnings, which bumped my version of eslint from v5.8.0 to v5.13.0Removing my
package-lock.jsonandnode_modulesfolder and runningnpm installworked to resolve this in my case.eslint: v5.13.0
babel-eslint: v10.0.1
aramk commentedon May 17, 2019
I fixed this issue by making sure I only have the one version of
@babel/types:I targeted version 7.3.4 and some packages were using the newer 7.4.4. For those packages I reverted to an older version which used @babel/types@7.3.4. I did this without adding the dependency to
package.json. Annpm installis sufficient to update thepackage-lock.json.Then I ran the dedupe command to ensure I had no duplicates of
@babel/types, since having multiple copies of the same version will still cause issues.You should then see that the npm list command shows a single
@babel/typeswithout "dedupe" and all others with it, indicating they're references. After this the linter ran just fine.minhna commentedon Jun 25, 2019
It works. Thank you.
30 remaining items
mhdcodes commentedon May 3, 2020
For any one reading this, here is how I solved this issue :
I added the following snippet to my
.eslintrcunder the rules directive :lolmaus commentedon May 3, 2020
Tried @elhaouari-mohammed 's suggestion. Unfortunately, did not help me.
My error happens at build time, so ESLint does not seem to be involved.
mhdcodes commentedon May 3, 2020
@lolmaus Actually for me it's the gitlab pipelines that fails because of eslint, everything works on local environment and on deploy server, so it's really weird , as @NicholasIoanJones said : Appeared out of nowhere.
lolmaus commentedon May 3, 2020
I've noticed that the error message has changed for me.
Instead of
Cannot read property 'range' of nullit's now sayingDebug failure.lolmaus commentedon May 4, 2020
Both error messages are very generic.
Multiple unrelated issues might lead to them.
agm1984 commentedon May 5, 2020
I started reproducing this earlier today while pasting code into my project. It seemed like ES Lint got overwhelmed by hundreds of infractions.
At the moment, I am seeing this:
That piece of code is:
Simply commenting out the
importkeyword fixes it.I tried wrapping the problematic block with
/* eslint-disable */and/* eslint-enable */, but the dynamic import keyword's appearance breaks the engine.I changed the code to concatenation:
I've never seen this error before from "just template literals", so if I had anything to contribute, it would be that the
importkeyword is related. When I remove that keyword but keep the template literal, it un-breaks ES Lint.packetstracer commentedon May 17, 2020
i'm using CRA (react-scripts@3.4.1), yarn and react-app-rewired@2.1.6 and this issue happens to me only transpiling the tests (yarn test) with import sentences using template literals such as this one:
Neither of the commented solutions worked for me but using the patch of disabling the corresponding eslint rules. To me this is not a valid solution, but by the moment will use it.
cdll commentedon Jun 1, 2020
same issue here with
"babel-eslint": "^10.0.1"in @vue/cli.paschalidi commentedon Jun 1, 2020
adding to the package.json would solve the issue for me
Also run
to clean all history of npm modules in your project and then reinstall them using
KrishnaPG commentedon Jul 1, 2020
Facing the same problem with below code:
Following the @richardvanbergen suggestion above, removed the template string and instead used as below and the warning went away.
Hope to see this fixed soon.
romulof commentedon Jul 1, 2020
@ljqx:
I'm getting this error with
template-curly-spacingandindentrules with thisnode_moduleslayout:@babeltraverse@7.10.1node_modulesdebug(non related, i guess)msty(non related, i guess)types@7.10.1node_modulesbabel-eslint@10.1.0node_modulesAdjusting both rules like this works:
@aramk:
I have just a single version of
@babel/types:[linter] Fix linter errors, see babel/babel-eslint#681
fix: babel-eslint crashing with dynamic import
Powersource commentedon Jul 16, 2020
I believe (although not sure) I started getting this when updating from babel-eslint 10.0.3 to 10.1.0
🚨 Add range error workaround