escover 2.5.1 → 2.5.3

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,15 @@
1
+ 2023.05.02, v2.5.3
2
+
3
+ feature:
4
+ - c3b81da package: find-cache-dir v4.0.0
5
+ - 0f5fa40 package: @putout/test v6.4.0
6
+ - 0625eff package: eslint-plugin-putout v17.5.1
7
+
8
+ 2023.03.06, v2.5.2
9
+
10
+ feature:
11
+ - package: putout v29.0.0
12
+
1
13
  2022.10.20, v2.5.1
2
14
 
3
15
  feature:
package/bin/escover.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  import {cli} from '../lib/cli/cli.js';
4
3
  import {readCoverage} from '../lib/coverage-file/coverage-file.js';
5
4
  import {readConfig} from '../lib/config.js';
@@ -10,4 +9,3 @@ cli({
10
9
  readCoverage,
11
10
  readConfig,
12
11
  });
13
-
package/lib/c4.js CHANGED
@@ -33,4 +33,3 @@ const init = (lines) => (line, column) => {
33
33
  };
34
34
 
35
35
  export const getFileEntries = () => __fileEntries;
36
-
package/lib/cli/cli.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import {execSync} from 'child_process';
2
2
  import tryCatch from 'try-catch';
3
3
  import yargsParser from 'yargs-parser';
4
-
5
4
  import {version} from './version.js';
6
5
  import reportLines from '../formatters/lines.js';
7
6
  import reportFiles from '../formatters/files.js';
8
7
 
9
- const {ESCOVER_FORMAT, NODE_OPTIONS = ''} = process.env;
8
+ const {
9
+ ESCOVER_FORMAT,
10
+ NODE_OPTIONS = '',
11
+ } = process.env;
10
12
 
