-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.js
102 lines (82 loc) · 1.55 KB
/
example.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
'use strict';
/* eslint-env node */
function sum(xs) { return xs.length === 0 ? 0 : xs[0] + sum (xs.slice (1)); }
const foo = x => y => z => [x, y, z];
if (parseInt ("foo 'bar' baz", 10) > 0) {
console.log (1);
} else if (foo.bar == null) {
console.log (2);
} else {
console.log (3);
}
const epoch = new Date ('1970-01-01T00:00:00.000Z');
if ((foo.bar = {baz: 'baz'})) console.log (epoch);
else console.log (sum (foo (123) (456) (789)));
foo (123)
(456)
(789);
foo
(123)
(456)
(789);
foo
.bar
.baz
.toUpperCase ()
.replace (/^/, '[')
.concat (']');
foo
.bar
.baz
.toUpperCase ()
.replace (/^/, '[')
.concat (']');
((foo.bar.baz.toUpperCase ()).replace (/^/, '[')).concat (']');
let baz = foo.bar.baz;
baz =
baz === 'foo' ? 1 :
baz === 'bar' ? 2 :
/* otherwise */ 3;
baz -= 1;
baz += 1;
baz = (baz => {
switch (baz) {
case 1: return 'foo';
case 2: return 'bar';
case 3: return 'baz';
}
}) (baz);
console.log (
baz !== 'baz' ? Math.abs :
/x/.test ('') ? Math.sin :
/* otherwise */ Math.cos
);
console.log (['foo',
'bar',
'baz']);
console.log ({foo: 1,
bar: 2,
baz: 3});
console.log ({
abc: 0,
var: 0,
['XYZ'.toLowerCase ()]: 0,
});
const rules = {
'semi': [
'error',
'always',
{omitLastInOneLineBlock: false},
],
'semi-spacing': [
'error',
{before: false, after: true},
],
'semi-style': [
'error',
'last',
],
};
console.log (rules['semi']);
console.log (rules['semi-spacing']);
console.log (rules['semi-style']);