/
prefer-event-target.mjs
48 lines (45 loc) · 1.18 KB
/
prefer-event-target.mjs
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
import outdent from 'outdent';
import {getTester} from './utils/test.mjs';
const {test} = getTester(import.meta);
test.snapshot({
valid: [
'class Foo {}',
'class Foo extends OtherClass {}',
'class Foo extends EventTarget {}',
'const Foo = class extends EventTarget {}',
'const Foo = class extends foo.EventTarget {}',
'const Foo = class extends foo.bar.EventTarget {}',
'class Foo extends foo.EventEmitter {}',
'class Foo extends foo.bar.EventEmitter {}',
'class EventEmitter extends Foo {}',
'const Foo = class EventEmitter extends Foo {}',
'new Foo(EventEmitter)',
'new foo.EventEmitter()',
],
invalid: [
'class Foo extends EventEmitter {}',
'class Foo extends EventEmitter { someMethod() {} }',
'const Foo = class extends EventEmitter {}',
outdent`
class Foo extends EventEmitter {
addListener() {}
removeListener() {}
}
`,
],
});
test.snapshot({
valid: [
'EventTarget()',
'new EventTarget',
'const target = new EventTarget;',
'const target = EventTarget()',
'const target = new Foo(EventEmitter);',
'EventEmitter()',
'const emitter = EventEmitter()',
],
invalid: [
'new EventEmitter',
'const emitter = new EventEmitter;',
],
});