Skip to content

Commit

Permalink
Fix false positives for interpolation in function-no-unknown (#5914)
Browse files Browse the repository at this point in the history
  • Loading branch information
m4thieulavoie committed Feb 15, 2022
1 parent 8bdd494 commit 7cc2e4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/function-no-unknown/__tests__/index.js
Expand Up @@ -54,6 +54,9 @@ testRule({
{
code: 'a { $list: (list) }',
},
{
code: 'a { --primary-color: #{theme(1px)}; }',
},
],
});

Expand Down
6 changes: 6 additions & 0 deletions lib/utils/__tests__/isStandardSyntaxFunction.test.js
Expand Up @@ -20,6 +20,12 @@ describe('isStandardSyntaxFunction', () => {
it('scss map', () => {
expect(isStandardSyntaxFunction(func('a { $map: (key: value) }'))).toBe(false);
});

it('scss function in custom prop', () => {
expect(isStandardSyntaxFunction(func('a { --primary-color: #{darken(#fff, 0.2)} }'))).toBe(
false,
);
});
});

function func(css) {
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/isStandardSyntaxFunction.js
Expand Up @@ -12,5 +12,9 @@ module.exports = function (node) {
return false;
}

if (node.value.startsWith('#{')) {
return false;
}

return true;
};

0 comments on commit 7cc2e4f

Please sign in to comment.