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

not work "builtinGlobals" in rule "no-redeclare" #8814

Closed
boggddan opened this issue Jun 26, 2017 · 7 comments · Fixed by homezen/eslint-config-homezen#43
Closed

not work "builtinGlobals" in rule "no-redeclare" #8814

boggddan opened this issue Jun 26, 2017 · 7 comments · Fixed by homezen/eslint-config-homezen#43
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 documentation Relates to ESLint's documentation rule Relates to ESLint's core rules

Comments

@boggddan
Copy link

Tell us about your environment

  • ESLint Version:
    v4.0.0
  • Node Version:
    v8.0.0
  • npm Version:
    v5.0.0

Hi, maybe I finded bug.
Not wokr rule property "builtinGlobals" in rule "no-redeclare".

/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
/*eslint-env browser*/

var top = 0;
var Object = 0;

console message without error "no-redeclare"

4:1   error  Unexpected var, use let or const instead        no-var
  4:5   error  'top' is assigned a value but never used        no-unused-vars
  4:11  error  Number constants declarations must use 'const'  no-magic-numbers
  5:1   error  Unexpected var, use let or const instead        no-var
  5:5   error  'Object' is assigned a value but never used     no-unused-vars
  5:14  error  Number constants declarations must use 'const'  no-magic-numbers
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 26, 2017
@platinumazure platinumazure added bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion question This issue asks a question about ESLint rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jun 26, 2017
@platinumazure
Copy link
Member

platinumazure commented Jun 26, 2017

Not 100% sure what's going on here, to be honest. Seems like a potential bug, but it might just be that your configuration needs to have a particular setting and we need to update the docs. Unfortunately, I can't tell immediately from the rule's source code.

@not-an-aardvark
Copy link
Member

I can't reproduce this issue. no-redeclare is reporting an error with your code, as expected:

@boggddan
Copy link
Author

I turning offall rule in my configuration file. And testing with the clean project.
Maybe, linter on the site use other version and I run Eslint in console and vs code editor, error not popping.

My .eslint.js

module.exports = {
  env: {
    browser: true,
    es6: true,
    jquery: true,
    node: true
  },
  extends: 'eslint:recommended',
  parserOptions: {
    ecmaVersion: 2017,
    sourceType: 'script',
    ecmaFeatures: {
      experimentalObjectRestSpread: true
    },
  }
};

VSCode Editor:
2017-06-27_09h09_01

Console:
2017-06-27_09h12_12

@mysticatea
Copy link
Member

Because you have env: {node: true} in your configuration.
The node environment has special function scope which encloses whole code. So variable declarations shadow globals but don't redeclare globals.

@platinumazure platinumazure added works as intended The behavior described in this issue is working correctly and removed bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion question This issue asks a question about ESLint rule Relates to ESLint's core rules labels Jun 27, 2017
@platinumazure
Copy link
Member

Per @mysticatea above, this is working as intended.

@boggddan I see that the no-shadow rule has a similar builtinGlobals option. I think that rule/option will do what you want. Please give it a shot, and if it doesn't work, please stop by our chatroom. Thanks!

@boggddan
Copy link
Author

@mysticatea, Thanks. It does work!
@platinumazure Could you make a note in the documentation about the fact that the builtinGlobals: true option. does not work when the parameter is switched on env: {node: true}. Thanks.

@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion documentation Relates to ESLint's documentation rule Relates to ESLint's core rules and removed works as intended The behavior described in this issue is working correctly labels Jun 27, 2017
@platinumazure
Copy link
Member

Good point @boggddan, we should add a note about module scope for Node and similar environments and recommend no-shadow's equivalent option. Thanks!

@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 documentation Relates to ESLint's documentation rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants