styled-components / webstorm-styled-components

styled-components highlighting support in IntelliJ editors
https://plugins.jetbrains.com/plugin/9997-styled-components
MIT License
375 stars 19 forks source link

\t chapter in copy-pasted code #88

Closed volos-st closed 4 years ago

volos-st commented 4 years ago
vladsholokhov commented 4 years ago

Hello @volos-st ! I see that you have a red line in your code example before @media, is that an error from some linter? Could you also tell does this happen only inside styled components or you can observe the same behavior in plain *.css? Thanks!

volos-st commented 4 years ago

Hy @vladsholokhov yes, it's an error from eslint, but I can reproduce the error with disabled eslint. It does only inside styled-components. All other css files (.css, and especially .scss) works as expected.

I have investigated deeply this problem and found how you can reproduce it

  1. create a simple project with create react app
  2. add styled-components to the project
  3. VERY IMPORTANT - convert all indents to tabs
  4. create new components for example
    const Div = styled.div`
    width: 1000px;
    .App-header {
        background-color: red;
        @media (max-width: 100px) {
            background-color: green;
        }
        @media (max-width: ${breakpoints.mobile}px) {
            background-color: green;
        }
    `;

    you must use tabs as indents symbols inside template string

  5. copy-paste @media (max-width: ${breakpoints.mobile}px) {... block and you will have this problem
  6. without js variable in template strings ${...} all works as expected
vladsholokhov commented 4 years ago

Thank you very much for the details! Reproduced.

Build #WS-202.4884, built on May 28, 2020
Non-Bundled Plugins: com.deadlock.scsyntax (1.1.2)
denofevil commented 4 years ago

This seems to be the problem in JavaScript language support, I've filed WEB-45802 with potential fix.