Skip to content

destructuring parameters fail checkParamNames #90

@AlexanderZeilmann

Description

@AlexanderZeilmann

These days I'm often using the following pattern to pass variables to functions

var f = function ({prop1, prop2}) {
  return prop1 + prop2;
};

This leads to the problem, that the destructuring object doesn't have a name, which is required by checkParamNames.

Giving the parameter no name, leads to the Missing param name error

/**
 * [f description]
 *
 * @param  {Object}
---^
 * @return {String} Some string
 */

Giving it a random name leads to the Expected undefined but got object error.

/**
 * [f description]
 *
 * @param  {Object} object
--------------------^
 * @return {String} Some string
 */

Trying to hack it with undefined gives a Parameters undefined and undefined are out of order error.

/**
 * [f description]
 *
 * @param  {Object} undefined
--------------------^
 * @return {String} Some string
 */

My .jscsrc:

  "jsDoc": {
    "checkParamNames": true,
    "checkRedundantParams": true,
    "requireParamTypes": true,
    "checkReturnTypes": true,
    "checkRedundantReturns": true,
    "requireReturnTypes": true,
    "checkTypes": true,
    "checkRedundantAccess": true,
    "leadingUnderscoreAccess": "private",
    "enforceExistence": true,
    "checkAnnotations": true,
    "requireReturnTypes": true,
    "checkRedundantAccess": true,
    "requireHyphenBeforeDescription": true
  },

Is there a way I can get this to work properly? If there is nothing implemented right now, I would suggest automatically disabling the checkParamNames rule for destructuring parameters. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions