jscs-dev / jscs-jsdoc

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

Parameter validation wrongly associates closure and doc block #176

Closed Krinkle closed 7 years ago

Krinkle commented 8 years ago

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:

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.

paladox commented 8 years ago

@Krinkle should we change /* too /! temporarily until the problem is fixed.

paladox commented 8 years ago

Please reopen this. The problem still happens.

paladox commented 8 years ago

https://integration.wikimedia.org/ci/job/mediawiki-core-npm/8190/console

paladox commented 8 years ago

It is to do with checkParamNames. checkParamNames is causing the error.