@@ -10,32 +10,30 @@ const fs = require('fs');
1010const path = require ( 'path' ) ;
1111const { ESLint} = require ( 'eslint' ) ;
1212const plugin = require ( '..' ) ;
13+ const parser = require ( '../parser' ) ;
1314
14- const FIXTURES_DIR = path . join (
15- __dirname ,
16- 'fixtures' ,
17- 'src' ,
18- 'content'
19- ) ;
20- const PARSER_PATH = path . join ( __dirname , '..' , 'parser.js' ) ;
21-
15+ const FIXTURES_DIR = path . join ( __dirname , 'fixtures' , 'src' , 'content' ) ;
2216function createESLint ( { fix = false } = { } ) {
2317 return new ESLint ( {
24- useEslintrc : false ,
18+ overrideConfigFile : true ,
2519 fix,
26- plugins : {
27- 'local-rules' : plugin ,
28- } ,
29- overrideConfig : {
30- parser : PARSER_PATH ,
31- plugins : [ 'local-rules' ] ,
32- rules : {
33- 'local-rules/lint-markdown-code-blocks' : 'error' ,
34- } ,
35- parserOptions : {
36- sourceType : 'module' ,
20+ overrideConfig : [
21+ {
22+ files : [ '**/*.md' ] ,
23+ languageOptions : {
24+ parser,
25+ parserOptions : {
26+ sourceType : 'module' ,
27+ } ,
28+ } ,
29+ plugins : {
30+ 'local-rules' : plugin ,
31+ } ,
32+ rules : {
33+ 'local-rules/lint-markdown-code-blocks' : 'error' ,
34+ } ,
3735 } ,
38- } ,
36+ ] ,
3937 } ) ;
4038}
4139
@@ -53,11 +51,7 @@ async function lintFixture(name, {fix = false} = {}) {
5351
5452async function run ( ) {
5553 const basicResult = await lintFixture ( 'basic-error.md' ) ;
56- assert . strictEqual (
57- basicResult . messages . length ,
58- 1 ,
59- 'expected one diagnostic'
60- ) ;
54+ assert . strictEqual ( basicResult . messages . length , 1 , 'expected one diagnostic' ) ;
6155 assert (
6256 basicResult . messages [ 0 ] . message . includes ( 'Calling setState during render' ) ,
6357 'expected message to mention setState during render'
@@ -91,9 +85,7 @@ async function run() {
9185 fix : true ,
9286 } ) ;
9387 assert (
94- duplicateFixed . output . includes (
95- "{expectedErrors: {'react-compiler': [4]}}"
96- ) ,
88+ duplicateFixed . output . includes ( "{expectedErrors: {'react-compiler': [4]}}" ) ,
9789 'expected duplicates to be rewritten to a single canonical block'
9890 ) ;
9991 assert (
@@ -118,14 +110,12 @@ async function run() {
118110 fix : true ,
119111 } ) ;
120112 assert (
121- malformedFixed . output . includes (
122- "{expectedErrors: {'react-compiler': [4]}}"
123- ) ,
113+ malformedFixed . output . includes ( "{expectedErrors: {'react-compiler': [4]}}" ) ,
124114 'expected malformed metadata to be replaced with canonical form'
125115 ) ;
126116}
127117
128- run ( ) . catch ( error => {
118+ run ( ) . catch ( ( error ) => {
129119 console . error ( error ) ;
130120 process . exitCode = 1 ;
131121} ) ;
0 commit comments