Expected property shorthand warning on computed property #6015

Closed
kikoanis opened this Issue Apr 30, 2016 · 7 comments

Projects

None yet

5 participants

@kikoanis
kikoanis commented Apr 30, 2016 edited

What version of ESLint are you using?
2.9.0

What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint = 6.0.4

Please show your full configuration:

rules: {
   ...
   "object-shorthand": 1,
   ...
}

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

const constant = 'foo'
....
const obj = { [constant]: constant }

What did you expect to happen?
This should pass or I am missing something on how to do it.
What actually happened? Please include the actual, raw output from ESLint.
warning Expected property shorthand object-shorthand

@eslintbot eslintbot added the triage label Apr 30, 2016
@kaicataldo kaicataldo added bug rule evaluating and removed triage labels Apr 30, 2016
@kaicataldo
Member
kaicataldo commented Apr 30, 2016 edited

Can you share the config you're using? Do you have the object-shorthand rule turned on? With the information you provided, it looks like you're not using the object shorthand syntax and, assuming you have the rule turned on in your config, this warning is the expected behavior. The shorthand notation would be:

const constant = 'foo'
const obj = { 
  constant
}
@michaelficarra
Member

@kaicataldo Look again at the example. The property name is computed.

@kaicataldo
Member

Ah, I see. Shouldn't be doing this so late.

@kikoanis

Updated my original comment to add the configuration part that is responsible for object-shorthand. I do not see any issue here. I only encountered this after upgrading to 2.9.0 and I suspect it is related to this e2ad1ec

@kaicataldo
Member
kaicataldo commented Apr 30, 2016 edited

@kikoanis Yeah, sorry, I shouldn't have been trying to triage so late in the evening. It does seem like a bug introduced in this commit: e2ad1ec.

Edit: Was able to recreate locally with the default parser as well.

@kaicataldo kaicataldo added accepted and removed evaluating labels Apr 30, 2016
@kaicataldo
Member

PR opened to fix this.

@benjycui benjycui referenced this issue in ant-design/ant-design May 3, 2016
Closed

site: add i18n for website #1443

@nzakas nzakas closed this in ef8cbff May 3, 2016
@252405649

good

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