forked from palantir/tslint
/
test.ts.lint
55 lines (48 loc) · 1.29 KB
/
test.ts.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
const bad = {
w: function() {},
~~~~~~~~~~~ [LONGHAND_METHOD % ("('{w() {...}}')")]
x: function *() {},
~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{*x() {...}}')")]
[y]: function() {},
~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{[y]() {...}}')")]
z: z
~~~~ [Expected property shorthand in object literal ('{z}').]
};
const good = {
w() {},
*x() {},
[y]() {},
z
};
const arrows = {
x: (y) => y // this is OK.
};
const namedFunctions = {
x: function y() {} // named function expressions are also OK.
};
const quotes = {
"foo-bar": function() {},
~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{\"foo-bar\"() {...}}')")]
"foo-bar"() {}
};
const extraCases = {
x,
a: 123,
b: "hello",
c: 'c',
["a" + "nested"]: {
x: x
~~~~ [Expected property shorthand in object literal ('{x}').]
}
};
const asyncFn = {
foo: async function() {},
~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async foo() {...}}')")]
bar: async function*() {}
~~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async *bar() {...}}')")]
}
({foo: foo} = {foo: foo});
~~~~~~~~ [LONGHAND_PROPERTY % ("('{foo}')")]
~~~~~~~~ [LONGHAND_PROPERTY % ("('{foo}')")]
[LONGHAND_METHOD]: Expected method shorthand in object literal %s.
[LONGHAND_PROPERTY]: Expected property shorthand in object literal %s.