Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Cannot read property '_tokenIndex' of undefined in v.1.11.0 #1013

Closed
lencioni opened this issue Feb 7, 2015 · 5 comments
Closed

Cannot read property '_tokenIndex' of undefined in v.1.11.0 #1013

lencioni opened this issue Feb 7, 2015 · 5 comments
Labels

Comments

@lencioni
Copy link
Contributor

lencioni commented Feb 7, 2015

Thanks for all the great work on this tool and congrats on the latest release. However, I just upgraded from 1.10.0 to 1.11.0 and ran into this error:

TypeError: Cannot read property '_tokenIndex' of undefined
    at Object.JsFile.getNextToken (/Users/joe/brigade/node_modules/jscs/lib/js-file.js:265:26)
    at /Users/joe/brigade/node_modules/jscs/lib/rules/require-space-before-object-values.js:53:37
    at Array.forEach (native)
    at /Users/joe/brigade/node_modules/jscs/lib/rules/require-space-before-object-values.js:43:29
    at Array.forEach (native)
    at Object.JsFile.iterateNodesByType (/Users/joe/brigade/node_modules/jscs/lib/js-file.js:379:42)
    at Object.module.exports.check (/Users/joe/brigade/node_modules/jscs/lib/rules/require-space-before-object-values.js:42:14)
    at null.<anonymous> (/Users/joe/brigade/node_modules/jscs/lib/string-checker.js:157:22)
    at Array.forEach (native)
    at StringChecker.checkString (/Users/joe/brigade/node_modules/jscs/lib/string-checker.js:155:35)

Removing this line from my .jscsrc file makes the error go away:

"requireSpaceBeforeObjectValues": true,

Here's some of my config that might be interesting?

  "fileExtensions": [".js", ".jsx"],
  "esnext": true,
  "esprima": "./node_modules/esprima-fb",

Let me know if I can provide any more info, or if there is something that I am doing wrong here.

@mikesherov
Copy link
Contributor

Thanks for contributing! Can you please:

  1. Provide the offending source file.
  2. Try not providing a custom esprima?
  3. Try passing tolerant: false as the esprimaOptions in your config?

@mrjoelkemp mrjoelkemp added the bug label Feb 7, 2015
@lencioni
Copy link
Contributor Author

lencioni commented Feb 7, 2015

I whittled it down to this case:

var myobj = {
  myfunc() {
    return null;
  }
};

It seems to be related to the ES6 object literal property value shorthand syntax. Removing custom esprima and adding "esprimaOptions": { "tolerant": false }, had no effect.

@qfox
Copy link
Member

qfox commented Feb 8, 2015

Looks like myfunc in { myfunc() { return null; } } doesn't evaluated as shorthand. Imo it should be fixed in esprima.

https://github.com/jscs-dev/node-jscs/blob/master/lib/rules/require-space-after-object-keys.js#L44

@mikesherov
Copy link
Contributor

@zxqfox, can you file an ESPrima bug? http://github.com/jquery/esprima

@qfox
Copy link
Member

qfox commented Feb 8, 2015

@mikesherov Thanks ;-) done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants