escover 1.13.0 → 1.14.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 +7 -0
- package/lib/formatters/files.js +2 -0
- package/lib/formatters/lines.js +2 -6
- 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 +37 -36
- package/package.json +1 -1
- package/lib/instrument/plugin-mark/throw.js +0 -17
package/ChangeLog
CHANGED
package/lib/formatters/files.js
CHANGED
package/lib/formatters/lines.js
CHANGED
|
@@ -56,19 +56,15 @@ export default (coverageFile) => {
|
|
|
56
56
|
out(`1..${files.length}`);
|
|
57
57
|
out(`# files: ${files.length}`);
|
|
58
58
|
out(`# covered: ${coverage.coveredCount}`);
|
|
59
|
-
|
|
60
59
|
out('');
|
|
61
60
|
|
|
62
|
-
if (!coverage.uncoveredCount)
|
|
61
|
+
if (!coverage.uncoveredCount)
|
|
63
62
|
out('#️ 🌴 ok');
|
|
64
|
-
}
|
|
65
63
|
|
|
66
|
-
if (coverage.uncoveredCount)
|
|
64
|
+
if (coverage.uncoveredCount)
|
|
67
65
|
out(`# 🧨 fail: ${coverage.uncoveredCount}`);
|
|
68
|
-
}
|
|
69
66
|
|
|
70
67
|
out('');
|
|
71
68
|
|
|
72
69
|
return output.join('\n');
|
|
73
70
|
};
|
|
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.isCallExpression()) {
|
|
56
|
+
if (path.isCallExpression() || path.isNewExpression()) {
|
|
60
57
|
const {node} = path;
|
|
58
|
+
|
|
61
59
|
replaceWith(path, SequenceExpression([
|
|
62
60
|
lineNode.expression,
|
|
63
61
|
node,
|
|
@@ -85,28 +83,18 @@ export const fix = (path, {options}) => {
|
|
|
85
83
|
return;
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
if (path.isNewExpression()) {
|
|
89
|
-
replaceWith(path, SequenceExpression([
|
|
90
|
-
lineNode.expression,
|
|
91
|
-
node,
|
|
92
|
-
]));
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (path.isReturnStatement())
|
|
97
|
-
return addMarkToReturn(path, lineNode);
|
|
98
|
-
|
|
99
86
|
if (path.isArrowFunctionExpression())
|
|
100
87
|
return addMarkToArrowFunction(path, lineNode);
|
|
101
88
|
|
|
102
|
-
if (path.isThrowStatement())
|
|
103
|
-
return
|
|
89
|
+
if (path.isReturnStatement() || path.isThrowStatement())
|
|
90
|
+
return addMarkToArgument(path, lineNode);
|
|
104
91
|
|
|
105
|
-
if (path.isContinueStatement() || path.isBreakStatement())
|
|
92
|
+
if (path.isContinueStatement() || path.isBreakStatement()) {
|
|
106
93
|
return replaceWithMultiple(path, [
|
|
107
94
|
lineNode,
|
|
108
95
|
path.node,
|
|
109
96
|
]);
|
|
97
|
+
}
|
|
110
98
|
|
|
111
99
|
replaceWith(path, BlockStatement([
|
|
112
100
|
node,
|
|
@@ -115,24 +103,39 @@ export const fix = (path, {options}) => {
|
|
|
115
103
|
|
|
116
104
|
const EXCLUDE = [
|
|
117
105
|
LINE,
|
|
118
|
-
`(${LINE}, __z)`,
|
|
119
106
|
`return (${LINE}, __z)`,
|
|
120
107
|
`return ${LINE}`,
|
|
121
108
|
`throw (${LINE}, __z)`,
|
|
122
109
|
];
|
|
123
110
|
|
|
124
|
-
|
|
111
|
+
const SEQUENCE = `(${LINE}, __z)`;
|
|
112
|
+
const isExclude = (node) => {
|
|
113
|
+
return compareAny(node, [
|
|
114
|
+
...EXCLUDE,
|
|
115
|
+
SEQUENCE,
|
|
116
|
+
]);
|
|
117
|
+
};
|
|
125
118
|
|
|
126
|
-
export const
|
|
127
|
-
'CallExpression',
|
|
128
|
-
'NewExpression',
|
|
129
|
-
'ReturnStatement',
|
|
130
|
-
'ThrowStatement',
|
|
131
|
-
];
|
|
119
|
+
export const exclude = () => EXCLUDE;
|
|
132
120
|
|
|
133
121
|
export const traverse = ({push}) => ({
|
|
122
|
+
'ThrowStatement|ReturnStatement'(path) {
|
|
123
|
+
push(path);
|
|
124
|
+
},
|
|
125
|
+
CallExpression(path) {
|
|
126
|
+
if (compare(path.parentPath.node, SEQUENCE))
|
|
127
|
+
return;
|
|
128
|
+
|
|
129
|
+
push(path);
|
|
130
|
+
},
|
|
131
|
+
'CallExpression|NewExpression'(path) {
|
|
132
|
+
if (compare(path.parentPath.node, SEQUENCE))
|
|
133
|
+
return;
|
|
134
|
+
|
|
135
|
+
push(path);
|
|
136
|
+
},
|
|
134
137
|
'AssignmentPattern|AssignmentExpression'(path) {
|
|
135
|
-
if (
|
|
138
|
+
if (isExclude(path.get('right')))
|
|
136
139
|
return;
|
|
137
140
|
|
|
138
141
|
push(path);
|
|
@@ -144,18 +147,13 @@ export const traverse = ({push}) => ({
|
|
|
144
147
|
push(path);
|
|
145
148
|
},
|
|
146
149
|
'ContinueStatement|BreakStatement'(path) {
|
|
147
|
-
if (
|
|
148
|
-
return;
|
|
149
|
-
|
|
150
|
-
const {body} = path.parentPath.node;
|
|
151
|
-
|
|
152
|
-
if (compare(body[0], LINE))
|
|
150
|
+
if (compare(path.getPrevSibling(), LINE))
|
|
153
151
|
return;
|
|
154
152
|
|
|
155
153
|
push(path);
|
|
156
154
|
},
|
|
157
155
|
LogicalExpression(path) {
|
|
158
|
-
if (
|
|
156
|
+
if (isExclude(path.get('left')))
|
|
159
157
|
return;
|
|
160
158
|
|
|
161
159
|
push(path);
|
|
@@ -167,6 +165,9 @@ export const traverse = ({push}) => ({
|
|
|
167
165
|
push(path);
|
|
168
166
|
},
|
|
169
167
|
SequenceExpression(path) {
|
|
168
|
+
if (compare(path, `(${LINE}, __z)`))
|
|
169
|
+
return;
|
|
170
|
+
|
|
170
171
|
const expressions = path.get('expressions');
|
|
171
172
|
|
|
172
173
|
for (const expPath of expressions) {
|
|
@@ -180,7 +181,7 @@ export const traverse = ({push}) => ({
|
|
|
180
181
|
const consequentPath = path.get('consequent');
|
|
181
182
|
const alternatePath = path.get('alternate');
|
|
182
183
|
|
|
183
|
-
if (!consequentPath.isBlockStatement() && !
|
|
184
|
+
if (!consequentPath.isBlockStatement() && !isExclude(consequentPath))
|
|
184
185
|
push(consequentPath);
|
|
185
186
|
|
|
186
187
|
if (!alternatePath.node)
|
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
|
-
|