Skip to content

Conversation

Copy link

Copilot AI commented Dec 17, 2025

Styled-components’ object-call form and other curried HOCs were still flagged as non-components. E.g.:

export const Flex = styled("div")({ display: "flex" }); // wrongly warned
  • Detection: Traverse chained HOC callees with depth guard; treat curried HOC call expressions as components while still requiring arguments.
  • Consistency: Reuse HOC detection for variable initializers so curried custom HOCs count as React components.
  • Regression tests: Added coverage for styled('div')({ ... }) in named and default exports when listed in customHOCs.

Example:

export const Flex = styled("div")({ display: "flex" }); // now accepted with customHOCs: ["styled"]
Original prompt

Hi, the template-literal form of styled components seems to have been fixed ArnaudBarre#32, but the object form still causes false positives:

export const Flex = styled('div')({display: 'flex'}) // Warning ❌

We can get halfway there with "customHOCs": ["styled"]

export const Flex = styled('div') // No warning ✅
export const Flex = styled('div')({display: 'flex'}) // Warning ❌

For the purposes of this plugin, I think it would be safe to assume that if you call the result of a "HOC", it should count as a react component.

I believe the correct term for a function like this case of styled is a curried HOC.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 17, 2025 10:29
Co-authored-by: jaskp <35872026+jaskp@users.noreply.github.com>
Co-authored-by: jaskp <35872026+jaskp@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix false positives for styled components object form Treat curried custom HOC calls as components in only-export-components rule Dec 17, 2025
Copilot AI requested a review from jaskp December 17, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for styled components

2 participants