jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.97k stars 515 forks source link

Error running rule requireObjectKeysOnNewLine #2224

Closed fernandopasik closed 8 years ago

fernandopasik commented 8 years ago

I'm using jscs v3.0.3 and didn't have this problem when I was using v2.11.0.

The code that is producing the error is:

module.exports.someObject = {
  property1: 'property1',
  property2: 'property2',
  method1() {
    // Do some stuff
  }
};

The stack trace:

internalError: Error running rule requireObjectKeysOnNewLine: This is an issue with JSCS and not your codebase.
Please file an issue (with the stack trace below) at: https://github.com/jscs-dev/node-jscs/issues/new
TypeError: Cannot read property 'getLastToken' of undefined
    at Object.JsFile.getLastNodeToken (node_modules/jscs/lib/js-file.js:168:20)
    at Object.<anonymous> (node_modules/jscs/lib/rules/require-object-keys-on-new-line.js:92:43)
    at Array.forEach (native)
    at Object.JsFile.iterateNodesByType (node_modules/jscs/lib/js-file.js:331:42)
    at Object.module.exports.check (node_modules/jscs/lib/rules/require-object-keys-on-new-line.js:85:14)
    at [object Object].<anonymous> (node_modules/jscs/lib/string-checker.js:154:22)
    at Array.forEach (native)
    at [object Object].StringChecker._checkJsFile (node_modules/jscs/lib/string-checker.js:150:31)
    at [object Object].StringChecker.checkString (node_modules/jscs/lib/string-checker.js:92:14)
    at [object Object].<anonymous> (node_modules/jscs/lib/checker.js:56:21)
markelog commented 8 years ago

Can't repro -

$ echo 'requireObjectKeysOnNewLine: true' > .jscsrc
$ echo 'module.exports.someObject = {
  property1: 'property1',
  property2: 'property2',
  method1() {
    // Do some stuff
  }
};
' > test.js
$ jscs test.js
$ jscs --version
3.0.3
fernandopasik commented 8 years ago

It can be reproduced with "requireObjectKeysOnNewLine": { "allExcept": [ "sameLine" ]}