forked from palantir/tslint
/
test.tsx.lint
80 lines (64 loc) · 1.5 KB
/
test.tsx.lint
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
class C {
method(x: number) {}
property: () => void;
template(strs: TemplateStringsArray, x: any) {}
}
const c = new C();
[0].forEach(c.method);
~~~~~~~~ [0]
[0].forEach(x => c.method(x));
[0].forEach(c.property);
c.template;
~~~~~~~~~~ [0]
c.template`foo${0}`;
String.raw`${c.template}`;
~~~~~~~~~~ [0]
expect(c.method).toHaveBeenCalled();
typeof c.method;
test(c.method);
~~~~~~~~ [0]
interface I {
foo(): void;
bar: () => void;
}
declare var i: I;
i.foo;
~~~~~ [0]
i.bar;
c.method === i.foo;
// OK in condition
c.method ? 1 : 2;
1 ? c.method : c.method;
~~~~~~~~ [0]
~~~~~~~~ [0]
if (c.method) {}
while (c.method) {}
do {} while (c.method);
for (c.method; c.method; c.method) {}
[0].forEach(c.method || i.foo);
~~~~~~~~ [0]
~~~~~ [0]
[0].forEach(c.method.bind(c));
<button onClick={c.method}>Click me!</button>;
~~~~~~~~ [0]
class Validators {
static required() {
return null;
}
static compose(...args: Function[]) {}
}
Validators.compose(Validators.required);
~~~~~~~~~~~~~~~~~~~ [0]
(condition ? expectA : expectB)(c.method);
~~~~~~~~ [0]
(await someObject)(c.method);
~~~~~~~~ [0]
(await someMethod())(c.method);
~~~~~~~~ [0]
const a = {
getText() {
return 'text';
}
};
delete a.getText;
[0]: Avoid referencing unbound methods which may cause unintentional scoping of 'this'.