File tree Expand file tree Collapse file tree
test/lib/rules/validate-jsdoc Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,6 +268,9 @@ function _simplifyType(node) {
268268 return res ;
269269}
270270
271+ var jsPrimitives = 'String Number Boolean Object Array Date Null Undefined Function Array RegExp'
272+ . toLowerCase ( ) . split ( ' ' ) ;
273+
271274/**
272275 * Compare parsed jsDocTypes with esprima node
273276 * @param {SimplifiedType[] } variants - result of jsDocParseType
@@ -278,6 +281,7 @@ function jsDocMatchType (variants, argument) {
278281 var l ;
279282 var variant ;
280283 var type ;
284+ var primitive ;
281285 var result = null ;
282286
283287 for ( i = 0 , l = variants . length ; i < l ; i += 1 ) {
@@ -288,6 +292,7 @@ function jsDocMatchType (variants, argument) {
288292 }
289293
290294 type = variant . type . toLowerCase ( ) ;
295+ primitive = jsPrimitives . indexOf ( type ) !== - 1 ;
291296
292297 if ( argument . type === 'Literal' ) {
293298 if ( argument . value === null ) {
@@ -307,7 +312,8 @@ function jsDocMatchType (variants, argument) {
307312 }
308313
309314 } else if ( argument . type === 'ObjectExpression' ) {
310- result = result || ( type === 'object' || type === 'class' ) ;
315+ result = result || ( type === 'object' ) ;
316+ result = result || ( ! primitive ) ;
311317
312318 } else if ( argument . type === 'ArrayExpression' ) {
313319 result = result || ( type === 'array' ) ;
Original file line number Diff line number Diff line change @@ -267,11 +267,13 @@ describe('rules/validate-jsdoc', function () {
267267 it : 'should not report on `@returns {Class}` for {}. issue #32' ,
268268 code : function ( ) {
269269 /**
270- * @return {Class }
270+ * @return {SomeObject }
271271 */
272272 Users . prototype . getState = function ( )
273273 {
274- return { } ;
274+ return {
275+ id : "main"
276+ } ;
275277 } ;
276278 }
277279 }
You can’t perform that action at this time.
0 commit comments