Prevent `at-rule-no-unknown` from warning against Sass directives
See original GitHub issueDescribe the issue. Is it a bug or a feature request (new rule, new option, etc.)?
A feature request to not warn against Sass directives like @import, @function, and @if when using Sass or SCSS syntax.
Which rule, if any, is this issue related to?
at-rule-no-unknown
What CSS is needed to reproduce this issue?
e.g.
@function foo ($bar) {
@if ($bar == 'a') {
$baz: 'b';
}
@else if ($bar == 'b') {
$baz: 'a';
}
@return $baz;
}
What stylelint configuration is needed to reproduce this issue?
e.g.
{
"rules": {
"at-rule-no-unknown": true,
}
}
Which version of stylelint are you using?
6.9.0.
How are you running stylelint: CLI, PostCSS plugin, Node API?
CLI with stylelint foo.scss --config .stylelintrc --syntax scss.
Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?
Yes, it’s related to SCSS directives.
What did you expect to happen?
No warnings to be flagged.
What actually happened (e.g. what warnings or errors you are getting)?
The following warnings were flagged:
foo.scss
1:1 ✖ Unexpected unknown at-rule "@function" at-rule-no-unknown
2:3 ✖ Unexpected unknown at-rule "@if" at-rule-no-unknown
5:3 ✖ Unexpected unknown at-rule "@else" at-rule-no-unknown
8:3 ✖ Unexpected unknown at-rule "@return" at-rule-no-unknown
Going over the Sass documentation results in the following list of keywords to additionally accept as known at-rules: @each, @else, @extend, @for, @function, @if, @include, @mixin, @return, @while.
The simplest solution would be to add these to the atRules set in src/reference/keywordSets.js, but that would incorrectly accept them in plain CSS. Creating a separate set for Sass directives will prevent that, but I can’t assess whether it’s easy to only consider that set in particular syntaxes.
It would be great if stylelint automatically applied this extra set when in Scss or Sass syntax.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:30
- Comments:10 (3 by maintainers)
Top Related StackOverflow Question
@benbonnet
Reference
@VincentSmedinga
stylelintrules not check non-standard syntax(not handling, not ignore and etc), use optionignoreAtRules: ['function', 'if']for resolve this issue. We offically support only css syntax in rules. Maybe you are interested instylelint-scss(some rules for only scss).