11
13
  export const cli = ({argv, exit, readCoverage}) => {
12
14
  const args = yargsParser(argv.slice(2), {
@@ -1,4 +1,5 @@
1
1
  import {readFileSync} from 'fs';
2
+
2
3
  const {parse} = JSON;
3
4
 
4
5
  const packageJson = new URL('../../package.json', import.meta.url);
package/lib/config.js CHANGED
@@ -42,3 +42,4 @@ export const readConfig = () => {
42
42
  ...parse(data),
43
43
  };
44
44
  };
45
+
@@ -5,6 +5,7 @@ export const generateLcov = (files) => {
5
5
 
6
6
  for (const {name, lines} of files) {
7
7
  result.push(`SF:${name}`);
8
+
8
9
  for (const [line, covered] of entries(lines)) {
9
10
  const count = covered ? 1 : 0;
10
11
  result.push(`DA:${line},${count}`);
@@ -34,6 +35,7 @@ export const parseLcov = (lcov) => {
34
35
 
35
36
  if (cmd === 'DA') {
36
37
  const [line, covered] = arg.split(',');
38
+
37
39
  lines[line] = Boolean(Number(covered));
38
40
  continue;
39
41
  }
package/lib/escover.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import process from 'process';
2
-
3
2
  import {instrument} from './instrument/index.js';
4
3
  import {exit} from './exit.js';
5
4
  import {createFileEntry} from './c4.js';
@@ -25,7 +24,10 @@ const EXCLUDE = [
25
24
  ];
26
25
 
27
26
  export async function load(url, context, defaultLoad) {
28
- const {format, source: rawSource} = await defaultLoad(url, context, defaultLoad);
27
+ const {
28
+ format,
29
+ source: rawSource,
30
+ } = await defaultLoad(url, context, defaultLoad);
29
31
 
30
32
  if (/commonjs|builtin/.test(format))
31
33
  return {
@@ -60,3 +62,4 @@ export async function load(url, context, defaultLoad) {
60
62
  source,
61
63
  };
62
64
  }
65
+
package/lib/exclude.js CHANGED
@@ -6,3 +6,4 @@ export const exclude = (url, names) => {
6
6
 
7
7
  return false;
8
8
  };
9
+
package/lib/exit.js CHANGED
@@ -4,3 +4,4 @@ import {writeCoverage} from './coverage-file/coverage-file.js';
4
4
  export const exit = once(() => {
5
5
  writeCoverage();
6
6
  });
7
+
@@ -2,10 +2,10 @@ import {
2
2
  table,
3
3
  getBorderCharacters,
4
4
  } from 'table';
5
-
6
5
  import chalk from 'chalk';
7
6
 
8
7
  const CWD = process.cwd();
8
+
9
9
  const {
10
10
  entries,
11
11
  keys,
@@ -22,11 +22,19 @@ export default (coverageFile) => {
22
22
  const uncoveredLines = formatLines(lines);
23
23
 
24
24
  if (covered) {
25
- tableData.push([chalk.green(filename), chalk.green(percentLines), '']);
25
+ tableData.push([
26
+ chalk.green(filename),
27
+ chalk.green(percentLines),
28
+ '',
29
+ ]);
26
30
  continue;
27
31
  }
28
32
 
29
- tableData.push([chalk.red(filename), chalk.red(percentLines), chalk.red(uncoveredLines)]);
33
+ tableData.push([
34
+ chalk.red(filename),
35
+ chalk.red(percentLines),
36
+ chalk.red(uncoveredLines),
37
+ ]);
30
38
  }
31
39
 
32
40
  return table(tableData, {
@@ -52,7 +60,9 @@ export default (coverageFile) => {
52
60
  };
53
61
 
54
62
  export function formatLines(array) {
55
- const lines = array.slice(0, 10).join(', ');
63
+ const lines = array
64
+ .slice(0, 10)
65
+ .join(', ');
56
66
 
57
67
  if (array.length <= 10)
58
68
  return lines;
@@ -79,7 +89,7 @@ function parseCoverageFile(coverageFile) {
79
89
  const files = [];
80
90
 
81
91
  for (const {name, lines} of coverageFile) {
82
- const filename = name.replace(CWD + '/', '');
92
+ const filename = name.replace(`${CWD}/`, '');
83
93
  const uncoveredLines = parseUncoveredLines(lines);
84
94
 
85
95
  const linesCount = keys(lines).length;
@@ -103,3 +113,4 @@ export function getLinesPercent(linesCount, uncoveredLinesCount) {
103
113
 
104
114
  return 100 - Math.round(100 / linesCount * uncoveredLinesCount);
105
115
  }
116
+
@@ -7,6 +7,7 @@ export default (coverageFile) => {
7
7
  const output = [];
8
8
  const out = createOut(output);
9
9
  const files = [];
10
+
10
11
  const coverage = {
11
12
  files,
12
13
  coveredCount: 0,
@@ -47,6 +48,7 @@ export default (coverageFile) => {
47
48
  out('🧨 should be covered');
48
49
  out('---');
49
50
  out(`lines:`);
51
+
50
52
  for (const line of uncoveredLines) {
51
53
  out(`️- ${chalk.red(line)} at file://${name}:${line}`);
52
54
  }
@@ -7,6 +7,7 @@ import * as mark from './plugin-mark/index.js';
7
7
 
8
8
  export const instrument = (url, source) => {
9
9
  const c4 = global.__createC4(url);
10
+
10
11
  const options = {
11
12
  fixCount: 1,
12
13
  rules: {
@@ -1,4 +1,5 @@
1
1
  import {types} from 'putout';
2
+
2
3
  const {SequenceExpression} = types;
3
4
 
4
5
  export const addMarkToArgument = (path, lineNode) => {
@@ -15,3 +16,4 @@ export const addMarkToArgument = (path, lineNode) => {
15
16
  node.argument,
16
17
  ]);
17
18
  };
19
+
@@ -3,10 +3,11 @@ import {
3
3
  types,
4
4
  operator,
5
5
  } from 'putout';
6
-
7
6
  import {addMarkToArgument} from './argument.js';
8
7
  import {addMarkToArrowFunction} from './arrow.js';
9
8
 
9
+ const noop = () => {};
10
+
10
11
  const {
11
12
  NumericLiteral,
12
13
  SequenceExpression,
@@ -21,6 +22,7 @@ const {
21
22
  } = operator;
22
23
 
23
24
  const LINE = `__c4['🧨'](__l, __c)`;
25
+
24
26
  const buildLineNode = template(LINE, {
25
27
  placeholderPattern: /^__[a-z]$/,
26
28
  });
@@ -42,7 +44,7 @@ export const fix = (path, {options}) => {
42
44
 
43
45
  const {
44
46
  c4 = {
45
- init: () => {},
47
+ init: noop,
46
48
  },
47
49
  } = options;
48
50
 
@@ -102,9 +104,7 @@ export const fix = (path, {options}) => {
102
104
  return;
103
105
  }
104
106
 
105
- replaceWith(path, BlockStatement([
106
- node,
107
- ]));
107
+ replaceWith(path, BlockStatement([node]));
108
108
  };
109
109
 
110
110
  const EXCLUDE = [
@@ -115,11 +115,13 @@ const EXCLUDE = [
115
115
  ];
116
116
 
117
117
  const SEQUENCE = `(${LINE}, __z)`;
118
+
118
119
  const isExclude = (node) => {
119
120
  const templates = [
120
121
  ...EXCLUDE,
121
122
  SEQUENCE,
122
123
  ];
124
+
123
125
  return compareAny(node, templates, {
124
126
  findUp: false,
125
127
  });
package/lib/transform.js CHANGED
@@ -1,4 +1,9 @@
1
- const sort = (a) => new Map(Array.from(a.entries()).sort());
1
+ const sort = (a) => {
2
+ const sorted = Array
3
+ .from(a.entries())
4
+ .sort();
5
+ return new Map(sorted);
6
+ };
2
7
 
3
8
  const isBool = (a) => typeof a === 'boolean';
4
9
 
@@ -34,4 +39,3 @@ function mergeLines(places) {
34
39
 
35
40
  return result;
36
41
  }
37
-
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "escover",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
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",
7
7
  "type": "module",
8
- "commitType": "colon",
9
8
  "bin": {
10
9
  "escover": "bin/escover.js"
11
10
  },
@@ -41,13 +40,13 @@
41
40
  },
42
41
  "dependencies": {
43
42
  "chalk": "^5.0.0",
44
- "find-cache-dir": "^3.3.2",
43
+ "find-cache-dir": "^4.0.0",
45
44
  "find-up": "^6.2.0",
46
45
  "mock-import": "^3.0.1",
47
46
  "montag": "^1.2.1",
48
47
  "once": "^1.4.0",
49
48
  "picomatch": "^2.3.1",
50
- "putout": "^28.0.0",
49
+ "putout": "^29.0.0",
51
50
  "strip-ansi": "^7.0.1",
52
51
  "table": "^6.8.0",
53
52
  "try-catch": "^3.0.0",
@@ -59,12 +58,12 @@
59
58
  },
60
59
  "license": "MIT",
61
60
  "devDependencies": {
62
- "@putout/test": "^5.0.0",
61
+ "@putout/test": "^6.4.0",
63
62
  "c8": "^7.8.0",
64
63
  "escover": "^2.0.1",
65
64
  "eslint": "^8.3.0",
66
65
  "eslint-plugin-n": "^15.2.4",
67
- "eslint-plugin-putout": "^16.0.0",
66
+ "eslint-plugin-putout": "^17.5.1",
68
67
  "madrun": "^9.0.0",
69
68
  "supertape": "^8.0.1"
70
69
  }