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

False positive from no-console when console is a custom object #7010

Closed
jochenberger opened this issue Aug 29, 2016 · 4 comments
Closed

False positive from no-console when console is a custom object #7010

jochenberger opened this issue Aug 29, 2016 · 4 comments
Assignees
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

@jochenberger
Copy link

The following code should not lead to an error/warning:

import console from 'customConsole';

console.info("Hello World!")
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 29, 2016
@mysticatea mysticatea added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Aug 29, 2016
@mysticatea
Copy link
Member

mysticatea commented Aug 29, 2016

Thank you for this issue.

I confirmed it.

@pmcelhaney
Copy link
Contributor

I don't think that's how no-console is supposed to work.

This isn't allowed either.

/*eslint no-console: "error" */
var console = {
  log: function (msg) {

  }
}

console.log('hello');

The name "console" is so ingrained that having a variable named "console" that isn't the built-in object can be confusing. I would suggest either using a different variable name or disabling the rule.

@platinumazure
Copy link
Member

@pmcelhaney I understand your reasoning, but it would at least be nice to be consistent with no-alert (which, if I recall correctly, is smart enough not to report when shadowed). At the very least we would need to decide what the best policy is for both rules (or perhaps add an option to allow users to configure whether shadowing should be flagged or not).

@pmcelhaney
Copy link
Contributor

Ah, good point. no-alert does indeed allow alert to be shadowed.

#1105

@mysticatea mysticatea self-assigned this Aug 31, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@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 Feb 6, 2018
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

No branches or pull requests

5 participants