Skip to content

Commit

Permalink
Fix end positions for function-no-unknown (#6038)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattxwang committed Apr 26, 2022
1 parent dcba172 commit 9716062
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions lib/rules/function-no-unknown/__tests__/index.js
Expand Up @@ -27,18 +27,24 @@ testRule({
message: messages.rejected('unknown'),
line: 1,
column: 16,
endLine: 1,
endColumn: 23,
},
{
code: 'a { transform: UNKNOWN(4); }',
message: messages.rejected('UNKNOWN'),
line: 1,
column: 16,
endLine: 1,
endColumn: 23,
},
{
code: 'a { width: calc(10% * unknown(1)); }',
message: messages.rejected('unknown'),
line: 1,
column: 23,
endLine: 1,
endColumn: 30,
},
],
});
Expand Down
11 changes: 7 additions & 4 deletions lib/rules/function-no-unknown/index.js
Expand Up @@ -49,6 +49,8 @@ const rule = (primary, secondaryOptions) => {
const { value } = decl;

valueParser(value).walk((node) => {
const name = node.value;

if (node.type !== 'function') {
return;
}
Expand All @@ -57,24 +59,25 @@ const rule = (primary, secondaryOptions) => {
return;
}

if (isCustomFunction(node.value)) {
if (isCustomFunction(name)) {
return;
}

if (optionsMatches(secondaryOptions, 'ignoreFunctions', node.value)) {
if (optionsMatches(secondaryOptions, 'ignoreFunctions', name)) {
return;
}

if (functionsList.includes(node.value.toLowerCase())) {
if (functionsList.includes(name.toLowerCase())) {
return;
}

report({
message: messages.rejected(node.value),
message: messages.rejected(name),
node: decl,
index: declarationValueIndex(decl) + node.sourceIndex,
result,
ruleName,
word: name,
});
});
});
Expand Down

0 comments on commit 9716062

Please sign in to comment.