jscs-dev / jscs-jsdoc

JsDoc validation rules for jscs
MIT License
99 stars 35 forks source link

Function is missing documentation for parameter `undefined` with default parameters #194

Open jipodine opened 8 years ago

jipodine commented 8 years ago

Hi,

When using an empty object as a default parameter, in a function, a method, or a constructor, I get the following errors, with jscs@2.11.0 and jscs-jsdoc@1.3.1:

jsDoc: Function is missing documentation for parameter `undefined`. at [...]
    30 | * @returns {AudioBuffer}
    31 | */
    32 |export function createDiracBuffer(options = {}) {
jsDoc: Function is missing documentation for parameter `undefined`. at [...]
   140 |   * @returns {Array.<String>} URLs that match every filter.
   141 |   */
   142 |  getUrls(options = {}) {
jsDoc: Function is missing documentation for parameter `undefined`. at [...]
    58 |
    59 |   */
    60 |  constructor(options = {}) {

With the configuration

  "jsDoc": {
    "checkAnnotations": true,
    "checkParamExistence": true,
    "checkParamNames": true,
    "checkRedundantParams": true,
    "checkRedundantReturns": true,
    "checkReturnTypes": true,
    "checkTypes": true,
    "enforceExistence": {
      "allExcept": [
        "arrow",
        "expressions"
      ]
    },
    "requireParamTypes": true,
    "requireReturnTypes": true
  }

And yes, option is defined:

/**
 * Create a Dirac buffer, zero-padded.
 *
 * Warning: the default length is 2 samples,
 * to by-pass a bug in Safari ≤ 9.
 *
 * @param {Object} options
 * @param {AudioContext} options.audioContext must be defined
 * @param {Number} [options.channelCount=1]
 * @param {Number} [options.gain=0] in dB
 * @param {Number} [options.length=2] in samples
 * @returns {AudioBuffer}
 */
export function createDiracBuffer(options = {}) {

Am I missing a configuration somewhere?

qfox commented 8 years ago

Looks like there is an error with wrong calculating line in checkAnnotations. This rule requires description for EVERY param in your jsdoc. You have 2 lines with missing description: @param {Object} options and @param {Number} [options.channelCount=1]. Also I'm not sure about @returns, prob it requires description too.

You can safely disable this rule to prevent errors of this kind.