-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathapply-arrow.js
More file actions
72 lines (60 loc) · 1.65 KB
/
apply-arrow.js
File metadata and controls
72 lines (60 loc) · 1.65 KB
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
import {createTest} from '@putout/test';
import {operator} from 'putout';
import * as plugin from '../lib/apply-arrow.js';
const {
compare,
getTemplateValues,
} = operator;
const test = createTest(import.meta.url, {
plugins: [
['apply-arrow', plugin],
],
});
test('putout: apply-arrow: report', (t) => {
t.report('apply-arrow', `Use 'Arrow Function' instead of 'Function Declaration`);
t.end();
});
test('putout: apply-arrow: transform', (t) => {
t.transform('apply-arrow');
t.end();
});
test('putout: apply-arrow: transform: other-scope-reference', (t) => {
t.transform('other-scope-reference');
t.end();
});
test('putout: apply-arrow: no report: long', (t) => {
t.noReport('long');
t.end();
});
test('putout: apply-arrow: no report: for-of', (t) => {
t.noReport('for-of');
t.end();
});
test('putout: apply-arrow: no report: comment', (t) => {
t.noReport('comment');
t.end();
});
test('putout: apply-arrow: no report: logical', (t) => {
t.noReport('logical');
t.end();
});
test('putout: apply-arrow: transform: no-loc', (t) => {
const FN = 'function __a(__args) {return __b}';
t.transform('no-loc', {
noLoc: {
report: () => '',
fix: (path) => {
const {__b} = getTemplateValues(path.get('body.0.declaration'), FN);
delete __b.loc;
},
include: () => [
'Program',
],
filter: (path) => {
const fnPath = path.get('body.0.declaration');
return compare(fnPath, FN);
},
},
});
t.end();
});