-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnot-optimal.js
58 lines (45 loc) · 1.4 KB
/
not-optimal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*eslint no-eval: "error"*/
var obj = { x: "foo" },
key = "x",
value = eval("obj." + key);
/*eslint no-implied-eval: "error"*/
setTimeout("alert('Hi!');", 100);
/*eslint no-new-func: "error"*/
var x = new Function("a", "b", "return a + b");
/*eslint no-self-assign: "error"*/
foo = foo;
/*eslint no-unused-expressions: ["error", {"allowShortCircuit": true, "allowTernary": true}]*/
n + 1; // This is a valid JavaScript expression,
// but isn’t actually used.
/*eslint no-inner-declarations: "error"*/
for (var i = 0; i < 10; ++i) {
// This feature will be announced 10 times.
function doSomethingElse () {
// ...
}
}
/*eslint no-loop-func: "error"*/
for (var i=10; i; i--) {
var a = function() { return i; };
a();
}
/*eslint no-constant-condition: "error"*/
if (false) {
// This function is never executed.
doSomething();
}
/*eslint no-unreachable: "error"*/
function fn() {
var x = 1;
return x;
x = 3; // This will never execute.
}
/*eslint no-empty: "error"*/
if (foo) {} // Empty block statements, while not technically errors, but they can cause confusion when reading code.
/*eslint no-extra-boolean-cast: "error"*/
var truth = true;
if (!!truth) { // This variable already coerced to a Boolean.
// ...
}
/*eslint no-useless-computed-key: "error"*/
var a = { ['0']: 0 }; // It’s unnecessary to use computed properties with literals such as.