styled-components / vscode-styled-components

Syntax highlighting for styled-components
MIT License
917 stars 118 forks source link

Media query string interpolation error, "( expectedts-styled-plugin(9999)" #369

Open mnogiec opened 2 years ago

mnogiec commented 2 years ago

Describe the bug (including copyable syntax) I have a breakpoints object with such structure in my code:

export const breakpoints = {
  iphoneSE: { query: '(max-width: 320px)' },
  mobile: { query: '(max-width: 576px)' },
  small: { query: '(max-width: 768px)' },
  smallLaptop: { query: '(max-width: 1024px)' },
  medium: { query: '(max-width: 1280px)' },
};

And I use it with media queries inside Styled Component just like that:

export const Container = styled.div`
  padding-bottom: 5px;

  @media screen and ${breakpoints?.mobile.query} {
    padding-bottom: 10px;
  }
`;

Unfortunately each time there appears to be an error with such message: ( expectedts-styled-plugin(9999)

Screenshot

image

To Reproduce A very basic app created using CRA, install styled-components and try to use above breakpoints object inside string interpolation of media query.

Expected behavior Don't throw such error, as strings in given object do have "(" in them. After disabling this extension the problem disappears.

Build environment (please complete the following information):

Slowl commented 2 years ago

More than a year that I have the same issue and it appears that nobody want to fix / add flexibility to disable tslint, crazy

jasonwilliams commented 2 years ago

@Slowl whats stopping you from having a go and fixing it yourself? We have a whole guide on contributing https://github.com/styled-components/vscode-styled-components/blob/master/CONTRIBUTING.md

Slowl commented 2 years ago

Sorry if I seemed rude with my comment, I was just surprised to see the same issue still popping up after a year.

As soon as I have free time I will, but it's the same problem for everyone I guess :)

elzup commented 2 years ago

Alternative code

const errorCase1 = css`
-   @media screen and ${val} {
+   ${`@media screen and ${val}`} {
        padding-bottom: 10px;
    }
`

const errorCase2 = keyframes`
-   ${50}% {
+   ${`${50}%`} {
        padding-bottom: 10px;
    }
`
Screen Shot 2022-08-11 at 19 18 09