coffeelint-callback-handle-error
Coffeelint rule finds instances of error objects passed through a callback not being handled
Last updated 3 years ago by srgraham .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install coffeelint-callback-handle-error 
SYNC missed versions from official npm registry.

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:

fs.stat '/invalid/path/to/file', (err, stats)->
  console.log stats
  return
fs.stat '/invalid/path/to/file', (err, stats)->
  # this err is not handled and is instead overwritten by the next stat

  fs.stat '/some/other/invalid/file', (err, stats2)->
    if err
      console.log err
    return
  return

These examples will pass, since their error variables are handled:

fs.stat '/invalid/path/to/file', (err, stats)->
  if err
    console.log err
  return
doStuff 123, (callback)->
  fs.stat '/invalid/path/to/file', (err, stats)->
    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": {
  "module": "coffeelint-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".

Current Tags

  • 1.0.3                                ...           latest (3 years ago)

4 Versions

  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |