-
Notifications
You must be signed in to change notification settings - Fork 61
Support styled-components-breakpoint #182
Comments
Sorry, now all interpolations will be treated as black boxes during the linting. Because the processor is a static code analyzer, which can't know meanings of interpolations. |
@chinesedfan what do you mean with 'treated as black boxes'? |
@daviddelusenet That means the processor doesn't know contents of interpolations. So |
Ah ok, thanks for your explanation! However, don't you think stuff like this needs to be supported? As the popularity and usage of Styled Components grows a lot more people will start using tools like I don't think this is the way the go since you'll be basically killing this processor. Maybe it's a solution to implement something like this (based on how Eslint handles inline configuration):
Quite simple: you add some comments arounds your interpolations which don't get linted by default. If Stylelint encounters these comments it will just assume that everything in between these comments and in interpolations is CSS and will lint it. What do you think about this solution? |
@daviddelusenet it's not by choice that they are black boxes, it's because interpolations are JS, and we only do static code analysis, which I'm pretty sure is also what ESlint does, unless we evaluate the javascript (which very often would include evaluating imported variables from other libraries and files etc. which really quickly becomes close to an impossible task) we don't know what to lint. What a processor does is basically take a file, extract the CSS and hand the CSS to Stylelint that then does the actual linting (and we give it sourcemaps so it can give errors on the correct lines). If you can come up with something brilliant to work around this, I'd love to hear it, but it's not as simple as you think |
It's way easier to just define the breakpoint medias as strings rather than template functions:
This lints correctly, and also syntax highlighting in VSCode works as expected. |
I just installed styled-components-breakpoint inside of my project and noticed the following: CSS inside of breakpoint declarations doesn't get linted.
This is my code:
]
When I run Stylelint inside of my terminal I get the following output:
So all of the code inside of the
${breakpoint('medium')``}
statements gets ignored. Can this be solved?Thanks in advance!
The text was updated successfully, but these errors were encountered: