escover 1.13.0 → 1.17.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 +25 -0
- package/lib/formatters/files.js +2 -0
- package/lib/formatters/lines.js +4 -7
- package/lib/instrument/index.js +0 -1
- package/lib/instrument/plugin-mark/{return.js → argument.js} +1 -1
- package/lib/instrument/plugin-mark/index.js +60 -47
- package/package.json +1 -1
- package/lib/instrument/plugin-mark/throw.js +0 -17
package/ChangeLog
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
2022.01.27, v1.17.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- escover: improve ternary support: Identifier
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
2022.01.27, v1.16.0
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- escover: add support of ternary
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
2022.01.26, v1.15.0
|
|
14
|
+
|
|
15
|
+
fix:
|
|
16
|
+
- escover: logical: find up
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
2022.01.21, v1.14.0
|
|
20
|
+
|
|
21
|
+
feature:
|
|
22
|
+
- escover: instrument: integrate with putout with crawling enabled
|
|
23
|
+
- escover: format: files: add align center
|
|
24
|
+
|
|
25
|
+
|
|
1
26
|
2022.01.20, v1.13.0
|
|
2
27
|
|
|
3
28
|
feature:
|
package/lib/formatters/files.js
CHANGED
package/lib/formatters/lines.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
const {entries} = Object;
|
|
3
2
|
|
|
3
|
+
const {entries} = Object;
|
|
4
4
|
const createOut = (output) => (a) => output.push(a);
|
|
5
|
+
|
|
5
6
|
export default (coverageFile) => {
|
|
6
7
|
const output = [];
|
|
7
8
|
const out = createOut(output);
|
|
@@ -56,19 +57,15 @@ export default (coverageFile) => {
|
|
|
56
57
|
out(`1..${files.length}`);
|
|
57
58
|
out(`# files: ${files.length}`);
|
|
58
59
|
out(`# covered: ${coverage.coveredCount}`);
|
|
59
|
-
|
|
60
60
|
out('');
|
|
61
61
|
|
|
62
|
-
if (!coverage.uncoveredCount)
|
|
62
|
+
if (!coverage.uncoveredCount)
|
|
63
63
|
out('#️ 🌴 ok');
|
|
64
|
-
}
|
|
65
64
|
|
|
66
|
-
if (coverage.uncoveredCount)
|
|
65
|
+
if (coverage.uncoveredCount)
|
|
67
66
|
out(`# 🧨 fail: ${coverage.uncoveredCount}`);
|
|
68
|
-
}
|
|
69
67
|
|
|
70
68
|
out('');
|
|
71
69
|
|
|
72
70
|
return output.join('\n');
|
|
73
71
|
};
|
|
74
|
-
|
package/lib/instrument/index.js
CHANGED
|
@@ -4,9 +4,8 @@ import {
|
|
|
4
4
|
operator,
|
|
5
5
|
} from 'putout';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {addMarkToArgument} from './argument.js';
|
|
8
8
|
import {addMarkToArrowFunction} from './arrow.js';
|
|
9
|
-
import {addMarkToThrow} from './throw.js';
|
|
10
9
|
|
|
11
10
|
const {
|
|
12
11
|
NumericLiteral,
|
|
@@ -39,12 +38,10 @@ export const report = () => 'Mark line';
|
|
|
39
38
|
|
|
40
39
|
export const fix = (path, {options}) => {
|
|
41
40
|
const {node} = path;
|
|
42
|
-
|
|
43
41
|
const {start} = path.node.loc;
|
|
44
42
|
|
|
45
43
|
const {
|
|
46
44
|
c4 = {
|
|
47
|
-
mark: () => {},
|
|
48
45
|
init: () => {},
|
|
49
46
|
},
|
|
50
47
|
} = options;
|
|
@@ -56,8 +53,9 @@ export const fix = (path, {options}) => {
|
|
|
56
53
|
return;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
if (path.
|
|
56
|
+
if (path.isIdentifier()) {
|
|
60
57
|
const {node} = path;
|
|
58
|
+
|
|
61
59
|
replaceWith(path, SequenceExpression([
|
|
62
60
|
lineNode.expression,
|
|
63
61
|
node,
|
|
@@ -65,48 +63,42 @@ export const fix = (path, {options}) => {
|
|
|
65
63
|
return;
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
if (path.
|
|
69
|
-
|
|
66
|
+
if (path.isCallExpression() || path.isNewExpression()) {
|
|
67
|
+
const {node} = path;
|
|
68
|
+
|
|
69
|
+
replaceWith(path, SequenceExpression([
|
|
70
70
|
lineNode.expression,
|
|
71
|
-
|
|
72
|
-
]));
|
|
73
|
-
replaceWith(path.get('right'), SequenceExpression([
|
|
74
|
-
getLineNode(c4, path.node.right.loc.start).expression,
|
|
75
|
-
path.node.right,
|
|
71
|
+
node,
|
|
76
72
|
]));
|
|
77
73
|
return;
|
|
78
74
|
}
|
|
79
75
|
|
|
80
|
-
if (path.
|
|
81
|
-
replaceWith(path
|
|
76
|
+
if (path.parentPath.isLogicalExpression())
|
|
77
|
+
return replaceWith(path, SequenceExpression([
|
|
82
78
|
lineNode.expression,
|
|
83
|
-
node
|
|
79
|
+
path.node,
|
|
84
80
|
]));
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
81
|
|
|
88
|
-
if (path.
|
|
89
|
-
replaceWith(path, SequenceExpression([
|
|
82
|
+
if (path.isAssignmentPattern() || path.isAssignmentExpression()) {
|
|
83
|
+
replaceWith(path.get('right'), SequenceExpression([
|
|
90
84
|
lineNode.expression,
|
|
91
|
-
node,
|
|
85
|
+
node.right,
|
|
92
86
|
]));
|
|
93
87
|
return;
|
|
94
88
|
}
|
|
95
89
|
|
|
96
|
-
if (path.isReturnStatement())
|
|
97
|
-
return addMarkToReturn(path, lineNode);
|
|
98
|
-
|
|
99
90
|
if (path.isArrowFunctionExpression())
|
|
100
91
|
return addMarkToArrowFunction(path, lineNode);
|
|
101
92
|
|
|
102
|
-
if (path.isThrowStatement())
|
|
103
|
-
return
|
|
93
|
+
if (path.isReturnStatement() || path.isThrowStatement())
|
|
94
|
+
return addMarkToArgument(path, lineNode);
|
|
104
95
|
|
|
105
|
-
if (path.isContinueStatement() || path.isBreakStatement())
|
|
96
|
+
if (path.isContinueStatement() || path.isBreakStatement()) {
|
|
106
97
|
return replaceWithMultiple(path, [
|
|
107
98
|
lineNode,
|
|
108
99
|
path.node,
|
|
109
100
|
]);
|
|
101
|
+
}
|
|
110
102
|
|
|
111
103
|
replaceWith(path, BlockStatement([
|
|
112
104
|
node,
|
|
@@ -115,24 +107,42 @@ export const fix = (path, {options}) => {
|
|
|
115
107
|
|
|
116
108
|
const EXCLUDE = [
|
|
117
109
|
LINE,
|
|
118
|
-
`(${LINE}, __z)`,
|
|
119
110
|
`return (${LINE}, __z)`,
|
|
120
111
|
`return ${LINE}`,
|
|
121
112
|
`throw (${LINE}, __z)`,
|
|
122
113
|
];
|
|
123
114
|
|
|
124
|
-
|
|
115
|
+
const SEQUENCE = `(${LINE}, __z)`;
|
|
116
|
+
const isExclude = (node) => {
|
|
117
|
+
const templates = [
|
|
118
|
+
...EXCLUDE,
|
|
119
|
+
SEQUENCE,
|
|
120
|
+
];
|
|
121
|
+
return compareAny(node, templates, {
|
|
122
|
+
findUp: false,
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
125
|
|
|
126
|
-
export const
|
|
127
|
-
'CallExpression',
|
|
128
|
-
'NewExpression',
|
|
129
|
-
'ReturnStatement',
|
|
130
|
-
'ThrowStatement',
|
|
131
|
-
];
|
|
126
|
+
export const exclude = () => EXCLUDE;
|
|
132
127
|
|
|
133
128
|
export const traverse = ({push}) => ({
|
|
129
|
+
'ThrowStatement|ReturnStatement'(path) {
|
|
130
|
+
push(path);
|
|
131
|
+
},
|
|
132
|
+
CallExpression(path) {
|
|
133
|
+
if (compare(path.parentPath.node, SEQUENCE))
|
|
134
|
+
return;
|
|
135
|
+
|
|
136
|
+
push(path);
|
|
137
|
+
},
|
|
138
|
+
'CallExpression|NewExpression'(path) {
|
|
139
|
+
if (compare(path.parentPath.node, SEQUENCE))
|
|
140
|
+
return;
|
|
141
|
+
|
|
142
|
+
push(path);
|
|
143
|
+
},
|
|
134
144
|
'AssignmentPattern|AssignmentExpression'(path) {
|
|
135
|
-
if (
|
|
145
|
+
if (isExclude(path.get('right')))
|
|
136
146
|
return;
|
|
137
147
|
|
|
138
148
|
push(path);
|
|
@@ -144,21 +154,20 @@ export const traverse = ({push}) => ({
|
|
|
144
154
|
push(path);
|
|
145
155
|
},
|
|
146
156
|
'ContinueStatement|BreakStatement'(path) {
|
|
147
|
-
if (
|
|
148
|
-
return;
|
|
149
|
-
|
|
150
|
-
const {body} = path.parentPath.node;
|
|
151
|
-
|
|
152
|
-
if (compare(body[0], LINE))
|
|
157
|
+
if (compare(path.getPrevSibling(), LINE))
|
|
153
158
|
return;
|
|
154
159
|
|
|
155
160
|
push(path);
|
|
156
161
|
},
|
|
157
162
|
LogicalExpression(path) {
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
const leftPath = path.get('left');
|
|
164
|
+
const rightPath = path.get('right');
|
|
160
165
|
|
|
161
|
-
|
|
166
|
+
if (!isExclude(leftPath))
|
|
167
|
+
push(leftPath);
|
|
168
|
+
|
|
169
|
+
if (!isExclude(rightPath))
|
|
170
|
+
push(rightPath);
|
|
162
171
|
},
|
|
163
172
|
BlockStatement(path) {
|
|
164
173
|
if (path.node.body.length)
|
|
@@ -167,6 +176,10 @@ export const traverse = ({push}) => ({
|
|
|
167
176
|
push(path);
|
|
168
177
|
},
|
|
169
178
|
SequenceExpression(path) {
|
|
179
|
+
if (compare(path, `(${LINE}, __z)`)) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
170
183
|
const expressions = path.get('expressions');
|
|
171
184
|
|
|
172
185
|
for (const expPath of expressions) {
|
|
@@ -176,17 +189,17 @@ export const traverse = ({push}) => ({
|
|
|
176
189
|
push(expPath);
|
|
177
190
|
}
|
|
178
191
|
},
|
|
179
|
-
IfStatement(path) {
|
|
192
|
+
'IfStatement|ConditionalExpression'(path) {
|
|
180
193
|
const consequentPath = path.get('consequent');
|
|
181
194
|
const alternatePath = path.get('alternate');
|
|
182
195
|
|
|
183
|
-
if (!consequentPath.isBlockStatement() && !
|
|
196
|
+
if (!consequentPath.isBlockStatement() && !isExclude(consequentPath))
|
|
184
197
|
push(consequentPath);
|
|
185
198
|
|
|
186
199
|
if (!alternatePath.node)
|
|
187
200
|
return;
|
|
188
201
|
|
|
189
|
-
if (!alternatePath.isBlockStatement())
|
|
202
|
+
if (!alternatePath.isBlockStatement() && !isExclude(alternatePath))
|
|
190
203
|
push(alternatePath);
|
|
191
204
|
},
|
|
192
205
|
});
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
types,
|
|
3
|
-
operator,
|
|
4
|
-
} from 'putout';
|
|
5
|
-
const {SequenceExpression} = types;
|
|
6
|
-
|
|
7
|
-
const {replaceWith} = operator;
|
|
8
|
-
|
|
9
|
-
export const addMarkToThrow = (path, lineNode) => {
|
|
10
|
-
const argumentPath = path.get('argument');
|
|
11
|
-
|
|
12
|
-
return replaceWith(argumentPath, SequenceExpression([
|
|
13
|
-
lineNode.expression,
|
|
14
|
-
argumentPath.node,
|
|
15
|
-
]));
|
|
16
|
-
};
|
|
17
|
-
|