diff --git a/docs/src/rules/no-dupe-class-members.md b/docs/src/rules/no-dupe-class-members.md index d186d33e21cc..1b44736da731 100644 --- a/docs/src/rules/no-dupe-class-members.md +++ b/docs/src/rules/no-dupe-class-members.md @@ -15,7 +15,7 @@ class Foo { bar() { console.log("goodbye"); } } -var foo = new Foo(); +const foo = new Foo(); foo.bar(); // goodbye ``` diff --git a/docs/src/rules/no-dupe-keys.md b/docs/src/rules/no-dupe-keys.md index 1527bf8f1ec7..b8edaf81ff0e 100644 --- a/docs/src/rules/no-dupe-keys.md +++ b/docs/src/rules/no-dupe-keys.md @@ -9,7 +9,7 @@ handled_by_typescript: true Multiple properties with the same key in object literals can cause unexpected behavior in your application. ```js -var foo = { +const foo = { bar: "baz", bar: "qux" }; @@ -26,17 +26,17 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-dupe-keys: "error"*/ -var foo = { +const foo = { bar: "baz", bar: "qux" }; -var foo = { +const bar = { "bar": "baz", bar: "qux" }; -var foo = { +const baz = { 0x1: "baz", 1: "qux" }; @@ -51,7 +51,7 @@ Examples of **correct** code for this rule: ```js /*eslint no-dupe-keys: "error"*/ -var foo = { +const foo = { bar: "baz", quxx: "qux" }; diff --git a/docs/src/rules/no-duplicate-case.md b/docs/src/rules/no-duplicate-case.md index 59a2a9874953..c65a58f7d059 100644 --- a/docs/src/rules/no-duplicate-case.md +++ b/docs/src/rules/no-duplicate-case.md @@ -18,7 +18,7 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-duplicate-case: "error"*/ -var a = 1, +const a = 1, one = 1; switch (a) { @@ -64,7 +64,7 @@ Examples of **correct** code for this rule: ```js /*eslint no-duplicate-case: "error"*/ -var a = 1, +const a = 1, one = 1; switch (a) { diff --git a/docs/src/rules/no-empty-character-class.md b/docs/src/rules/no-empty-character-class.md index 2ab0679b394c..7f72ece6aec6 100644 --- a/docs/src/rules/no-empty-character-class.md +++ b/docs/src/rules/no-empty-character-class.md @@ -8,7 +8,7 @@ rule_type: problem Because empty character classes in regular expressions do not match anything, they might be typing mistakes. ```js -var foo = /^abc[]/; +const foo = /^abc[]/; ``` ## Rule Details @@ -73,5 +73,5 @@ Example of a *false negative* when this rule reports correct code: ```js /*eslint no-empty-character-class: "error"*/ -var abcNeverMatches = new RegExp("^abc[]"); +const abcNeverMatches = new RegExp("^abc[]"); ``` diff --git a/docs/src/rules/no-empty-pattern.md b/docs/src/rules/no-empty-pattern.md index 92000add1857..86aac082235a 100644 --- a/docs/src/rules/no-empty-pattern.md +++ b/docs/src/rules/no-empty-pattern.md @@ -9,21 +9,21 @@ When using destructuring, it's possible to create a pattern that has no effect. ```js // doesn't create any variables -var {a: {}} = foo; +const {a: {}} = foo; ``` In this code, no new variables are created because `a` is just a location helper while the `{}` is expected to contain the variables to create, such as: ```js // creates variable b -var {a: { b }} = foo; +const {a: { b }} = foo; ``` In many cases, the empty object pattern is a mistake where the author intended to use a default value instead, such as: ```js // creates variable a -var {a = {}} = foo; +const {a = {}} = foo; ``` The difference between these two patterns is subtle, especially because the problematic empty pattern looks just like an object literal. @@ -39,10 +39,10 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-empty-pattern: "error"*/ -var {} = foo; -var [] = foo; -var {a: {}} = foo; -var {a: []} = foo; +const {} = foo; +const [] = foo; +const {a: {}} = foo; +const {a: []} = foo; function foo({}) {} function bar([]) {} function baz({a: {}}) {} @@ -58,8 +58,8 @@ Examples of **correct** code for this rule: ```js /*eslint no-empty-pattern: "error"*/ -var {a = {}} = foo; -var {a = []} = foo; +const {a = {}} = foo; +const {b = []} = foo; function foo({a = {}}) {} function bar({a = []}) {} ``` @@ -84,10 +84,10 @@ Examples of **incorrect** code for this rule with the `{"allowObjectPatternsAsPa /*eslint no-empty-pattern: ["error", { "allowObjectPatternsAsParameters": true }]*/ function foo({a: {}}) {} -var bar = function({a: {}}) {}; -var bar = ({a: {}}) => {}; -var bar = ({} = bar) => {}; -var bar = ({} = { bar: 1 }) => {}; +const bar = function({a: {}}) {}; +const qux = ({a: {}}) => {}; +const quux = ({} = bar) => {}; +const item = ({} = { bar: 1 }) => {}; function baz([]) {} ``` @@ -102,8 +102,8 @@ Examples of **correct** code for this rule with the `{"allowObjectPatternsAsPara /*eslint no-empty-pattern: ["error", { "allowObjectPatternsAsParameters": true }]*/ function foo({}) {} -var bar = function({}) {}; -var bar = ({}) => {}; +const bar = function({}) {}; +const qux = ({}) => {}; function baz({} = {}) {} ``` 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