csslint icon indicating copy to clipboard operation
csslint copied to clipboard

calc() causing RBRACE Expected error

Open constantology opened this issue 14 years ago • 10 comments

Hi,

we use CSSLint at work and I broke the build with code similar to:


.selector {
    border   : 1px solid #ccc ; 
    padding  : 4px 8px 3px ; 
    width    : 99% ; 
        width : -moz-calc( 100% - 16px ) ; 
        width : -webkit-calc( 100% - 16px ) ; 
    width    : calc( 100% - 16px ) ; 
    }

The error we get is something like, RBRACE Expected at line X....

This has happened when calc() is used for heights and widths. I've noticed that there is no support for calc in CSSLint right now, is there a plan to add it any time soon?

constantology avatar May 02 '12 18:05 constantology

Ah yes, the parser doesn't yet support calc(). It's a bit tricky to add, but it's definitely time to do it.

nzakas avatar May 02 '12 18:05 nzakas

Ahh cool, thanks! :D

I cloned the repo to see if there was anything in there atm and was going to have a go at adding support myself, then submitting a pull request.

Unfortunately, time constraints for our project mean my time is required elsewhere, shame though, I would have liked to have taken a deep dive in. The code looks hella-sexy btw. ;^)

constantology avatar May 02 '12 18:05 constantology

This should be fixed in v0.9.10.

nzakas avatar Jan 17 '13 19:01 nzakas

Are we sure this is fixed? I'm coming across the same error using 0.9.10. Specific case is:

CSS: height: -webkit-calc(100% + 2px); Complaint: 1: error at line 183, col 36, Expected RBRACE at line 183, col 36

I couldn't find any docs on ignoring this line specifically. Would that be possible in the interm?

ejzn avatar Feb 13 '13 05:02 ejzn

I just tried it and didn't get an error. It's possible that there is an error somewhere close to that line but not necessarily with the calc().

On Tue, Feb 12, 2013 at 9:07 PM, Erik Johnson [email protected]:

Are we sure this is fixed? I'm coming across the same error using 0.9.10. Specific case is:

CSS: height: -webkit-calc(100% + 2px); Complaint: 1: error at line 183, col 36, Expected RBRACE at line 183, col 36

I couldn't find any docs on ignoring this line specifically. Would that be possible in the interm?

— Reply to this email directly or view it on GitHubhttps://github.com/stubbornella/csslint/issues/267#issuecomment-13474802.


Nicholas C. Zakas @slicknet

Author, Professional JavaScript for Web Developers Buy it at Amazon.com: http://www.amazon.com/Professional-JavaScript-Developers-Nicholas-Zakas/dp/1118026691/ref=sr_1_3

nzakas avatar Feb 18 '13 19:02 nzakas

Thanks for the response. Must be incompatibility with my specific node version. I'll try a couple different things.

ejzn avatar Feb 19 '13 16:02 ejzn

@nzakas this still causes an error when the expression uses parenthesis itself, like the valid calc((5em - 100%) / -2).

dougwilson avatar Jul 22 '13 18:07 dougwilson

Same for me with this line: width: calc((100% - 20px) / 3);

ZorGleH avatar Jul 29 '13 09:07 ZorGleH

I just noticed the same today with http://csslint.net with

    width:  calc(((100% - 15%) / 3 - 1px) * 3 + 10%);

lborgman avatar Mar 30 '14 18:03 lborgman

@nzakas, what's the reason for not applying/re-using the fix from https://github.com/CSSLint/parser-lib/pull/113?

tophf avatar Mar 09 '15 08:03 tophf