vscode-styled-components icon indicating copy to clipboard operation
vscode-styled-components copied to clipboard

Using .attrs() without a template literal would break highlight

Open lihanqi opened this issue 5 years ago • 5 comments

image

Without the empty template literal it would break the highlight.

image

lihanqi avatar Mar 11 '20 10:03 lihanqi

Possibly related to highlighting breaking on a prettier formatting: Working: image

Breaking hightlight after prettier format: image

EDIT: trying out some combinations, it looks like styled() and .attrs needs to be on the same line to function with this extension.

roffelsaurus avatar Mar 11 '20 11:03 roffelsaurus

its due to the way the regex parses, you can only parse one line at a time. so https://github.com/styled-components/vscode-styled-components/blob/master/syntaxes/styled-components.json#L7 will need adjusting

jasonwilliams avatar Apr 13 '21 22:04 jasonwilliams

@roffelsaurus is this still broken in v1.5.1 ?

jasonwilliams avatar Apr 26 '21 10:04 jasonwilliams

Yes, it still does not highlight in 1.5.1.

image

I am not particularly bothered though, because after discovering styled-components automatically injects dollar props I have switched almost exclusively to an alternate syntax instead of attrs() because it is more concise. The lines are shorter too so they end up on the same line.

`export const CloseIcon = styled(FontIcon)<{ $color: string }> color: ${props => props.$color};

`

roffelsaurus avatar Apr 27 '21 14:04 roffelsaurus

Same here. I was observing, this bug only happens when props is used inside attrs( ), otherwise everything is fine. VSCode 1.57.1

andrefangeloni avatar Jun 27 '21 21:06 andrefangeloni