Skip to content

Commit 17cb958

Browse files
docs: replace var with let and const in rule examples (#19515)
1 parent 83e24f5 commit 17cb958

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

docs/src/rules/no-caller.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The use of `arguments.caller` and `arguments.callee` make several code optimizat
88

99
```js
1010
function foo() {
11-
var callee = arguments.callee;
11+
const callee = arguments.callee;
1212
}
1313
```
1414

docs/src/rules/no-delete-var.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Examples of **incorrect** code for this rule:
2020
```js
2121
/*eslint no-delete-var: "error"*/
2222

23-
var x;
23+
let x;
2424
delete x;
2525
```
2626

docs/src/rules/no-extend-native.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ For example here we are overriding a builtin method that will then affect all Ob
1515
Object.prototype.extra = 55;
1616

1717
// loop through some userIds
18-
var users = {
18+
const users = {
1919
"123": "Stan",
2020
"456": "David"
2121
};
2222

2323
// not what you'd expect
24-
for (var id in users) {
24+
for (const id in users) {
2525
console.log(id); // "123", "456", "extra"
2626
}
2727
```
@@ -68,7 +68,7 @@ Object.prototype.a = "a";
6868
This rule *does not* report any of the following less obvious approaches to modify the prototype of builtin objects:
6969

7070
```js
71-
var x = Object;
71+
const x = Object;
7272
x.prototype.thing = a;
7373

7474
eval("Array.prototype.forEach = 'muhahaha'");

docs/src/rules/no-extra-bind.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ further_reading:
1111
The `bind()` method is used to create functions with specific `this` values and, optionally, binds arguments to specific values. When used to specify the value of `this`, it's important that the function actually uses `this` in its function body. For example:
1212

1313
```js
14-
var boundGetName = (function getName() {
14+
const boundGetName = (function getName() {
1515
return this.name;
1616
}).bind({ name: "ESLint" });
1717

@@ -24,7 +24,7 @@ Sometimes during the course of code maintenance, the `this` value is removed fro
2424

2525
```js
2626
// useless bind
27-
var boundGetName = (function getName() {
27+
const boundGetName = (function getName() {
2828
return "ESLint";
2929
}).bind({ name: "ESLint" });
3030

@@ -46,25 +46,25 @@ Examples of **incorrect** code for this rule:
4646
```js
4747
/*eslint no-extra-bind: "error"*/
4848

49-
var x = function () {
49+
const x = function () {
5050
foo();
5151
}.bind(bar);
5252

53-
var x = (() => {
53+
const y = (() => {
5454
foo();
5555
}).bind(bar);
5656

57-
var x = (() => {
57+
const z = (() => {
5858
this.foo();
5959
}).bind(bar);
6060

61-
var x = function () {
61+
const a = function () {
6262
(function () {
6363
this.foo();
6464
}());
6565
}.bind(bar);
6666

67-
var x = function () {
67+
const b = function () {
6868
function foo() {
6969
this.bar();
7070
}
@@ -80,11 +80,11 @@ Examples of **correct** code for this rule:
8080
```js
8181
/*eslint no-extra-bind: "error"*/
8282

83-
var x = function () {
83+
const x = function () {
8484
this.foo();
8585
}.bind(bar);
8686

87-
var x = function (a) {
87+
const y = function (a) {
8888
return a + 1;
8989
}.bind(foo, bar);
9090
```

docs/src/rules/no-global-assign.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Examples of **correct** code for this rule:
5757
/*eslint no-global-assign: "error"*/
5858

5959
a = 1
60-
var b = 1
60+
let b = 1
6161
b = 2
6262
```
6363

0 commit comments

Comments
 (0)