Stylelint: Fix false positives for Less variables and mixins in at-rule-*

Created on 29 Oct 2018  Â·  1Comment  Â·  Source: stylelint/stylelint

When linting a Less file, there are error since you deployed version 9.7.0.

For instance this basic Less file:

@my-variable: #f7f8f9;
@anotherVariable: 1px;

.some-mixin() {
    margin: 0;
}

span {
    .some-mixin();
    background-color: @my-variable;
    margin-left: @anotherVariable;
}

would give:

 1:1  ✖  Unexpected unknown at-rule "@my-variable"            at-rule-no-unknown
 2:1  ✖  Expected "anotherVariable" to be "anothervariable"   at-rule-name-case 
 2:1  ✖  Unexpected unknown at-rule "@anotherVariable"        at-rule-no-unknown
 9:5  ✖  Unexpected unknown at-rule "@some-mixin"             at-rule-no-unknown

This is due to moving to postcss-less 3.0.1 in version 9.7.0. They now generate AtRule nodes for mixins and variables (with respectively mixin: true and variable: true properties), I suppose we should handle these cases in all at-rule-* rules.

good first issue wip less bug

Most helpful comment

@glutentag Thanks for the report.

Yes, I think we should consider these non-standard at-rules. The fix is to:

  1. Confirm that the heuristics are correct in the isStandardSyntaxAtRule util
  2. Use this util to return early in the at-rule-name-case, at-rule-no-unknown and any other affected at-rule-* rules like so
  3. Add a relevant test or two to the rules like so

If someone can do this today then I can put out a patch release this evening.

>All comments

@glutentag Thanks for the report.

Yes, I think we should consider these non-standard at-rules. The fix is to:

  1. Confirm that the heuristics are correct in the isStandardSyntaxAtRule util
  2. Use this util to return early in the at-rule-name-case, at-rule-no-unknown and any other affected at-rule-* rules like so
  3. Add a relevant test or two to the rules like so

If someone can do this today then I can put out a patch release this evening.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oliviertassinari picture oliviertassinari  Â·  3Comments

jitendravyas picture jitendravyas  Â·  3Comments

verpixelt picture verpixelt  Â·  3Comments

nilsborg picture nilsborg  Â·  3Comments

Havunen picture Havunen  Â·  3Comments