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

Closed
lo1tuma opened this issue Apr 21, 2019 · 1 comment · Fixed by #11638
Closed

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

lo1tuma opened this issue Apr 21, 2019 · 1 comment · Fixed by #11638
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@lo1tuma
Copy link
Member

lo1tuma 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.

@lo1tuma lo1tuma added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Apr 21, 2019
@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Apr 22, 2019
@platinumazure
Copy link
Member

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!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Oct 28, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants