styled-components/babel-plugin-styled-components

babel plugin which will change order of styled components

redexp opened this issue · 1 comments

Hello, what do think about to create new plugin or add it to current plugin which will change order of styled components
from:

const First = styled.div`
  // ...
  &:hover ${Second} {
    opacity: 1;
  }
`;

const Second = styled.div`
  opacity: 0;
`;

to:

const Second = styled.div`
  opacity: 0;
`;

const First = styled.div`
  // ...
  &:hover ${Second} {
    opacity: 1;
  }
`;

So plugin will check if some component included in previous component than it must be placed before it.

I can do such plugin by my self, I just want ask do it make sense for you?

Hmm, this seems like it'd make more sense for a linting plugin to catch before the code ever even got to Babel.