File tree 3 files changed +37
-0
lines changed
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 5
5
"url" : " http://gajus.com"
6
6
},
7
7
"dependencies" : {
8
+ "ajv" : " ^4.11.4" ,
8
9
"babel-plugin-syntax-jsx" : " ^6.18.0" ,
9
10
"babel-types" : " ^6.19.0" ,
10
11
"generic-names" : " ^1.0.2" ,
Original file line number Diff line number Diff line change @@ -6,11 +6,17 @@ import {
6
6
} from 'path' ;
7
7
import babelPluginJsxSyntax from 'babel-plugin-syntax-jsx' ;
8
8
import BabelTypes from 'babel-types' ;
9
+ import Ajv from 'ajv' ;
10
+ import optionsSchema from './schemas/optionsSchema.json' ;
9
11
import createObjectExpression from './createObjectExpression' ;
10
12
import requireCssModule from './requireCssModule' ;
11
13
import resolveStringLiteral from './resolveStringLiteral' ;
12
14
import replaceJsxExpressionContainer from './replaceJsxExpressionContainer' ;
13
15
16
+ const ajv = new Ajv ( ) ;
17
+
18
+ const validate = ajv . compile ( optionsSchema ) ;
19
+
14
20
export default ( {
15
21
types : t
16
22
} : {
@@ -170,6 +176,13 @@ export default ({
170
176
}
171
177
} ,
172
178
Program ( path : Object , stats : Object ) : void {
179
+ if ( ! validate ( stats . opts ) ) {
180
+ // eslint-disable-next-line no-console
181
+ console . error ( validate . errors ) ;
182
+
183
+ throw new Error ( 'Invalid configuration' ) ;
184
+ }
185
+
173
186
const filename = stats . file . opts . filename ;
174
187
175
188
filenameMap [ filename ] = {
Original file line number Diff line number Diff line change
1
+ {
2
+ "additionalProperties" : false ,
3
+ "properties" : {
4
+ "context" : {
5
+ "type" : " string"
6
+ },
7
+ "filetypes" : {
8
+ "patternGroups" : {
9
+ ".*" : {
10
+ "type" : " string"
11
+ }
12
+ },
13
+ "type" : " object"
14
+ },
15
+ "generateScopedName" : {
16
+ "type" : " string"
17
+ },
18
+ "webpackHotModuleReloading" : {
19
+ "type" : " boolean"
20
+ }
21
+ },
22
+ "type" : " object"
23
+ }
You can’t perform that action at this time.
0 commit comments