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

Fix: no-new-wrappers reports only wrappers #11984

Closed
wants to merge 1 commit into from

Conversation

mysticatea
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 12.2.0
  • npm Version: 6.9.2

What parser (default, Babel-ESLint, etc.) are you using?

Default.

Please show your full configuration:
What did you do? Please include the actual source code causing the issue.

new Math
new JSON
> eslint test.js --no-eslintrc --no-ignore --rule "no-new-wrappers:error"

What did you expect to happen?

No errors because those are not wrappers.

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

~\dev\eslint\test.js
  1:1  error  Do not use Math as a constructor  no-new-wrappers
  2:1  error  Do not use JSON as a constructor  no-new-wrappers

✖ 2 problems (2 errors, 0 warnings)

What changes did you make? (Give an overview)

This PR makes no-new-wrappers reporting only wrappers.

I guess that no-obj-calls rule is a more proper place to report it.

Is there anything you'd like reviewers to focus on?

Is this direction correct?

@mysticatea mysticatea added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 14, 2019
@mdjermanovic
Copy link
Member

From the history it seems that Math and JSON were inherited from the removed no-ctor rule.

I'd be happy to prepare PR to check NewExpression nodes as well in no-obj-calls. This should catch only runtime errors as the rule checks the globals only since the last commit, so I guess it is acceptable for a semver-minor?

@ljharb
Copy link
Sponsor Contributor

ljharb commented Sep 14, 2019

they're not wrappers, but since those things are always objects and never functions, it's never code that should ship to production. Perhaps the replacement could merge before this fix?

@mdjermanovic
Copy link
Member

Would be good to merge both at the same time, or maybe better have a single PR for both changes.

(of course, all this if it's acceptable for a semver-minor to have more warnings in no-obj-calls by default)

@platinumazure
Copy link
Member

I think we need an RFC with more specific details to show the full design needed to solve this issue.

@kaicataldo
Copy link
Member

How do we want to proceed here?

@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Feb 7, 2020
@nzakas
Copy link
Member

nzakas commented Feb 7, 2020

I'd recommend we merge this PR and update no-obj-calls to cover Math and JSON.

@mdjermanovic
Copy link
Member

I'd recommend we merge this PR and update no-obj-calls to cover Math and JSON.

PR #12909

@nzakas
Copy link
Member

nzakas commented Feb 25, 2020

@mysticatea can you take a look at the merge conflicts on this?

@nzakas
Copy link
Member

nzakas commented Mar 24, 2020

The commits in this PR have been included in #12909, so closing this one.

@nzakas nzakas closed this Mar 24, 2020
@mysticatea mysticatea deleted the fix-no-new-wrappers branch April 14, 2020 09:01
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 22, 2020
@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 Sep 22, 2020
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 this pull request may close these issues.

None yet

6 participants