-
-
Notifications
You must be signed in to change notification settings - Fork 930
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
Fix false positives for styled-components in no-descending-specificity #3862
Comments
Yes, I agree. |
As far as I can see, the fix for this should be contained in v9.10.1? I'm still experiencing this problem with that version. I'm using stylelint with |
@cdauth don't use |
@evilebottnawi I don't know why everyone keeps saying that. When I used it without, it was reporting an error on every inline comment, until I specified |
I think there is confusion because the function of the stylelint now supports two ways of extracting styles from containers (like template literals or The latter came first, but it is being replaced with the former because stylelint processors don't support autofix. When a processor isn't used, the
However, it's a different story with stylelint processors. The What is also muddying the water is that styled-components doesn't use SCSS. The docs say it uses a processor called stylis, which is an SCSS-like preprepressor that supports inline comments. The default PostCSS parser supports everything stylis does except inline comments, which is probably why this issue is only being detected now. It only appears when inline comments are used.
Because styled-components uses stylis behind the scenes, I think the parser stylelint uses to extract the template literal styles from JavaScript files (postcss-styled) should support inline comments. I've raised an issue upstream about this.
I believe this bug was fixed if you use the built-in support for styled-components. It might not be fixed if you use the processor. Due to the way processors and PostCSS syntax differ, it might not be possible to fix this when using the processors. Long story short, it's all a bit confusing sorry. I believe processors will be replaced by the PostCSS syntaxes going forward, so you might want to try your luck not using the processor. At the moment it doesn't look like the built-in template literal support can parse inline comments, so you'll need to use standard CSS comment ( |
@fabb did you find any walk around? I have same issue in project except for a simple, small, tiny fact that it occurs only on windows machines. |
Unfortunately not, apart from putting the components to different files, or deactivating linting for that line. |
Uh, thanks, I'll try to look into it. |
False positives for
no-descending-specificity
in Styled Components. The rule looks into two different components which is not correct. Every styled component should be treated as a separate file if we speak in CSS terms.Link
andLinkIcon
are two different components, and stylelint can't know if their rules collapse or not.This is most likely has to do with how
postcss-styled
parses a file.Test repository: https://github.com/hudochenkov/styled-component-stylelint-bugs/tree/master/false-positive-no-descending-specificity
no-descending-specificity
9.9.0
CLI with
stylelint "**/*.styled.js" --syntax styled
Yes, it's related to styled components.
No warnings to be flagged.
The following warnings were flagged:
The text was updated successfully, but these errors were encountered: