You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/src/rules/no-shadow-restricted-names.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ further_reading:
13
13
ES5 §15.1.1 Value Properties of the Global Object (`NaN`, `Infinity`, `undefined`) as well as strict mode restricted identifiers `eval` and `arguments` are considered to be restricted names in JavaScript. Defining them to mean something else can have unintended consequences and confuse others reading the code. For example, there's nothing preventing you from writing:
14
14
15
15
```js
16
-
varundefined="foo";
16
+
constundefined="foo";
17
17
```
18
18
19
19
Then any code used within the same scope would not get the global `undefined`, but rather the local version with a very different meaning.
@@ -31,7 +31,7 @@ function NaN(){}
31
31
32
32
!function(Infinity){};
33
33
34
-
varundefined=5;
34
+
constundefined=5;
35
35
36
36
try {} catch(eval){}
37
37
```
@@ -59,12 +59,12 @@ Examples of **correct** code for this rule:
59
59
```js
60
60
/*eslint no-shadow-restricted-names: "error"*/
61
61
62
-
varObject;
62
+
letObject;
63
63
64
64
functionf(a, b){}
65
65
66
66
// Exception: `undefined` may be shadowed if the variable is never assigned a value.
Copy file name to clipboardexpand all lines: docs/src/rules/no-underscore-dangle.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ rule_type: suggestion
6
6
As far as naming conventions for identifiers go, dangling underscores may be the most polarizing in JavaScript. Dangling underscores are underscores at either the beginning or end of an identifier, such as:
7
7
8
8
```js
9
-
var _foo;
9
+
let _foo;
10
10
```
11
11
12
12
There is a long history of marking "private" members with dangling underscores in JavaScript, beginning with SpiderMonkey adding nonstandard methods such as `__defineGetter__()`. Since that time, using a single underscore prefix has become the most popular convention for indicating a member is not part of the public interface of an object.
@@ -26,8 +26,8 @@ Examples of **incorrect** code for this rule:
26
26
```js
27
27
/*eslint no-underscore-dangle: "error"*/
28
28
29
-
var foo_;
30
-
var __proto__ = {};
29
+
let foo_;
30
+
const__proto__= {};
31
31
foo._bar();
32
32
```
33
33
@@ -40,10 +40,10 @@ Examples of **correct** code for this rule:
40
40
```js
41
41
/*eslint no-underscore-dangle: "error"*/
42
42
43
-
var _ =require('underscore');
44
-
var obj =_.contains(items, item);
43
+
const_=require('underscore');
44
+
constobj=_.contains(items, item);
45
45
obj.__proto__= {};
46
-
var file =__filename;
46
+
constfile=__filename;
47
47
functionfoo(_bar) {};
48
48
constbar= { onClick(_bar) {} };
49
49
constbaz= (_bar) => {};
@@ -74,7 +74,7 @@ Examples of additional **correct** code for this rule with the `{ "allow": ["foo
0 commit comments