escover 2.5.3 → 3.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 CHANGED
@@ -1,3 +1,14 @@
1
+ 2023.05.04, v3.1.0
2
+
3
+ feature:
4
+ - d7f612c escover: add support of OptionalChainig
5
+
6
+ 2023.05.03, v3.0.0
7
+
8
+ feature:
9
+ - 49fca58 escover: use @putout/printer
10
+ - 1dfbea6 escover: use @putout/printer
11
+
1
12
  2023.05.02, v2.5.3
2
13
 
3
14
  feature:
package/lib/cli/cli.js CHANGED
@@ -35,7 +35,7 @@ export const cli = ({argv, exit, readCoverage}) => {
35
35
  const cmd = argv.slice(2);
36
36
 
37
37
  if (cmd.length) {
38
- execute('"' + cmd.join(`" "`) + '"', exit);
38
+ execute(`"${cmd.join('" "')}"`, exit);
39
39
  }
40
40
 
41
41
  const coverage = readCoverage();
@@ -1,9 +1,8 @@
1
- import {
2
- parse,
3
- generate,
4
- transform,
5
- } from 'putout';
1
+ import {transform} from 'putout';
2
+ import {parse} from '@babel/parser';
3
+ import {print} from '@putout/printer';
6
4
  import * as mark from './plugin-mark/index.js';
5
+ import convertOptionalToLogical from '@putout/plugin-convert-optional-to-logical';
7
6
 
8
7
  export const instrument = (url, source) => {
9
8
  const c4 = global.__createC4(url);
@@ -17,14 +16,14 @@ export const instrument = (url, source) => {
17
16
  },
18
17
  plugins: [
19
18
  ['mark', mark],
19
+ ['convert-optional-to-logical', convertOptionalToLogical],
20
20
  ],
21
21
  };
22
22
 
23
23
  const ast = parse(source);
24
24
 
25
25
  transform(ast, source, options);
26
- const {code} = generate(ast);
27
26
 
28
- return code;
27
+ return print(ast);
29
28
  };
30
29
 
@@ -38,9 +38,13 @@ function getLineNode(c4, {line, column}) {
38
38
 
39
39
  export const report = () => 'Mark line';
40
40
 
41
+ const isLoc = (path) => path.node.loc;
42
+
43
+ const findLoc = (path) => path.find(isLoc).node.loc;
44
+
41
45
  export const fix = (path, {options}) => {
42
46
  const {node} = path;
43
- const {start} = path.node.loc || path.parentPath.node.loc;
47
+ const {start} = findLoc(path);
44
48
 
45
49
  const {
46
50
  c4 = {
package/lib/transform.js CHANGED
@@ -2,6 +2,7 @@ const sort = (a) => {
2
2
  const sorted = Array
3
3
  .from(a.entries())
4
4
  .sort();
5
+
5
6
  return new Map(sorted);
6
7
  };
7
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "2.5.3",
3
+ "version": "3.1.0",
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",
@@ -39,6 +39,10 @@
39
39
  "prewisdom": "madrun prewisdom"
40
40
  },
41
41
  "dependencies": {
42
+ "@babel/parser": "^7.21.8",
43
+ "@babel/plugin-proposal-optional-chaining": "^7.21.0",
44
+ "@putout/plugin-convert-optional-to-logical": "^1.0.0",
45
+ "@putout/printer": "^1.80.3",
42
46
  "chalk": "^5.0.0",
43
47
  "find-cache-dir": "^4.0.0",
44
48
  "find-up": "^6.2.0",