-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
arrow-parens.test.ts
46 lines (42 loc) · 1.1 KB
/
arrow-parens.test.ts
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
import { noFormat, RuleTester } from '@typescript-eslint/rule-tester';
import { getESLintCoreRule } from '../../src/util/getESLintCoreRule';
const rule = getESLintCoreRule('arrow-parens');
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
});
ruleTester.run('arrow-parens', rule, {
valid: [
// https://github.com/typescript-eslint/typescript-eslint/issues/14
noFormat`const foo = (t) => {};`,
'const foo = <T>(t) => {};',
'const foo = <T>(t: T) => {};',
'const foo = <T>((t: T) => {});',
'const foo = function <T>(t: T) {};',
`
const foo = <T>(bar: any): void => {
// Do nothing
};
`,
{
code: 'const foo = t => {};',
options: ['as-needed'],
},
{
code: 'const foo = <T>(t) => {};',
options: ['as-needed'],
},
{
code: 'const foo = (t: T) => {};',
options: ['as-needed'],
},
{
code: 'const foo = <T>(t: T) => {};',
options: ['as-needed'],
},
{
code: 'const foo = <T>(t: T) => ({});',
options: ['as-needed', { requireForBlockBody: true }],
},
],
invalid: [],
});