@@ -6,9 +6,10 @@ interface CommentState {
66 end : number ;
77}
88
9- const reg = new RegExp ( / \/ \/ \s * e s l i n t - d i s a b l e - n e x t - l i n e \b [ \t ] * ( \S * ) \b / g) ;
10-
11- export function create ( reportsUnusedComments = true ) : Plugin {
9+ export function create (
10+ reportsUnusedComments = true ,
11+ reg = new RegExp ( / \/ \/ \s * e s l i n t - d i s a b l e - n e x t - l i n e \b [ \t ] * (?< ruleId > \S * ) \b / g)
12+ ) : Plugin {
1213 return ( { languageService } ) => ( {
1314 resolveDiagnostics ( fileName , results ) {
1415 if (
@@ -21,14 +22,13 @@ export function create(reportsUnusedComments = true): Plugin {
2122 const disabledLines = new Map < number , CommentState > ( ) ;
2223 const disabledLinesByRules = new Map < string , Map < number , CommentState > > ( ) ;
2324 for ( const comment of sourceFile . text . matchAll ( reg ) ) {
24- const line =
25- sourceFile . getLineAndCharacterOfPosition ( comment . index ) . line + 1 ;
26- const rule = comment [ 1 ] ;
27- if ( rule ) {
28- if ( ! disabledLinesByRules . has ( rule ) ) {
29- disabledLinesByRules . set ( rule , new Map ( ) ) ;
25+ const line = sourceFile . getLineAndCharacterOfPosition ( comment . index ) . line + 1 ;
26+ const ruleId = comment . groups ?. ruleId ;
27+ if ( ruleId ) {
28+ if ( ! disabledLinesByRules . has ( ruleId ) ) {
29+ disabledLinesByRules . set ( ruleId , new Map ( ) ) ;
3030 }
31- disabledLinesByRules . get ( rule ) ! . set ( line , {
31+ disabledLinesByRules . get ( ruleId ) ! . set ( line , {
3232 start : comment . index ,
3333 end : comment . index + comment [ 0 ] . length ,
3434 } ) ;
0 commit comments