Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-throw-literal: confusing error message when throwing object literal #11637

lo1tuma opened this issue Apr 21, 2019 · 1 comment


None yet
2 participants
Copy link

commented Apr 21, 2019

Tell us about your environment

  • ESLint Version: 6.0.0-alpha.0 and 5.16.0 (via demo)
  • Node Version: 11.13.0
  • npm Version: I’m using pnpm v3.0.1 instead of npm

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Here is an example of the problem where a object literal is thrown:

throw { foo: 'bar' };

What did you expect to happen?

I think the wording of the reported message is very confusing because in my example I did throw an object. I would expect a message like Unexpected object literal thrown. or Expected an error object to be thrown..

What actually happened? Please include the actual, raw output from ESLint.

The reported problem message is Expected an object to be thrown..

Are you willing to submit a pull request to fix this bug?

Yes. However I’m not completely sure if this will be considered as a bug or as a breaking change.

@platinumazure platinumazure added accepted rule and removed triage labels Apr 22, 2019


This comment has been minimized.

Copy link

commented Apr 22, 2019

Hi @lo1tuma, thanks for the issue!

I think this is reasonable to fix as a bugfix. I personally like this message: Expected an error object to be thrown. (Using an "Unexpected" message might require that we craft similar language for string literals and other literal values of different types.) Other team members may feel differently, but I think this would be a great starting point for a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.