Skip to content

Parameter validation wrongly associates closure and doc block #176

Closed
@Krinkle

Description

@Krinkle

JSDuck supports the concept of documenting class members not explicitly declared in code. Typically this is used for creating basic entities for upstream libraries.

Examples:

In general however it uses the rule that a documentation block and code are only associated when directly connected. If there is an empty line between, then it is no longer associated.

So e.g.

/**
 * Descriptive description of Foo.
 *
 * @class Foo
 */

/**
 * Descriptive description of bar.
 *
 * @method bar
 * @param x
 */

( function ( $ ) {
  ..
}( jQuery ) );

Would not associate method bar with the closure. And it would not throw a warning about parameter x not matching $, for two reasons:

  • There is a new line in between.
  • It is not a plain function declaration or expression assigned to a property in an object literal, or variable assignment. As such, the function seen there is irrelevant.

The same is like this:

/**
 * @param x
 */
var foo = ( function ( y, z ) {
  ..
  return function ( x ) { .. };
}( 1, 2 ) );

I'm not sure whether this error is a regression, or that it is part of a new rule. But for Wikimedia, jquery.suggestions.js (source code) is causing the following warning:

   27 | * @param {Object} options
13:54:14 Expected $ but got options at ./resources/src/jquery/jquery.suggestions.js :

Because it is wrongly associating the block with the closure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions