Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf92a680

Browse files
docs: replace var with let or const in rule examples (#19331)
* fix(docs): replace var with let or const in rule examples* docs: replace var with let or const in rule examples* docs: replace var with let or const in rule examplesCo-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>---------Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
1 parentb04b84b commitf92a680

File tree

5 files changed

+54
-54
lines changed

5 files changed

+54
-54
lines changed

‎docs/src/rules/camelcase.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Examples of **incorrect** code for this rule with the default `{ "properties": "
3535

3636
import {no_camelcased }from"external-module"
3737

38-
var my_favorite_color="#112C85";
38+
constmy_favorite_color="#112C85";
3939

4040
functiondo_something() {
4141
// ...
@@ -57,15 +57,15 @@ function baz({ no_camelcased = 'default value' }) {
5757
// ...
5858
};
5959

60-
var obj= {
60+
constobj= {
6161
my_pref:1
6262
};
6363

64-
var { category_id=1 }= query;
64+
const {category_id=1 }= query;
6565

66-
var { foo: snake_cased }= bar;
66+
const { foo:snake_cased }= bar;
6767

68-
var { foo: bar_baz=1 }= quz;
68+
const { foo:bar_baz=1 }= quz;
6969
```
7070

7171
:::
@@ -79,18 +79,18 @@ Examples of **correct** code for this rule with the default `{ "properties": "al
7979

8080
import {no_camelcasedascamelCased }from"external-module";
8181

82-
var myFavoriteColor="#112C85";
83-
var _myFavoriteColor="#112C85";
84-
var myFavoriteColor_="#112C85";
85-
varMY_FAVORITE_COLOR="#112C85";
86-
var foo1=bar.baz_boom;
87-
var foo2= { qux:bar.baz_boom };
82+
constmyFavoriteColor="#112C85";
83+
const_myFavoriteColor="#112C85";
84+
constmyFavoriteColor_="#112C85";
85+
constMY_FAVORITE_COLOR="#112C85";
86+
constfoo1=bar.baz_boom;
87+
constfoo2= { qux:bar.baz_boom };
8888

8989
obj.do_something();
9090
do_something();
9191
newdo_something();
9292

93-
var { category_id: category }= query;
93+
const { category_id:category }= query;
9494

9595
functionfoo({ isCamelCased }) {
9696
// ...
@@ -104,11 +104,11 @@ function baz({ isCamelCased = 'default value' }) {
104104
// ...
105105
};
106106

107-
var { categoryId=1 }= query;
107+
const {categoryId=1 }= query;
108108

109-
var { foo: isCamelCased }= bar;
109+
const { foo:isCamelCased }= bar;
110110

111-
var { foo:isCamelCased=1 }= quz;
111+
const { foo:camelCasedName=1 }= quz;
112112

113113
```
114114

@@ -123,7 +123,7 @@ Examples of **correct** code for this rule with the `{ "properties": "never" }`
123123
```js
124124
/*eslint camelcase: ["error", {properties: "never"}]*/
125125

126-
var obj= {
126+
constobj= {
127127
my_pref:1
128128
};
129129

@@ -141,15 +141,15 @@ Examples of **incorrect** code for this rule with the default `{ "ignoreDestruct
141141
```js
142142
/*eslint camelcase: "error"*/
143143

144-
var { category_id }= query;
144+
const {category_id }= query;
145145

146-
var { category_name=1 }= query;
146+
const {category_name=1 }= query;
147147

148-
var { category_id: category_title }= query;
148+
const { category_id:category_title }= query;
149149

150-
var { category_id: category_alias }= query;
150+
const { category_id:category_alias }= query;
151151

152-
var { category_id: categoryId,...other_props }= query;
152+
const { category_id:categoryId,...other_props }= query;
153153
```
154154

155155
:::
@@ -163,9 +163,9 @@ Examples of **incorrect** code for this rule with the `{ "ignoreDestructuring":
163163
```js
164164
/*eslint camelcase: ["error", {ignoreDestructuring: true}]*/
165165

166-
var { category_id: category_alias }= query;
166+
const { category_id:category_alias }= query;
167167

168-
var { category_id,...other_props }= query;
168+
const {category_id,...other_props }= query;
169169
```
170170

171171
:::
@@ -177,11 +177,11 @@ Examples of **correct** code for this rule with the `{ "ignoreDestructuring": tr
177177
```js
178178
/*eslint camelcase: ["error", {ignoreDestructuring: true}]*/
179179

180-
var { category_id }= query;
180+
const {category_id }= query;
181181

182-
var {category_id=1 }= query;
182+
const {category_name=1 }= query;
183183

184-
var {category_id: category_id }= query;
184+
const {category_id_name:category_id_name }= query;
185185
```
186186

187187
:::
@@ -195,8 +195,8 @@ Examples of additional **incorrect** code for this rule with the `{ "ignoreDestr
195195
```js
196196
/*eslint camelcase: ["error", {ignoreDestructuring: true}]*/
197197

198-
var { some_property }= obj;// allowed by {ignoreDestructuring: true}
199-
var foo= some_property+1;// error, ignoreDestructuring does not apply to this statement
198+
const {some_property }= obj;// allowed by {ignoreDestructuring: true}
199+
constfoo= some_property+1;// error, ignoreDestructuring does not apply to this statement
200200
```
201201

202202
:::
@@ -210,7 +210,7 @@ Examples of additional **correct** code for this rule with the `{ "ignoreDestruc
210210
```js
211211
/*eslint camelcase: ["error", {ignoreDestructuring: true}]*/
212212

213-
var { some_property,...rest }= obj;
213+
const {some_property,...rest }= obj;
214214
// do something with 'rest', nothing with 'some_property'
215215
```
216216

@@ -225,7 +225,7 @@ Examples of additional **correct** code for this rule with the `{ "properties":
225225
```js
226226
/*eslint camelcase: ["error", {"properties": "never", ignoreDestructuring: true}]*/
227227

228-
var { some_property }= obj;
228+
const {some_property }= obj;
229229
doSomething({ some_property });
230230
```
231231

‎docs/src/rules/curly.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ while (true) {
9696
doSomething();
9797
}
9898

99-
for (var i=0; i<items.length; i++) {
99+
for (let i=0; i<items.length; i++) {
100100
doSomething();
101101
}
102102
```
@@ -209,7 +209,7 @@ while (true) {
209209
doSomething();
210210
}
211211

212-
for (var i=0; foo; i++) {
212+
for (let i=0; foo; i++) {
213213
doSomething();
214214
}
215215
```
@@ -243,7 +243,7 @@ if (foo)
243243
while (true)
244244
doSomething();
245245

246-
for (var i=0; foo; i++)
246+
for (let i=0; foo; i++)
247247
doSomething();
248248
```
249249

‎docs/src/rules/dot-notation.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Examples of **incorrect** code for this rule:
2222
```js
2323
/*eslint dot-notation: "error"*/
2424

25-
var x= foo["bar"];
25+
constx= foo["bar"];
2626
```
2727

2828
:::
@@ -34,9 +34,9 @@ Examples of **correct** code for this rule:
3434
```js
3535
/*eslint dot-notation: "error"*/
3636

37-
var x=foo.bar;
37+
constx=foo.bar;
3838

39-
var x= foo[bar];// Property name is a variable, square-bracket notation required
39+
consty= foo[bar];// Property name is a variable, square-bracket notation required
4040
```
4141

4242
:::
@@ -57,8 +57,8 @@ Examples of **correct** code for the `{ "allowKeywords": false }` option:
5757
```js
5858
/*eslint dot-notation: ["error", { "allowKeywords": false }]*/
5959

60-
var foo= {"class":"CS 101" }
61-
var x= foo["class"];// Property name is a reserved word, square-bracket notation required
60+
constfoo= {"class":"CS 101" }
61+
constx= foo["class"];// Property name is a reserved word, square-bracket notation required
6262
```
6363

6464
:::
@@ -91,7 +91,7 @@ Examples of **incorrect** code for the sample `{ "allowPattern": "^[a-z]+(_[a-z]
9191
```js
9292
/*eslint dot-notation: ["error", { "allowPattern": "^[a-z]+(_[a-z]+)+$" }]*/
9393

94-
var data= {};
94+
constdata= {};
9595
data["fooBar"]=42;
9696
```
9797

@@ -103,7 +103,7 @@ Examples of **correct** code for the sample `{ "allowPattern": "^[a-z]+(_[a-z]+)
103103
```js
104104
/*eslint dot-notation: ["error", { "allowPattern": "^[a-z]+(_[a-z]+)+$" }]*/
105105

106-
var data= {};
106+
constdata= {};
107107
data["foo_bar"]=42;
108108
```
109109

‎docs/src/rules/id-denylist.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Examples of **incorrect** code for this rule with sample `"data", "callback"` re
4646
```js
4747
/*eslint id-denylist: ["error", "data", "callback"]*/
4848

49-
var data= {...values };
49+
constdata= {...values };
5050

5151
functioncallback() {
5252
// ...
@@ -56,7 +56,7 @@ element.callback = function() {
5656
// ...
5757
};
5858

59-
var itemSet= {
59+
constitemSet= {
6060
data: [...values]
6161
};
6262

@@ -86,7 +86,7 @@ Examples of **correct** code for this rule with sample `"data", "callback"` rest
8686
```js
8787
/*eslint id-denylist: ["error", "data", "callback"]*/
8888

89-
var encodingOptions= {...values};
89+
constencodingOptions= {...values};
9090

9191
functionprocessFileResult() {
9292
// ...
@@ -96,7 +96,7 @@ element.successHandler = function() {
9696
// ...
9797
};
9898

99-
var itemSet= {
99+
constitemSet= {
100100
entities: [...values]
101101
};
102102

‎docs/src/rules/max-lines.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Examples of **incorrect** code for this rule with a max value of `3`:
3939

4040
```js
4141
/*eslint max-lines: ["error", 3]*/
42-
var a,
42+
let a,
4343
b,
4444
c;
4545
```
@@ -51,7 +51,7 @@ var a,
5151
```js
5252
/*eslint max-lines: ["error", 3]*/
5353

54-
var a,
54+
let a,
5555
b,c;
5656
```
5757

@@ -62,7 +62,7 @@ var a,
6262
```js
6363
/*eslint max-lines: ["error", 3]*/
6464
// a comment
65-
var a,
65+
let a,
6666
b,c;
6767
```
6868

@@ -74,7 +74,7 @@ Examples of **correct** code for this rule with a max value of `3`:
7474

7575
```js
7676
/*eslint max-lines: ["error", 3]*/
77-
var a,
77+
let a,
7878
b, c;
7979
```
8080

@@ -85,7 +85,7 @@ var a,
8585
```js
8686
/*eslint max-lines: ["error", 3]*/
8787

88-
var a, b, c;
88+
let a, b, c;
8989
```
9090

9191
:::
@@ -95,7 +95,7 @@ var a, b, c;
9595
```js
9696
/*eslint max-lines: ["error", 3]*/
9797
// a comment
98-
var a, b, c;
98+
let a, b, c;
9999
```
100100

101101
:::
@@ -109,7 +109,7 @@ Examples of **incorrect** code for this rule with the `{ "skipBlankLines": true
109109
```js
110110
/*eslint max-lines: ["error", {"max": 3, "skipBlankLines": true}]*/
111111

112-
var a,
112+
let a,
113113
b,
114114
c;
115115
```
@@ -123,7 +123,7 @@ Examples of **correct** code for this rule with the `{ "skipBlankLines": true }`
123123
```js
124124
/*eslint max-lines: ["error", {"max": 3, "skipBlankLines": true}]*/
125125

126-
var a,
126+
let a,
127127
b, c;
128128
```
129129

@@ -138,7 +138,7 @@ Examples of **incorrect** code for this rule with the `{ "skipComments": true }`
138138
```js
139139
/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
140140
// a comment
141-
var a,
141+
let a,
142142
b,
143143
c;
144144
```
@@ -152,7 +152,7 @@ Examples of **correct** code for this rule with the `{ "skipComments": true }` o
152152
```js
153153
/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
154154
// a comment
155-
var a,
155+
let a,
156156
b, c;
157157
```
158158

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp