Skip to content

Commit

Permalink
at-function-named-arguments: correctly parse functions inside Sass maps
Browse files Browse the repository at this point in the history
  • Loading branch information
kristerkari committed Dec 5, 2018
1 parent 0c77143 commit 0fa5584
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# HEAD

- Fixed: `at-function-named-arguments` was not correctly handling functions inside Sass maps.

# 3.4.0

- Added: `at-mixin-argumentless-call-parentheses` autofix (#280).
Expand Down
16 changes: 14 additions & 2 deletions src/rules/at-function-named-arguments/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import rule, { ruleName, messages } from "..";
import rule, { messages, ruleName } from "..";

// Required ("always")
testRule(rule, {
Expand Down Expand Up @@ -377,7 +377,19 @@ testRule(rule, {
}
`,
description:
"Always. Example: native CSS function is ignored inside a function call."
"Never. Example: native CSS function is ignored inside a function call."
},
{
code: `
$color: #123456;
$rgb: (
"r": red($color),
"g": green($color),
"b": blue($color)
);
`,
description: "Never. function call inside a map."
}
],

Expand Down
8 changes: 4 additions & 4 deletions src/rules/at-function-named-arguments/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { isString } from "lodash";
import valueParser from "postcss-value-parser";
import { utils } from "stylelint";
import {
isNativeCssFunction,
namespace,
optionsHaveIgnored,
isNativeCssFunction,
parseFunctionArguments
} from "../../utils";
import { isString } from "lodash";
import valueParser from "postcss-value-parser";

export const ruleName = namespace("at-function-named-arguments");

Expand Down Expand Up @@ -74,7 +74,7 @@ export default function(expectation, options) {
return;
}

const args = parseFunctionArguments(decl.value);
const args = parseFunctionArguments(valueParser.stringify(node));
const isSingleArgument = args.length === 1;

if (isSingleArgument && shouldIgnoreSingleArgument) {
Expand Down

0 comments on commit 0fa5584

Please sign in to comment.