escover 1.0.3 → 1.0.4

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 CHANGED
@@ -1,3 +1,9 @@
1
+ 2022.01.08, v1.0.4
2
+
3
+ feature:
4
+ - escover: add support of AssignmentExpression
5
+
6
+
1
7
  2022.01.08, v1.0.3
2
8
 
3
9
  feature:
package/coverage.json CHANGED
@@ -1,8 +1 @@
1
- [
2
- {
3
- "name": "/Users/coderaiser/escover/example/example.js",
4
- "lines": {
5
- "1": true
6
- }
7
- }
8
- ]
1
+ []
package/lib/c4.js CHANGED
@@ -5,10 +5,10 @@ export const createFileEntry = (url) => {
5
5
  files.set(url, lines);
6
6
 
7
7
  return {
8
- mark: (line, column) => {
8
+ '🧨': (line, column) => {
9
9
  lines.set(`${line}:${column}`, true);
10
10
  },
11
- init: (line, column) => {
11
+ 'init': (line, column) => {
12
12
  lines.set(`${line}:${column}`, false);
13
13
  },
14
14
  };
package/lib/escover.js CHANGED
@@ -27,8 +27,6 @@ export async function load(url, context, defaultLoad) {
27
27
  ${instrument(url, rawSource)}
28
28
  `;
29
29
 
30
- console.log(source);
31
-
32
30
  return {
33
31
  format,
34
32
  source,
@@ -1,6 +1,6 @@
1
1
  export const nothing = (a, b) => {
2
- return __c4.mark(2, 4);
2
+ return __c4['🧨'](2, 4);
3
3
  };
4
4
  export const sum = (a, b) => {
5
- return __c4.mark(5, 4), a + b;
5
+ return __c4['🧨'](5, 4), a + b;
6
6
  };
@@ -1 +1,2 @@
1
- const [error, {packageJson} = (__c4.mark(1, 14), {})] = (__c4.mark(1, 36), tryCatch(readPackageUpSync));
1
+ const [error, {packageJson} = (__c4['🧨'](1, 14), {})] = (__c4['🧨'](1, 36), tryCatch(readPackageUpSync));
2
+ data += (__c4['🧨'](2, 0), 'fix:' + '\n');
@@ -1 +1,2 @@
1
1
  const [error, {packageJson} = {}] = tryCatch(readPackageUpSync);
2
+ data += 'fix:' + '\n';
@@ -1,3 +1,6 @@
1
1
  if (error) {
2
- throw (__c4.mark(2, 4), `error reading package.json: ${error.message}`);
2
+ throw (__c4['🧨'](2, 4), `error reading package.json: ${error.message}`);
3
3
  }
4
+
5
+ if (error)
6
+ throw (__c4['🧨'](6, 4), (__c4.mark(11, 8), `error reading package.json: ${error.message}`));
@@ -1,3 +1,6 @@
1
1
  if (error) {
2
2
  throw `error reading package.json: ${error.message}`;
3
3
  }
4
+
5
+ if (error)
6
+ throw (__c4.mark(11, 8), `error reading package.json: ${error.message}`);
@@ -1,3 +1,3 @@
1
- if ((__c4.mark(1, 4), a) || (__c4.mark(1, 9), b)) {
2
- __c4.mark(1, 12);
1
+ if ((__c4['🧨'](1, 4), a) || (__c4['🧨'](1, 9), b)) {
2
+ __c4['🧨'](1, 12);
3
3
  }
@@ -1,30 +1,30 @@
1
1
  const a = () => {
2
- a = 5;
3
- __c4.mark(3, 4), console.log(5);
2
+ a = (__c4['🧨'](2, 4), 5);
3
+ __c4['🧨'](3, 4), console.log(5);
4
4
  };
5
5
 
6
6
 
7
7
  function x() {
8
8
 
9
9
  if (a > 2) {
10
- __c4.mark(9, 14), a();
10
+ __c4['🧨'](9, 14), a();
11
11
  } else {
12
- __c4.mark(10, 9), b();
12
+ __c4['🧨'](10, 9), b();
13
13
  }
14
14
  }
15
15
 
16
16
  for (const x of y) {
17
- __c4.mark(13, 19);
17
+ __c4['🧨'](13, 19);
18
18
  }
19
19
 
20
- const ax = ((__c4.mark(16, 12), a()), (__c4.mark(16, 17), b()));
21
- const bx = (c, (__c4.mark(17, 15), d()));
20
+ const ax = ((__c4['🧨'](16, 12), a()), (__c4['🧨'](16, 17), b()));
21
+ const bx = (c, (__c4['🧨'](17, 15), d()));
22
22
 
23
- if ((__c4.mark(19, 4), a) || (__c4.mark(19, 9), b)) {
24
- __c4.mark(19, 12);
23
+ if ((__c4['🧨'](19, 4), a) || (__c4['🧨'](19, 9), b)) {
24
+ __c4['🧨'](19, 12);
25
25
  }
26
26
 
27
27
 
28
- function x1(a, b = (__c4.mark(23, 15), 5)) {
29
- __c4.mark(23, 22);
28
+ function x1(a, b = (__c4['🧨'](23, 15), 5)) {
29
+ __c4['🧨'](23, 22);
30
30
  }
@@ -1 +1 @@
1
- const files = (__c4.mark(1, 14), new Map());
1
+ const files = (__c4['🧨'](1, 14), new Map());
@@ -1,8 +1,8 @@
1
- __c4.mark(1, 0), cli({
1
+ __c4['🧨'](1, 0), cli({
2
2
  stdout,
3
3
  stderr,
4
4
  exit,
5
- cwd: (__c4.mark(5, 9), process.cwd()),
6
- argv: (__c4.mark(6, 10), process.argv.slice(2))
5
+ cwd: (__c4['🧨'](5, 9), process.cwd()),
6
+ argv: (__c4['🧨'](6, 10), process.argv.slice(2))
7
7
  });
8
8
 
@@ -5,6 +5,7 @@ import {
5
5
  } from 'putout';
6
6
  import {addMarkToReturn} from './return.js';
7
7
  import {addMarkToArrowFunction} from './arrow.js';
8
+ import {addMarkToThrow} from './throw.js';
8
9
 
9
10
  const {
10
11
  NumericLiteral,
@@ -13,12 +14,11 @@ const {
13
14
  } = types;
14
15
 
15
16
  const {
16
- replaceWithMultiple,
17
17
  replaceWith,
18
18
  compareAny,
19
19
  } = operator;
20
20
 
21
- const LINE = '__c4.mark(__l, __c)';
21
+ const LINE = `__c4['🧨'](__l, __c)`;
22
22
  const buildLineNode = template(LINE, {
23
23
  placeholderPattern: /^__[a-z]$/,
24
24
  });
@@ -80,11 +80,11 @@ export const fix = (path, {options}) => {
80
80
  return;
81
81
  }
82
82
 
83
- if (path.isAssignmentPattern()) {
84
- replaceWithMultiple(path.get('right'), [
85
- lineNode,
83
+ if (path.isAssignmentPattern() || path.isAssignmentExpression()) {
84
+ replaceWith(path.get('right'), SequenceExpression([
85
+ lineNode.expression,
86
86
  node.right,
87
- ]);
87
+ ]));
88
88
  return;
89
89
  }
90
90
 
@@ -102,12 +102,8 @@ export const fix = (path, {options}) => {
102
102
  if (path.isArrowFunctionExpression())
103
103
  return addMarkToArrowFunction(path, lineNode);
104
104
 
105
- if (path.isThrowStatement()) {
106
- return replaceWith(path.get('argument'), SequenceExpression([
107
- lineNode.expression,
108
- node.argument,
109
- ]));
110
- }
105
+ if (path.isThrowStatement())
106
+ return addMarkToThrow(path, lineNode);
111
107
 
112
108
  replaceWith(path, BlockStatement([
113
109
  node,
@@ -132,7 +128,7 @@ export const include = () => [
132
128
  ];
133
129
 
134
130
  export const traverse = ({push}) => ({
135
- AssignmentPattern(path) {
131
+ 'AssignmentPattern|AssignmentExpression'(path) {
136
132
  if (compareAny(path.get('right'), EXCLUDE))
137
133
  return;
138
134
 
@@ -170,7 +166,7 @@ export const traverse = ({push}) => ({
170
166
  const consequentPath = path.get('consequent');
171
167
  const alternatePath = path.get('alternate');
172
168
 
173
- if (!consequentPath.isBlockStatement())
169
+ if (!consequentPath.isBlockStatement() && !compareAny(consequentPath, EXCLUDE))
174
170
  push(consequentPath);
175
171
 
176
172
  if (!alternatePath.node)
package/lib/report.js CHANGED
@@ -14,7 +14,7 @@ export const report = () => {
14
14
  uncoveredCount: 0,
15
15
  };
16
16
 
17
- console.log('# TAP version 13');
17
+ console.log('# CAP version 13');
18
18
  console.log('');
19
19
 
20
20
  for (const {name, lines} of coverageFile) {
@@ -45,9 +45,9 @@ export const report = () => {
45
45
  for (const {name, covered, uncoveredLines} of files) {
46
46
  if (!covered) {
47
47
  console.log(`# ${name}`);
48
- console.log(' should be covered');
48
+ console.log('🧨 should be covered');
49
49
  console.log('---');
50
- console.log(`lines: ${chalk.red(uncoveredLines.join(','))}`);
50
+ console.log(`lines: ${chalk.red(uncoveredLines.join(', '))}`);
51
51
  }
52
52
  }
53
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "Coverage for EcmaScript Modules",
6
6
  "main": "lib/escover.js",