Parameter validation wrongly associates closure and doc block
Krinkle opened this issue · 4 comments
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:
- https://github.com/senchalabs/jsduck/blob/v5.3.4/js-classes/Array.js
- https://github.com/wikimedia/VisualEditor/blob/REL1_25/.jsduck/external.js
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.
Please reopen this. The problem still happens.
It is to do with checkParamNames. checkParamNames is causing the error.