@@ -40,174 +40,209 @@ function runResolverTests(resolver) {
40
40
// CommonJS modules
41
41
test ( {
42
42
code : 'require("./../files/malformed.js")' ,
43
+ output : 'require("../files/malformed.js")' ,
43
44
options : [ { commonjs : true } ] ,
44
45
errors : [ 'Useless path segments for "./../files/malformed.js", should be "../files/malformed.js"' ] ,
45
46
} ) ,
46
47
test ( {
47
48
code : 'require("./../files/malformed")' ,
49
+ output : 'require("../files/malformed")' ,
48
50
options : [ { commonjs : true } ] ,
49
51
errors : [ 'Useless path segments for "./../files/malformed", should be "../files/malformed"' ] ,
50
52
} ) ,
51
53
test ( {
52
54
code : 'require("../files/malformed.js")' ,
55
+ output : 'require("./malformed.js")' ,
53
56
options : [ { commonjs : true } ] ,
54
57
errors : [ 'Useless path segments for "../files/malformed.js", should be "./malformed.js"' ] ,
55
58
} ) ,
56
59
test ( {
57
60
code : 'require("../files/malformed")' ,
61
+ output : 'require("./malformed")' ,
58
62
options : [ { commonjs : true } ] ,
59
63
errors : [ 'Useless path segments for "../files/malformed", should be "./malformed"' ] ,
60
64
} ) ,
61
65
test ( {
62
66
code : 'require("./test-module/")' ,
67
+ output : 'require("./test-module")' ,
63
68
options : [ { commonjs : true } ] ,
64
69
errors : [ 'Useless path segments for "./test-module/", should be "./test-module"' ] ,
65
70
} ) ,
66
71
test ( {
67
72
code : 'require("./")' ,
73
+ output : 'require(".")' ,
68
74
options : [ { commonjs : true } ] ,
69
75
errors : [ 'Useless path segments for "./", should be "."' ] ,
70
76
} ) ,
71
77
test ( {
72
78
code : 'require("../")' ,
79
+ output : 'require("..")' ,
73
80
options : [ { commonjs : true } ] ,
74
81
errors : [ 'Useless path segments for "../", should be ".."' ] ,
75
82
} ) ,
76
83
test ( {
77
84
code : 'require("./deep//a")' ,
85
+ output : 'require("./deep/a")' ,
78
86
options : [ { commonjs : true } ] ,
79
87
errors : [ 'Useless path segments for "./deep//a", should be "./deep/a"' ] ,
80
88
} ) ,
81
89
82
90
// CommonJS modules + noUselessIndex
83
91
test ( {
84
92
code : 'require("./bar/index.js")' ,
93
+ output : 'require("./bar/")' ,
85
94
options : [ { commonjs : true , noUselessIndex : true } ] ,
86
95
errors : [ 'Useless path segments for "./bar/index.js", should be "./bar/"' ] , // ./bar.js exists
87
96
} ) ,
88
97
test ( {
89
98
code : 'require("./bar/index")' ,
99
+ output : 'require("./bar/")' ,
90
100
options : [ { commonjs : true , noUselessIndex : true } ] ,
91
101
errors : [ 'Useless path segments for "./bar/index", should be "./bar/"' ] , // ./bar.js exists
92
102
} ) ,
93
103
test ( {
94
104
code : 'require("./importPath/")' ,
105
+ output : 'require("./importPath")' ,
95
106
options : [ { commonjs : true , noUselessIndex : true } ] ,
96
107
errors : [ 'Useless path segments for "./importPath/", should be "./importPath"' ] , // ./importPath.js does not exist
97
108
} ) ,
98
109
test ( {
99
110
code : 'require("./importPath/index.js")' ,
111
+ output : 'require("./importPath")' ,
100
112
options : [ { commonjs : true , noUselessIndex : true } ] ,
101
113
errors : [ 'Useless path segments for "./importPath/index.js", should be "./importPath"' ] , // ./importPath.js does not exist
102
114
} ) ,
103
115
test ( {
104
116
code : 'require("./importType/index")' ,
117
+ output : 'require("./importType")' ,
105
118
options : [ { commonjs : true , noUselessIndex : true } ] ,
106
119
errors : [ 'Useless path segments for "./importType/index", should be "./importType"' ] , // ./importPath.js does not exist
107
120
} ) ,
108
121
test ( {
109
122
code : 'require("./index")' ,
123
+ output : 'require(".")' ,
110
124
options : [ { commonjs : true , noUselessIndex : true } ] ,
111
125
errors : [ 'Useless path segments for "./index", should be "."' ] ,
112
126
} ) ,
113
127
test ( {
114
128
code : 'require("../index")' ,
129
+ output : 'require("..")' ,
115
130
options : [ { commonjs : true , noUselessIndex : true } ] ,
116
131
errors : [ 'Useless path segments for "../index", should be ".."' ] ,
117
132
} ) ,
118
133
test ( {
119
134
code : 'require("../index.js")' ,
135
+ output : 'require("..")' ,
120
136
options : [ { commonjs : true , noUselessIndex : true } ] ,
121
137
errors : [ 'Useless path segments for "../index.js", should be ".."' ] ,
122
138
} ) ,
123
139
124
140
// ES modules
125
141
test ( {
126
142
code : 'import "./../files/malformed.js"' ,
143
+ output : 'import "../files/malformed.js"' ,
127
144
errors : [ 'Useless path segments for "./../files/malformed.js", should be "../files/malformed.js"' ] ,
128
145
} ) ,
129
146
test ( {
130
147
code : 'import "./../files/malformed"' ,
148
+ output : 'import "../files/malformed"' ,
131
149
errors : [ 'Useless path segments for "./../files/malformed", should be "../files/malformed"' ] ,
132
150
} ) ,
133
151
test ( {
134
152
code : 'import "../files/malformed.js"' ,
153
+ output : 'import "./malformed.js"' ,
135
154
errors : [ 'Useless path segments for "../files/malformed.js", should be "./malformed.js"' ] ,
136
155
} ) ,
137
156
test ( {
138
157
code : 'import "../files/malformed"' ,
158
+ output : 'import "./malformed"' ,
139
159
errors : [ 'Useless path segments for "../files/malformed", should be "./malformed"' ] ,
140
160
} ) ,
141
161
test ( {
142
162
code : 'import "./test-module/"' ,
163
+ output : 'import "./test-module"' ,
143
164
errors : [ 'Useless path segments for "./test-module/", should be "./test-module"' ] ,
144
165
} ) ,
145
166
test ( {
146
167
code : 'import "./"' ,
168
+ output : 'import "."' ,
147
169
errors : [ 'Useless path segments for "./", should be "."' ] ,
148
170
} ) ,
149
171
test ( {
150
172
code : 'import "../"' ,
173
+ output : 'import ".."' ,
151
174
errors : [ 'Useless path segments for "../", should be ".."' ] ,
152
175
} ) ,
153
176
test ( {
154
177
code : 'import "./deep//a"' ,
178
+ output : 'import "./deep/a"' ,
155
179
errors : [ 'Useless path segments for "./deep//a", should be "./deep/a"' ] ,
156
180
} ) ,
157
181
158
182
// ES modules + noUselessIndex
159
183
test ( {
160
184
code : 'import "./bar/index.js"' ,
185
+ output : 'import "./bar/"' ,
161
186
options : [ { noUselessIndex : true } ] ,
162
187
errors : [ 'Useless path segments for "./bar/index.js", should be "./bar/"' ] , // ./bar.js exists
163
188
} ) ,
164
189
test ( {
165
190
code : 'import "./bar/index"' ,
191
+ output : 'import "./bar/"' ,
166
192
options : [ { noUselessIndex : true } ] ,
167
193
errors : [ 'Useless path segments for "./bar/index", should be "./bar/"' ] , // ./bar.js exists
168
194
} ) ,
169
195
test ( {
170
196
code : 'import "./importPath/"' ,
197
+ output : 'import "./importPath"' ,
171
198
options : [ { noUselessIndex : true } ] ,
172
199
errors : [ 'Useless path segments for "./importPath/", should be "./importPath"' ] , // ./importPath.js does not exist
173
200
} ) ,
174
201
test ( {
175
202
code : 'import "./importPath/index.js"' ,
203
+ output : 'import "./importPath"' ,
176
204
options : [ { noUselessIndex : true } ] ,
177
205
errors : [ 'Useless path segments for "./importPath/index.js", should be "./importPath"' ] , // ./importPath.js does not exist
178
206
} ) ,
179
207
test ( {
180
208
code : 'import "./importPath/index"' ,
209
+ output : 'import "./importPath"' ,
181
210
options : [ { noUselessIndex : true } ] ,
182
211
errors : [ 'Useless path segments for "./importPath/index", should be "./importPath"' ] , // ./importPath.js does not exist
183
212
} ) ,
184
213
test ( {
185
214
code : 'import "./index"' ,
215
+ output : 'import "."' ,
186
216
options : [ { noUselessIndex : true } ] ,
187
217
errors : [ 'Useless path segments for "./index", should be "."' ] ,
188
218
} ) ,
189
219
test ( {
190
220
code : 'import "../index"' ,
221
+ output : 'import ".."' ,
191
222
options : [ { noUselessIndex : true } ] ,
192
223
errors : [ 'Useless path segments for "../index", should be ".."' ] ,
193
224
} ) ,
194
225
test ( {
195
226
code : 'import "../index.js"' ,
227
+ output : 'import ".."' ,
196
228
options : [ { noUselessIndex : true } ] ,
197
229
errors : [ 'Useless path segments for "../index.js", should be ".."' ] ,
198
230
} ) ,
199
231
test ( {
200
232
code : 'import("./")' ,
233
+ output : 'import(".")' ,
201
234
errors : [ 'Useless path segments for "./", should be "."' ] ,
202
235
parser : require . resolve ( 'babel-eslint' ) ,
203
236
} ) ,
204
237
test ( {
205
238
code : 'import("../")' ,
239
+ output : 'import("..")' ,
206
240
errors : [ 'Useless path segments for "../", should be ".."' ] ,
207
241
parser : require . resolve ( 'babel-eslint' ) ,
208
242
} ) ,
209
243
test ( {
210
244
code : 'import("./deep//a")' ,
245
+ output : 'import("./deep/a")' ,
211
246
errors : [ 'Useless path segments for "./deep//a", should be "./deep/a"' ] ,
212
247
parser : require . resolve ( 'babel-eslint' ) ,
213
248
} ) ,
0 commit comments