1
1
import * as path from 'path' ;
2
2
3
- import { test , SYNTAX_CASES } from '../utils' ;
3
+ import { test , SYNTAX_CASES , testVersion } from '../utils' ;
4
4
5
5
import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve' ;
6
6
@@ -22,7 +22,7 @@ function runResolverTests(resolver) {
22
22
}
23
23
24
24
ruleTester . run ( `no-unresolved (${ resolver } )` , rule , {
25
- valid : [
25
+ valid : [ ] . concat (
26
26
test ( { code : 'import "./malformed.js"' } ) ,
27
27
28
28
rest ( { code : 'import foo from "./bar";' } ) ,
@@ -32,6 +32,13 @@ function runResolverTests(resolver) {
32
32
rest ( { code : "import('fs');" ,
33
33
parser : require . resolve ( 'babel-eslint' ) } ) ,
34
34
35
+ // check with eslint parser
36
+ testVersion ( '>= 6' , ( ) => rest ( {
37
+ code : "import('fs');" ,
38
+ parser : require . resolve ( 'espree' ) ,
39
+ parserOptions : { ecmaVersion : 2021 } ,
40
+ } ) ) || [ ] ,
41
+
35
42
rest ( { code : 'import * as foo from "a"' } ) ,
36
43
37
44
rest ( { code : 'export { foo } from "./bar"' } ) ,
@@ -85,7 +92,7 @@ function runResolverTests(resolver) {
85
92
options : [ { commonjs : true } ] } ) ,
86
93
] ,
87
94
88
- invalid : [
95
+ invalid : [ ] . concat (
89
96
rest ( {
90
97
code : 'import reallyfake from "./reallyfake/module"' ,
91
98
settings : { 'import/ignore' : [ '^\\./fake/' ] } ,
@@ -118,9 +125,9 @@ function runResolverTests(resolver) {
118
125
} ] } ) ,
119
126
rest ( {
120
127
code : "import('in-alternate-root').then(function({DEEP}){});" ,
121
- errors : [ { message : 'Unable to resolve path to ' +
122
- " module 'in-alternate-root'." ,
123
- type : 'Literal' ,
128
+ errors : [ {
129
+ message : 'Unable to resolve path to module \ 'in-alternate-root\'.' ,
130
+ type : 'Literal' ,
124
131
} ] ,
125
132
parser : require . resolve ( 'babel-eslint' ) } ) ,
126
133
@@ -131,6 +138,17 @@ function runResolverTests(resolver) {
131
138
errors : [ "Unable to resolve path to module './does-not-exist'." ] ,
132
139
} ) ,
133
140
141
+ // check with eslint parser
142
+ testVersion ( '>= 6' , ( ) => rest ( {
143
+ code : "import('in-alternate-root').then(function({DEEP}){});" ,
144
+ errors : [ {
145
+ message : 'Unable to resolve path to module \'in-alternate-root\'.' ,
146
+ type : 'Literal' ,
147
+ } ] ,
148
+ parser : require . resolve ( 'espree' ) ,
149
+ parserOptions : { ecmaVersion : 2021 } ,
150
+ } ) ) || [ ] ,
151
+
134
152
// export symmetry proposal
135
153
rest ( { code : 'export * as bar from "./does-not-exist"' ,
136
154
parser : require . resolve ( 'babel-eslint' ) ,
@@ -187,7 +205,7 @@ function runResolverTests(resolver) {
187
205
type : 'Literal' ,
188
206
} ] ,
189
207
} ) ,
190
- ] ,
208
+ ) ,
191
209
} ) ;
192
210
193
211
ruleTester . run ( `issue #333 (${ resolver } )` , rule , {
0 commit comments