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

False "Whitespace between a mixin name and parentheses for a mixin call" deprecation warning

Open egonolieux opened this issue 10 months ago • 11 comments

I'm getting a lot of mixin related errors like these:

<w> DEPRECATED WARNING: Whitespace between a mixin name and parentheses for a mixin call is deprecated in /home/egonolieux/projects/some-project/assets/less/mixins/divider.less on line 50, column 20:
<w> 50     .divider-bottom(
<w> 

It seems like splitting the mixin arguments over multiple lines (for better readability) causes the issue:

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

This is confusing because there is no whitespace between the mixin name and parentheses here. However, when rewriting it like this:

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

Or like this:

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

The deprecation warning no longer shows up. It seems this has been introduced since https://github.com/less/less.js/pull/4319.

egonolieux avatar Apr 11 '25 17:04 egonolieux

Hello @egonolieux! I'm Dosu, your friendly helper bot here to assist you with bugs, answer questions, and guide you toward becoming a contributor. I'm here while you wait for a human maintainer!

To resolve the deprecation warning about whitespace between a mixin name and parentheses for a mixin call in Less, ensure there is no whitespace between the mixin name and the opening parenthesis. Your initial example is actually correct and should not trigger a warning:

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

If you're still encountering warnings, it might be due to a bug or an issue with the specific version of Less.js you are using. The warning is intended to be triggered when there is whitespace directly between the mixin name and the parenthesis, like in .a ();, which is deprecated [1]. If the warning persists despite correct syntax, consider checking for updates or patches that might address this issue.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Apr 11 '25 18:04 dosubot[bot]

Thank you for the bug report. I'll see if I can take a look this weekend.

puckowski avatar Apr 11 '25 22:04 puckowski

Oh oops. Yeah this shouldn't cause the warning.

matthew-dean avatar Apr 12 '25 19:04 matthew-dean

How to disable this warning❓❓❓

Y80 avatar Apr 16 '25 09:04 Y80

How to disable this warning❓❓❓

Either remove the whitespace after the parenthesis as well, or wait for a fix. In our case, it was only a handful of issues, so I just fixed them all and warning is gone 👍

Svish avatar Apr 22 '25 11:04 Svish

You can try the newer --quiet flag to suppress the deprecation warnings when compiling Less.

@Y80

puckowski avatar Apr 22 '25 20:04 puckowski

Any chance we'll see a fix for this soon-ish? Many thanks!

hostep avatar Aug 29 '25 12:08 hostep

I'll try to take a look at this issue this weekend.

puckowski avatar Aug 30 '25 14:08 puckowski

I think I have a fix in https://github.com/less/less.js/pull/4365

If anyone wants to patch their Less parser and confirm the fix corrects the behavior I would appreciate it.

puckowski avatar Aug 30 '25 19:08 puckowski

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!

hostep avatar Aug 31 '25 13:08 hostep

@hostep Thank you for testing!

puckowski avatar Sep 01 '25 19:09 puckowski