Skip to content

Commit

Permalink
Fix value-keyword-case false positives for mixed case `ignoreFuncti…
Browse files Browse the repository at this point in the history
…ons` option (#6517)
  • Loading branch information
kimulaco committed Dec 11, 2022
1 parent 11acf31 commit e30ec86
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-hounds-exercise.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `value-keyword-case` false positives for mixed case `ignoreFunctions` option
5 changes: 4 additions & 1 deletion lib/rules/value-keyword-case/__tests__/index.js
Expand Up @@ -2274,7 +2274,7 @@ testRule({

testRule({
ruleName,
config: ['upper', { ignoreFunctions: ['t', /^(f|F)oo$/] }],
config: ['upper', { ignoreFunctions: ['t', 'camelCase', /^(f|F)oo$/] }],
fix: true,

accept: [
Expand All @@ -2293,6 +2293,9 @@ testRule({
{
code: 'a { color: Foo(--camelCase); }',
},
{
code: 'a { color: camelCase(value); }',
},
],

reject: [
Expand Down
9 changes: 4 additions & 5 deletions lib/rules/value-keyword-case/index.js
Expand Up @@ -84,7 +84,8 @@ const rule = (primary, secondaryOptions, context) => {
let needFix = false;

parsed.walk((node) => {
const valueLowerCase = node.value.toLowerCase();
const keyword = node.value;
const valueLowerCase = keyword.toLowerCase();

// Ignore system colors
if (systemColorsKeywords.has(valueLowerCase)) {
Expand All @@ -107,19 +108,17 @@ const rule = (primary, secondaryOptions, context) => {

if (
node.type === 'function' &&
optionsMatches(secondaryOptions, 'ignoreFunctions', valueLowerCase)
optionsMatches(secondaryOptions, 'ignoreFunctions', keyword)
) {
return false;
}

const keyword = node.value;

const { unit } = getDimension(node);

// Ignore css variables, and hex values, and math operators, and sass interpolation
if (
node.type !== 'word' ||
!isStandardSyntaxValue(node.value) ||
!isStandardSyntaxValue(keyword) ||
value.includes('#') ||
ignoredCharacters.has(keyword) ||
unit
Expand Down

0 comments on commit e30ec86

Please sign in to comment.