escover 3.0.0 → 3.1.1

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,13 @@
1
+ 2023.05.05, v3.1.1
2
+
3
+ fix:
4
+ - a75bc7a escover: buffer passed to loader
5
+
6
+ 2023.05.04, v3.1.0
7
+
8
+ feature:
9
+ - d7f612c escover: add support of OptionalChainig
10
+
1
11
  2023.05.03, v3.0.0
2
12
 
3
13
  feature:
package/lib/escover.js CHANGED
@@ -54,7 +54,7 @@ export async function load(url, context, defaultLoad) {
54
54
 
55
55
  const source = `
56
56
  const __c4 = global.__createC4('${url}');
57
- ${instrument(url, rawSource)}
57
+ ${instrument(url, String(rawSource))}
58
58
  `;
59
59
 
60
60
  return {
@@ -1,12 +1,12 @@
1
- import {transform} from 'putout';
2
- import {parse} from '@babel/parser';
3
- import {print} from '@putout/printer';
1
+ import putout from 'putout';
4
2
  import * as mark from './plugin-mark/index.js';
3
+ import convertOptionalToLogical from '@putout/plugin-convert-optional-to-logical';
5
4
 
6
5
  export const instrument = (url, source) => {
7
6
  const c4 = global.__createC4(url);
8
7
 
9
- const options = {
8
+ const {code} = putout(source, {
9
+ printer: 'putout',
10
10
  fixCount: 1,
11
11
  rules: {
12
12
  mark: ['on', {
@@ -15,13 +15,10 @@ export const instrument = (url, source) => {
15
15
  },
16
16
  plugins: [
17
17
  ['mark', mark],
18
+ ['convert-optional-to-logical', convertOptionalToLogical],
18
19
  ],
19
- };
20
+ });
20
21
 
21
- const ast = parse(source);
22
-
23
- transform(ast, source, options);
24
-
25
- return print(ast);
22
+ return code;
26
23
  };
27
24
 
@@ -28,7 +28,6 @@ const buildLineNode = template(LINE, {
28
28
  });
29
29
 
30
30
  function getLineNode(c4, {line, column}) {
31
- debugger;
32
31
  c4.init(line, column);
33
32
 
34
33
  return buildLineNode({
@@ -39,9 +38,13 @@ function getLineNode(c4, {line, column}) {
39
38
 
40
39
  export const report = () => 'Mark line';
41
40
 
41
+ const isLoc = (path) => path.node.loc;
42
+
43
+ const findLoc = (path) => path.find(isLoc).node.loc;
44
+
42
45
  export const fix = (path, {options}) => {
43
46
  const {node} = path;
44
- const {start} = path.node.loc;
47
+ const {start} = findLoc(path);
45
48
 
46
49
  const {
47
50
  c4 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
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",
@@ -40,6 +40,8 @@
40
40
  },
41
41
  "dependencies": {
42
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",
43
45
  "@putout/printer": "^1.80.3",
44
46
  "chalk": "^5.0.0",
45
47
  "find-cache-dir": "^4.0.0",