escover 3.1.0 → 3.1.2

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.2
2
+
3
+ feature:
4
+ - 520372c escover: improve support of OptionalChaining
5
+
6
+ 2023.05.05, v3.1.1
7
+
8
+ fix:
9
+ - a75bc7a escover: buffer passed to loader
10
+
1
11
  2023.05.04, v3.1.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,13 +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';
5
3
  import convertOptionalToLogical from '@putout/plugin-convert-optional-to-logical';
6
4
 
7
5
  export const instrument = (url, source) => {
8
6
  const c4 = global.__createC4(url);
9
7
 
10
- const options = {
8
+ const {code} = putout(source, {
9
+ printer: 'putout',
11
10
  fixCount: 1,
12
11
  rules: {
13
12
  mark: ['on', {
@@ -18,12 +17,8 @@ export const instrument = (url, source) => {
18
17
  ['mark', mark],
19
18
  ['convert-optional-to-logical', convertOptionalToLogical],
20
19
  ],
21
- };
20
+ });
22
21
 
23
- const ast = parse(source);
24
-
25
- transform(ast, source, options);
26
-
27
- return print(ast);
22
+ return code;
28
23
  };
29
24
 
@@ -40,7 +40,23 @@ export const report = () => 'Mark line';
40
40
 
41
41
  const isLoc = (path) => path.node.loc;
42
42
 
43
- const findLoc = (path) => path.find(isLoc).node.loc;
43
+ const findLoc = (path) => {
44
+ const current = path.find(isLoc);
45
+ const {loc} = current.node;
46
+
47
+ if (current.__escover_loc_column) {
48
+ return {
49
+ start: {
50
+ ...loc.start,
51
+ column: ++current.__escover_loc_column,
52
+ },
53
+ };
54
+ }
55
+
56
+ current.__escover_loc_column = 1;
57
+
58
+ return loc;
59
+ };
44
60
 
45
61
  export const fix = (path, {options}) => {
46
62
  const {node} = path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
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",