coffeelint-callback-handle-error
CoffeeLint rule that finds instances of error objects passed through a callback function without being handled.
Ex: Any of these code blocks do not handle their error variable:
fsstat '/invalid/path/to/file' consolelog stats return
fsstat '/invalid/path/to/file' # this err is not handled and is instead overwritten by the next stat fsstat '/some/other/invalid/file' if err consolelog err return return
These examples will pass, since their error variables are handled:
fsstat '/invalid/path/to/file' if err consolelog err return
doStuff 123 fsstat '/invalid/path/to/file' callback err return return
Installation
npm install coffeelint-callback-handle-error
Usage
To get started, insert this configuration somewhere in your coffeelint.json
file:
"callback_handle_error":
Configuration
This plugin has one custom configurable option.
patterns
: ["^err(or)?", "[Ee]rr(or)?$"]
A list of regular expressions used to match parameter names for detecting error objects in function parameters.
The default setting looks for any variable which starts with "err"/"error" or ends with "err"/"Err" or "error"/"Error".