Fix false positives for variables and color functions in `color-function-notation`
See original GitHub issueClearly 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:
- Created 2 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
@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 aword
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:
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.