@@ -51,6 +51,17 @@ const validModuleConfigs = [
51
51
} ,
52
52
schema : schemaFn ( { rules : { 'loader-prefer-include' : true } } ) ,
53
53
} ,
54
+ {
55
+ // should allow mix of objects and strings in `loaders` array
56
+ input : {
57
+ loaders : [
58
+ {
59
+ test : / f o o / ,
60
+ loaders : [ 'style-loader' , { loader : 'file-loader' } ] ,
61
+ } ,
62
+ ] ,
63
+ } ,
64
+ } ,
54
65
]
55
66
56
67
const invalidModuleConfigs = [
@@ -84,7 +95,10 @@ const invalidModuleConfigs = [
84
95
{ test : / \. l e s s $ / , loaders : [ 1 , 2 ] } ,
85
96
] ,
86
97
} ,
87
- error : { message : '"0" must be a string' , path : 'loaders.0.loaders.0' } ,
98
+ error : {
99
+ message : '"loaders" at position 0 does not match any of the allowed types' ,
100
+ path : 'loaders.0.loaders.0' ,
101
+ } ,
88
102
} ,
89
103
{
90
104
input : {
@@ -152,6 +166,37 @@ const invalidModuleConfigs = [
152
166
} ,
153
167
schema : schemaFn ( { rules : { 'loader-enforce-include-or-exclude' : true } } ) ,
154
168
} ,
169
+ {
170
+ // should enforce `loader` property, if object is found in `loaders` array
171
+ input : {
172
+ loaders : [ {
173
+ test : / f o o / ,
174
+ loaders : [
175
+ { query : { foo : 'bar' } } ,
176
+ ] ,
177
+ } ] ,
178
+ } ,
179
+ error : {
180
+ message : '"loaders" at position 0 does not match any of the allowed types' ,
181
+ path : 'loaders.0.loaders.0' ,
182
+ } ,
183
+ } ,
184
+ {
185
+ // should disallow properties, other than `loader` and `query`
186
+ // in objects inside the `loaders` array
187
+ input : {
188
+ loaders : [ {
189
+ test : / f o o / ,
190
+ loaders : [
191
+ { loader : 'foo' , query : { foo : 'bar' } , include : / f o o / } ,
192
+ ] ,
193
+ } ] ,
194
+ } ,
195
+ error : {
196
+ message : '"loaders" at position 0 does not match any of the allowed types' ,
197
+ path : 'loaders.0.loaders.0' ,
198
+ } ,
199
+ } ,
155
200
]
156
201
157
202
const moduleSchema = schemaFn ( {
0 commit comments