Skip to content

at-rule-conditional-no-parentheses

Reports the condition of an @if, @else if or @while that is written in parentheses (@if ($a == 1)).

In Sass the condition ends at the block, so the parentheses do nothing; they come from the languages where they are needed, and they add noise.

To fix, delete the parentheses.

With this configuration:

no-global-function-names: warn
at-mixin-argumentless-call-parentheses: warn
at-rule-conditional-no-parentheses: warn
at-extend-no-missing-placeholder: warn
at-if-no-null: warn
load-no-partial-leading-underscore: warn
dollar-variable-pattern: { level: warn, options: { pattern: "^[a-z-]+$" } }
at-mixin-pattern: { level: warn, options: { pattern: "^[a-z-]+$" } }
at-function-pattern: { level: warn, options: { pattern: "^[a-z-]+$" } }
Reported
...
@extend %b;
@extend .c-#{$x};
@if ($a == 1) { top: 0; }
@else if $a != null { top: 1; }
@else if $a != null and $b { top: 2; }
...
css:
lint:
rules:
at-rule-conditional-no-parentheses: warn # off (default), warn, error
less:
lint:
rules:
at-rule-conditional-no-parentheses: warn # off (default), warn, error
scss:
lint:
rules:
at-rule-conditional-no-parentheses: warn # off (default), warn, error

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line at-rule-conditional-no-parentheses in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
stylelint-scss scss/at-rule-conditional-no-parentheses full