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?
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?
Share Improve this question asked Feb 17, 2017 at 16:23 Suthan BalaSuthan Bala 3,2995 gold badges40 silver badges61 bronze badges 2-
You can't. You could just disable that check on that line.
// eslint-disable-next-line func-name
before it should do the trick. It's a linter, doesn't mean your code won't run or will cause errors, just that, if you agree with this rule, it's bad practice. – Sergiu Paraschiv Commented Feb 17, 2017 at 16:29 - 1 Maybe you should read what the rule means first, then use your judgement as to whether the rule makes sense in this case. – Heretic Monkey Commented Feb 17, 2017 at 16:32
1 Answer
Reset to default 5You 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 ment, so in your case:
/*eslint func-names: ["error", "never"]*/