File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ const isEmpty = node =>
1313 || node . type === 'EmptyStatement'
1414 || ( node . type === 'ExpressionStatement' && 'directive' in node ) ;
1515
16+ const isTripleSlashDirective = node =>
17+ node . type === 'Line' && node . value . startsWith ( '/' ) ;
18+
19+ const hasTripeSlashDirectives = comments =>
20+ comments . some ( currentNode => isTripleSlashDirective ( currentNode ) ) ;
21+
1622/** @param {import('eslint').Rule.RuleContext } context */
1723const create = context => {
1824 const filename = context . getPhysicalFilename ( ) . toLowerCase ( ) ;
@@ -27,6 +33,13 @@ const create = context => {
2733 return ;
2834 }
2935
36+ const sourceCode = context . getSourceCode ( ) ;
37+ const comments = sourceCode . getAllComments ( ) ;
38+
39+ if ( hasTripeSlashDirectives ( comments ) ) {
40+ return ;
41+ }
42+
3043 return {
3144 node,
3245 messageId : MESSAGE_ID ,
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ test.snapshot({
3737 'svelte' ,
3838 'tsx' ,
3939 ] . map ( extension => ( { code : '' , filename : `example.${ extension } ` } ) ) ,
40+ ...[
41+ 'd.ts' ,
42+ 'ts' ,
43+ ] . map ( extension => ( { code : '/// <reference types="example" />' , filename : `example.${ extension } ` } ) ) ,
4044 ] ,
4145 invalid : [
4246 ...[
You can’t perform that action at this time.
0 commit comments