1

We're using promises in an AngularJS project and want to ensure that the then method is always called with 2 arguments, the 2nd being an error handler, like so:

$http.get(url).then(function () {
  console.log('hooray!');
}, function (error) {
  console.log('boo! error');
});

We're using jshint on the project. Can that perform this analysis?

Some calls to then do not require an error handler, i.e. in a chain of handlers:

$http.get(url1).then(function () {
  console.log('hooray!');
  return $http.get(url2);
}).then(function () {
  console.log('hooray again! all our data loaded');
}, function (error) {
  console.log('boo! error in one of our 2 requests');
});

We could mark these up using jshint's /* jshint ignore:start */ comments or similar.

afternoon
  • 1,285
  • 16
  • 25

0 Answers0