styled-components / babel-plugin-styled-components

Improve the debugging experience and add server-side rendering support to styled-components
MIT License
1.07k stars 141 forks source link

babel plugin which will change order of styled components #372

Closed redexp closed 1 year ago

redexp commented 2 years ago

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?

quantizor commented 1 year ago

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