jscs-dev / node-jscs

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

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

Closed mtpultz closed 8 years ago

mtpultz commented 8 years ago

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
markelog commented 8 years ago

Is jscs-jsdoc included in your deps?

mtpultz commented 8 years ago

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.

markelog commented 8 years ago
  "plugins": [
    "jscs-jsdoc"
  ]

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