vscode-styled-components: createGlobalStyle not being auto formatted
Anything inside another styled tag will be properly formatted, for example a styled.div. But a createGlobaStyle function will not have it’s contents formatted. Color is still being applied, but formatting won’t happen.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 22
Same issue, not sure of any side-effects yet but as a workaround, I’m just wrapping the whole thing in the
cssfunction, which seems to re-enable the auto-formatting.flowing code works 💪
fixed in 1.0.0
I’m late to the party but this will also work fine
@luizwhite in nextjs one can write something like this as a workaround
but well I mean…
@alikadir That’s the best solution thus far. It looks like Prettier is looking for the
styledidentifier.@luizwhite this extension does not do formatting, its a prettier (or whatever formatter you use) issue
Issue for me was that multiple formatters were active and I just had to pick a default. You can do so by hitting Shift + Option + F and you’ll get a window asking to select a default. Simply selecting Prettier here solved the non-formatting issue for me.
This is definitely working for me (as of v1.5.2), we even have it passing in our fixtures https://github.com/styled-components/vscode-styled-components/blob/27a0ab882628646d775989075cfb270085e011f2/src/tests/suite/colorize-fixtures/createGlobalStyle.js
Could someone confirm this is still broken and show their extension version?
@ibqn I see this when using your example.
It bugs my Next.js when using that solution, because babel-plugin-styled-components doesn’t quite understand that. So my workaworkaround is just type
styled.beforecreateGlobalStyle, and my formatter already shows me the linting, and i can push my format/fix keyboard shortcut, then save the file after removing the typedstyled.