Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postcss-sorting complains about less-mixins #71

Open
stephanschubert opened this issue Oct 23, 2018 · 9 comments
Open

postcss-sorting complains about less-mixins #71

stephanschubert opened this issue Oct 23, 2018 · 9 comments

Comments

@stephanschubert
Copy link

When less-mixins is used:

    "order/order": [
      "custom-properties",
      "dollar-variables",
      "at-variables",
      "declarations",
      "rules",
      "at-rules",
      "less-mixins",
    ],
    "order/properties-alphabetical-order": true,

Result:

postcss-sorting: order: Every item in the array must be an object with a "type" property, or one of keywords: custom-properties, dollar-variables, at-variables, declarations, rules, at-rules.

Removing less-mixins "fixes" the error.

@hudochenkov
Copy link
Owner

Thank you for reporting!

Indeed, this problem exists, because postcss-sorting (a plugin which handles order fixing) doesn't support this keyword.

I believe it could be fixed if add to https://github.com/hudochenkov/postcss-sorting/blob/944da947a628192b54448368c197f586fbbe0c10/lib/getOrderData.js code similar to

} else if (node.type === 'rule' && node.empty && !node.extend) {
nodeType = 'less-mixins';

Consider contributing this fix, because Less is not in my priority.

While problem exists you can disable autofixing for order/order.

@NE-SmallTown
Copy link

NE-SmallTown commented Oct 24, 2018

Same problem.

@hudochenkov The bad I feel is that this will cause the entire file won't be fixed(it lets me think it's my own fault), I think we should just ignore less-mixins and still fix the file and throw the error rather than just log(for me, I even don't see the warning because it use console.log which use black font color and spend 2 hours to dig into the source code of stylelint-order)

What's your suggestion/plan to fix this? If @stephanschubert doesn't have time, I could send a PR for this.

@hudochenkov
Copy link
Owner

@NE-SmallTown Sorry, you faced this situation. It's a rare case when something was added to stylelint-order but wasn't reflected in postcss-sorting. My suggestion is to add support for less-mixins into postcss-sorting. I wrote above where to start.

@NE-SmallTown
Copy link

NE-SmallTown commented Oct 24, 2018

Never mind, I will take a look this weekend if @stephanschubert doesn't have time

@oller
Copy link

oller commented Apr 16, 2020

The ol' 18month later bump. I'm encountering this issue too, is it as easy a fix as the snippet in the thread above?

@hudochenkov
Copy link
Owner

Pretty much. Add new keyword and add tests for it.

@oller
Copy link

oller commented Apr 16, 2020 via email

@Astrael1
Copy link
Contributor

Astrael1 commented Oct 15, 2024

Fixing this requires adding some LESS parser to postcss-sorting e.g. postcss-less because postcss parser doesn't accept usage of LESS mixins and throws error

.le_mixin {
  color: red;
}

a {
  .le_mixin();
}

@hudochenkov do you allow adding that dependency or shall we just close this issue?

@hudochenkov
Copy link
Owner

I don't think it is needed. For 6 years this issue is open it only got 3 reactions.

But I'm open for a PR to postcss-sorting as described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants