Skip to content

Commit f3aeefb

Browse files
PoloSparkamareshsm
andauthored
docs: rewrite using let and const in rule examples (#19320)
* docs: rewrite var using let and const * docs: rewrite examples using let and const * docs: rewrite var using let and const * Update docs/src/rules/accessor-pairs.md Co-authored-by: Amaresh S M <amareshsm13@gmail.com> * Update docs/src/rules/accessor-pairs.md Co-authored-by: Amaresh S M <amareshsm13@gmail.com> * docs: rewrite using const * Update accessor-pairs.md * Update accessor-pairs.md * Update let variables to const --------- Co-authored-by: Amaresh S M <amareshsm13@gmail.com>
1 parent 0b680b3 commit f3aeefb

File tree

2 files changed

+82
-82
lines changed

2 files changed

+82
-82
lines changed

docs/src/rules/accessor-pairs.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Here are some examples:
1717

1818
```js
1919
// Bad
20-
var o = {
20+
const o = {
2121
set a(value) {
2222
this.val = value;
2323
}
2424
};
2525

2626

2727
// Good
28-
var o = {
28+
const p = {
2929
set a(value) {
3030
this.val = value;
3131
},
@@ -61,15 +61,15 @@ Examples of **incorrect** code for the default `{ "setWithoutGet": true }` optio
6161
```js
6262
/*eslint accessor-pairs: "error"*/
6363

64-
var o = {
64+
const q = {
6565
set a(value) {
6666
this.val = value;
6767
}
6868
};
6969

7070

71-
var o = {d: 1};
72-
Object.defineProperty(o, 'c', {
71+
const r = {d: 1};
72+
Object.defineProperty(r, 'c', {
7373
set: function(value) {
7474
this.val = value;
7575
}
@@ -85,7 +85,7 @@ Examples of **correct** code for the default `{ "setWithoutGet": true }` option:
8585
```js
8686
/*eslint accessor-pairs: "error"*/
8787

88-
var o = {
88+
const s = {
8989
set a(value) {
9090
this.val = value;
9191
},
@@ -94,8 +94,8 @@ var o = {
9494
}
9595
};
9696

97-
var o = {d: 1};
98-
Object.defineProperty(o, 'c', {
97+
const t = {d: 1};
98+
Object.defineProperty(t, 'c', {
9999
set: function(value) {
100100
this.val = value;
101101
},
@@ -117,27 +117,27 @@ Examples of **incorrect** code for the `{ "getWithoutSet": true }` option:
117117
```js
118118
/*eslint accessor-pairs: ["error", { "getWithoutSet": true }]*/
119119

120-
var o = {
120+
const u = {
121121
set a(value) {
122122
this.val = value;
123123
}
124124
};
125125

126-
var o = {
126+
const v = {
127127
get a() {
128128
return this.val;
129129
}
130130
};
131131

132-
var o = {d: 1};
133-
Object.defineProperty(o, 'c', {
132+
const w = {d: 1};
133+
Object.defineProperty(w, 'c', {
134134
set: function(value) {
135135
this.val = value;
136136
}
137137
});
138138

139-
var o = {d: 1};
140-
Object.defineProperty(o, 'c', {
139+
const x = {d: 1};
140+
Object.defineProperty(x, 'c', {
141141
get: function() {
142142
return this.val;
143143
}
@@ -152,7 +152,7 @@ Examples of **correct** code for the `{ "getWithoutSet": true }` option:
152152

153153
```js
154154
/*eslint accessor-pairs: ["error", { "getWithoutSet": true }]*/
155-
var o = {
155+
const y = {
156156
set a(value) {
157157
this.val = value;
158158
},
@@ -161,8 +161,8 @@ var o = {
161161
}
162162
};
163163

164-
var o = {d: 1};
165-
Object.defineProperty(o, 'c', {
164+
const z = {d: 1};
165+
Object.defineProperty(z, 'c', {
166166
set: function(value) {
167167
this.val = value;
168168
},
@@ -281,14 +281,14 @@ might not report a missing pair for a getter/setter that has a computed key, lik
281281
```js
282282
/*eslint accessor-pairs: "error"*/
283283

284-
var a = 1;
284+
const z = 1;
285285

286286
// no warnings
287-
var o = {
288-
get [a++]() {
287+
const a = {
288+
get [z++]() {
289289
return this.val;
290290
},
291-
set [a++](value) {
291+
set [z++](value) {
292292
this.val = value;
293293
}
294294
};
@@ -301,7 +301,7 @@ might not report a missing pair for a getter/setter, like in the following examp
301301
/*eslint accessor-pairs: "error"*/
302302

303303
// no warnings
304-
var o = {
304+
const b = {
305305
get a() {
306306
return this.val;
307307
},

docs/src/rules/array-bracket-newline.md

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ Examples of **incorrect** code for this rule with the `"always"` option:
3535
```js
3636
/*eslint array-bracket-newline: ["error", "always"]*/
3737

38-
var a = [];
39-
var b = [1];
40-
var c = [1, 2];
41-
var d = [1,
38+
const a = [];
39+
const b = [1];
40+
const c = [1, 2];
41+
const d = [1,
4242
2];
43-
var e = [function foo() {
43+
const e = [function foo() {
4444
dosomething();
4545
}];
4646
```
@@ -54,19 +54,19 @@ Examples of **correct** code for this rule with the `"always"` option:
5454
```js
5555
/*eslint array-bracket-newline: ["error", "always"]*/
5656

57-
var a = [
57+
const a = [
5858
];
59-
var b = [
59+
const b = [
6060
1
6161
];
62-
var c = [
62+
const c = [
6363
1, 2
6464
];
65-
var d = [
65+
const d = [
6666
1,
6767
2
6868
];
69-
var e = [
69+
const e = [
7070
function foo() {
7171
dosomething();
7272
}
@@ -84,19 +84,19 @@ Examples of **incorrect** code for this rule with the `"never"` option:
8484
```js
8585
/*eslint array-bracket-newline: ["error", "never"]*/
8686

87-
var a = [
87+
const a = [
8888
];
89-
var b = [
89+
const b = [
9090
1
9191
];
92-
var c = [
92+
const c = [
9393
1, 2
9494
];
95-
var d = [
95+
const d = [
9696
1,
9797
2
9898
];
99-
var e = [
99+
const e = [
100100
function foo() {
101101
dosomething();
102102
}
@@ -112,12 +112,12 @@ Examples of **correct** code for this rule with the `"never"` option:
112112
```js
113113
/*eslint array-bracket-newline: ["error", "never"]*/
114114

115-
var a = [];
116-
var b = [1];
117-
var c = [1, 2];
118-
var d = [1,
115+
const a = [];
116+
const b = [1];
117+
const c = [1, 2];
118+
const d = [1,
119119
2];
120-
var e = [function foo() {
120+
const e = [function foo() {
121121
dosomething();
122122
}];
123123
```
@@ -133,15 +133,15 @@ Examples of **incorrect** code for this rule with the `"consistent"` option:
133133
```js
134134
/*eslint array-bracket-newline: ["error", "consistent"]*/
135135

136-
var a = [1
136+
const a = [1
137137
];
138-
var b = [
138+
const b = [
139139
1];
140-
var c = [function foo() {
140+
const c = [function foo() {
141141
dosomething();
142142
}
143143
]
144-
var d = [
144+
const d = [
145145
function foo() {
146146
dosomething();
147147
}]
@@ -156,17 +156,17 @@ Examples of **correct** code for this rule with the `"consistent"` option:
156156
```js
157157
/*eslint array-bracket-newline: ["error", "consistent"]*/
158158

159-
var a = [];
160-
var b = [
159+
const a = [];
160+
const b = [
161161
];
162-
var c = [1];
163-
var d = [
162+
const c = [1];
163+
const d = [
164164
1
165165
];
166-
var e = [function foo() {
166+
const e = [function foo() {
167167
dosomething();
168168
}];
169-
var f = [
169+
const f = [
170170
function foo() {
171171
dosomething();
172172
}
@@ -184,17 +184,17 @@ Examples of **incorrect** code for this rule with the default `{ "multiline": tr
184184
```js
185185
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/
186186

187-
var a = [
187+
const a = [
188188
];
189-
var b = [
189+
const b = [
190190
1
191191
];
192-
var c = [
192+
const c = [
193193
1, 2
194194
];
195-
var d = [1,
195+
const d = [1,
196196
2];
197-
var e = [function foo() {
197+
const e = [function foo() {
198198
dosomething();
199199
}];
200200
```
@@ -208,14 +208,14 @@ Examples of **correct** code for this rule with the default `{ "multiline": true
208208
```js
209209
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/
210210

211-
var a = [];
212-
var b = [1];
213-
var c = [1, 2];
214-
var d = [
211+
const a = [];
212+
const b = [1];
213+
const c = [1, 2];
214+
const d = [
215215
1,
216216
2
217217
];
218-
var e = [
218+
const e = [
219219
function foo() {
220220
dosomething();
221221
}
@@ -233,15 +233,15 @@ Examples of **incorrect** code for this rule with the `{ "minItems": 2 }` option
233233
```js
234234
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/
235235

236-
var a = [
236+
const a = [
237237
];
238-
var b = [
238+
const b = [
239239
1
240240
];
241-
var c = [1, 2];
242-
var d = [1,
241+
const c = [1, 2];
242+
const d = [1,
243243
2];
244-
var e = [
244+
const e = [
245245
function foo() {
246246
dosomething();
247247
}
@@ -257,16 +257,16 @@ Examples of **correct** code for this rule with the `{ "minItems": 2 }` option:
257257
```js
258258
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/
259259

260-
var a = [];
261-
var b = [1];
262-
var c = [
260+
const a = [];
261+
const b = [1];
262+
const c = [
263263
1, 2
264264
];
265-
var d = [
265+
const d = [
266266
1,
267267
2
268268
];
269-
var e = [function foo() {
269+
const e = [function foo() {
270270
dosomething();
271271
}];
272272
```
@@ -282,15 +282,15 @@ Examples of **incorrect** code for this rule with the `{ "multiline": true, "min
282282
```js
283283
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/
284284

285-
var a = [
285+
const a = [
286286
];
287-
var b = [
287+
const b = [
288288
1
289289
];
290-
var c = [1, 2];
291-
var d = [1,
290+
const c = [1, 2];
291+
const d = [1,
292292
2];
293-
var e = [function foo() {
293+
const e = [function foo() {
294294
dosomething();
295295
}];
296296
```
@@ -304,16 +304,16 @@ Examples of **correct** code for this rule with the `{ "multiline": true, "minIt
304304
```js
305305
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/
306306

307-
var a = [];
308-
var b = [1];
309-
var c = [
307+
const a = [];
308+
const b = [1];
309+
const c = [
310310
1, 2
311311
];
312-
var d = [
312+
const d = [
313313
1,
314314
2
315315
];
316-
var e = [
316+
const e = [
317317
function foo() {
318318
dosomething();
319319
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy