File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 1- export default function validate ( ) { }
1+ import forEach from 'lodash.foreach' ;
2+ import { is } from './utility' ;
3+ import { format } from 'util' ;
4+
5+ const rules = {
6+ // hook
7+ extensions : 'array' ,
8+ preprocessCss : 'function' ,
9+ processCss : 'function' ,
10+ to : 'string' ,
11+ // plugins
12+ append : 'array' ,
13+ prepend : 'array' ,
14+ use : 'array' ,
15+ createImportedName : 'function' ,
16+ generateScopedName : 'function|string' ,
17+ mode : 'string' ,
18+ rootDir : 'string' ,
19+ } ;
20+
21+ export default function validate ( options = { } ) {
22+ forEach ( rules , ( types , rule ) => {
23+ if ( ! options [ rule ] ) {
24+ return ;
25+ }
26+
27+ if ( ! types . split ( '|' ) . some ( type => is ( type , options [ rule ] ) ) ) {
28+ throw new Error ( format ( 'should specify %s for the %s' , types , rule ) ) ;
29+ } ;
30+ } ) ;
31+ }
You can’t perform that action at this time.
0 commit comments