Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@supports considered by inspection as non valid #62

Open
cedricjimenez opened this issue Feb 13, 2019 · 2 comments
Open

@supports considered by inspection as non valid #62

cedricjimenez opened this issue Feb 13, 2019 · 2 comments

Comments

@cedricjimenez
Copy link

cedricjimenez commented Feb 13, 2019

image

The styled-components plugin (1.0.6) in phpstorm (2018.3) inspection rise an error Invalid CSS selector. Any idea why ?

image

@undeadcat
Copy link
Contributor

Thanks for the issue!
Sorry for abandoning this project for a bit.
A simpler reproduction would be:

const Title = styled(Title)`

  position: relative;
  overflow: hidden;

  @supports (-webkit-line-clamp: 4) {
      -webkit-line-clamp: 1; //parse errors here
      text-overflow: ellipsis;
  }

The cause is: the plugin currently assumes syntax within styled-components string to be LESS but styled-components allows more syntax. We should definitely bring this in line with what's acceptable at runtime.

As a workaround, if I understand correctly, one could surround the properties inside @supports with a rule-set with a '&' selector, it would be processed to the equivalent CSS :

const Title = styled(Title)`
  position: relative;
  overflow: hidden;

  @supports (-webkit-line-clamp: 4) {
    & {
      -webkit-line-clamp: 1;
      text-overflow: ellipsis;
    }
  }
`

@undeadcat
Copy link
Contributor

I'd like bring the plugin closer to parsing the same set of syntex that styled-components actually accepts. @mxstbr, can you help figure out what other syntax styled-components supports that's not present in CSS/Less?

Semicolons seem to be optional, as one example.

It seems to me like styled-components uses stylis.js to parse styles internally, but then there is also the PostCSS parser used in one place.

If stylis is what's used, should I assume the stylis tests are a good reference of what's supported and what's not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants