dart-sass icon indicating copy to clipboard operation
dart-sass copied to clipboard

Improve error message for "a:b" with no nesting in indented syntax

Open hunterashaw opened this issue 5 years ago • 6 comments

I'm receiving a warning message when I render what I thought was simple sass code:

.header { background-color:#ffffffb2; border-bottom:#0000004c; box-shadow:0 0 20px #0000004c; top:0px; left:0px; width:100%; height:70px; position:absolute; a{ font-size:1rem; display:inline; padding:2rem 3rem; color:#0000004c;}}

`WARNING on line 18, column 5 of stdin: This selector doesn't have any properties and won't be rendered. ╷ 18 │ position:absolute │ ^^^^^^^^^^^^^^^^^ ╵

WARNING on line 21, column 9 of stdin: This selector doesn't have any properties and won't be rendered. ╷ 21 │ display:inline │ ^^^^^^^^^^^^^^ `

Can anyone see my problem here because this looks like a bug to me. I need those display and position styles to render and they are being left out of the output CSS...

Edit: I had to change the indented sass code above to scss code in order for it to start working (and the comment editor doesn't allow indented code???). Not sure if this is a bug with the indented parser

hunterashaw avatar Dec 28 '19 16:12 hunterashaw

So this is the file I'm giving sass to compile and it's still giving me the warnings from above...

test.txt

hunterashaw avatar Dec 28 '19 16:12 hunterashaw

I posted this in stack overflow and got an answer. Apparently I needed spaces after the colon on those particular styles. Is there a good reason why sass requires this?

hunterashaw avatar Dec 28 '19 19:12 hunterashaw

In order to avoid being too dependent on keeping up with the latest CSS specs, Sass doesn't have any knowledge about what specific identifiers are valid property or selector names. This means that when it sees something like foo:bar, it doesn't know whether to parse that as a property declaration or a selector followed by a pseudo-selector. It defaults to the latter, which is why you're seeing those errors.

nex3 avatar Jan 16 '20 01:01 nex3

Would it be possible to throw a better error here, covering this? It seems like this has the potential to cause difficult to debug confusion.

brookjordan avatar Jun 05 '20 04:06 brookjordan

+1 on this. Complete showstopper for me, and there is no indication in the documentation that unlike in CSS spaces after colons are absolutely necessary.

ThisTheThe avatar Dec 08 '23 14:12 ThisTheThe

Reopening this to improve the messaging.

nex3 avatar Dec 11 '23 21:12 nex3