0.1.9 • Published 10 years ago

thenlint v0.1.9

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

thenlint

A lint for promises that checks for possible Promise.then usage errors.

usage

From the command-line:

thenlint <file.js> [<other.js> ...]

As a library:

report = require('thenlint')(fileContent, filename)
  .map(function(item) { return item.toString(); }).join('\n');

example errors

Suggests ending the promise chain with .done()

// no return or var/assignment
promise.then(function(val) {
  console.log(val);
}); // no errback
// no catch and no .done()

Missing return statement in the middle of a return chain:

promise.then(function(val) {
  // not returning from then
  console.log(val);
  
// but trying to chain another
// call to then/spread
}).then(function(other) {
  // anything
});

non-errors

Adding catch instead of done is okay.

Not returning from within .then is okay as long as we're not trying to chain another .then or .spread

// no return or assignment
promise.then(function(val) {
  // no return...
  console.log(val);
// but has an error handler
// and is not trying to chain a .then/.spread
}).catch(function(err) {
  // anything
}); 

license

MIT

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago