jscs-dev/node-jscs

Error running rule jsDoc throws TypeError: node.getFirstToken is not a function

mtpultz opened this issue · 3 comments

Using the config below in my .jscsrc file for jsDoc throws an error. Removing jsDoc from the config stops all the errors, and everything works.

Config

  "jsDoc": {
    "checkAnnotations": true,
    "checkParamExistence": true,
    "checkParamNames": true,
    "requireParamTypes": true,
    "checkRedundantParams": true,
    "checkReturnTypes": true,
    "checkRedundantReturns": true,
    "requireReturnTypes": true,
    "checkTypes": "strictNativeCase",
    "enforceExistence": {
      "allExcept": ["exports"]
    },
    "requireHyphenBeforeDescription": true,
    "disallowNewlineAfterDescription": true,
    "requireDescriptionCompleteSentence": true,
    "requireParamDescription": true
  },

Error

Error running rule jsDoc: 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: node.getFirstToken is not a function
    at findDocCommentBeforeNode (D:\projects\app\node_modules\jscs-jsdoc\lib\rules\validate-jsdoc.js:265:24)
    at Object.getJsdoc (D:\projects\app\node_modules\jscs-jsdoc\lib\rules\validate-jsdoc.js:237:19)
    at Object.checkParamExistence (D:\projects\app\node_modules\jscs-jsdoc\lib\rules\validate-jsdoc\check-param-existence.js:14:14)
    at D:\projects\app\node_modules\jscs-jsdoc\lib\rules\validate-jsdoc.js:128:27
    at Array.forEach (native)
    at Object.<anonymous> (D:\projects\app\node_modules\jscs-jsdoc\lib\rules\validate-jsdoc.js:127:32)
    at Array.forEach (native)
    at Object.JsFile.iterateNodesByType (D:\projects\app\node_modules\jscs\lib\js-file.js:595:42)
    at D:\projects\app\node_modules\jscs-jsdoc\lib\rules\validate-jsdoc.js:120:18

Is jscs-jsdoc included in your deps?

Hi @markelog, yah I have "jscs-jsdoc": "^2.0.0", installed, but I noticed I had this in my config as well:

  "plugins": [
    "jscs-jsdoc"
  ],

Removing this stops the error, I would assume this is needed and without it the jsDoc tests are not run, but I don't see this in the presets for Google or others, and they include jsDoc. I pulled it from the example at https://github.com/jscs-dev/jscs-jsdoc.

  "plugins": [
    "jscs-jsdoc"
  ]

Yeah, this is redundant, jsdoc is jscs dependency for some time now, just remove it - should work fine without it