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
no-undefined doesn't allow undefined as an object property #7964
no-undefined doesn't allow undefined as an object property #7964
Comments
Reproduced in the online demo. I assume all of the following should be valid cases. 'use strict';
var foo = {
undefined: 'bar',
};
// ES6 destructuring, case 1
var { undefined: bar } = foo;
// Invalid? ES6 destructuring, case 2
var { bar: undefined } = foo; |
They might only be valid in strict mode, with an ecmaVersion > 5 or 6 - but I think there's other rules that can handle that.
|
@ljharb What about in sloppy ES6, can you assign to |
A local variable called |
@not-an-aardvark Thanks, that helps a bit. Unfortunately I'm not super familiar with destructuring. Do these cases create/shadow // Case 1
var { bar: undefined } = foo;
// Case 2
({ bar: undefined } = foo); Feel free to edit this post with inline remarks if it's easier. Thanks for your help. |
Case 1 creates a local variable The ES5 equivalents of those cases are: // Case 1
var undefined = foo.bar;
// Case 2
undefined = foo.bar; |
Okay. I assume that assigning to |
Tell us about your environment
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.
What did you expect to happen?
undefined
should be permitted as an unquoted object property.What actually happened? Please include the actual, raw output from ESLint.
no-undefined
produces an error. Quotingundefined
(which would otherwise be a workaround) produces an error fromquote-props
.Given that
undefined
is a permissable object property name, I believeno-undefined
should be modified to permit this behaviour.The text was updated successfully, but these errors were encountered: