stylelint-processor-styled-components icon indicating copy to clipboard operation
stylelint-processor-styled-components copied to clipboard

Styleint Treats Multiple Components As Same Component

Open Undistraction opened this issue 6 years ago • 3 comments

The following two components defined in the same file results in an error:

Components

const Layout = styled(HSpreadLayout)`
  > *:first-child {
    padding: 1.25rem;
  }
`

const NavList = styled(HList)`
  > * + * {
    border-left: 1px solid #bbb;
  }
`

Error

Expected selector ".selector6 > * + *" to come before selector ".selector5 > *:first-child" no-descending-specificity

Expected Each component should be evaluated separately.

  • Node 8.11.3
  • "stylelint": "^9.5.0",
  • "stylelint-config-recommended": "^2.1.0",
  • "stylelint-config-styled-components": "^0.1.1",
  • "stylelint-processor-styled-components": "^1.3.2"

Undistraction avatar Sep 10 '18 13:09 Undistraction

@Undistraction You're right. But I am afraid that stylelint doesn't give a processor the possibility to do that. Because a processor can only extract codes from user's input file and ask stylelint to lint together, which is a string, instead of array.

chinesedfan avatar Sep 11 '18 08:09 chinesedfan

@chinesedfan That seems like a pretty big issue to me because it forces you to define your components in an order just to satisfy the processor. It could also potentially lead to cases that cannot be satisfied by changing component order.

Undistraction avatar Sep 11 '18 09:09 Undistraction

We have the same issue, turning off no-descending-specificity linting rule until this gets fixed. Big issue :(

sergio-toro avatar Oct 24 '18 12:10 sergio-toro