From a372c10e8ab582a62d421eab4687b618e6668f60 Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Wed, 1 Jan 2025 01:06:48 +0530 Subject: [PATCH 01/10] docs: rewrite examples with var using let and const --- docs/src/rules/comma-spacing.md | 36 ++++++------- docs/src/rules/consistent-this.md | 23 ++++++--- docs/src/rules/id-length.md | 86 +++++++++++++++---------------- docs/src/rules/id-match.md | 14 ++--- docs/src/rules/no-iterator.md | 2 +- docs/src/rules/no-multi-assign.md | 8 +-- docs/src/rules/no-octal-escape.md | 8 +-- docs/src/rules/no-self-compare.md | 2 +- 8 files changed, 94 insertions(+), 85 deletions(-) diff --git a/docs/src/rules/comma-spacing.md b/docs/src/rules/comma-spacing.md index ffc85f27de3f..0f44df4fcd57 100644 --- a/docs/src/rules/comma-spacing.md +++ b/docs/src/rules/comma-spacing.md @@ -21,8 +21,8 @@ This rule was **deprecated** in ESLint v8.53.0. Please use the [corresponding ru Spacing around commas improves readability of a list of items. Although most of the style guidelines for languages prescribe adding a space after a comma and not before it, it is subjective to the preferences of a project. ```js -var foo = 1, bar = 2; -var foo = 1 ,bar = 2; +const foo = 1, bar = 2; +const baz = 1 ,qux = 2; ``` ## Rule Details @@ -55,9 +55,9 @@ Examples of **incorrect** code for this rule with the default `{ "before": false ```js /*eslint comma-spacing: ["error", { "before": false, "after": true }]*/ -var foo = 1 ,bar = 2; -var arr = [1 , 2]; -var obj = {"foo": "bar" ,"baz": "qur"}; +const foo = 1 ,bar = 2; +const arr = [1 , 2]; +const obj = {"foo": "bar" ,"baz": "qur"}; foo(a ,b); new Foo(a ,b); function baz(a ,b){} @@ -73,11 +73,11 @@ Examples of **correct** code for this rule with the default `{ "before": false, ```js /*eslint comma-spacing: ["error", { "before": false, "after": true }]*/ -var foo = 1, bar = 2 +const foo = 1, bar = 2 , baz = 3; -var arr = [1, 2]; -var arr = [1,, 3] -var obj = {"foo": "bar", "baz": "qur"}; +const arr = [1, 2]; +const nums = [1,, 3] +const obj = {"foo": "bar", "baz": "qur"}; foo(a, b); new Foo(a, b); function qur(a, b){} @@ -108,8 +108,8 @@ var arr = [a, b,]; [a, b,] = arr; // this rule does not enforce spacing before `}` -var obj = {x, y,}; -var {z, q,} = obj; +const obj = {x, y,}; +const {z, q,} = obj; import {foo, bar,} from "mod"; // this rule does not enforce spacing before `)` @@ -127,9 +127,9 @@ Examples of **incorrect** code for this rule with the `{ "before": true, "after" ```js /*eslint comma-spacing: ["error", { "before": true, "after": false }]*/ -var foo = 1, bar = 2; -var arr = [1 , 2]; -var obj = {"foo": "bar", "baz": "qur"}; +const foo = 1, bar = 2; +const arr = [1 , 2]; +const obj = {"foo": "bar", "baz": "qur"}; new Foo(a,b); function baz(a,b){} a, b @@ -144,11 +144,11 @@ Examples of **correct** code for this rule with the `{ "before": true, "after": ```js /*eslint comma-spacing: ["error", { "before": true, "after": false }]*/ -var foo = 1 ,bar = 2 , +const foo = 1 ,bar = 2 , baz = true; -var arr = [1 ,2]; -var arr = [1 ,,3] -var obj = {"foo": "bar" ,"baz": "qur"}; +const arr = [1 ,2]; +const nums = [1 ,,3] +const obj = {"foo": "bar" ,"baz": "qur"}; foo(a ,b); new Foo(a ,b); function qur(a ,b){} diff --git a/docs/src/rules/consistent-this.md b/docs/src/rules/consistent-this.md index 8f029adaa937..32fe105c0243 100644 --- a/docs/src/rules/consistent-this.md +++ b/docs/src/rules/consistent-this.md @@ -36,9 +36,9 @@ Examples of **incorrect** code for this rule with the default `"that"` option: ```js /*eslint consistent-this: ["error", "that"]*/ -var that = 42; +let that = 42; -var self = this; +let self = this; that = 42; @@ -54,7 +54,7 @@ Examples of **correct** code for this rule with the default `"that"` option: ```js /*eslint consistent-this: ["error", "that"]*/ -var that = this; +let that = this; var self = 42; @@ -74,7 +74,7 @@ Examples of **incorrect** code for this rule with the default `"that"` option, i ```js /*eslint consistent-this: ["error", "that"]*/ -var that; +let that; function f() { that = this; } @@ -84,16 +84,25 @@ function f() { Examples of **correct** code for this rule with the default `"that"` option, if the variable is not initialized: +Declaring a variable that and assigning this to it. ::: correct ```js /*eslint consistent-this: ["error", "that"]*/ -var that; +let that; that = this; +``` + +::: + +Declaring two variables, foo and that, with foo initialized, and then assigning this to that. +::: correct + +```js +/*eslint consistent-this: ["error", "that"]*/ -var foo, that; -foo = 42; +let foo = 42, that; that = this; ``` diff --git a/docs/src/rules/id-length.md b/docs/src/rules/id-length.md index 7c8359e47945..87523832928f 100644 --- a/docs/src/rules/id-length.md +++ b/docs/src/rules/id-length.md @@ -12,7 +12,7 @@ related_rules: Very short identifier names like `e`, `x`, `_t` or very long ones like `hashGeneratorResultOutputContainerObject` can make code harder to read and potentially less maintainable. To prevent this, one may enforce a minimum and/or maximum identifier length. ```js -var x = 5; // too short; difficult to understand its purpose without context +const x = 5; // too short; difficult to understand its purpose without context ``` ## Rule Details @@ -30,15 +30,15 @@ Examples of **incorrect** code for this rule with the default options: ```js /*eslint id-length: "error"*/ // default is minimum 2-chars ({ "min": 2 }) -var x = 5; +const x = 5; obj.e = document.body; -var foo = function (e) { }; +const foo = function (e) { }; try { dangerousStuff(); } catch (e) { // ignore as many do } -var myObj = { a: 1 }; +const myObj = { a: 1 }; (a) => { a * a }; class y { } class Foo { x() {} } @@ -47,11 +47,11 @@ class Baz { x = 1 } class Qux { #x = 1 } function bar(...x) { } function baz([x]) { } -var [x] = arr; -var { prop: [x]} = {}; +const [z] = arr; +const { prop: [i]} = {}; function qux({x}) { } -var { x } = {}; -var { prop: a} = {}; +const { j } = {}; +const { prop: a} = {}; ({ prop: obj.x } = {}); ``` @@ -64,17 +64,17 @@ Examples of **correct** code for this rule with the default options: ```js /*eslint id-length: "error"*/ // default is minimum 2-chars ({ "min": 2 }) -var num = 5; +const num = 5; function _f() { return 42; } function _func() { return 42; } obj.el = document.body; -var foo = function (evt) { /* do stuff */ }; +const foo = function (evt) { /* do stuff */ }; try { dangerousStuff(); } catch (error) { // ignore as many do } -var myObj = { apple: 1 }; +const myObj = { apple: 1 }; (num) => { num * num }; function bar(num = 0) { } class MyClass { } @@ -85,14 +85,14 @@ class Qux { #field = 1 } function baz(...args) { } function qux([longName]) { } var { prop } = {}; -var { prop: [longName] } = {}; -var [longName] = arr; +var { prop: [name] } = {}; +const [longName] = arr; function foobar({ prop }) { } function foobaz({ a: prop }) { } var { prop } = {}; var { a: prop } = {}; ({ prop: obj.longName } = {}); -var data = { "x": 1 }; // excused because of quotes +const data = { "x": 1 }; // excused because of quotes data["y"] = 3; // excused because of calculated property access ``` @@ -116,7 +116,7 @@ Examples of **incorrect** code for this rule with the `{ "min": 4 }` option: ```js /*eslint id-length: ["error", { "min": 4 }]*/ -var val = 5; +const val = 5; obj.e = document.body; function foo (e) { }; try { @@ -124,15 +124,15 @@ try { } catch (e) { // ignore as many do } -var myObj = { a: 1 }; +const myObj = { a: 1 }; (val) => { val * val }; class y { } class Foo { x() {} } function bar(...x) { } -var { x } = {}; -var { prop: a} = {}; -var [x] = arr; -var { prop: [x]} = {}; +const { x } = {}; +const { prop: a} = {}; +const [i] = arr; +const { prop: [num]} = {}; ({ prop: obj.x } = {}); ``` @@ -145,27 +145,27 @@ Examples of **correct** code for this rule with the `{ "min": 4 }` option: ```js /*eslint id-length: ["error", { "min": 4 }]*/ -var value = 5; +const value = 5; function func() { return 42; } object.element = document.body; -var foobar = function (event) { /* do stuff */ }; +const foobar = function (event) { /* do stuff */ }; try { dangerousStuff(); } catch (error) { // ignore as many do } -var myObj = { apple: 1 }; +const myObj = { apple: 1 }; (value) => { value * value }; function foobaz(value = 0) { } class MyClass { } class Foobar { method() {} } function barbaz(...args) { } -var { prop } = {}; -var [longName] = foo; -var { a: [prop] } = {}; -var { a: longName } = {}; +const { prop } = {}; +const [longName] = foo; +const { a: [name] } = {}; +const { a: record } = {}; ({ prop: object.name } = {}); -var data = { "x": 1 }; // excused because of quotes +const data = { "x": 1 }; // excused because of quotes data["y"] = 3; // excused because of calculated property access ``` @@ -180,17 +180,17 @@ Examples of **incorrect** code for this rule with the `{ "max": 10 }` option: ```js /*eslint id-length: ["error", { "max": 10 }]*/ -var reallyLongVarName = 5; +const reallyLongVarName = 5; function reallyLongFuncName() { return 42; } obj.reallyLongPropName = document.body; -var foo = function (reallyLongArgName) { /* do stuff */ }; +const foo = function (reallyLongArgName) { /* do stuff */ }; try { dangerousStuff(); } catch (reallyLongErrorName) { // ignore as many do } (reallyLongArgName) => { return !reallyLongArgName; }; -var [reallyLongFirstElementName] = arr; +const [reallyLongFirstElementName] = arr; ``` ::: @@ -202,17 +202,17 @@ Examples of **correct** code for this rule with the `{ "max": 10 }` option: ```js /*eslint id-length: ["error", { "max": 10 }]*/ -var varName = 5; +const varName = 5; function funcName() { return 42; } obj.propName = document.body; -var foo = function (arg) { /* do stuff */ }; +const foo = function (arg) { /* do stuff */ }; try { dangerousStuff(); } catch (error) { // ignore as many do } (arg) => { return !arg; }; -var [first] = arr; +const [first] = arr; ``` ::: @@ -226,7 +226,7 @@ Examples of **correct** code for this rule with the `{ "properties": "never" }` ```js /*eslint id-length: ["error", { "properties": "never" }]*/ -var myObj = { a: 1 }; +const myObj = { a: 1 }; ({ a: obj.x.y.z } = {}); ({ prop: obj.i } = {}); ``` @@ -240,19 +240,19 @@ Examples of additional **correct** code for this rule with the `{ "exceptions": ::: correct ```js -/*eslint id-length: ["error", { "exceptions": ["x", "y", "z", "ζ"] }]*/ +/*eslint id-length: ["error", { "exceptions": ["x", "y", "z", "ζ", "i"] }]*/ -var x = 5; +const x = 5; function y() { return 42; } obj.x = document.body; -var foo = function (x) { /* do stuff */ }; +const foo = function (x) { /* do stuff */ }; try { dangerousStuff(); } catch (x) { // ignore as many do } (x) => { return x * x; }; -var [x] = arr; +const [i] = arr; const { z } = foo; const { a: ζ } = foo; ``` @@ -266,19 +266,19 @@ Examples of additional **correct** code for this rule with the `{ "exceptionPatt ::: correct ```js -/*eslint id-length: ["error", { "exceptionPatterns": ["E|S", "[x-z]"] }]*/ +/*eslint id-length: ["error", { "exceptionPatterns": ["E|S|X", "[x-z]"] }]*/ -var E = 5; +const E = 5; function S() { return 42; } obj.x = document.body; -var foo = function (x) { /* do stuff */ }; +const foo = function (x) { /* do stuff */ }; try { dangerousStuff(); } catch (x) { // ignore as many do } (y) => {return y * y}; -var [E] = arr; +const [X] = arr; const { y } = foo; const { a: z } = foo; ``` diff --git a/docs/src/rules/id-match.md b/docs/src/rules/id-match.md index 3fbe3925d5d3..f22b537fb562 100644 --- a/docs/src/rules/id-match.md +++ b/docs/src/rules/id-match.md @@ -34,10 +34,10 @@ Examples of **incorrect** code for this rule with the `"^[a-z]+([A-Z][a-z]+)*$"` ```js /*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$"]*/ -var my_favorite_color = "#112C85"; -var _myFavoriteColor = "#112C85"; -var myFavoriteColor_ = "#112C85"; -var MY_FAVORITE_COLOR = "#112C85"; +const my_favorite_color = "#112C85"; +const _myFavoriteColor = "#112C85"; +const myFavoriteColor_ = "#112C85"; +const MY_FAVORITE_COLOR = "#112C85"; function do_something() { // ... } @@ -62,11 +62,11 @@ Examples of **correct** code for this rule with the `"^[a-z]+([A-Z][a-z]+)*$"` o ```js /*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$"]*/ -var myFavoriteColor = "#112C85"; +const myFavoriteColor = "#112C85"; var foo = bar.baz_boom; var foo = { qux: bar.baz_boom }; do_something(); -var obj = { +const obj = { my_pref: 1 }; @@ -103,7 +103,7 @@ Examples of **incorrect** code for this rule with the `"^[a-z]+([A-Z][a-z]+)*$", ```js /*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$", { "properties": true }]*/ -var obj = { +const obj = { my_pref: 1 }; diff --git a/docs/src/rules/no-iterator.md b/docs/src/rules/no-iterator.md index 70186826239b..7da0a23775f4 100644 --- a/docs/src/rules/no-iterator.md +++ b/docs/src/rules/no-iterator.md @@ -48,7 +48,7 @@ Examples of **correct** code for this rule: ```js /*eslint no-iterator: "error"*/ -var __iterator__ = foo; // Not using the `__iterator__` property. +const __iterator__ = foo; // Not using the `__iterator__` property. ``` ::: diff --git a/docs/src/rules/no-multi-assign.md b/docs/src/rules/no-multi-assign.md index f4f4c2fce5aa..44ba2595fa4d 100644 --- a/docs/src/rules/no-multi-assign.md +++ b/docs/src/rules/no-multi-assign.md @@ -27,7 +27,7 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-multi-assign: "error"*/ -var a = b = c = 5; +const a = b = c = 5; const foo = bar = "baz"; @@ -51,9 +51,9 @@ Examples of **correct** code for this rule: ```js /*eslint no-multi-assign: "error"*/ -var a = 5; -var b = 5; -var c = 5; +let a = 5; +let b = 5; +const c = 5; const foo = "baz"; const bar = "baz"; diff --git a/docs/src/rules/no-octal-escape.md b/docs/src/rules/no-octal-escape.md index 755bc56bc84f..d470007536a2 100644 --- a/docs/src/rules/no-octal-escape.md +++ b/docs/src/rules/no-octal-escape.md @@ -7,7 +7,7 @@ rule_type: suggestion As of the ECMAScript 5 specification, octal escape sequences in string literals are deprecated and should not be used. Unicode escape sequences should be used instead. ```js -var foo = "Copyright \251"; +const foo = "Copyright \251"; ``` ## Rule Details @@ -23,7 +23,7 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-octal-escape: "error"*/ -var foo = "Copyright \251"; +const foo = "Copyright \251"; ``` ::: @@ -35,9 +35,9 @@ Examples of **correct** code for this rule: ```js /*eslint no-octal-escape: "error"*/ -var foo = "Copyright \u00A9"; // unicode +const foo = "Copyright \u00A9"; // unicode -var foo = "Copyright \xA9"; // hexadecimal +const buz = "Copyright \xA9"; // hexadecimal ``` ::: diff --git a/docs/src/rules/no-self-compare.md b/docs/src/rules/no-self-compare.md index bf0562993df1..3d961b7fea39 100644 --- a/docs/src/rules/no-self-compare.md +++ b/docs/src/rules/no-self-compare.md @@ -19,7 +19,7 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-self-compare: "error"*/ -var x = 10; +const x = 10; if (x === x) { x = 20; } From 0b06b581fd0b6ec58a924e2104518cbd4f87e1df Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Wed, 1 Jan 2025 01:28:12 +0530 Subject: [PATCH 02/10] revert comma-spacing.md changes --- docs/src/rules/comma-spacing.md | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/src/rules/comma-spacing.md b/docs/src/rules/comma-spacing.md index 0f44df4fcd57..ffc85f27de3f 100644 --- a/docs/src/rules/comma-spacing.md +++ b/docs/src/rules/comma-spacing.md @@ -21,8 +21,8 @@ This rule was **deprecated** in ESLint v8.53.0. Please use the [corresponding ru Spacing around commas improves readability of a list of items. Although most of the style guidelines for languages prescribe adding a space after a comma and not before it, it is subjective to the preferences of a project. ```js -const foo = 1, bar = 2; -const baz = 1 ,qux = 2; +var foo = 1, bar = 2; +var foo = 1 ,bar = 2; ``` ## Rule Details @@ -55,9 +55,9 @@ Examples of **incorrect** code for this rule with the default `{ "before": false ```js /*eslint comma-spacing: ["error", { "before": false, "after": true }]*/ -const foo = 1 ,bar = 2; -const arr = [1 , 2]; -const obj = {"foo": "bar" ,"baz": "qur"}; +var foo = 1 ,bar = 2; +var arr = [1 , 2]; +var obj = {"foo": "bar" ,"baz": "qur"}; foo(a ,b); new Foo(a ,b); function baz(a ,b){} @@ -73,11 +73,11 @@ Examples of **correct** code for this rule with the default `{ "before": false, ```js /*eslint comma-spacing: ["error", { "before": false, "after": true }]*/ -const foo = 1, bar = 2 +var foo = 1, bar = 2 , baz = 3; -const arr = [1, 2]; -const nums = [1,, 3] -const obj = {"foo": "bar", "baz": "qur"}; +var arr = [1, 2]; +var arr = [1,, 3] +var obj = {"foo": "bar", "baz": "qur"}; foo(a, b); new Foo(a, b); function qur(a, b){} @@ -108,8 +108,8 @@ var arr = [a, b,]; [a, b,] = arr; // this rule does not enforce spacing before `}` -const obj = {x, y,}; -const {z, q,} = obj; +var obj = {x, y,}; +var {z, q,} = obj; import {foo, bar,} from "mod"; // this rule does not enforce spacing before `)` @@ -127,9 +127,9 @@ Examples of **incorrect** code for this rule with the `{ "before": true, "after" ```js /*eslint comma-spacing: ["error", { "before": true, "after": false }]*/ -const foo = 1, bar = 2; -const arr = [1 , 2]; -const obj = {"foo": "bar", "baz": "qur"}; +var foo = 1, bar = 2; +var arr = [1 , 2]; +var obj = {"foo": "bar", "baz": "qur"}; new Foo(a,b); function baz(a,b){} a, b @@ -144,11 +144,11 @@ Examples of **correct** code for this rule with the `{ "before": true, "after": ```js /*eslint comma-spacing: ["error", { "before": true, "after": false }]*/ -const foo = 1 ,bar = 2 , +var foo = 1 ,bar = 2 , baz = true; -const arr = [1 ,2]; -const nums = [1 ,,3] -const obj = {"foo": "bar" ,"baz": "qur"}; +var arr = [1 ,2]; +var arr = [1 ,,3] +var obj = {"foo": "bar" ,"baz": "qur"}; foo(a ,b); new Foo(a ,b); function qur(a ,b){} From e96cb784f59d54dc558dab97333fb27f987057ec Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Thu, 2 Jan 2025 20:29:01 +0530 Subject: [PATCH 03/10] consistent this rename to let/const --- docs/src/rules/consistent-this.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/rules/consistent-this.md b/docs/src/rules/consistent-this.md index 32fe105c0243..103f442c06ae 100644 --- a/docs/src/rules/consistent-this.md +++ b/docs/src/rules/consistent-this.md @@ -7,7 +7,7 @@ rule_type: suggestion It is often necessary to capture the current execution context in order to make it available subsequently. A prominent example of this are jQuery callbacks: ```js -var that = this; +const that = this; jQuery('li').click(function (event) { // here, "this" is the HTMLElement where the click event occurred that.setFoo(42); @@ -56,9 +56,9 @@ Examples of **correct** code for this rule with the default `"that"` option: let that = this; -var self = 42; +const self = 42; -var self; +let foo; that = this; From 8ea3c6ba8e3d4ac814925d54807f3c6c489d2705 Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Thu, 2 Jan 2025 20:34:37 +0530 Subject: [PATCH 04/10] id-length rename eg with let/const --- docs/src/rules/id-length.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/src/rules/id-length.md b/docs/src/rules/id-length.md index 87523832928f..01b51da8377f 100644 --- a/docs/src/rules/id-length.md +++ b/docs/src/rules/id-length.md @@ -84,13 +84,12 @@ class Baz { field = 1 } class Qux { #field = 1 } function baz(...args) { } function qux([longName]) { } -var { prop } = {}; -var { prop: [name] } = {}; +const { prop } = {}; +const { prop: [name] } = {}; const [longName] = arr; function foobar({ prop }) { } function foobaz({ a: prop }) { } -var { prop } = {}; -var { a: prop } = {}; +var { a: property } = {}; ({ prop: obj.longName } = {}); const data = { "x": 1 }; // excused because of quotes data["y"] = 3; // excused because of calculated property access From 8f8cfd493a2aea44006a23e462a503703a016b0a Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Thu, 2 Jan 2025 20:53:17 +0530 Subject: [PATCH 05/10] id-match rename eg with let/const --- docs/src/rules/id-match.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/src/rules/id-match.md b/docs/src/rules/id-match.md index f22b537fb562..b1b85b1949ea 100644 --- a/docs/src/rules/id-match.md +++ b/docs/src/rules/id-match.md @@ -63,8 +63,8 @@ Examples of **correct** code for this rule with the `"^[a-z]+([A-Z][a-z]+)*$"` o /*eslint id-match: ["error", "^[a-z]+([A-Z][a-z]+)*$"]*/ const myFavoriteColor = "#112C85"; -var foo = bar.baz_boom; -var foo = { qux: bar.baz_boom }; +const foo = bar.baz_boom; +const buz = { qux: bar.baz_boom }; do_something(); const obj = { my_pref: 1 @@ -157,15 +157,15 @@ Examples of **incorrect** code for this rule with the default `"^[^_]+$", { "ign ```js /*eslint id-match: [2, "^[^_]+$", { "ignoreDestructuring": false }]*/ -var { category_id } = query; +const { category_id } = query; -var { category_id = 1 } = query; +const { categoryid_Default = 1 } = query; -var { category_id: category_id } = query; +const { category_id: category_Id } = query; -var { category_id: category_alias } = query; +const { category_id: category_Alias } = query; -var { category_id: categoryId, ...other_props } = query; +const { category_id: category_IdRenamed, ...other_Props } = query; ``` ::: @@ -179,9 +179,9 @@ Examples of **incorrect** code for this rule with the `"^[^_]+$", { "ignoreDestr ```js /*eslint id-match: [2, "^[^_]+$", { "ignoreDestructuring": true }]*/ -var { category_id: category_alias } = query; +const { category_id: category_alias } = query; -var { category_id, ...other_props } = query; +const { category_id: category_Id, ...other_props } = query; ``` ::: @@ -193,11 +193,11 @@ Examples of **correct** code for this rule with the `"^[^_]+$", { "ignoreDestruc ```js /*eslint id-match: [2, "^[^_]+$", { "ignoreDestructuring": true }]*/ -var { category_id } = query; +const { category_id } = query; -var { category_id = 1 } = query; +const { category_Id = 1 } = query; -var { category_id: category_id } = query; +const { category_alias: category_alias } = query; ``` ::: From c14ae55dd0726ad1928d3efba89796d68c94c559 Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Thu, 2 Jan 2025 21:28:41 +0530 Subject: [PATCH 06/10] rewrite missed eg --- docs/src/rules/id-length.md | 2 +- docs/src/rules/no-self-compare.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/rules/id-length.md b/docs/src/rules/id-length.md index 01b51da8377f..8d18cacee7eb 100644 --- a/docs/src/rules/id-length.md +++ b/docs/src/rules/id-length.md @@ -89,7 +89,7 @@ const { prop: [name] } = {}; const [longName] = arr; function foobar({ prop }) { } function foobaz({ a: prop }) { } -var { a: property } = {}; +const { a: property } = {}; ({ prop: obj.longName } = {}); const data = { "x": 1 }; // excused because of quotes data["y"] = 3; // excused because of calculated property access diff --git a/docs/src/rules/no-self-compare.md b/docs/src/rules/no-self-compare.md index 3d961b7fea39..139b97c96c3e 100644 --- a/docs/src/rules/no-self-compare.md +++ b/docs/src/rules/no-self-compare.md @@ -19,7 +19,7 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-self-compare: "error"*/ -const x = 10; +let x = 10; if (x === x) { x = 20; } From 64741ae820d75b6f69165eec894e5ab61378fe2f Mon Sep 17 00:00:00 2001 From: Amaresh S M Date: Thu, 2 Jan 2025 22:55:09 +0530 Subject: [PATCH 07/10] Update docs/src/rules/consistent-this.md Co-authored-by: Milos Djermanovic --- docs/src/rules/consistent-this.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/rules/consistent-this.md b/docs/src/rules/consistent-this.md index 103f442c06ae..0f6209af1142 100644 --- a/docs/src/rules/consistent-this.md +++ b/docs/src/rules/consistent-this.md @@ -84,7 +84,8 @@ function f() { Examples of **correct** code for this rule with the default `"that"` option, if the variable is not initialized: -Declaring a variable that and assigning this to it. +Declaring a variable `that` and assigning `this` to it. + ::: correct ```js From 7503c8907e0d753ab67388e3f52f06b4690c4230 Mon Sep 17 00:00:00 2001 From: Amaresh S M Date: Thu, 2 Jan 2025 22:55:16 +0530 Subject: [PATCH 08/10] Update docs/src/rules/consistent-this.md Co-authored-by: Milos Djermanovic --- docs/src/rules/consistent-this.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/rules/consistent-this.md b/docs/src/rules/consistent-this.md index 0f6209af1142..a77ea987179e 100644 --- a/docs/src/rules/consistent-this.md +++ b/docs/src/rules/consistent-this.md @@ -97,7 +97,8 @@ that = this; ::: -Declaring two variables, foo and that, with foo initialized, and then assigning this to that. +Declaring two variables, `foo` and `that`, with `foo` initialized, and then assigning `this` to `that`. + ::: correct ```js From 1af6aed59d9a9151e8c9c72dfbbe7e02725809b4 Mon Sep 17 00:00:00 2001 From: Amaresh S M Date: Fri, 3 Jan 2025 13:28:39 +0530 Subject: [PATCH 09/10] Update docs/src/rules/no-multi-assign.md Co-authored-by: Tanuj Kanti <86398394+Tanujkanti4441@users.noreply.github.com> --- docs/src/rules/no-multi-assign.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/rules/no-multi-assign.md b/docs/src/rules/no-multi-assign.md index 44ba2595fa4d..a9d9c158eb4a 100644 --- a/docs/src/rules/no-multi-assign.md +++ b/docs/src/rules/no-multi-assign.md @@ -27,7 +27,7 @@ Examples of **incorrect** code for this rule: ```js /*eslint no-multi-assign: "error"*/ -const a = b = c = 5; +let a = b = c = 5; const foo = bar = "baz"; From 502518c407035263a5d5468c9e9a6adba5f3d4be Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:11:24 +0530 Subject: [PATCH 10/10] Update id-match.md --- docs/src/rules/id-match.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/rules/id-match.md b/docs/src/rules/id-match.md index b1b85b1949ea..c51a672a4564 100644 --- a/docs/src/rules/id-match.md +++ b/docs/src/rules/id-match.md @@ -161,7 +161,7 @@ const { category_id } = query; const { categoryid_Default = 1 } = query; -const { category_id: category_Id } = query; +const { category_ids: category_ids } = query; const { category_id: category_Alias } = query; 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