File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 55 "url" : " http://gajus.com"
66 },
77 "dependencies" : {
8+ "ajv" : " ^4.11.4" ,
89 "babel-plugin-syntax-jsx" : " ^6.18.0" ,
910 "babel-types" : " ^6.19.0" ,
1011 "generic-names" : " ^1.0.2" ,
Original file line number Diff line number Diff line change @@ -6,11 +6,17 @@ import {
66} from 'path' ;
77import babelPluginJsxSyntax from 'babel-plugin-syntax-jsx' ;
88import BabelTypes from 'babel-types' ;
9+ import Ajv from 'ajv' ;
10+ import optionsSchema from './schemas/optionsSchema.json' ;
911import createObjectExpression from './createObjectExpression' ;
1012import requireCssModule from './requireCssModule' ;
1113import resolveStringLiteral from './resolveStringLiteral' ;
1214import replaceJsxExpressionContainer from './replaceJsxExpressionContainer' ;
1315
16+ const ajv = new Ajv ( ) ;
17+
18+ const validate = ajv . compile ( optionsSchema ) ;
19+
1420export default ( {
1521 types : t
1622} : {
@@ -170,6 +176,13 @@ export default ({
170176 }
171177 } ,
172178 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+
173186 const filename = stats . file . opts . filename ;
174187
175188 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