redput 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +6 -0
- package/lib/get-report/plugin-get-report/index.js +48 -22
- package/lib/redput.js +1 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,30 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
operator,
|
|
3
|
+
types,
|
|
4
|
+
} from 'putout';
|
|
2
5
|
|
|
6
|
+
const {isStringLiteral} = types;
|
|
3
7
|
const {getTemplateValues} = operator;
|
|
8
|
+
|
|
4
9
|
const REPORT = 'export const report = () => __a';
|
|
10
|
+
const REPORT_COMMONJS = 'module.exports.report = () => __a';
|
|
5
11
|
const ASSIGN = 'export const report = __a';
|
|
6
12
|
|
|
13
|
+
const templates = [
|
|
14
|
+
REPORT,
|
|
15
|
+
REPORT_COMMONJS,
|
|
16
|
+
ASSIGN,
|
|
17
|
+
];
|
|
18
|
+
|
|
7
19
|
export const report = ({value}) => value;
|
|
8
20
|
export const fix = () => {};
|
|
9
|
-
export const traverse = ({push}) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
path.stop();
|
|
19
|
-
},
|
|
20
|
-
[ASSIGN](path) {
|
|
21
|
-
const {__a} = getTemplateValues(path, ASSIGN);
|
|
22
|
-
|
|
23
|
-
push({
|
|
24
|
-
path,
|
|
25
|
-
value: __a.quasis[0].value.cooked,
|
|
21
|
+
export const traverse = ({push}) => {
|
|
22
|
+
const pushValue = process(push);
|
|
23
|
+
const visitors = {};
|
|
24
|
+
|
|
25
|
+
for (const template of templates) {
|
|
26
|
+
visitors[template] = process({
|
|
27
|
+
push,
|
|
28
|
+
template,
|
|
26
29
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return visitors;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const process = ({push, template}) => (path) => {
|
|
36
|
+
const {__a} = getTemplateValues(path, template);
|
|
37
|
+
|
|
38
|
+
if (!__a)
|
|
39
|
+
return;
|
|
40
|
+
|
|
41
|
+
const value = parseValue(__a);
|
|
42
|
+
|
|
43
|
+
push({
|
|
44
|
+
path,
|
|
45
|
+
value,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
path.stop();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function parseValue(a) {
|
|
52
|
+
if (isStringLiteral(a))
|
|
53
|
+
return a.value;
|
|
54
|
+
|
|
55
|
+
return a.quasis[0].value.cooked;
|
|
56
|
+
}
|
package/lib/redput.js
CHANGED
|
@@ -26,7 +26,7 @@ export const redput = async (link, {token}) => {
|
|
|
26
26
|
const [comment, ...lines] = raw.split('\n');
|
|
27
27
|
const name = comment.replace(/\/\/\s+?/, '');
|
|
28
28
|
|
|
29
|
-
if (name.includes(':'))
|
|
29
|
+
if (name.includes(':') || name.includes('{'))
|
|
30
30
|
return [
|
|
31
31
|
Error(`Bad name: ${name}`),
|
|
32
32
|
];
|