@@ -64,29 +64,21 @@ function getAllDirectiveCommentsFromInlineConfigNodes(sourceCode) {
64
64
if (
65
65
result . some (
66
66
( comment ) =>
67
- comment . range [ 0 ] > range [ 1 ] && range [ 0 ] < comment . range [ 1 ]
67
+ comment . range [ 0 ] <= range [ 1 ] && range [ 0 ] <= comment . range [ 1 ]
68
68
)
69
69
) {
70
70
continue
71
71
}
72
72
const nodeText = sourceCode . text . slice ( range [ 0 ] , range [ 1 ] )
73
- // Extract comment content from the comment text.
74
- // The comment format was based on the language comment definition in vscode-eslint.
75
- // See https://github.com/microsoft/vscode-eslint/blob/c0e753713ea9935667e849d91e549adbff213e7e/server/src/languageDefaults.ts#L14
76
- const commentValue =
77
- nodeText . startsWith ( "/*" ) && nodeText . startsWith ( "*/" )
78
- ? nodeText . slice ( 2 , - 2 )
79
- : nodeText . startsWith ( "//" )
80
- ? nodeText . slice ( 2 )
81
- : nodeText . startsWith ( "<!--" ) && nodeText . endsWith ( "-->" )
82
- ? nodeText . slice ( 4 , - 3 )
83
- : nodeText . startsWith ( "###" ) && nodeText . endsWith ( "###" )
84
- ? nodeText . slice ( 1 )
85
- : nodeText . startsWith ( "#" )
86
- ? nodeText . slice ( 1 )
87
- : nodeText
73
+ const commentValue = extractCommentContent ( nodeText )
88
74
const directiveComment = utils . parseDirectiveText ( commentValue )
89
- if ( directiveComment != null ) {
75
+ if (
76
+ directiveComment != null &&
77
+ directiveComment . kind !== "eslint-disable" &&
78
+ directiveComment . kind !== "eslint-disable-line" &&
79
+ directiveComment . kind !== "eslint-disable-next-line" &&
80
+ directiveComment . kind !== "eslint-enable"
81
+ ) {
90
82
result . push ( {
91
83
kind : directiveComment . kind ,
92
84
value : directiveComment . value ,
@@ -102,6 +94,23 @@ function getAllDirectiveCommentsFromInlineConfigNodes(sourceCode) {
102
94
return result
103
95
}
104
96
97
+ function extractCommentContent ( text ) {
98
+ // Extract comment content from the comment text.
99
+ // The comment format was based on the language comment definition in vscode-eslint.
100
+ // See https://github.com/microsoft/vscode-eslint/blob/c0e753713ea9935667e849d91e549adbff213e7e/server/src/languageDefaults.ts#L14
101
+ return text . startsWith ( "/*" ) && text . endsWith ( "*/" )
102
+ ? text . slice ( 2 , - 2 )
103
+ : text . startsWith ( "//" )
104
+ ? text . slice ( 2 )
105
+ : text . startsWith ( "<!--" ) && text . endsWith ( "-->" )
106
+ ? text . slice ( 4 , - 3 )
107
+ : text . startsWith ( "###" ) && text . endsWith ( "###" )
108
+ ? text . slice ( 1 )
109
+ : text . startsWith ( "#" )
110
+ ? text . slice ( 1 )
111
+ : text
112
+ }
113
+
105
114
module . exports = {
106
115
/**
107
116
* Get all directive comments for the given rule context.
0 commit comments