Babel-eslint: Mixed babel versions through babel-eslint@8 throw error during processing indent in template strings.

Created on 31 Jan 2018  路  12Comments  路  Source: babel/babel-eslint

Sorry for the long title. I have a tough time getting it any shorter. I am currently experience an issue where two of my projects don't work together well anymore. The reason seems to be that the current version of babel-eslint is based on the beta version of babel while my babel preset is being based on v7.

That's the error I am seeing:

> eslint error.js 
Cannot read property 'range' of null
TypeError: Cannot read property 'range' of null
    at OffsetStorage.setDesiredOffset (/Users/swerner/Workspace/test/node_modules/eslint/lib/rules/indent.js:335:45)
    at TemplateLiteral.node.expressions.forEach (/Users/swerner/Workspace/test/node_modules/eslint/lib/rules/indent.js:1306:29)
    at Array.forEach (<anonymous>)
    at Object.TemplateLiteral [as listener] (/Users/swerner/Workspace/test/node_modules/eslint/lib/rules/indent.js:1300:34)
    at Program:exit.listenerCallQueue.filter.forEach.nodeInfo (/Users/swerner/Workspace/test/node_modules/eslint/lib/rules/indent.js:1475:55)
    at Array.forEach (<anonymous>)
    at Program:exit (/Users/swerner/Workspace/test/node_modules/eslint/lib/rules/indent.js:1475:26)
    at listeners.(anonymous function).forEach.listener (/Users/swerner/Workspace/test/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/swerner/Workspace/test/node_modules/eslint/lib/util/safe-emitter.js:47:38)

The checked file looks trivially simple:

var x = {
  foo: `${any}thing`
}

My eslint configuration just extends the preset:

extends:
  - readable

When I force switch to [email protected] everything works fine again:

works-with-old-version

I inspected the code in indent.js inside eslints code base and it seems where with the old version there is a TemplateLiteral there is passed null to setDesiredOffset() when using the new version.

This is the content of my package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-preset-edge": "^1.5.1",
    "eslint-config-readable": "^1.7.0"
  }
}

I am not sure what happens here. It seems eslints code does not protect against null values but this might be okay as it worked before.

I am wondering about what people deeper in the babel eco system are thinking of this.

Most helpful comment

Same problem with 8.2.2 and 4.19.1 :(

All 12 comments

I downgraded babel-eslint in the new minor version of eslint-config-readable and now it works again flawlessly:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-preset-edge": "^1.5.1",
    "eslint-config-readable": "^1.8.0"
  }
}

Quite unfortunate release notes: https://github.com/sebastian-software/eslint-config-readable/releases/tag/1.8.0

I can't see the reasoning why babel-eslint@8 is being published as stable while being based on a beta ecosystem of babel@7. No harm intended. But this seems to be the wrong approach for such a fundamental piece of many ecosystems.

@swernerx same problem, but doing a little research, i 've found at least on my case, that it works just by going back to version 8.2.1; the offending version is 8.2.2

Linking the same issue from eslint. (They seem to agree its a babel-eslint issue)
https://github.com/eslint/eslint/issues/10043

Seems fixed with 8.2.2 and eslint 4.19.0

Sent with GitHawk

Same problem with 8.2.2 and 4.19.1 :(

make sure you鈥檙e using eslint from within your node_modules, not global. also make sure your node_modules are in a good clean state. (delete them, and package lock and reinstall)

Some problem and babel still in beta version

Same problem with 8.2.2 and 4.19.1 with stylelint

Closing this in favor of the other issue.

Hey so on using babel-elint I get the same error ,
Although im using eslint version 4.30
babel-eslint version7.2.2
eslint-config-airbnb version 15.0.2

Was this page helpful?
0 / 5 - 0 ratings