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 variables and color functions in `color-function-notation`

See original GitHub issue

Clearly describe the bug

A follow-up from #5638, where the original issue was fixed correctly in my tests but more advanced scenarios still result in false positives, e.g. when using Sass’ color.mix within rgba().

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

color-function-notation

What code is needed to reproduce the bug?

@use 'sass:color';

$color: rgba(color.mix(#000, #fff, 35%), 0.6);

What Stylelint configuration is needed to reproduce the bug?

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

Which version of Stylelint are you using?

14.0.1 as well as main from commit e2c3473.

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

stylelint \"src/**/*.scss\"

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

Yes, SCSS color functions

What did you expect to happen?

No errors

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

 25:27  ✖  Expected legacy color-function notation  color-function-notation

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lachiehcommented, Dec 21, 2021

If anyone subbed to this issue is interested, I created a rule proposal about how sass color functions work and how they can potentially be linted to avoid confusion. stylelint-scss/stylelint-scss#582

1reaction
jeddy3commented, Oct 29, 2021

@cascornelissen Thanks for creating the issue.

I think we can improve the heuristics in the isStandardSyntaxColorFunction util to catch this. If we change the logic to look for a word starting with # within any of the nodes within the function (including those nested within other functions).

I don’t believe there’s a situation where this can happen with standard CSS. The closest we can get is:

a { color: rgba(var(--r, 20), var(--g), var(--b), 0.6); }

But the fallback words, e.g. 20, will never be hex colours.

I’ve labelled the issue as ready to implement. Please consider contributing if you have time.

There are steps on how to fix a bug in a rule in the Developer guide.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog | Stylelint
Fixed : showing of incorrect missing package in customSyntax require handling (#5763). Fixed: color-function-notation false positives for variables and color ...
Read more >
Controlling false positive rates in research and its clinical ...
One of the procedures employed to correct false-positive rates is the Bonferroni correction. It consists of dividing the significance level by the number...
Read more >
History PEX - Peganza
fixed some issues for WARN7-"Local variables that are referenced before they are set" ... removed some false positives from REDU12-"Functions called only as ......
Read more >
NetLogo 6.3.0 User Manual: Programming Guide
Some variables are built into NetLogo. For example, all turtles and links have a color variable, and all patches have a pcolor variable....
Read more >
Sass Color Functions - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python,...
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