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

Duplicate errors when reassigning native globals #731

Closed
nickmccurdy opened this issue Jan 3, 2017 · 3 comments

Comments

@nickmccurdy
Copy link

commented Jan 3, 2017

I have some test code that needs to reassign global because the implementation code is instrumenting the global scope with a DSL, but I don't want this to pollute my tests.

According to eslint, this should be as simple as disabling no-native-reassign, or the new no-global-assign which deprecates it. I would except that I would only need to disable one of these rules, but standard -v produces two errors for the same line, one for each rule. I would expect to only need to disable the latter. This looked like an issue with standard to me, but I'll reopen this upstream if you think it's internal to eslint.

Reproduction

With standard@8.6.0:

var oldGlobal = global
global = oldGlobal

Expected

standard: Use JavaScript Standard Style (http://standardjs.com)
  /Users/nick/Repos/purified/test/example.js:2:1: Read-only global 'global' should not be modified. (no-global-assign)

Actual

standard: Use JavaScript Standard Style (http://standardjs.com)
  /Users/nick/example.js:2:1: Read-only global 'global' should not be modified. (no-global-assign)
  /Users/nick/example.js:2:1: Read-only global 'global' should not be modified. (no-native-reassign)

Workaround

Disabling a single rule doesn't work, you must disable both.

var oldGlobal = global
global = oldGlobal // eslint-disable-line no-native-reassign, no-global-assign

feross added a commit to standard/eslint-config-standard that referenced this issue Jan 18, 2017

Remove deprecated no-native-reassign rule
The replacement rule "no-global-assign" is already enabled.

Fix standard/standard#731
@feross

This comment has been minimized.

Copy link
Member

commented Jan 18, 2017

@nickmccurdy You're correct. We currently have both rules enabled. I'll disable the deprecated one.

@feross

This comment has been minimized.

Copy link
Member

commented Jan 18, 2017

This will go out in the next release of standard

@nickmccurdy

This comment has been minimized.

Copy link
Author

commented Jan 18, 2017

Cool, thanks!

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.