@@ -71,6 +71,8 @@ const create = context => {
7171 }
7272 } ;
7373
74+ const isComment = token => token ?. type === 'Block' || token ?. type === 'Line' ;
75+
7476 /**
7577 Find a comment on this node or its parent, in cases where the node passed is part of a variable or export declaration.
7678 @param {import('estree').Node } node
@@ -79,7 +81,7 @@ const create = context => {
7981 let previousToken = sourceCode . getTokenBefore ( node , { includeComments : true } ) ;
8082 let commentableNode = node ;
8183 while (
82- ( previousToken ?. type !== 'Block' && previousToken ?. type !== 'Line' )
84+ ! isComment ( previousToken )
8385 && ( commentableNode . parent . type === 'VariableDeclarator'
8486 || commentableNode . parent . type === 'VariableDeclaration'
8587 || commentableNode . parent . type === 'ExportNamedDeclaration'
@@ -89,7 +91,7 @@ const create = context => {
8991 previousToken = sourceCode . getTokenBefore ( commentableNode , { includeComments : true } ) ;
9092 }
9193
92- if ( previousToken ?. type === 'Block' || previousToken ?. type === 'Line' ) {
94+ if ( isComment ( previousToken ) ) {
9395 return previousToken . value ;
9496 }
9597 } ;
@@ -107,7 +109,7 @@ const create = context => {
107109 . replace ( / ( \* \s * ) * / , '' ) // JSDoc comments like `/** @isolated */` are parsed into `* @isolated`. And `/**\n * @isolated */` is parsed into `*\n * @isolated `
108110 . trim ( )
109111 . toLowerCase ( ) ;
110- const match = options . comments . find ( comment => previousComment === comment || previousComment . startsWith ( `${ comment } - ` ) ) ;
112+ const match = options . comments . find ( comment => previousComment === comment || previousComment . startsWith ( `${ comment } - ` ) || previousComment . startsWith ( ` ${ comment } -- ` ) ) ;
111113 if ( match ) {
112114 return `follows comment ${ JSON . stringify ( match ) } ` ;
113115 }
0 commit comments