Skip to content
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

Fix false positives for negation within interpolation in declaration-bang-space-before #4713

Closed
Tracked by #4574
Benwick91 opened this issue Apr 22, 2020 · 2 comments
Labels
status: ready to implement is ready to be worked on by someone syntax: css-in-js relates to JS objects & template literals type: bug a problem with a feature or rule upstream relates to an upstream package

Comments

@Benwick91
Copy link

Clearly describe the bug

I had the following error after a stylelint update:
TypeError: Cannot read property 'stringify' of null

In my research I find out, that I don't need the deprecated stylelint-processor-styled-components. So I delete the package and the error wasn't show anymore. But now stylelint also mark the logical "not" operator "!". Is there a possible to disable this behaviour? With the processor and version 13.0.0 it worked.

Which rule, if any, is the bug related to?

declaration-bang-space-before

What code is needed to reproduce the bug?

const Styles = styled.div<Props>`
  display: inline-block;
  border: 1px solid;
  border-color: ${(props: Props) =>
    !props.disabled ? '#000' : '#FFF'};
`

What stylelint configuration is needed to reproduce the bug?

e.g.

{
  "extends": [
    "stylelint-config-airbnb",
    "stylelint-config-styled-components",
    "stylelint-config-prettier"
  ],
  "plugins": ["stylelint-order"],
  "rules": {
    "order/order": [
      "custom-properties",
      "declarations"
    ],
  }
}

Which version of stylelint are you using?

13.3.3

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

"Yes, it's related to styled-components"

What did you expect to happen?

No warnings/errors with "!" operator in conditional statements.

What actually happened (e.g. what warnings or errors did you get)?

The following warnings were flagged:

Expected single space before "!"

Thank you!

@jeddy3 jeddy3 mentioned this issue May 10, 2020
23 tasks
@jeddy3 jeddy3 changed the title Disable declaration-bang-space-before with CSS-in-JS / styled-components Fix false positives for negation within interpolation in declaration-bang-space-before May 10, 2020
@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone syntax: css-in-js relates to JS objects & template literals type: bug a problem with a feature or rule upstream relates to an upstream package labels May 10, 2020
@jeddy3
Copy link
Member

jeddy3 commented May 10, 2020

@Benwick91 Thanks for the report and for using the template.

I can reproduce this using the demo with:

const S = styled.a<Props>`
  property: ${(props: Props) =>
    !props.disabled ? '#000' : '#FFF'};
`

It's likely a problem with the parser stylelint uses to support CSS-in-JS. I've added this issue to #4574, which is a growing list of the problems with the syntax that we need help to fix.

Please consider contributing to the parser if you have time.

Is there a possible to disable this behaviour?

Until the bug is resolved, you can turn off the rule using null.

@jeddy3
Copy link
Member

jeddy3 commented Jan 18, 2022

Closing as stylistic rules are frozen. The community is welcome to migrate the rule to a plugin and fix this bug.

@jeddy3 jeddy3 closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to implement is ready to be worked on by someone syntax: css-in-js relates to JS objects & template literals type: bug a problem with a feature or rule upstream relates to an upstream package
Development

No branches or pull requests

2 participants