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

experimentalObjectRestSpread should allow AssignmentExpression #167

Closed
gre opened this issue Jul 16, 2015 · 5 comments
Closed

experimentalObjectRestSpread should allow AssignmentExpression #167

gre opened this issue Jul 16, 2015 · 5 comments

Comments

@gre
Copy link

gre commented Jul 16, 2015

I have first created the issue at eslint/eslint#3030

const foo = {
  a: 1
}
const obj = {
  foo
};
const bar = "bar";
const res2 = {
  ...obj.foo, // does not get parsed, unexpected '.'
  bar
};
@michaelficarra
Copy link
Member

Note that AssignmentExpression is only allowed in spread position. Object rest, like array and parameter list rest, still only allows BindingIdentifier.

@nzakas
Copy link
Member

nzakas commented Jul 16, 2015

Thanks, I'll take a look.

@nzakas
Copy link
Member

nzakas commented Jul 16, 2015

Working on this.

@nzakas nzakas closed this as completed in b12548b Jul 16, 2015
nzakas added a commit that referenced this issue Jul 16, 2015
Fix: Allow AssignmentExpression in object spread (fixes #167)
@gre
Copy link
Author

gre commented Jul 17, 2015

Hi,
thanks for the fast handling of the issue :)
I still can't make this working (I'm not having the same error though), I don't know if this is from espree or eslint.

Here is what happens to me:

$ npm install -g [email protected]     # this grabs espree 2.2.2
...
$ eslint test.js
/Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/lib/rules/no-dupe-keys.js:25
                var keyName = property.key.name || property.key.value,
                                          ^
TypeError: Cannot read property 'name' of undefined
    at /Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/lib/rules/no-dupe-keys.js:25:43
    at Array.forEach (native)
    at EventEmitter.ObjectExpression (/Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/lib/rules/no-dupe-keys.js:24:29)
    at emitOne (events.js:82:20)
    at EventEmitter.emit (events.js:169:7)
    at Controller.controller.traverse.enter (/Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/lib/eslint.js:790:25)
    at Controller.__execute (/Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:495:28)
    at EventEmitter.module.exports.api.verify (/Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/lib/eslint.js:783:24)
    at processText (/Users/gre/.nvm/versions/io.js/v2.3.4/lib/node_modules/eslint/lib/cli-engine.js:199:27)

test.js

const a = { foo: {} };

const b = {
  ...a.foo,
  a
};

.eslintrc

{
    "rules": {
        "indent": [
            2,
            4
        ],
        "quotes": [
            2,
            "double"
        ],
        "linebreak-style": [
            2,
            "unix"
        ],
        "semi": [
            2,
            "always"
        ]
    },
    "env": {
        "es6": true,
        "browser": true
    },
    "extends": "eslint:recommended",
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true
    }
}

@gre
Copy link
Author

gre commented Jul 17, 2015

ok I'll create it on eslint project, this seems to be related to no-dupe-keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants