Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'range' of null error with one-var #10937

Closed
jkrup opened this issue Oct 8, 2018 · 1 comment

Comments

@jkrup
Copy link
Contributor

commented Oct 8, 2018

Tell us about your environment

  • ESLint Version: master
  • Node Version: 8 / 10
  • npm Version: 5

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:

Configuration
{
  module.exports = {
    "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    'one-var': ['error', 'never'],
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

var a = 1, b = 2
eslint file.js

What did you expect to happen?

var a = 1; var b = 2

What actually happened? Please include the actual, raw output from ESLint.

TypeError: Cannot read property 'range' of null
    at SourceCode.getTokenAfter (/Users/justink/eslintbugtest/node_modules/eslint/lib/token-store/index.js:320:18)
    at declaration.declarations.map.declarator (/Users/justink/eslintbugtest/node_modules/eslint/lib/rules/one-var.js:322:47)
    at Array.map (<anonymous>)
    at Object.fixer [as fix] (/Users/justink/eslintbugtest/node_modules/eslint/lib/rules/one-var.js:315:54)
    at normalizeFixes (/Users/justink/eslintbugtest/node_modules/eslint/lib/report-translator.js:176:28)
    at args (/Users/justink/eslintbugtest/node_modules/eslint/lib/report-translator.js:278:18)
    at Object.report (/Users/justink/eslintbugtest/node_modules/eslint/lib/linter.js:830:41)
    at checkVariableDeclaration (/Users/justink/eslintbugtest/node_modules/eslint/lib/rules/one-var.js:480:33)
    at listeners.(anonymous function).forEach.listener (/Users/justink/eslintbugtest/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)

Additional Details:
This only happens if the last statement in the file is a var X, Y, ... statement (and does not terminate with a ;)

@eslint eslint bot added the triage label Oct 8, 2018

@not-an-aardvark not-an-aardvark added bug rule accepted and removed triage labels Oct 8, 2018

@not-an-aardvark

This comment has been minimized.

Copy link
Member

commented Oct 8, 2018

Thanks for the report, I can reproduce this issue.

jkrup added a commit to jkrup/eslint that referenced this issue Oct 8, 2018

@btmills btmills closed this in 543edfa Oct 12, 2018

btmills added a commit that referenced this issue Oct 12, 2018

@eslint eslint bot locked and limited conversation to collaborators Apr 11, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.