@@ -9,8 +9,33 @@ const NODE_MODULES = '../../node_modules';
99
1010const parsers = {
1111 BABEL_ESLINT : path . join ( __dirname , NODE_MODULES , 'babel-eslint' ) ,
12+ '@BABEL_ESLINT' : path . join ( __dirname , NODE_MODULES , '@babel/eslint-parser' ) ,
1213 TYPESCRIPT_ESLINT : path . join ( __dirname , NODE_MODULES , 'typescript-eslint-parser' ) ,
1314 '@TYPESCRIPT_ESLINT' : path . join ( __dirname , NODE_MODULES , '@typescript-eslint/parser' ) ,
15+ babelParserOptions : function parserOptions ( test , features ) {
16+ return Object . assign ( { } , test . parserOptions , {
17+ requireConfigFile : false ,
18+ babelOptions : {
19+ presets : [
20+ '@babel/preset-react' ,
21+ ] ,
22+ plugins : [
23+ '@babel/plugin-syntax-do-expressions' ,
24+ '@babel/plugin-syntax-function-bind' ,
25+ [ '@babel/plugin-syntax-decorators' , { legacy : true } ] ,
26+ ] ,
27+ } ,
28+ ecmaFeatures : Object . assign (
29+ { } ,
30+ test . parserOptions && test . parserOptions . ecmaFeatures ,
31+ {
32+ jsx : true ,
33+ modules : true ,
34+ legacyDecorators : features . has ( 'decorators' ) ,
35+ }
36+ ) ,
37+ } ) ;
38+ } ,
1439 all : function all ( tests ) {
1540 const t = flatMap ( tests , ( test ) => {
1641 if ( typeof test === 'string' ) {
@@ -25,7 +50,7 @@ const parsers = {
2550 const es = test . parserOptions && test . parserOptions . ecmaVersion ;
2651
2752 function addComment ( testObject , parser ) {
28- const extraComment = `\n// features: [${ Array . from ( features ) . join ( ',' ) } ], parser: ${ parser } ` ;
53+ const extraComment = `\n// features: [${ Array . from ( features ) . join ( ',' ) } ], parser: ${ parser } , parserOptions: ${ testObject . parserOptions } ` ;
2954 return Object . assign (
3055 { } ,
3156 testObject ,
@@ -46,6 +71,8 @@ const parsers = {
4671 || ( features . has ( 'fragment' ) && semver . satisfies ( version , '< 5' ) ) ;
4772
4873 const skipBabel = features . has ( 'no-babel' ) ;
74+ const skipOldBabel = skipBabel || semver . satisfies ( version , '>= 8' ) ;
75+ const skipNewBabel = skipBabel || features . has ( 'types' ) || features . has ( 'flow' ) || features . has ( 'ts' ) || features . has ( 'no-babel-new' ) ;
4976 const skipTS = semver . satisfies ( version , '< 5' )
5077 || features . has ( 'flow' )
5178 || features . has ( 'no-ts' )
@@ -57,7 +84,11 @@ const parsers = {
5784
5885 return [ ] . concat (
5986 skipBase ? [ ] : addComment ( test , 'default' ) ,
60- skipBabel ? [ ] : addComment ( Object . assign ( { } , test , { parser : parsers . BABEL_ESLINT } ) , 'babel-eslint' ) ,
87+ skipOldBabel ? [ ] : addComment ( Object . assign ( { } , test , { parser : parsers . BABEL_ESLINT } ) , 'babel-eslint' ) ,
88+ skipNewBabel ? [ ] : addComment ( Object . assign ( { } , test , {
89+ parser : parsers [ '@BABEL_ESLINT' ] ,
90+ parserOptions : parsers . babelParserOptions ( test , features ) ,
91+ } ) , '@babel/eslint-parser' ) ,
6192 tsOld ? addComment ( Object . assign ( { } , test , { parser : parsers . TYPESCRIPT_ESLINT } ) , 'typescript-eslint' ) : [ ] ,
6293 tsNew ? addComment ( Object . assign ( { } , test , { parser : parsers [ '@TYPESCRIPT_ESLINT' ] } ) , '@typescript/eslint' ) : [ ]
6394 ) ;
0 commit comments