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-func-assign.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ handled_by_typescript: true
6
6
7
7
8
8
9
-
JavaScript functions can be written as a FunctionDeclaration `function foo() { ... }` or as a FunctionExpression `var foo = function() { ... };`. While a JavaScript interpreter might tolerate it, overwriting/reassigning a function written as a FunctionDeclaration is often indicative of a mistake or issue.
9
+
JavaScript functions can be written as a FunctionDeclaration `function foo() { ... }` or as a FunctionExpression `const foo = function() { ... };`. While a JavaScript interpreter might tolerate it, overwriting/reassigning a function written as a FunctionDeclaration is often indicative of a mistake or issue.
10
10
11
11
```js
12
12
functionfoo() {}
@@ -31,7 +31,7 @@ function baz() {
31
31
baz = bar;
32
32
}
33
33
34
-
vara=functionhello() {
34
+
leta=functionhello() {
35
35
hello =123;
36
36
};
37
37
```
@@ -58,15 +58,15 @@ Examples of **correct** code for this rule:
Copy file name to clipboardexpand all lines: docs/src/rules/no-new-native-nonconstructor.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,10 @@ It is a convention in JavaScript that global variables beginning with an upperca
16
16
17
17
```js
18
18
// throws a TypeError
19
-
let foo =newSymbol("foo");
19
+
constfoo=newSymbol("foo");
20
20
21
21
// throws a TypeError
22
-
let result =newBigInt(9007199254740991);
22
+
constresult=newBigInt(9007199254740991);
23
23
```
24
24
25
25
Both `new Symbol` and `new BigInt` throw a type error because they are functions and not classes. It is easy to make this mistake by assuming the uppercase letters indicate classes.
@@ -40,8 +40,8 @@ Examples of **incorrect** code for this rule:
40
40
```js
41
41
/*eslint no-new-native-nonconstructor: "error"*/
42
42
43
-
var foo =newSymbol('foo');
44
-
var bar =newBigInt(9007199254740991);
43
+
constfoo=newSymbol('foo');
44
+
constbar=newBigInt(9007199254740991);
45
45
```
46
46
47
47
:::
@@ -53,8 +53,8 @@ Examples of **correct** code for this rule:
0 commit comments