@@ -11,12 +11,7 @@ const path = require('path');
1111const { ESLint} = require ( 'eslint' ) ;
1212const plugin = require ( '..' ) ;
1313
14- const FIXTURES_DIR = path . join (
15- __dirname ,
16- 'fixtures' ,
17- 'src' ,
18- 'content'
19- ) ;
14+ const FIXTURES_DIR = path . join ( __dirname , 'fixtures' , 'src' , 'content' ) ;
2015const PARSER_PATH = path . join ( __dirname , '..' , 'parser.js' ) ;
2116
2217function createESLint ( { fix = false } = { } ) {
@@ -53,11 +48,7 @@ async function lintFixture(name, {fix = false} = {}) {
5348
5449async function run ( ) {
5550 const basicResult = await lintFixture ( 'basic-error.md' ) ;
56- assert . strictEqual (
57- basicResult . messages . length ,
58- 1 ,
59- 'expected one diagnostic'
60- ) ;
51+ assert . strictEqual ( basicResult . messages . length , 1 , 'expected one diagnostic' ) ;
6152 assert (
6253 basicResult . messages [ 0 ] . message . includes ( 'Calling setState during render' ) ,
6354 'expected message to mention setState during render'
@@ -91,9 +82,7 @@ async function run() {
9182 fix : true ,
9283 } ) ;
9384 assert (
94- duplicateFixed . output . includes (
95- "{expectedErrors: {'react-compiler': [4]}}"
96- ) ,
85+ duplicateFixed . output . includes ( "{expectedErrors: {'react-compiler': [4]}}" ) ,
9786 'expected duplicates to be rewritten to a single canonical block'
9887 ) ;
9988 assert (
@@ -118,14 +107,43 @@ async function run() {
118107 fix : true ,
119108 } ) ;
120109 assert (
121- malformedFixed . output . includes (
122- "{expectedErrors: {'react-compiler': [4]}}"
123- ) ,
110+ malformedFixed . output . includes ( "{expectedErrors: {'react-compiler': [4]}}" ) ,
124111 'expected malformed metadata to be replaced with canonical form'
125112 ) ;
113+
114+ const validHighlightResult = await lintFixture ( 'valid-highlight.md' ) ;
115+ assert . strictEqual (
116+ validHighlightResult . messages . length ,
117+ 0 ,
118+ 'expected a valid inline highlight to pass'
119+ ) ;
120+
121+ const missingHighlightResult = await lintFixture ( 'missing-highlight.md' ) ;
122+ assert . strictEqual (
123+ missingHighlightResult . messages . length ,
124+ 1 ,
125+ 'expected a highlight with text missing from its line to fail'
126+ ) ;
127+ assert . strictEqual (
128+ missingHighlightResult . messages [ 0 ] . message ,
129+ "Could not find 'submitAction' on highlighted line 1"
130+ ) ;
131+
132+ const outOfBoundsHighlightResult = await lintFixture (
133+ 'out-of-bounds-highlight.md'
134+ ) ;
135+ assert . strictEqual (
136+ outOfBoundsHighlightResult . messages . length ,
137+ 1 ,
138+ 'expected an out-of-bounds highlight line to fail'
139+ ) ;
140+ assert . strictEqual (
141+ outOfBoundsHighlightResult . messages [ 0 ] . message ,
142+ 'Code highlight line 3 is outside this code block'
143+ ) ;
126144}
127145
128- run ( ) . catch ( error => {
146+ run ( ) . catch ( ( error ) => {
129147 console . error ( error ) ;
130148 process . exitCode = 1 ;
131149} ) ;
0 commit comments