File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ let options = {}
8
8
let importIndex = 0
9
9
let createImportedName = options && options . createImportedName || ( ( importName /*, path*/ ) => `i__const_${ importName . replace ( / \W / g, '_' ) } _${ importIndex ++ } ` )
10
10
11
- export default css => {
11
+ export default ( css , result ) => {
12
12
let importAliases = [ ]
13
13
let definitions = { }
14
14
@@ -49,6 +49,10 @@ export default css => {
49
49
if ( matchImports . exec ( atRule . params ) ) {
50
50
addImport ( atRule )
51
51
} else {
52
+ if ( atRule . params . indexOf ( '@value' ) !== - 1 ) {
53
+ result . warn ( 'Invalid value definition: ' + atRule . params )
54
+ }
55
+
52
56
addDefinition ( atRule )
53
57
}
54
58
} )
Original file line number Diff line number Diff line change @@ -19,6 +19,16 @@ describe('constants', () => {
19
19
test ( '@value red blue;' , ':export {\n red: blue\n}' )
20
20
} )
21
21
22
+ it ( 'gives an error when there is no semicolon between lines' , ( ) => {
23
+ const input = '@value red blue\n@value green yellow'
24
+ let processor = postcss ( [ constants ] )
25
+ const result = processor . process ( input )
26
+ const warnings = result . warnings ( )
27
+
28
+ assert . equal ( warnings . length , 1 )
29
+ assert . equal ( warnings [ 0 ] . text , 'Invalid value definition: red blue\n@value green yellow' )
30
+ } )
31
+
22
32
it ( 'should export a more complex constant' , ( ) => {
23
33
test ( '@value small (max-width: 599px);' , ':export {\n small: (max-width: 599px)\n}' )
24
34
} )
You can’t perform that action at this time.
0 commit comments