diff --git a/docs/src/rules/no-prototype-builtins.md b/docs/src/rules/no-prototype-builtins.md index e3da23e9cdc6..81b01999af0d 100644 --- a/docs/src/rules/no-prototype-builtins.md +++ b/docs/src/rules/no-prototype-builtins.md @@ -22,11 +22,11 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-prototype-builtins: "error"*/ -var hasBarProperty = foo.hasOwnProperty("bar"); +const hasBarProperty = foo.hasOwnProperty("bar"); -var isPrototypeOfBar = foo.isPrototypeOf(bar); +const isPrototypeOfBar = foo.isPrototypeOf(bar); -var barIsEnumerable = foo.propertyIsEnumerable("bar"); +const barIsEnumerable = foo.propertyIsEnumerable("bar"); ``` ::: @@ -38,11 +38,11 @@ Examples of **correct** code for this rule: ```js /*eslint no-prototype-builtins: "error"*/ -var hasBarProperty = Object.prototype.hasOwnProperty.call(foo, "bar"); +const hasBarProperty = Object.prototype.hasOwnProperty.call(foo, "bar"); -var isPrototypeOfBar = Object.prototype.isPrototypeOf.call(foo, bar); +const isPrototypeOfBar = Object.prototype.isPrototypeOf.call(foo, bar); -var barIsEnumerable = {}.propertyIsEnumerable.call(foo, "bar"); +const barIsEnumerable = {}.propertyIsEnumerable.call(foo, "bar"); ``` ::: diff --git a/docs/src/rules/no-setter-return.md b/docs/src/rules/no-setter-return.md index 50353c754dab..bc0ae00b56e9 100644 --- a/docs/src/rules/no-setter-return.md +++ b/docs/src/rules/no-setter-return.md @@ -33,7 +33,7 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-setter-return: "error"*/ -var foo = { +const foo = { set a(value) { this.val = value; return value; @@ -76,7 +76,7 @@ Examples of **correct** code for this rule: ```js /*eslint no-setter-return: "error"*/ -var foo = { +const foo = { set a(value) { this.val = value; } diff --git a/docs/src/rules/no-sparse-arrays.md b/docs/src/rules/no-sparse-arrays.md index ec41bb23df45..ddb619a0eeb6 100644 --- a/docs/src/rules/no-sparse-arrays.md +++ b/docs/src/rules/no-sparse-arrays.md @@ -10,13 +10,13 @@ further_reading: Sparse arrays contain empty slots, most frequently due to multiple commas being used in an array literal, such as: ```js -var items = [,,]; +const items = [,,]; ``` While the `items` array in this example has a `length` of 2, there are actually no values in `items[0]` or `items[1]`. The fact that the array literal is valid with only commas inside, coupled with the `length` being set and actual item values not being set, make sparse arrays confusing for many developers. Consider the following: ```js -var colors = [ "red",, "blue" ]; +const colors = [ "red",, "blue" ]; ``` In this example, the `colors` array has a `length` of 3. But did the developer intend for there to be an empty spot in the middle of the array? Or is it a typo? @@ -34,8 +34,8 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-sparse-arrays: "error"*/ -var items = [,]; -var colors = [ "red",, "blue" ]; +const items = [,]; +const colors = [ "red",, "blue" ]; ``` ::: @@ -47,11 +47,11 @@ Examples of **correct** code for this rule: ```js /*eslint no-sparse-arrays: "error"*/ -var items = []; -var items = new Array(23); +const items = []; +const arr = new Array(23); // trailing comma (after the last element) is not a problem -var colors = [ "red", "blue", ]; +const colors = [ "red", "blue", ]; ``` ::: diff --git a/docs/src/rules/no-undef.md b/docs/src/rules/no-undef.md index c27532c405e4..d9af2902e21a 100644 --- a/docs/src/rules/no-undef.md +++ b/docs/src/rules/no-undef.md @@ -22,8 +22,8 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-undef: "error"*/ -var foo = someFunction(); -var bar = a + 1; +const foo = someFunction(); +const bar = a + 1; ``` ::: @@ -36,8 +36,8 @@ Examples of **correct** code for this rule with `global` declaration: /*global someFunction, a*/ /*eslint no-undef: "error"*/ -var foo = someFunction(); -var bar = a + 1; +const foo = someFunction(); +const bar = a + 1; ``` ::: diff --git a/docs/src/rules/no-unexpected-multiline.md b/docs/src/rules/no-unexpected-multiline.md index b8f3582fb39d..d134fe7f344f 100644 --- a/docs/src/rules/no-unexpected-multiline.md +++ b/docs/src/rules/no-unexpected-multiline.md @@ -31,20 +31,20 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-unexpected-multiline: "error"*/ -var foo = bar +const foo = bar (1 || 2).baz(); -var hello = 'world' +const hello = 'world' [1, 2, 3].forEach(addNumber); -let x = function() {} +const x = function() {} `hello` -let y = function() {} +const y = function() {} y `hello` -let z = foo +const z = foo /regex/g.test(bar) ``` @@ -57,22 +57,22 @@ Examples of **correct** code for this rule: ```js /*eslint no-unexpected-multiline: "error"*/ -var foo = bar; +const foo = bar; (1 || 2).baz(); -var foo = bar +const baz = bar ;(1 || 2).baz() -var hello = 'world'; +const hello = 'world'; [1, 2, 3].forEach(addNumber); -var hello = 'world' +const hi = 'world' void [1, 2, 3].forEach(addNumber); -let x = function() {}; +const x = function() {}; `hello` -let tag = function() {} +const tag = function() {} tag `hello` ```