File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var validateString = require ( 'csstree-validator' ) . validateString ;
4
+
5
+ exports . addon = function ( renderer ) {
6
+ if ( process . env . NODE_ENV !== 'production' ) {
7
+ require ( './__dev__/warnOnMissingDependencies' ) ( 'validate' , renderer , [ 'putRaw' ] ) ;
8
+ }
9
+
10
+ if ( process . env . NODE_ENV === 'production' ) {
11
+ console . warn (
12
+ 'You are using nano-css "validate" in production. ' +
13
+ 'This addon is suggested to be used only in development.'
14
+ ) ;
15
+ }
16
+
17
+ var putRaw = renderer . putRaw ;
18
+
19
+ renderer . putRaw = function ( rawCssRule ) {
20
+ var errors = validateString ( rawCssRule ) [ '<unknown>' ] ;
21
+
22
+ if ( errors . length ) {
23
+ errors . forEach ( function ( error ) {
24
+ console . error ( 'Error in CSS: ' + error . message ) ;
25
+ console . error ( error ) ;
26
+ // eslint-disable-next-line
27
+ console . log ( rawCssRule ) ;
28
+ } ) ;
29
+ }
30
+
31
+ putRaw ( rawCssRule ) ;
32
+ } ;
33
+ } ;
You can’t perform that action at this time.
0 commit comments