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
Closed

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

jkrup opened this issue Oct 8, 2018 · 1 comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@jkrup
Copy link
Contributor

jkrup 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-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Oct 8, 2018
@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 8, 2018
@not-an-aardvark
Copy link
Member

Thanks for the report, I can reproduce this issue.

jkrup added a commit to jkrup/eslint that referenced this issue Oct 8, 2018
btmills added a commit that referenced this issue Oct 12, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 11, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

2 participants