File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,13 @@ const create = context => {
284284
285285 const { sourceCode} = context ;
286286 const comments = sourceCode . getAllComments ( ) ;
287+
288+ const isEslintDirectiveComment = comment => {
289+ // Strip leading whitespace and optional `*` from block comments
290+ const normalizedComment = comment . value . trimStart ( ) . replace ( / ^ \* \s * / , '' ) ;
291+ return / ^ e s l i n t (?: - (?: e n | d i s ) a b l e ) ? (?: - (?: n e x t - ) ? l i n e ) ? \b / . test ( normalizedComment ) ;
292+ } ;
293+
287294 const unusedComments = comments
288295 . filter ( token => token . type !== 'Shebang' )
289296 // Block comments come as one.
@@ -319,6 +326,10 @@ const create = context => {
319326
320327 // eslint-disable-next-line complexity
321328 function processComment ( comment ) {
329+ if ( isEslintDirectiveComment ( comment ) ) {
330+ return ;
331+ }
332+
322333 if ( ignoreRegexes . some ( ignore => ignore . test ( comment . value ) ) ) {
323334 return ;
324335 }
Original file line number Diff line number Diff line change @@ -114,6 +114,18 @@ test({
114114 code : '// TODO [2001-01-01]: quite old' ,
115115 options : [ { date : '2000-01-01' } ] ,
116116 } ,
117+ {
118+ code : `// eslint-disable-next-line rule-to-test/expiring-todo-comments
119+ // TODO without a date` ,
120+ options : [ { allowWarningComments : false } ] ,
121+ } ,
122+ {
123+ code : `/* eslint-disable rule-to-test/expiring-todo-comments */
124+ // TODO without a date
125+ // fixme [2000-01-01]: too old'
126+ /* eslint-enable rule-to-test/expiring-todo-comments */` ,
127+ options : [ { allowWarningComments : false } ] ,
128+ } ,
117129 ] ,
118130 invalid : [
119131 {
You can’t perform that action at this time.
0 commit comments