Skip to content

docs: rewrite using let and const in rule examples #19320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 9, 2025
44 changes: 22 additions & 22 deletions docs/src/rules/accessor-pairs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Here are some examples:

```js
// Bad
var o = {
const o = {
set a(value) {
this.val = value;
}
};


// Good
var o = {
const p = {
set a(value) {
this.val = value;
},
Expand Down Expand Up @@ -61,15 +61,15 @@ Examples of **incorrect** code for the default `{ "setWithoutGet": true }` optio
```js
/*eslint accessor-pairs: "error"*/

var o = {
const q = {
set a(value) {
this.val = value;
}
};


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

var o = {
const s = {
set a(value) {
this.val = value;
},
Expand All @@ -94,8 +94,8 @@ var o = {
}
};

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

var o = {
const u = {
set a(value) {
this.val = value;
}
};

var o = {
const v = {
get a() {
return this.val;
}
};

var o = {d: 1};
Object.defineProperty(o, 'c', {
const w = {d: 1};
Object.defineProperty(w, 'c', {
set: function(value) {
this.val = value;
}
});

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

```js
/*eslint accessor-pairs: ["error", { "getWithoutSet": true }]*/
var o = {
const y = {
set a(value) {
this.val = value;
},
Expand All @@ -161,8 +161,8 @@ var o = {
}
};

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

var a = 1;
const z = 1;

// no warnings
var o = {
get [a++]() {
const a = {
get [z++]() {
return this.val;
},
set [a++](value) {
set [z++](value) {
this.val = value;
}
};
Expand All @@ -301,7 +301,7 @@ might not report a missing pair for a getter/setter, like in the following examp
/*eslint accessor-pairs: "error"*/

// no warnings
var o = {
const b = {
get a() {
return this.val;
},
Expand Down
120 changes: 60 additions & 60 deletions docs/src/rules/array-bracket-newline.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Examples of **incorrect** code for this rule with the `"always"` option:
```js
/*eslint array-bracket-newline: ["error", "always"]*/

var a = [];
var b = [1];
var c = [1, 2];
var d = [1,
const a = [];
const b = [1];
const c = [1, 2];
const d = [1,
2];
var e = [function foo() {
const e = [function foo() {
dosomething();
}];
```
Expand All @@ -54,19 +54,19 @@ Examples of **correct** code for this rule with the `"always"` option:
```js
/*eslint array-bracket-newline: ["error", "always"]*/

var a = [
const a = [
];
var b = [
const b = [
1
];
var c = [
const c = [
1, 2
];
var d = [
const d = [
1,
2
];
var e = [
const e = [
function foo() {
dosomething();
}
Expand All @@ -84,19 +84,19 @@ Examples of **incorrect** code for this rule with the `"never"` option:
```js
/*eslint array-bracket-newline: ["error", "never"]*/

var a = [
const a = [
];
var b = [
const b = [
1
];
var c = [
const c = [
1, 2
];
var d = [
const d = [
1,
2
];
var e = [
const e = [
function foo() {
dosomething();
}
Expand All @@ -112,12 +112,12 @@ Examples of **correct** code for this rule with the `"never"` option:
```js
/*eslint array-bracket-newline: ["error", "never"]*/

var a = [];
var b = [1];
var c = [1, 2];
var d = [1,
const a = [];
const b = [1];
const c = [1, 2];
const d = [1,
2];
var e = [function foo() {
const e = [function foo() {
dosomething();
}];
```
Expand All @@ -133,15 +133,15 @@ Examples of **incorrect** code for this rule with the `"consistent"` option:
```js
/*eslint array-bracket-newline: ["error", "consistent"]*/

var a = [1
const a = [1
];
var b = [
const b = [
1];
var c = [function foo() {
const c = [function foo() {
dosomething();
}
]
var d = [
const d = [
function foo() {
dosomething();
}]
Expand All @@ -156,17 +156,17 @@ Examples of **correct** code for this rule with the `"consistent"` option:
```js
/*eslint array-bracket-newline: ["error", "consistent"]*/

var a = [];
var b = [
const a = [];
const b = [
];
var c = [1];
var d = [
const c = [1];
const d = [
1
];
var e = [function foo() {
const e = [function foo() {
dosomething();
}];
var f = [
const f = [
function foo() {
dosomething();
}
Expand All @@ -184,17 +184,17 @@ Examples of **incorrect** code for this rule with the default `{ "multiline": tr
```js
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/

var a = [
const a = [
];
var b = [
const b = [
1
];
var c = [
const c = [
1, 2
];
var d = [1,
const d = [1,
2];
var e = [function foo() {
const e = [function foo() {
dosomething();
}];
```
Expand All @@ -208,14 +208,14 @@ Examples of **correct** code for this rule with the default `{ "multiline": true
```js
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/

var a = [];
var b = [1];
var c = [1, 2];
var d = [
const a = [];
const b = [1];
const c = [1, 2];
const d = [
1,
2
];
var e = [
const e = [
function foo() {
dosomething();
}
Expand All @@ -233,15 +233,15 @@ Examples of **incorrect** code for this rule with the `{ "minItems": 2 }` option
```js
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/

var a = [
const a = [
];
var b = [
const b = [
1
];
var c = [1, 2];
var d = [1,
const c = [1, 2];
const d = [1,
2];
var e = [
const e = [
function foo() {
dosomething();
}
Expand All @@ -257,16 +257,16 @@ Examples of **correct** code for this rule with the `{ "minItems": 2 }` option:
```js
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/

var a = [];
var b = [1];
var c = [
const a = [];
const b = [1];
const c = [
1, 2
];
var d = [
const d = [
1,
2
];
var e = [function foo() {
const e = [function foo() {
dosomething();
}];
```
Expand All @@ -282,15 +282,15 @@ Examples of **incorrect** code for this rule with the `{ "multiline": true, "min
```js
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/

var a = [
const a = [
];
var b = [
const b = [
1
];
var c = [1, 2];
var d = [1,
const c = [1, 2];
const d = [1,
2];
var e = [function foo() {
const e = [function foo() {
dosomething();
}];
```
Expand All @@ -304,16 +304,16 @@ Examples of **correct** code for this rule with the `{ "multiline": true, "minIt
```js
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/

var a = [];
var b = [1];
var c = [
const a = [];
const b = [1];
const c = [
1, 2
];
var d = [
const d = [
1,
2
];
var e = [
const e = [
function foo() {
dosomething();
}
Expand Down
Loading
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