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

Remove deprecated key 'root' from node's env #9144

Closed
eight04 opened this issue Aug 23, 2017 · 4 comments
Closed

Remove deprecated key 'root' from node's env #9144

eight04 opened this issue Aug 23, 2017 · 4 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion works as intended The behavior described in this issue is working correctly

Comments

@eight04
Copy link

eight04 commented Aug 23, 2017

Tell us about your environment

  • ESLint Version: 4.5.0
  • Node Version: 7.9.0
  • npm Version: 5.3.0

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

Please show your full configuration:

Configuration
eslint --no-eslintrc --env es6,node --rule "no-undef: 2" test.js

What did you do? Please include the actual source code causing the issue.

class Test {
	constructor(root) {
		this.root = root;
	}
	doSomething() {
		console.log(`${root}`);
	}
}

What did you expect to happen?

  6:18  error  'root' is not defined     no-undef

What actually happened? Please include the actual, raw output from ESLint.
Nothing is reported, because root is a global variable in node env.

However, global root is a deprecated feature. By removing root from node's env, it should help those developers that accidentally access global root variable.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 23, 2017
@kaicataldo
Copy link
Member

kaicataldo commented Aug 23, 2017

Unfortunately, ESLint can't make any assumptions about which version of Node someone is using. This is the package we use: https://github.com/sindresorhus/globals/blob/master/globals.json#L867

There are third party plugins such as https://www.npmjs.com/package/eslint-plugin-node that will actually do feature-checking based on the Node version, and something like that could be a good place for a feature like this.

Alternatively, are you suggesting that ESLint should be enhanced to allow specification of the target Node version? That's an interesting thought, though it's not a trivial thing to implement.

@kaicataldo kaicataldo added works as intended The behavior described in this issue is working correctly and removed triage An ESLint team member will look at this issue soon labels Aug 23, 2017
@eight04
Copy link
Author

eight04 commented Aug 24, 2017

It seems that this issue should be moved to https://github.com/sindresorhus/globals.

I understand those platform-specified rules should be handled by plugins. However, I don't know if env global is in this case. Are those globals maintained by ESLint team? For example, Greasemonkey is working on version 4.0 which might add/remove some globals too (greasemonkey/greasemonkey#2484).

BTW, https://github.com/mysticatea/eslint-plugin-node looks good. I'll definitely try it.

@eight04
Copy link
Author

eight04 commented Aug 24, 2017

@platinumazure
Copy link
Member

@eight04 By the way, you could use no-restricted-globals to enforce that root is not used as a global in your code.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 21, 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 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion works as intended The behavior described in this issue is working correctly
Projects
None yet
Development

No branches or pull requests

4 participants