less.js icon indicating copy to clipboard operation
less.js copied to clipboard

Fix for issue #4339 false positive deprecation notice for mixins

Open puckowski opened this issue 4 months ago • 4 comments

What:

Fixes issue https://github.com/less/less.js/issues/4339

This Less:

@spacing-top: 4px;
@spacing-bottom: 4px;
@border-width: 4px;
@border-color: #444;

.divider-bottom(
    @spacing-top: @spacing-top,
  @spacing-bottom: @spacing-bottom,
  @border-width: @border-width,
  @border-color: @border-color
) {
  margin-top: @spacing-top;
  margin-bottom: @spacing-bottom;
  border-bottom: @border-width solid @border-color;
}

div {
  .divider-bottom(
  @spacing-top,
  @spacing-bottom,
  @border-width,
  @border-color
);
}

div {
  .divider-bottom ( @spacing-top,
@spacing-bottom,
  @border-width,
  @border-color
);
}

div {
  .divider-bottom (@spacing-top,
@spacing-bottom,
  @border-width,
  @border-color
);
}

div {
  .divider-bottom(@spacing-top,
@spacing-bottom,
  @border-width,
  @border-color
);
}

yields the following deprecation notices:

less.js:11431 DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in http://172.25.80.1:8000/test.less on line 27, column 19:
27   .divider-bottom ( @spacing-top,

warn @ less.js:11431Understand this warning
less.js:11431 DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in http://172.25.80.1:8000/test.less on line 35, column 19:
35   .divider-bottom (@spacing-top,

which should resolve false positive deprecation notices for syntax like:

.divider-bottom(
  @spacing-top,
  @spacing-bottom,
  @border-width,
  @border-color
);

Why:

Many users have reported the false positive behavior and wish to not see the notice or have to rewrite their valid Less.

Checklist:

  • [ ] Documentation
  • [ ] Added/updated unit tests
  • [x] Code complete

puckowski avatar Aug 30 '25 19:08 puckowski

What needs to happen to release this fix in a new stable version? Thanks!

hostep avatar Sep 16 '25 09:09 hostep

I just noticed a new version was released but this fix wasn't included for some reason? Do we have an idea on a timeframe when this fix will get released? Sorry to keep pushing this, but I'd like to start fixing the actual deprecated problems in Magento, but for that to happen I would like to see a stable release of less where the false positives have been removed.

Many thanks!

hostep avatar Oct 07 '25 16:10 hostep

@matthew-dean @iChenLei Would either of you be able to peer review this PR so we can merge and release?

Comment from the issue from hostep (see https://github.com/less/less.js/issues/4339):

Looks good @puckowski!

I just tried it in the ecosystem I'm active in, which is Magento2 ecommerce platform written in php, that uses less files for its frontend, and the amount of deprecated warnings dropped from 1220 to 39 after your changes, and those 39 seem like valid warnings. (example where warning went away, and example where warning still shows up, but that seems valid)

Many thanks!

puckowski avatar Oct 09 '25 21:10 puckowski

Any update on reviewing this?

egonolieux avatar Oct 25 '25 13:10 egonolieux

@matthew-dean are you ok with this being merged and released?

lukpsaxo avatar Dec 15 '25 14:12 lukpsaxo