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

Require Object Literal Shorthand Syntax (object-shorthand) #1354

Open
feross opened this issue Aug 12, 2019 · 1 comment

Comments

@feross
Copy link
Member

commented Aug 12, 2019

Thoughts on enabling this rule? https://eslint.org/docs/rules/object-shorthand

ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner.

Here are a few common examples using the ES5 syntax:

// properties
var foo = {
    x: x,
    y: y,
    z: z,
}

// methods
var foo = {
    a: function() {},
    b: function() {}
}

Now here are ES6 equivalents:

// properties
var foo = {x, y, z}

// methods
var foo = {
    a() {},
    b() {}
}

Related to: #159

@feross feross added the enhancement label Aug 12, 2019

@mightyiam

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2019

I'd love this.

avoidQuotes

false, because minimalism? Although I don't remember writing such a function. avoidQuotes is relevant only to functions, isn't it? If I understand this correctly, then I'd say false. I have no problem with

{ 'foo-bar'() {} }

ignoreConstructors

Why is this a thing, please? I don't understand how in the example the rule can figure out that it's a constructor. It determines according to the name of the function, ConstructorFunction? Is it case detection?

And, again, why bother making it an exception at all?

avoidExplicitReturnArrows

I kinda like it. Yes... I'd say true. It kinda gets a bit too nit-picky compared to the rest of Standard, maybe. But why not? There are two ways of writing it and we can decide on one.

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