File tree 2 files changed +19
-6
lines changed
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ export default class LessParser extends Parser {
143
143
let bracket = null ;
144
144
const brackets = [ ] ;
145
145
const start = this . pos ;
146
-
146
+
147
147
// we need pass "()" as spaces
148
148
// However we can override method Parser.loop, but it seems less maintainable
149
149
if ( this . tokens [ start ] [ 0 ] === 'brackets' ) {
@@ -213,7 +213,8 @@ export default class LessParser extends Parser {
213
213
this . unclosedBracket ( bracket ) ;
214
214
}
215
215
216
- if ( end ) {
216
+ // dont process an end of rule if there's only one token and it's unknown (#64)
217
+ if ( end && this . tokens . length > 1 ) {
217
218
const foundEndOfRule = this . processEndOfRule ( {
218
219
start,
219
220
params,
Original file line number Diff line number Diff line change 1
1
// chai uses expressions for validation
2
2
/* eslint no-unused-expressions: 0 */
3
3
4
+ import CssSyntaxError from 'postcss/lib/css-syntax-error' ;
4
5
import { expect } from 'chai' ;
5
6
import lessSyntax from '../lib/less-syntax' ;
6
7
import postcss from 'postcss' ;
7
8
8
9
describe ( '#postcss' , ( ) => {
9
- it ( 'can process LESS syntax' , ( done ) => {
10
+ it ( 'should process LESS syntax' , ( done ) => {
10
11
const lessText = 'a { b {} }' ;
11
12
12
13
postcss ( )
@@ -19,8 +20,8 @@ describe('#postcss', () => {
19
20
done ( ) ;
20
21
} ) . catch ( done ) ;
21
22
} ) ;
22
-
23
- it ( 'can parse LESS mixins as at rules' , ( done ) => {
23
+
24
+ it ( 'should parse LESS mixins as at rules' , ( done ) => {
24
25
const lessText = '.foo (@bar; @baz...) { border: @{baz}; }' ;
25
26
26
27
postcss ( )
@@ -33,4 +34,15 @@ describe('#postcss', () => {
33
34
done ( ) ;
34
35
} ) . catch ( done ) ;
35
36
} ) ;
36
- } ) ;
37
+
38
+ it ( 'should not parse invalid LESS (#64)' , ( done ) => {
39
+ const lessText = '.foo' ;
40
+
41
+ postcss ( )
42
+ . process ( lessText , { syntax : lessSyntax } )
43
+ . catch ( ( err ) => {
44
+ expect ( err ) . to . be . an . instanceof ( CssSyntaxError ) ;
45
+ done ( ) ;
46
+ } ) ;
47
+ } ) ;
48
+ } ) ;
You can’t perform that action at this time.
0 commit comments