@@ -16,6 +16,8 @@ const tagToName = {
1616 security : 'security scheme name' ,
1717} ;
1818
19+ const openAPIRegex = / ^ ( G E T | P U T | P O S T | D E L E T E | O P T I O N S | H E A D | P A T C H | T R A C E ) \/ .* $ / ;
20+
1921const missing = ( context , comment , tag , name ) => {
2022 const commentLines = comment . value . split ( / \r \n | \r | \n / ) ;
2123 const start = commentLines [ tag . line ] . indexOf ( `@${ tag . tag } ` ) ;
@@ -56,13 +58,9 @@ const statusCodeUndefined = (context, comment, tag, status) => {
5658 } ) ;
5759} ;
5860
59- function parseErrors ( comment , context ) {
61+ function parseErrors ( comment , jsDocComment , context ) {
6062 const seenResponses = [ ] ;
6163
62- const openAPIRegex = / ^ ( G E T | P U T | P O S T | D E L E T E | O P T I O N S | H E A D | P A T C H | T R A C E ) \/ .* $ / ;
63-
64- const [ jsDocComment ] = parseComments ( `/*${ comment . value } */` ) ;
65-
6664 if ( openAPIRegex . test ( jsDocComment . description ) ) {
6765 jsDocComment . tags . forEach ( ( tag ) => {
6866 // const commentLines = comment.value.split(/\r\n|\r|\n/);
@@ -226,11 +224,7 @@ function parseErrors(comment, context) {
226224 }
227225}
228226
229- function parse ( comment , context ) {
230- const openAPIRegex = / ^ ( G E T | P U T | P O S T | D E L E T E | O P T I O N S | H E A D | P A T C H | T R A C E ) \/ .* $ / ;
231-
232- const [ jsDocComment ] = parseComments ( `/*${ comment . value } */` ) ;
233-
227+ function parse ( comment , jsDocComment , context ) {
234228 if ( openAPIRegex . test ( jsDocComment . description ) ) {
235229 const [ method , path ] = jsDocComment . description . split ( ' ' ) ;
236230
@@ -387,7 +381,10 @@ function getComments(cb) {
387381 node . comments
388382 . filter ( ( comment ) => comment . type === 'Block' )
389383 . forEach ( ( comment ) => {
390- cb ( comment ) ;
384+ const [ jsDocComment ] = parseComments ( `/*${ comment . value } */` ) ;
385+ if ( jsDocComment ) {
386+ cb ( comment , jsDocComment ) ;
387+ }
391388 } ) ;
392389 } ,
393390 } ;
@@ -397,15 +394,15 @@ module.exports = {
397394 rules : {
398395 errors : {
399396 create : function ( context ) {
400- return getComments ( ( comment ) => {
401- parseErrors ( comment , context ) ;
397+ return getComments ( ( comment , jsDocComment ) => {
398+ parseErrors ( comment , jsDocComment , context ) ;
402399 } ) ;
403400 } ,
404401 } ,
405402 warnings : {
406403 create : ( context ) => {
407- return getComments ( ( comment ) => {
408- parse ( comment , context ) ;
404+ return getComments ( ( comment , jsDocComment ) => {
405+ parse ( comment , jsDocComment , context ) ;
409406 } ) ;
410407 } ,
411408 } ,
0 commit comments