Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ES Lint error for jQuery anonymous function

The code I have is as follows:

$('.panel').each( function() {
    $(this).css('height', 'auto');
    $(this).find('.portlet-panel-item').css('height', 'auto');
});

I am getting the following error: 37:26 warning Missing function expression name func-names.

I can't use the ES6 arrow functions because of the way this is being handled in the two use cases.

How can I fix this issue without having to put named functions for each?

like image 868
Suthan Bala Avatar asked Mar 13 '26 23:03

Suthan Bala


1 Answers

You should either use a named function or disable the rule.

From AirBnB JavaScript style guide:

Don’t forget to name the expression - anonymous functions can make it harder to locate the problem in an Error's call stack.

You can set this rule to check "always", "as-needed", or "never" by using a comment, so in your case: /*eslint func-names: ["error", "never"]*/

like image 135
DaveBagler Avatar answered Mar 15 '26 12:03

DaveBagler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!