@@ -37,7 +37,21 @@ eslint-enable no-console -- ok to use console here
3737
3838<!--
3939 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"] ] -->` ;
4155
4256const ast = fromMarkdown ( markdownText ) ;
4357
@@ -93,7 +107,7 @@ describe("MarkdownSourceCode", () => {
93107 describe ( "getInlineConfigNodes()" , ( ) => {
94108 it ( "should return the inline config nodes" , ( ) => {
95109 const nodes = sourceCode . getInlineConfigNodes ( ) ;
96- assert . strictEqual ( nodes . length , 5 ) ;
110+ assert . strictEqual ( nodes . length , 10 ) ;
97111
98112 /* eslint-disable no-restricted-properties -- Needed to avoid extra asserts. */
99113
@@ -137,6 +151,46 @@ describe("MarkdownSourceCode", () => {
137151 } ,
138152 } ) ;
139153
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+
140194 /* eslint-enable no-restricted-properties -- Needed to avoid extra asserts. */
141195 } ) ;
142196 } ) ;
@@ -157,7 +211,7 @@ describe("MarkdownSourceCode", () => {
157211 end : { line : 23 , column : 5 , offset : 427 } ,
158212 } ) ;
159213
160- assert . strictEqual ( directives . length , 4 ) ;
214+ assert . strictEqual ( directives . length , 5 ) ;
161215
162216 assert . strictEqual ( directives [ 0 ] . type , "disable-next-line" ) ;
163217 assert . strictEqual ( directives [ 0 ] . value , "no-console" ) ;
@@ -177,6 +231,45 @@ describe("MarkdownSourceCode", () => {
177231 assert . strictEqual ( directives [ 3 ] . type , "disable" ) ;
178232 assert . strictEqual ( directives [ 3 ] . value , "semi" ) ;
179233 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 ) ;
180273 } ) ;
181274 } ) ;
182275
@@ -243,6 +336,44 @@ describe("MarkdownSourceCode", () => {
243336 ] ,
244337 [ 1 , "html" , "<!--\n eslint-disable-line no-console\n -->" ] ,
245338 [ 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+ ] ,
246377 [ 2 , "root" , void 0 ] ,
247378 ] ) ;
248379 } ) ;
0 commit comments