forked from typescript-eslint/typescript-eslint
/
no-empty-function.test.ts
69 lines (66 loc) · 1.3 KB
/
no-empty-function.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import rule from '../../src/rules/no-empty-function';
import { RuleTester } from '../RuleTester';
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
});
ruleTester.run('no-empty-function', rule, {
valid: [
{
code: `class Person {
private name: string
constructor(name: string) {
this.name = name;
}
}`,
},
{
code: `class Person {
constructor(private name: string) {}
}`,
},
{
code: `class Person {
constructor(name: string) {}
}`,
options: [{ allow: ['constructors'] }],
},
{
code: `class Person {
otherMethod(name: string) {}
}`,
options: [{ allow: ['methods'] }],
},
],
invalid: [
{
code: `class Person {
constructor(name: string) {}
}`,
errors: [
{
messageId: 'unexpected',
data: {
name: 'constructor',
},
line: 2,
column: 35,
},
],
},
{
code: `class Person {
otherMethod(name: string) {}
}`,
errors: [
{
messageId: 'unexpected',
data: {
name: "method 'otherMethod'",
},
line: 2,
column: 35,
},
],
},
],
});