question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatibility with ESLint's "no-throw-literal" rule

See original GitHub issue

Hi,

Async validation example ( http://redux-form.com/6.4.3/examples/asyncValidation/ ) advises to throw an object on error, however eslint’s “no-throw-literal” (ex. part of AirBnb’s eslint rules) will return an error in this case, expecting an Error object only. However, when trying to throw an Error obj. from the async validator, the validator fails (uncaught exception).

For now, as a workaround I have to use

      /* eslint no-throw-literal: "off" */
      throw { email: 'Unknown error :(' };

Please advise if it is possible to throw an Error? If not, please consider this to be a feature request.

Thanks D

P.S. Sorry for several words “error” on every line ;-P

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

8reactions
gustavohenkecommented, Jan 14, 2017

You could do this instead:

return Promise.reject({ foo: "bar" });
1reaction
idangozlancommented, May 16, 2018

It’s not a good workaround. let’s create asyncValidatorError class? or it should accept SubmissionError class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-throw-literal - ESLint - Pluggable JavaScript Linter
This rule is aimed at maintaining consistency when throwing exception by disallowing to throw literals and other expressions which cannot possibly be an...
Read more >
no-throw-literal | typescript-eslint
This rule is aimed at maintaining consistency when throwing exception by disallowing to throw literals and other expressions which cannot possibly be an...
Read more >
Proposal: no-reject-literal rule · Issue #7685 · eslint ... - GitHub
Basically, I think reporting object and array expressions is probably more correct, but it would be inconsistent with no-throw-literal . Since ...
Read more >
How to only disable 'no-throw-literal' webpack warnings?
For the moment, I'd like to disable all 'no-throw-literal' warnings globally. How can I do this (without typing // eslint-disable-next-line ...
Read more >
Changelog - JavaScript Standard Style
This pre-release exists to test out the ESLint 8 related changes and discover possible backwards incompatible changes that comes with it and mitigate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found