@@ -19,9 +19,20 @@ validateAnnotations.configure = function(options) {
1919
2020 if ( typeof o === 'string' ) {
2121 o = { preset : o } ;
22+ } else if ( typeof o === 'object' ) {
23+ var oKeys = Object . keys ( o ) ;
24+ oKeys . forEach ( function ( key ) {
25+ if ( key === 'preset' ) {
26+ assert ( typeof o . preset === 'string' , 'jsDoc.checkAnnotation.preset should be preset name' ) ;
27+ } else if ( key === 'extra' ) {
28+ assert ( typeof o [ key ] === 'object' , 'jsDoc.checkAnnotation.preset should be `tag: fulfill` map' ) ;
29+ } else {
30+ throw new Error ( 'jsDoc.checkAnnotation.' + key + ' is unsupported field' ) ;
31+ }
32+ } ) ;
2233 }
2334
24- tags = { } ;
35+ tags = Object . create ? Object . create ( null ) : { } ;
2536
2637 if ( o === true ) {
2738 Object . keys ( availablePresets ) . forEach ( function ( preset ) {
@@ -33,15 +44,18 @@ validateAnnotations.configure = function(options) {
3344
3445 } else if ( typeof o === 'object' ) {
3546 if ( o . preset ) {
36- assert ( typeof o . preset === 'string' , 'jsDoc.checkAnnotation.preset should be preset name' ) ;
3747 assert ( availablePresets [ o . preset ] , 'Unknown tag preset ' + o . preset ) ;
3848 Object . keys ( availablePresets [ o . preset ] ) . forEach ( function ( tag ) {
3949 tags [ tag ] = tags [ tag ] || availablePresets [ o . preset ] [ tag ] ;
4050 } ) ;
4151 }
4252 if ( o . extra ) {
4353 Object . keys ( o . extra ) . forEach ( function ( tag ) {
44- tags [ tag ] = o . extra [ tag ] ;
54+ if ( o . extra [ tag ] === null ) {
55+ delete tags [ tag ] ;
56+ } else {
57+ tags [ tag ] = o . extra [ tag ] ;
58+ }
4559 } ) ;
4660 }
4761 }
@@ -53,6 +67,7 @@ validateAnnotations.configure = function(options) {
5367 * @param {JSCS.Errors } errors
5468 */
5569function validateAnnotations ( file , errors ) {
70+ var checkFulfill = true ; //this._options.checkAnnotations.checkFulfill;
5671 var comments = file . getComments ( ) ;
5772 comments . forEach ( function ( commentNode ) {
5873 if ( commentNode . type !== 'Block' || commentNode . value [ 0 ] !== '*' ) {
@@ -66,11 +81,19 @@ function validateAnnotations(file, errors) {
6681 }
6782
6883 node . iterate ( function ( tag ) {
69- if ( ! tags . hasOwnProperty [ tag . id ] ) {
84+ if ( ! ( tag . id in tags ) ) {
7085 errors . add ( 'unavailable tag ' + tag . id , tag . loc ) ;
7186 }
72- else if ( tags [ tag . id ] && ( ! tag . name || ! tag . type ) ) {
73- errors . add ( 'incomplete tag ' + tag . id + ' data' , tag . loc ) ;
87+ if ( ! checkFulfill ) {
88+ return ;
89+ }
90+
91+ // checking tag fullfill
92+ var isFilled = tag . name || tag . type || tag . description ;
93+ if ( tags [ tag . id ] === false && isFilled ) {
94+ errors . add ( 'unexpected data in tag ' + tag . id , tag . loc ) ;
95+ } else if ( tags [ tag . id ] === true && ! isFilled ) {
96+ errors . add ( 'incomplete data in tag ' + tag . id , tag . loc ) ;
7497 }
7598 } ) ;
7699 } ) ;
0 commit comments