question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix false positives for hex colours in color-function-notation

See original GitHub issue

Clearly describe the bug

After upgrading to the latest major, I experienced an issue with color-function-notation, and turns out it wasn’t an issue per-say, but I think stylelint could’ve made a better job at telling me the issue.

So I had this rule prior to the upgrade

background-color: rgba(#fff, 0.85);

After running stylelint, I had the warning I should use color-function-notation (nice!). So what I did is the following

background-color: rgba(#fff / 0.85);

After that, stylelint passed. However, it was a false-positive as when I built my SCSS, it actually failed. I discovered that hex colors aren’t allowed. The correct syntax is the following

background-color: rgba(255 255 255 / 0.85);

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

color-function-notation

What code is needed to reproduce the bug?

a {
  background-color: rgba(#fff / 0.85);
}

What Stylelint configuration is needed to reproduce the bug?

Default one or the following

{
  "rules": {
    "color-function-notation": "modern"
  }
}

Which version of Stylelint are you using?

"stylelint": "14.0.0",

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

npx stylelint

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

I don’t think so?

What did you expect to happen?

A warning from stylelint directly in my code (with a tooltip)

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

✅ from stylelint when it actually was invalid code

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
lachiehcommented, Oct 25, 2021

Thanks, makes sense. PR submitted!

3reactions
alexander-akaitcommented, Oct 23, 2021

/ is evil in SCSS 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog
Fixed : color-function-notation false positives for hex colours (#5650). ... Fixed: color-hex-case false negatives for css-in-js object notation (#5101).
Read more >
How to check if a string is a valid hex color representation?
This answer used to throw false positives because instead of Number('0x' + hex) , it used parseInt(hex, 16) .
Read more >
How to Read Hex Color Codes - Hexadecimal Color
Hex color codes are one type of HTML color code that you'll often hear referred to as hexadecimal color or hex color. Learn...
Read more >
How to validate Hexadecimal Color Code using Regular ...
The given string doesn't start with a '#' symbol, therefore it is not a valid hexadecimal color code. Input: str = “#123abce”; Output:...
Read more >
8-Digit Hex Codes?
Weird right? 4-digit hex codes too. They are a way put alpha transparency information into the hex format for colors.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found