This rule requires return statements to either always or never specify values. This rule ignores function definitions where the name begins with an uppercase letter, because constructors (when invoked with the new operator) return the instantiated object implicitly if they do not return another object explicitly.
log() statements that ESLint doesn't like. To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console. log('JavaScript debug log'); console.
ESLint comes with a large number of built-in rules and you can add more rules through plugins. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values: "off" or 0 - turn the rule off.
http://eslint.org/docs/rules/consistent-return says:
This rule requires return statements to either always or never specify values.
When your if-condition is not met, the arrow function will terminate without encountering a return statement, which violates this rule. Your second version violates this rule because your second return does not specify a value, contrary to the first return. The second warning tells you that your additional return statement is redundant.
To make the linter happy, you probably should think about what to properly return from the arrow-function if the condition is not met. I do not know what your find function does exactly, but if it behaves similar to Array.prototype.find you might want to return false at the end of the arrow function. If you need to return undefined in that case, this paragraph from the same page applies:
When Not To Use It
If you want to allow functions to have different return behavior depending on code branching, then it is safe to disable this rule.
EDIT: I previously wrote to have a look at the option treatUndefinedAsUnspecified
, but looks like either setting will not help if you need to return undefined in just one of the branches.
the return is correctly inserted, however its value should be given ...
return false;
is the correct value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With