Falsy error in `array-callback-return`
See original GitHub issueReturning something inside a try/catch
block inside arr.map
will sometimes falsely report an error. The following code should be perfectly valid (since there’s an process.exit()
which should imply that it should return or exit). Currently I have to assign my return to a variable and return it outside the try/catch
.
arr.map(() => {
try {
return require('foo');
} catch (err) {
console.error(err);
process.exit(1);
}
});
Using ESLint version 2.9.0
and the failing rule is array-callback-return
.
Ref https://github.com/imagemin/imagemin-cli/pull/6#discussion_r61607411.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:19 (14 by maintainers)
Top Results From Across the Web
array-callback-return - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >[array-callback-return] False positive when in a map that uses ...
I have read the FAQ and my problem is not listed. Repro. The rule array-callback-return is enabled with default settings. There are no...
Read more >Callback function with a truthy value in JavaScript
The conditional callback(array[i]) verifies if the value of isEven() function passed as callback evaluates to true/false for array[i] .
Read more >Mastering Hard Parts of JavaScript: Callbacks III
The callback will return either true or false. majority will iterate through the array and perform the callback on each element until it...
Read more >JavaScript Array some: Check If at Least one Array Element ...
In this tutorial, you will learn how to use the JavaScript Array some() method ... causes the callback() to return true , the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have added node/process-exit-as-throw rule experimentally to eslint-plugin-node. If this rule is turned on, ESLint’s code path analysis will address
process.exit()
asthrow
. This might help this issue.Just want to go on the record and clarify my position: I don’t believe a rule that isn’t already runtime-specific should become runtime-specific by handling runtime-specific cases. That was what I meant in my initial reply. On May 1, 2016 8:41 AM, “Sindre Sorhus” notifications@github.com wrote: