alphapilgrim
alphapilgrim

Reputation: 3975

Does EsLint have a rule to prefer Object values as key and value?

Looking for a rule(can't seem to find anything, might've just missed it) in EsLint to basically prefer something like this:

const example = {
    foo,
    bar
};

vs something like this:

const example = {
    foo: foo,
    bar: bar
};

Thanks in advance!

Upvotes: 2

Views: 1042

Answers (1)

GOTO 0
GOTO 0

Reputation: 47961

You are looking for the rule object-shorthand:

Requires or disallows method and property shorthand syntax for object literals.

It will work fine with the default settings. You can test it in this demo.

Upvotes: 2

Related Questions