-
Notifications
You must be signed in to change notification settings - Fork 61
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
Properties-alphabetical-order mixin error within styled-components #63
Comments
Sorry for a late response. This plugin doesn't know anything about styled components. From what I see in your report, you're probably using |
I'm facing the same issue. Would it make sense to add an option to ignore the sorting when Imo it would be handy |
Can we please reopen this issue for a workaround, since stylelint-processor-styled-components can't be changed to improve this? I think the best we can do is automatically ignore rules starting with |
@nickmccurdy stylelint supports CSS-in-JS out of the box now. Have you tried it without using |
I removed |
It is weird that every Stylelint rule I tested so far works in CSS-in-JS (including ---fix) out of the box. Except for stylelint-order. The order rules don't report any errors in CSS-in-JS. |
@taylon please, create a separate issue with a description of your problem. |
Definitely having a similar problem as @nickmccurdy here. I realize this may not be a direct issue in this repository but it does seem odd that this lib can't ignore styled-component mixins. See code below: import styled, { css } from 'styled-components';
export const buttonReset = css`
background: none;
border-bottom: 0;
font: inherit;
padding: 0;
`;
export const StyledButton = styled.button`
${buttonReset}
border: 1px solid red;
} And I get this in the console: Expected border to come before -styled-mixin0 order/properties-alphabetical-order Looks like its expecting the mixin variable |
sorry I meant that issue is the same one that @ekfuhrmann originally had. Can we reopen this issue and explore a possible fix? |
stylelint-order works great with Styled Components. I use it every day. Don't use |
Sure, but as @nickmccurdy has already pointed out, Also, just to clarify. These are not warnings, they're actual errors that fail the lint tests. |
Please, create an issue in I have no intention to support |
😕 This is the same error that was originally brought up in the thread. Why not just reopen this? |
Hmm, don't think anyone is asking for you to support |
The original error is caused by using I asked you to not use this processor, and you said that there are other errors. Please, report these errors to stylelint, so we can fix it. |
See my previous comment. It's not caused by the use of
😕 never said there are any other errors than those that are already mentioned here. |
I think there is misunderstanding from both sides. Warning like this:
Is definitely caused by Try to remove |
This will be my last comment about this since I'm pretty busy. Your statement above is incorrect. It looks like everything is fine because stylelint stops discovering other errors altogether and no longer works properly. Use my example again, remove |
I have a dumb hack for this, that doesn’t really fix the problem but at least suppresses the error in many scenarios. This works because the list from // .stylelintrc.js
const properties = require('known-css-properties').all;
module.exports = {
processors: ['stylelint-processor-styled-components'],
plugins: ['stylelint-order'],
rules: {
'order/properties-order': [...properties, '-styled-mixin0'], // alphabetize, but put Styled Components last The real problem is that certain properties used by Styled Components, et al shouldn’t be alphabetized at all—they either need to come first or last depending on the situation. Anyway, what I’d like to see with this plugin would be an ignore option that would let you whitelist things like I could open a PR for this if this is desirable to others. |
@DangoDev why |
@hudochenkov I’m sorry—I’ve read this entire thread, and I know you keep saying that, and feel like you’re being ignored. But that doesn’t seem to be the case. As of stylelint
Not only does that error appear in every Styled Components block, but without the processor, all the other lint rules stop working (such as alphabetization). That’s trying to run it without What’s more, the Styled Components documentation still recommends using the processor, and the repo is still actively maintained. It’s hard to see how to use Styled Components in Stylelint without this. |
@DangoDev would you mind opening an issue in stylelint repository about If you have examples of other core rules, please, open issues in stylelint repository as well. Help us make stylelint better :) |
@DangoDev either he's just not getting it or all of us are just doing a very very bad job explaining this lol. |
I'm getting it. styled-components processor were introduced long before stylelint was supporting CSS-in-JS. Now there are less reasons to use processor. There are some problems which developers of stylelint don't know about, because users don't report them. What I see from this thread, that users facing problems with built-in support, so they choose quick solution — use processor, and users happy unless process backfires sometimes (like this issue). It's a workaround to a problem and a short term solution. I'm asking to invest a little bit of time to long term solution — report issues you're encountering to stylelint repository. Help us to help you and make better tool for everyone. |
What confused us was the messaging here. I see issues like this one that are working toward deprecating processors. And I’m all for it! Love the idea of Stylelint supporting CSS-in-JS natively 🎉! We can (and will) open up tickets, for sure. But when you say “it supports,“ that’s not accurate because for (arguably) the most popular CSS-in-JS library, Styled Components, it is clearly and obviously broken. It is lacking the most basic of support. Let’s just level with the fact that it doesn’t work, and the official Styled Components documentation still recommending you to use the processor agrees with this. Saying “it works now” isn’t correct. But saying “we’re moving toward deprecating processors, and want to be able to support Styled Components without it” is awesome! 💯 All in favor of working for that solution. Hopefully that clarifies the disconnect here. |
For a note: I use styled components for half a year now with stylelint and autofixing. I use That where from some of my confusion comes. I use both and don't have problems (almost :)). |
While fixing everything in stylelint could take a while, users want to continue using processor in the meanwhile. Consider contributing a fix to ignore |
@hudochenkov would you mind sharing your stylelint config that you use for React? |
@ekfuhrmann I use two configs. One default, which is also picked up by editor plugin —
// .stylelintrc.js
module.exports = {
extends: ['stylelint-config-recommended'],
plugins: ['stylelint-order'],
rules: {
'no-empty-source': null,
'order/order': [['declarations', 'rules']],
},
};
|
Has anyone got a hack/solution for globally ignoring errors which contain e.g.
|
It's been close to 2 years since @hudochenkov last commented on this. Is there a way we can move forward? Currently, using styled components and using this rule are mutually exclusive. |
I had the same issue, disabling |
Closing as |
With the following component:
I receive this error:
Expected -styled-mixin0 to come before text-transform (order/properties-alphabetical-order)
The mixin I have is simply creating some font style properties based off of the parameters. It seems like the alphabetical ordering is using the word
mixin
and thus wants it placed abovetext-transform
but aftermargin
.The text was updated successfully, but these errors were encountered: