Skip to content

Commit

Permalink
Merge pull request #393 from kristerkari/bugfix/at-rule-conditional-n…
Browse files Browse the repository at this point in the history
…o-parentheses-ignore-function-calls

at-rule-conditional-no-parentheses: don't warn for function calls
  • Loading branch information
kristerkari committed Nov 3, 2019
2 parents 91993a1 + 69b4a32 commit 6d703f4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
# HEAD

- Fixed: `at-rule-conditional-no-parentheses` don't warn for function calls.
- Fixed: `map-keys-quotes` ignore math operators inside map values.
- Fixed: `operator-no-unspaced` was looking for operators inside `@forward` and `@use`.

Expand Down
29 changes: 28 additions & 1 deletion src/rules/at-rule-conditional-no-parentheses/__tests__/index.js
@@ -1,4 +1,4 @@
import rule, { ruleName, messages } from "..";
import rule, { messages, ruleName } from "..";

testRule(rule, {
ruleName,
Expand Down Expand Up @@ -29,6 +29,33 @@ testRule(rule, {
@else if true {}
@else {}`,
description: "accepts @else unconditionally"
},
{
code: `
@function strip-unit($number) {
@if type-of($number) == "number" and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}
`,
description: "accepts function calls using @if"
},
{
code: `
@function strip-unit($number) {
@if true {
@return $number;
}
@else if type-of($number) == "number" and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}
`,
description: "accepts function calls using @else if"
}
],

Expand Down
4 changes: 2 additions & 2 deletions src/rules/at-rule-conditional-no-parentheses/index.js
@@ -1,6 +1,6 @@
import _ from "lodash";
import { utils } from "stylelint";
import { namespace } from "../../utils";
import _ from "lodash";

export const ruleName = namespace("at-rule-conditional-no-parentheses");

Expand Down Expand Up @@ -57,7 +57,7 @@ export default function(primary, _unused, context) {
}
}
} else {
if (atrule.params.match(/ ?\(.*\) ?$/)) {
if (atrule.params.trim().match(/^\(.*\)$/)) {
if (context.fix) {
fix(atrule);
} else {
Expand Down

0 comments on commit 6d703f4

Please sign in to comment.