File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
test/lib/rules/validate-jsdoc Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,9 @@ function _simplifyType(node) {
268
268
return res ;
269
269
}
270
270
271
+ var jsPrimitives = 'String Number Boolean Object Array Date Null Undefined Function Array RegExp'
272
+ . toLowerCase ( ) . split ( ' ' ) ;
273
+
271
274
/**
272
275
* Compare parsed jsDocTypes with esprima node
273
276
* @param {SimplifiedType[] } variants - result of jsDocParseType
@@ -278,6 +281,7 @@ function jsDocMatchType (variants, argument) {
278
281
var l ;
279
282
var variant ;
280
283
var type ;
284
+ var primitive ;
281
285
var result = null ;
282
286
283
287
for ( i = 0 , l = variants . length ; i < l ; i += 1 ) {
@@ -288,6 +292,7 @@ function jsDocMatchType (variants, argument) {
288
292
}
289
293
290
294
type = variant . type . toLowerCase ( ) ;
295
+ primitive = jsPrimitives . indexOf ( type ) !== - 1 ;
291
296
292
297
if ( argument . type === 'Literal' ) {
293
298
if ( argument . value === null ) {
@@ -307,7 +312,8 @@ function jsDocMatchType (variants, argument) {
307
312
}
308
313
309
314
} else if ( argument . type === 'ObjectExpression' ) {
310
- result = result || ( type === 'object' || type === 'class' ) ;
315
+ result = result || ( type === 'object' ) ;
316
+ result = result || ( ! primitive ) ;
311
317
312
318
} else if ( argument . type === 'ArrayExpression' ) {
313
319
result = result || ( type === 'array' ) ;
Original file line number Diff line number Diff line change @@ -267,11 +267,13 @@ describe('rules/validate-jsdoc', function () {
267
267
it : 'should not report on `@returns {Class}` for {}. issue #32' ,
268
268
code : function ( ) {
269
269
/**
270
- * @return {Class }
270
+ * @return {SomeObject }
271
271
*/
272
272
Users . prototype . getState = function ( )
273
273
{
274
- return { } ;
274
+ return {
275
+ id : "main"
276
+ } ;
275
277
} ;
276
278
}
277
279
}
You can’t perform that action at this time.
0 commit comments