-
-
Notifications
You must be signed in to change notification settings - Fork 209
Template string failing with Cannot read property 'range' of null #799
Comments
Solution in #530 (comment) worked for me. |
Same for me, I'm having issues where eslint after upgrading from |
@ethansisson good point, for me simply just doing |
Thanks man. |
@einsiol it worked |
It shows same error on code with dynamic import, template literal inline and rule Tested on:
Sample code:import(`${'package.json'}`) .eslintrc.json{
"parser": "babel-eslint",
"rules": {
"template-curly-spacing": ["error", "never"]
}
} Workaround:Declare the template literal in a I was not knowledgeable enough to fix it, hope someone will. EDIT:It looks like the problem is actually coming from |
I resolved this by adding |
works for me eslint config "rules": {
"indent": [
"error",
2,
{
"ignoredNodes": [
"TemplateLiteral"
]
}
],
"template-curly-spacing": [
"off"
]
}, |
this suddenly started failing after a recent yarn upgrade
replaced by
Fixed the error, but now am getting this warning instead Can also confirm that adding this to my eslint rules also works as an alternative
|
@yitomok pretty much nails it I think. Happens with a vue/airbnb setup as well:
I've yet to see a stack trace so here's mine:
@einsiol's solution did not work for me either. Here's my setup: eslintrc.js
package.json
index.js
|
Adding this to package.json is a temporary work-around: "resolutions": {
"@babel/parser": "7.7.5"
} Then delete node_modules, package-lock.json/yarn.lock and then run |
I'm facing the same situation, when TemplateLiteral is inside a dynamic import statement, error occurs. I found the |
This worked for me! I tried all the others solutions, but none of them worked. Until this one, just added |
This comment has been minimized.
This comment has been minimized.
It worked for me. thanks! |
I had to install yarn beforehand with (warning: the ubuntu package of yarn seems buggy for now) |
Same issue here. Assigning the template to a const is not a viable option for me, as to do so breaks the webpack chunk naming mechanism. As I don't like messing up with dependencies I've disabled the problematic rules for now, but I hope for a better solution soon.... |
Why this issue is appears again and again? |
Updates |
I too had issues after using nullish coalescing (
|
Looks like you just switched from the Babel eslint parser to the typescript eslint parser, which isn't really relevant to this issue, and will not work for everyone depending on which Babel plugins they're using. |
Hi! While we are in the same boat for this issue, a better version for "resolutions": {
"babel-eslint/@babel/parser": "7.7.5"
}, This helps only using old For the alternative workaround, there was a difference for switch-case ident. So i used: {
"rules": {
"indent": [
"error",
2,
{
"SwitchCase": 1,
"ignoredNodes": [
"TemplateLiteral"
]
}
],
"template-curly-spacing": 0
}
} |
The template string issue may be a separate issue from the nullish coalescing issue, so I'm gonna open a new ticket for the nullish coalescing and ref this thread. |
My workaround was to not use backticks to interpolate strings. I refactored this:
into this:
and voila, it worked. |
@joemaffei I'm having this issue with a Vue.js component containing this code: this.dynamicComponent = () => import('~/static/blog/${this.fileName}.md').then((loaded) => {
// ... but, unfortunately, turning it into this.dynamicComponent = () => import('~/static/blog/'
+ this.fileName + '.md').then((loaded) => {
// ... didn't work. I'm still getting $ npx eslint --version gives "parser": "vue-eslint-parser",
"parserOptions": {
"parser": "babel-eslint",
"ecmaVersion": 2018,
"sourceType": "module"
}, because before that ESlint complained about "unexpected import". Edit: What ultimately worked for me is the |
Fixed in |
@JLHwung I'm still experiencing this issue with const foo = import(`${bar}`); I've created a small repo to reproduce this issue: https://github.com/miikka/babel-eslint-799-repro |
Thank you for the PR. Now that |
Upgraded to 10.0.3 and now everywhere in my .jsx I have template strings, it blows up with this error.
TypeError: Cannot read property 'range' of null
This is my current list of devDependencies
"@babel/core": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-transform-regenerator": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/plugin-transform-template-literals": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.6.0",
"autoprefixer": "^9.1.3",
"babel-eslint": "10.0.3",
"babel-loader": "^8.0.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-istanbul": "^5.2.0",
"babel-plugin-lodash": "^3.3.4",
"babel-preset-react-hmre": "^1.1.1",
"chai": "^3.4.1",
"chai-as-promised": "^5.1.0",
"chai-enzyme": "^1.0.0-beta.1",
"compression-webpack-plugin": "^1.1.11",
"css-loader": "^3.2.0",
"cssnano": "^4.1.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
"eslint": "^6.0.1",
"eslint-config-airbnb": "^10.0.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-babel": "^3.2.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.2.0",
"extract-text-webpack-plugin": "^3.0.2",
"fetch-mock": "^5.10.0",
"file-loader": "^1.1.11",
"fs-extra": "^0.30.0",
"html-webpack-plugin": "^3.2.0",
"image-webpack-loader": "^4.6.0",
"ip": "^1.1.4",
"js-md5": "^0.4.1",
"karma": "^4.3.0",
"karma-chai": "^0.1.0",
"karma-chai-as-promised": "^0.1.2",
"karma-chai-sinon": "^0.1.5",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^4.0.0-beta.0",
"koa-logger": "^1.3.0",
"loader-utils": "^1.1.0",
"lost": "^7.0.3",
"macaddress": "~0.2.9",
"mini-css-extract-plugin": "^0.3.0",
"mocha": "~5.2.0",
"node-noop": "^1.0.0",
"nodemon": "^1.18.7",
"optimize-css-assets-webpack-plugin": "^5.0.0",
"postcss-custom-media": "^7.0.8",
"postcss-focus-visible": "^3.0.0",
"postcss-focus-within": "^2.0.0",
"postcss-import": "^12.0.0",
"postcss-loader": "^3.0.0",
"postcss-nesting": "^6.0.0",
"postcss-preset-env": "^5.3.0",
"postcss-reporter": "^6.0.0",
"puppeteer": "^1.19.0",
"raw-loader": "^0.5.1",
"react-hot-loader": "^3.0.0-beta.7",
"react-text-truncate": "^0.12.0",
"react-toastify": "^2.1.0",
"redbox-react": "^1.5.0",
"redux-devtools": "^3.4.1",
"redux-devtools-dock-monitor": "^1.1.2",
"redux-devtools-log-monitor": "^1.4.0",
"redux-logger": "^3.0.6",
"redux-mock-store": "^1.0.2",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0",
"sonarqube-scanner": "^2.5.0",
"style-loader": "^0.21.0",
"stylelint": "^9.10.1",
"stylelint-webpack-plugin": "^0.10.5",
"svg-sprite-loader": "3.9.0",
"svgo": "^1.3.0",
"svgo-loader": "^2.1.0",
"url-loader": "^1.1.2",
"webpack": "^4.20.2",
"webpack-cli": "^3.0.8",
"webpack-dev-middleware": "^3.1.3",
"webpack-hot-middleware": "^2.22.3",
"webpack-merge": "^4.1.1",
"webpack-modernizr-loader": "^4.0.1"
The text was updated successfully, but these errors were encountered: