@@ -16,14 +16,14 @@ Here are a few common examples using the ES5 syntax:
1616
1717``` js
1818// properties
19- var foo = {
19+ const foo = {
2020 x: x,
2121 y: y,
2222 z: z,
2323};
2424
2525// methods
26- var foo = {
26+ const bar = {
2727 a : function () {},
2828 b : function () {}
2929};
@@ -33,10 +33,10 @@ Now here are ES6 equivalents:
3333
3434``` js
3535// properties
36- var foo = {x, y, z};
36+ const foo = {x, y, z};
3737
3838// methods
39- var foo = {
39+ const bar = {
4040 a () {},
4141 b () {}
4242};
@@ -53,7 +53,7 @@ Each of the following properties would warn:
5353``` js
5454/* eslint object-shorthand: "error"*/
5555
56- var foo = {
56+ const foo = {
5757 w : function () {},
5858 x : function * () {},
5959 [y]: function () {},
@@ -66,7 +66,7 @@ In that case the expected syntax would have been:
6666``` js
6767/* eslint object-shorthand: "error"*/
6868
69- var foo = {
69+ const foo = {
7070 w () {},
7171 * x () {},
7272 [y ]() {},
@@ -80,7 +80,7 @@ The following will *not* warn:
8080``` js
8181/* eslint object-shorthand: "error"*/
8282
83- var foo = {
83+ const foo = {
8484 x : (y ) => y
8585};
8686```
@@ -126,7 +126,7 @@ Example of **incorrect** code for this rule with the `"always", { "avoidQuotes":
126126``` js
127127/* eslint object-shorthand: ["error", "always", { "avoidQuotes": true }]*/
128128
129- var foo = {
129+ const foo = {
130130 " bar-baz" () {}
131131};
132132```
@@ -140,7 +140,7 @@ Example of **correct** code for this rule with the `"always", { "avoidQuotes": t
140140``` js
141141/* eslint object-shorthand: ["error", "always", { "avoidQuotes": true }]*/
142142
143- var foo = {
143+ const foo = {
144144 " bar-baz " : function () {},
145145 " qux" : qux
146146};
@@ -163,7 +163,7 @@ Example of **correct** code for this rule with the `"always", { "ignoreConstruct
163163``` js
164164/* eslint object-shorthand: ["error", "always", { "ignoreConstructors": true }]*/
165165
166- var foo = {
166+ const foo = {
167167 ConstructorFunction : function () {}
168168};
169169```
@@ -179,7 +179,7 @@ Example of **correct** code for this rule with the `"always", { "methodsIgnorePa
179179``` js
180180/* eslint object-shorthand: ["error", "always", { "methodsIgnorePattern": "^bar$" }]*/
181181
182- var foo = {
182+ const foo = {
183183 bar : function () {}
184184};
185185```
@@ -201,7 +201,7 @@ Example of **incorrect** code for this rule with the `"always", { "avoidExplicit
201201``` js
202202/* eslint object-shorthand: ["error", "always", { "avoidExplicitReturnArrows": true }]*/
203203
204- var foo = {
204+ const foo = {
205205 foo : (bar , baz ) => {
206206 return bar + baz;
207207 },
@@ -221,7 +221,7 @@ Example of **correct** code for this rule with the `"always", { "avoidExplicitRe
221221``` js
222222/* eslint object-shorthand: ["error", "always", { "avoidExplicitReturnArrows": true }]*/
223223
224- var foo = {
224+ const foo = {
225225 foo (bar , baz ) {
226226 return bar + baz;
227227 },
@@ -239,7 +239,7 @@ Example of **incorrect** code for this rule with the `"consistent"` option:
239239``` js
240240/* eslint object-shorthand: [2, "consistent"]*/
241241
242- var foo = {
242+ const foo = {
243243 a,
244244 b: " foo" ,
245245};
@@ -254,12 +254,12 @@ Examples of **correct** code for this rule with the `"consistent"` option:
254254``` js
255255/* eslint object-shorthand: [2, "consistent"]*/
256256
257- var foo = {
257+ const foo = {
258258 a: a,
259259 b: " foo"
260260};
261261
262- var bar = {
262+ const bar = {
263263 a,
264264 b,
265265};
@@ -274,7 +274,7 @@ Example of **incorrect** code with the `"consistent-as-needed"` option, which is
274274``` js
275275/* eslint object-shorthand: [2, "consistent-as-needed"]*/
276276
277- var foo = {
277+ const foo = {
278278 a: a,
279279 b: b,
280280};
0 commit comments