@@ -37,7 +37,21 @@ eslint-enable no-console -- ok to use console here
37
37
38
38
<!--
39
39
eslint-disable-line no-console
40
- -->` ;
40
+ -->
41
+
42
+ <!-- eslint markdown/no-html: "error" -->
43
+
44
+ <div> This is a div </div>
45
+
46
+ <!-- eslint-disable markdown/no-html -- ok here -->
47
+
48
+ <!-- eslint markdown/no-html: warn, markdown/no-empty-links: error -->
49
+
50
+ <!-- invalid rule config comments -->
51
+
52
+ <!-- eslint markdown/no-html: [error -->
53
+
54
+ <!-- eslint markdown/no-html: ["error", { allowed: ["b"] ] -->` ;
41
55
42
56
const ast = fromMarkdown ( markdownText ) ;
43
57
@@ -93,7 +107,7 @@ describe("MarkdownSourceCode", () => {
93
107
describe ( "getInlineConfigNodes()" , ( ) => {
94
108
it ( "should return the inline config nodes" , ( ) => {
95
109
const nodes = sourceCode . getInlineConfigNodes ( ) ;
96
- assert . strictEqual ( nodes . length , 5 ) ;
110
+ assert . strictEqual ( nodes . length , 10 ) ;
97
111
98
112
/* eslint-disable no-restricted-properties -- Needed to avoid extra asserts. */
99
113
@@ -137,6 +151,46 @@ describe("MarkdownSourceCode", () => {
137
151
} ,
138
152
} ) ;
139
153
154
+ assert . deepEqual ( nodes [ 5 ] , {
155
+ value : 'eslint markdown/no-html: "error"' ,
156
+ position : {
157
+ start : { line : 25 , column : 1 , offset : 429 } ,
158
+ end : { line : 25 , column : 42 , offset : 470 } ,
159
+ } ,
160
+ } ) ;
161
+
162
+ assert . deepEqual ( nodes [ 6 ] , {
163
+ value : "eslint-disable markdown/no-html -- ok here" ,
164
+ position : {
165
+ start : { line : 29 , column : 1 , offset : 500 } ,
166
+ end : { line : 29 , column : 52 , offset : 551 } ,
167
+ } ,
168
+ } ) ;
169
+
170
+ assert . deepEqual ( nodes [ 7 ] , {
171
+ value : "eslint markdown/no-html: warn, markdown/no-empty-links: error" ,
172
+ position : {
173
+ start : { line : 31 , column : 1 , offset : 553 } ,
174
+ end : { line : 31 , column : 71 , offset : 623 } ,
175
+ } ,
176
+ } ) ;
177
+
178
+ assert . deepEqual ( nodes [ 8 ] , {
179
+ value : "eslint markdown/no-html: [error" ,
180
+ position : {
181
+ start : { line : 35 , column : 1 , offset : 664 } ,
182
+ end : { line : 35 , column : 41 , offset : 704 } ,
183
+ } ,
184
+ } ) ;
185
+
186
+ assert . deepEqual ( nodes [ 9 ] , {
187
+ value : 'eslint markdown/no-html: ["error", { allowed: ["b"] ]' ,
188
+ position : {
189
+ start : { line : 37 , column : 1 , offset : 706 } ,
190
+ end : { line : 37 , column : 63 , offset : 768 } ,
191
+ } ,
192
+ } ) ;
193
+
140
194
/* eslint-enable no-restricted-properties -- Needed to avoid extra asserts. */
141
195
} ) ;
142
196
} ) ;
@@ -157,7 +211,7 @@ describe("MarkdownSourceCode", () => {
157
211
end : { line : 23 , column : 5 , offset : 427 } ,
158
212
} ) ;
159
213
160
- assert . strictEqual ( directives . length , 4 ) ;
214
+ assert . strictEqual ( directives . length , 5 ) ;
161
215
162
216
assert . strictEqual ( directives [ 0 ] . type , "disable-next-line" ) ;
163
217
assert . strictEqual ( directives [ 0 ] . value , "no-console" ) ;
@@ -177,6 +231,45 @@ describe("MarkdownSourceCode", () => {
177
231
assert . strictEqual ( directives [ 3 ] . type , "disable" ) ;
178
232
assert . strictEqual ( directives [ 3 ] . value , "semi" ) ;
179
233
assert . strictEqual ( directives [ 3 ] . justification , "" ) ;
234
+
235
+ assert . strictEqual ( directives [ 4 ] . type , "disable" ) ;
236
+ assert . strictEqual ( directives [ 4 ] . value , "markdown/no-html" ) ;
237
+ assert . strictEqual ( directives [ 4 ] . justification , "ok here" ) ;
238
+ } ) ;
239
+ } ) ;
240
+
241
+ describe ( "applyInlineConfig()" , ( ) => {
242
+ it ( "should return rule configs and problems" , ( ) => {
243
+ const allComments = sourceCode . getInlineConfigNodes ( ) ;
244
+ const { configs, problems } = sourceCode . applyInlineConfig ( ) ;
245
+
246
+ assert . deepStrictEqual ( configs , [
247
+ {
248
+ config : {
249
+ rules : {
250
+ "markdown/no-html" : "error" ,
251
+ } ,
252
+ } ,
253
+ loc : allComments [ 5 ] . position ,
254
+ } ,
255
+ {
256
+ config : {
257
+ rules : {
258
+ "markdown/no-html" : "warn" ,
259
+ "markdown/no-empty-links" : "error" ,
260
+ } ,
261
+ } ,
262
+ loc : allComments [ 7 ] . position ,
263
+ } ,
264
+ ] ) ;
265
+
266
+ assert . strictEqual ( problems . length , 2 ) ;
267
+ assert . strictEqual ( problems [ 0 ] . ruleId , null ) ;
268
+ assert . match ( problems [ 0 ] . message , / F a i l e d t o p a r s e / u) ;
269
+ assert . strictEqual ( problems [ 0 ] . loc , allComments [ 8 ] . position ) ;
270
+ assert . strictEqual ( problems [ 1 ] . ruleId , null ) ;
271
+ assert . match ( problems [ 1 ] . message , / F a i l e d t o p a r s e / u) ;
272
+ assert . strictEqual ( problems [ 1 ] . loc , allComments [ 9 ] . position ) ;
180
273
} ) ;
181
274
} ) ;
182
275
@@ -243,6 +336,44 @@ describe("MarkdownSourceCode", () => {
243
336
] ,
244
337
[ 1 , "html" , "<!--\n eslint-disable-line no-console\n -->" ] ,
245
338
[ 2 , "html" , "<!--\n eslint-disable-line no-console\n -->" ] ,
339
+ [ 1 , "html" , '<!-- eslint markdown/no-html: "error" -->' ] ,
340
+ [ 2 , "html" , '<!-- eslint markdown/no-html: "error" -->' ] ,
341
+ [ 1 , "html" , "<div> This is a div </div>" ] ,
342
+ [ 2 , "html" , "<div> This is a div </div>" ] ,
343
+ [
344
+ 1 ,
345
+ "html" ,
346
+ "<!-- eslint-disable markdown/no-html -- ok here -->" ,
347
+ ] ,
348
+ [
349
+ 2 ,
350
+ "html" ,
351
+ "<!-- eslint-disable markdown/no-html -- ok here -->" ,
352
+ ] ,
353
+ [
354
+ 1 ,
355
+ "html" ,
356
+ "<!-- eslint markdown/no-html: warn, markdown/no-empty-links: error -->" ,
357
+ ] ,
358
+ [
359
+ 2 ,
360
+ "html" ,
361
+ "<!-- eslint markdown/no-html: warn, markdown/no-empty-links: error -->" ,
362
+ ] ,
363
+ [ 1 , "html" , "<!-- invalid rule config comments -->" ] ,
364
+ [ 2 , "html" , "<!-- invalid rule config comments -->" ] ,
365
+ [ 1 , "html" , "<!-- eslint markdown/no-html: [error -->" ] ,
366
+ [ 2 , "html" , "<!-- eslint markdown/no-html: [error -->" ] ,
367
+ [
368
+ 1 ,
369
+ "html" ,
370
+ '<!-- eslint markdown/no-html: ["error", { allowed: ["b"] ] -->' ,
371
+ ] ,
372
+ [
373
+ 2 ,
374
+ "html" ,
375
+ '<!-- eslint markdown/no-html: ["error", { allowed: ["b"] ] -->' ,
376
+ ] ,
246
377
[ 2 , "root" , void 0 ] ,
247
378
] ) ;
248
379
} ) ;
0 commit comments