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 = {}
88let importIndex = 0
99let createImportedName = options && options . createImportedName || ( ( importName /*, path*/ ) => `i__const_${ importName . replace ( / \W / g, '_' ) } _${ importIndex ++ } ` )
1010
11- export default css => {
11+ export default ( css , result ) => {
1212 let importAliases = [ ]
1313 let definitions = { }
1414
@@ -49,6 +49,10 @@ export default css => {
4949 if ( matchImports . exec ( atRule . params ) ) {
5050 addImport ( atRule )
5151 } else {
52+ if ( atRule . params . indexOf ( '@value' ) !== - 1 ) {
53+ result . warn ( 'Invalid value definition: ' + atRule . params )
54+ }
55+
5256 addDefinition ( atRule )
5357 }
5458 } )
Original file line number Diff line number Diff line change @@ -19,6 +19,16 @@ describe('constants', () => {
1919 test ( '@value red blue;' , ':export {\n red: blue\n}' )
2020 } )
2121
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+
2232 it ( 'should export a more complex constant' , ( ) => {
2333 test ( '@value small (max-width: 599px);' , ':export {\n small: (max-width: 599px)\n}' )
2434 } )
You can’t perform that action at this time.
0 commit comments