@putout/plugin-tape 16.1.0 → 18.0.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.
Files changed (38) hide show
  1. package/lib/add-args/index.js +12 -4
  2. package/lib/add-await-to-re-import/index.js +4 -5
  3. package/lib/add-node-prefix-to-mock-require/index.js +5 -7
  4. package/lib/add-stop-all/index.js +11 -18
  5. package/lib/add-t-end/index.js +13 -15
  6. package/lib/apply-destructuring/index.js +4 -5
  7. package/lib/apply-stub/index.js +4 -6
  8. package/lib/apply-with-name/index.js +4 -6
  9. package/lib/convert-called-with-args/index.js +5 -5
  10. package/lib/convert-called-with-no-args-to-called-with/index.js +2 -4
  11. package/lib/convert-called-with-to-called-with-no-args/index.js +2 -4
  12. package/lib/convert-deep-equal-to-equal/index.js +4 -6
  13. package/lib/convert-does-not-throw-to-try-catch/index.js +3 -4
  14. package/lib/convert-emitter-to-promise/index.js +11 -13
  15. package/lib/convert-equal-to-called-once/index.js +2 -4
  16. package/lib/convert-equal-to-deep-equal/index.js +4 -5
  17. package/lib/convert-equal-to-not-ok/index.js +4 -6
  18. package/lib/convert-equal-to-ok/index.js +4 -6
  19. package/lib/convert-equals-to-equal/index.js +2 -4
  20. package/lib/convert-match-regexp-to-string/index.js +4 -5
  21. package/lib/convert-mock-require-to-mock-import/index.js +3 -5
  22. package/lib/convert-ok-to-called-with/index.js +3 -4
  23. package/lib/convert-ok-to-match/index.js +3 -5
  24. package/lib/convert-tape-to-supertape/index.js +2 -4
  25. package/lib/convert-throws-to-try-catch/index.js +3 -4
  26. package/lib/declare/index.js +1 -3
  27. package/lib/index.js +38 -41
  28. package/lib/jest/index.js +2 -4
  29. package/lib/remove-default-messages/index.js +2 -4
  30. package/lib/remove-only/index.js +3 -5
  31. package/lib/remove-skip/index.js +4 -5
  32. package/lib/remove-stop-all/index.js +8 -11
  33. package/lib/remove-useless-not-called-args/index.js +2 -4
  34. package/lib/remove-useless-t-end/index.js +6 -7
  35. package/lib/switch-expected-with-result/index.js +2 -4
  36. package/lib/sync-with-name/index.js +3 -5
  37. package/lib/test-signatures.js +6 -8
  38. package/package.json +8 -10
@@ -1,9 +1,11 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {addArgs} = operator;
5
-
6
- module.exports = addArgs({
4
+ const {
5
+ report,
6
+ fix,
7
+ traverse,
8
+ } = addArgs({
7
9
  t: ['t', [
8
10
  'test("__a", (__args) => __body)',
9
11
  'test("__a", async (__args) => __body)',
@@ -13,3 +15,9 @@ module.exports = addArgs({
13
15
  'test.skip("__a", async (__args) => __body)',
14
16
  ]],
15
17
  });
18
+
19
+ export {
20
+ report,
21
+ fix,
22
+ traverse,
23
+ };
@@ -1,11 +1,10 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {isFunction} = types;
5
4
 
6
- module.exports.report = () => `Call 'reImport()' using await`;
5
+ export const report = () => `Call 'reImport()' using await`;
7
6
 
8
- module.exports.match = () => ({
7
+ export const match = () => ({
9
8
  'reImport(__a)': (vars, path) => {
10
9
  const {parentPath} = path;
11
10
 
@@ -13,7 +12,7 @@ module.exports.match = () => ({
13
12
  },
14
13
  });
15
14
 
16
- module.exports.replace = () => ({
15
+ export const replace = () => ({
17
16
  'reImport(__a)': (vars, path) => {
18
17
  const fnPath = path.findParent(isFunction);
19
18
 
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
- const {isBuiltin} = require('node:module');
4
- const {operator, types} = require('putout');
1
+ import {isBuiltin} from 'node:module';
2
+ import {operator, types} from 'putout';
5
3
 
6
4
  const {isStringLiteral} = types;
7
5
  const {
@@ -9,16 +7,16 @@ const {
9
7
  setLiteralValue,
10
8
  } = operator;
11
9
 
12
- module.exports.report = ({__a}) => `Add 'node:' prefix: '${__a.value}' -> 'node:${__a.value}'`;
10
+ export const report = ({__a}) => `Add 'node:' prefix: '${__a.value}' -> 'node:${__a.value}'`;
13
11
 
14
- module.exports.fix = ({__a}) => {
12
+ export const fix = ({__a}) => {
15
13
  setLiteralValue(__a, `node:${__a.value}`);
16
14
  };
17
15
 
18
16
  const MOCK_REQUIRE = 'mockRequire(__a, __b)';
19
17
  const MOCK_IMPORT = 'mockImport(__a, __b)';
20
18
 
21
- module.exports.traverse = ({push}) => ({
19
+ export const traverse = ({push}) => ({
22
20
  [MOCK_REQUIRE]: createTraverser(push, MOCK_REQUIRE),
23
21
  [MOCK_IMPORT]: createTraverser(push, MOCK_IMPORT),
24
22
  });
@@ -1,38 +1,31 @@
1
- 'use strict';
2
-
3
- const {
1
+ import {
4
2
  types,
5
3
  operator,
6
4
  template,
7
- } = require('putout');
8
-
9
- const {
5
+ } from 'putout';
6
+ import {
10
7
  TEST,
11
8
  TEST_ONLY,
12
9
  TEST_SKIP,
13
10
  TEST_ASYNC,
14
11
  TEST_ASYNC_ONLY,
15
12
  TEST_ASYNC_SKIP,
16
- } = require('../test-signatures');
13
+ } from '../test-signatures.js';
17
14
 
18
- const {
19
- traverse,
20
- compare,
21
- insertBefore,
22
- } = operator;
15
+ const {compare, insertBefore} = operator;
23
16
 
24
- const {ExpressionStatement} = types;
17
+ const {expressionStatement} = types;
25
18
 
26
- module.exports.report = () => `Call 'stopAll()' at the end of test when 'mockImport()' used`;
19
+ export const report = () => `Call 'stopAll()' at the end of test when 'mockImport()' used`;
27
20
 
28
- module.exports.fix = (path) => {
21
+ export const fix = (path) => {
29
22
  const assertionPath = getAssertionsPath(path);
30
23
  const stopAllNode = template.ast('stopAll()');
31
24
 
32
- insertBefore(assertionPath, ExpressionStatement(stopAllNode));
25
+ insertBefore(assertionPath, expressionStatement(stopAllNode));
33
26
  };
34
27
 
35
- module.exports.traverse = ({push}) => ({
28
+ export const traverse = ({push}) => ({
36
29
  [TEST]: createTraverse(push),
37
30
  [TEST_ONLY]: createTraverse(push),
38
31
  [TEST_SKIP]: createTraverse(push),
@@ -65,7 +58,7 @@ function check(path) {
65
58
  let hasMockImport = false;
66
59
  let hasAssertions = false;
67
60
 
68
- traverse(path, {
61
+ operator.traverse(path, {
69
62
  'mockImport(__a, __b)': () => {
70
63
  hasMockImport = true;
71
64
  },
@@ -1,27 +1,25 @@
1
- 'use strict';
2
-
3
- const {
1
+ import {
4
2
  types,
5
3
  template,
6
4
  operator,
7
- } = require('putout');
5
+ } from 'putout';
8
6
 
9
7
  const {compare, traverse} = operator;
10
- const {ExpressionStatement} = types;
8
+ const {expressionStatement} = types;
11
9
 
12
- module.exports.report = () => `'t.end()' is missing at the end of the test`;
10
+ export const report = () => `'t.end()' is missing at the end of the test`;
13
11
 
14
- module.exports.match = () => ({
15
- 'test(__a, (t) => __body)': match,
16
- 'test(__a, async (t) => __body)': match,
12
+ export const match = () => ({
13
+ 'test(__a, (t) => __body)': check,
14
+ 'test(__a, async (t) => __body)': check,
17
15
  });
18
16
 
19
- module.exports.replace = () => ({
20
- 'test(__a, (t) => __body)': replace,
21
- 'test(__a, async (t) => __body)': replace,
17
+ export const replace = () => ({
18
+ 'test(__a, (t) => __body)': transform,
19
+ 'test(__a, async (t) => __body)': transform,
22
20
  });
23
21
 
24
- function match({__body}, path) {
22
+ function check({__body}, path) {
25
23
  const {body} = __body;
26
24
  const {length} = body;
27
25
 
@@ -49,7 +47,7 @@ function match({__body}, path) {
49
47
  return !found;
50
48
  }
51
49
 
52
- function replace({__body}, path) {
53
- __body.body.push(ExpressionStatement(template.ast('t.end()')));
50
+ function transform({__body}, path) {
51
+ __body.body.push(expressionStatement(template.ast('t.end()')));
54
52
  return path;
55
53
  }
@@ -1,15 +1,14 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {remove} = operator;
5
4
 
6
- module.exports.report = () => `Use destructuring when using 'stub()' in 'test()'`;
5
+ export const report = () => `Use destructuring when using 'stub()' in 'test()'`;
7
6
 
8
- module.exports.match = () => ({
7
+ export const match = () => ({
9
8
  'const test = require("supertape")': (vars, path) => path.scope.bindings.stub,
10
9
  });
11
10
 
12
- module.exports.replace = () => ({
11
+ export const replace = () => ({
13
12
  'const test = require("supertape")': (vars, path) => {
14
13
  remove(path.scope.bindings.stub.path);
15
14
  return 'const {test, stub} = require("supertape")';
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const {template, types} = require('putout');
1
+ import {template, types} from 'putout';
4
2
 
5
3
  const {
6
4
  isUnaryExpression,
@@ -10,9 +8,9 @@ const {
10
8
 
11
9
  const REJECTS = template('stub().rejects(A)');
12
10
 
13
- module.exports.report = () => `Use 'stub()' instead of creating a function`;
11
+ export const report = () => `Use 'stub()' instead of creating a function`;
14
12
 
15
- module.exports.match = () => ({
13
+ export const match = () => ({
16
14
  'async () => __a': ({__a}, path) => {
17
15
  if (!path.parentPath.isVariableDeclarator())
18
16
  return false;
@@ -27,7 +25,7 @@ module.exports.match = () => ({
27
25
  },
28
26
  });
29
27
 
30
- module.exports.replace = () => ({
28
+ export const replace = () => ({
31
29
  'async () => __a': ({__a}) => {
32
30
  if (isUnaryExpression(__a, {operator: 'throw'}))
33
31
  return REJECTS({
@@ -1,18 +1,16 @@
1
- 'use strict';
2
-
3
- const {template, operator} = require('putout');
1
+ import {template, operator} from 'putout';
4
2
 
5
3
  const {replaceWith} = operator;
6
4
 
7
- module.exports.report = () => `'stub().withName()' should be used`;
5
+ export const report = () => `'stub().withName()' should be used`;
8
6
 
9
- module.exports.match = () => ({
7
+ export const match = () => ({
10
8
  't.calledBefore(__a, __b)': checkStubs,
11
9
  't.calledAfter(__a, __b)': checkStubs,
12
10
  't.calledInOrder(__array)': checkStubsArray,
13
11
  });
14
12
 
15
- module.exports.replace = () => ({
13
+ export const replace = () => ({
16
14
  't.calledBefore(__a, __b)': applyWithName,
17
15
  't.calledAfter(__a, __b)': applyWithName,
18
16
  't.calledInOrder(__array)': applyWithNameToArray,
@@ -1,14 +1,13 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {
5
4
  isIdentifier,
6
5
  isArrayExpression,
7
6
  } = types;
8
7
 
9
- module.exports.report = () => `Use an array as args to 'calledWith()'`;
8
+ export const report = () => `Use an array as args to 'calledWith()'`;
10
9
 
11
- module.exports.match = () => ({
10
+ export const match = () => ({
12
11
  't.calledWith(__a, __b)': ({__b}) => {
13
12
  if (isIdentifier(__b))
14
13
  return false;
@@ -17,6 +16,7 @@ module.exports.match = () => ({
17
16
  },
18
17
  });
19
18
 
20
- module.exports.replace = () => ({
19
+ export const replace = () => ({
21
20
  't.calledWith(__a, __b)': 't.calledWith(__a, [__b])',
21
+ 't.calledWith(__a, [...__b], __c)': 't.calledWith(__a, __b, __c)',
22
22
  });
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => '"calledWithArgs" should be used when arguments are present';
2
2
 
3
- module.exports.report = () => '"calledWithArgs" should be used when arguments are present';
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  't.calledWithNoArgs(__a, __array)': 't.calledWith(__a, __array)',
7
5
  't.calledWithNoArgs(__a, __array, __b)': 't.calledWith(__a, __array, __b)',
8
6
  't.calledWithNoArgs(__a, __identifier)': 't.calledWith(__a, __identifier)',
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => `Use 'calledWithNoArgs()' when arguments are absent`;
2
2
 
3
- module.exports.report = () => '"calledWithNoArgs" should be used when arguments are absent';
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  't.calledWith(__a)': 't.calledWithNoArgs(__a)',
7
5
  't.calledWith(__a, [])': 't.calledWithNoArgs(__a)',
8
6
  't.calledWith(__a, [], __b)': 't.calledWithNoArgs(__a, __b)',
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const {types, operator} = require('putout');
1
+ import {types, operator} from 'putout';
4
2
 
5
3
  const isNull = (a) => !a && typeof a === 'object';
6
4
  const isUndefined = (a) => typeof a === 'undefined';
@@ -16,7 +14,7 @@ const {
16
14
  isIdentifier,
17
15
  } = types;
18
16
 
19
- module.exports.report = (path) => {
17
+ export const report = (path) => {
20
18
  const args = path.get('arguments');
21
19
 
22
20
  if (args.length === 2)
@@ -45,12 +43,12 @@ const check = ({__b}, path) => {
45
43
  return is && isPrimitive(value);
46
44
  };
47
45
 
48
- module.exports.match = () => ({
46
+ export const match = () => ({
49
47
  't.deepEqual(__a, __b)': check,
50
48
  't.deepEqual(__a, __b, __c)': check,
51
49
  });
52
50
 
53
- module.exports.replace = () => ({
51
+ export const replace = () => ({
54
52
  't.deepEqual(__a, __b)': 't.equal(__a, __b)',
55
53
  't.deepEqual(__a, __b, __c)': 't.equal(__a, __b, __c)',
56
54
  });
@@ -1,11 +1,10 @@
1
- 'use strict';
1
+ import {template, operator} from 'putout';
2
2
 
3
- const {template, operator} = require('putout');
4
3
  const {insertBefore} = operator;
5
4
 
6
- module.exports.report = () => 'try-catch should be used instead of t.doesNotThrow';
5
+ export const report = () => 'try-catch should be used instead of t.doesNotThrow';
7
6
 
8
- module.exports.replace = () => ({
7
+ export const replace = () => ({
9
8
  't.doesNotThrow(__a, __b)': ({__a}, path) => {
10
9
  const tryCatchNode = template.ast.fresh(`
11
10
  const [error] = tryCatch(__a)
@@ -1,11 +1,9 @@
1
- 'use strict';
2
-
3
- const {
1
+ import {
4
2
  generate,
5
3
  operator,
6
4
  template,
7
5
  types,
8
- } = require('putout');
6
+ } from 'putout';
9
7
 
10
8
  const {
11
9
  compare,
@@ -22,19 +20,19 @@ const onceEnd = template(`await once(%%emitter%%, 'end')`);
22
20
  const onceError = template(`const [%%error%%] = await once(%%emitter%%, 'error')`);
23
21
  const onceAnyNoResult = template(`await once(%%emitter%%, %%event%%)`);
24
22
 
25
- module.exports.report = () => '"await once" should be used';
23
+ export const report = () => '"await once" should be used';
26
24
 
27
- module.exports.match = () => ({
28
- 'test(__a, (__args) => __body)': match,
29
- 'test(__a, async (__args) => __body)': match,
25
+ export const match = () => ({
26
+ 'test(__a, (__args) => __body)': doMatch,
27
+ 'test(__a, async (__args) => __body)': doMatch,
30
28
  });
31
29
 
32
- module.exports.replace = () => ({
33
- 'test(__a, (__args) => __body)': replace,
34
- 'test(__a, async (__args) => __body)': replace,
30
+ export const replace = () => ({
31
+ 'test(__a, (__args) => __body)': doReplace,
32
+ 'test(__a, async (__args) => __body)': doReplace,
35
33
  });
36
34
 
37
- function match({__body}) {
35
+ function doMatch({__body}) {
38
36
  for (const codeLine of __body.body) {
39
37
  const {
40
38
  expression = codeLine,
@@ -53,7 +51,7 @@ function match({__body}) {
53
51
  return false;
54
52
  }
55
53
 
56
- function replace({__a}, path) {
54
+ function doReplace({__a}, path) {
57
55
  declareOnce(path);
58
56
 
59
57
  const arg = path.get('arguments.1').node;
@@ -1,11 +1,9 @@
1
- 'use strict';
2
-
3
- module.exports.report = (path) => {
1
+ export const report = (path) => {
4
2
  const arg = path.get('arguments.0');
5
3
  return `Use 't.calledOnce(${arg.get('object')})' instead of '${path}'`;
6
4
  };
7
5
 
8
- module.exports.replace = () => ({
6
+ export const replace = () => ({
9
7
  't.equal(__a.callCount, 1)': 't.calledOnce(__a)',
10
8
  't.equal(__a.callCount, 1, __b)': 't.calledOnce(__a, __b)',
11
9
  });
@@ -1,6 +1,5 @@
1
- 'use strict';
1
+ import {types, operator} from 'putout';
2
2
 
3
- const {types, operator} = require('putout');
4
3
  const {compare} = operator;
5
4
  const {
6
5
  isArrayExpression,
@@ -8,14 +7,14 @@ const {
8
7
  isObjectExpression,
9
8
  } = types;
10
9
 
11
- module.exports.report = () => `Use 't.deepEqual()' when comparing Objects an Arrays`;
10
+ export const report = () => `Use 't.deepEqual()' when comparing Objects an Arrays`;
12
11
 
13
- module.exports.match = () => ({
12
+ export const match = () => ({
14
13
  't.equal(__a, __b)': check,
15
14
  't.notEqual(__a, __b)': check,
16
15
  });
17
16
 
18
- module.exports.replace = () => ({
17
+ export const replace = () => ({
19
18
  't.equal(__a, __b)': 't.deepEqual(__a, __b)',
20
19
  't.notEqual(__a, __b)': 't.notDeepEqual(__a, __b)',
21
20
  });
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const {operator, types} = require('putout');
1
+ import {operator, types} from 'putout';
4
2
 
5
3
  const isNumber = (a) => typeof a === 'number';
6
4
  const isString = (a) => typeof a === 'string';
@@ -13,12 +11,12 @@ const {
13
11
  isNumericLiteral,
14
12
  } = types;
15
13
 
16
- module.exports.report = (path) => {
14
+ export const report = (path) => {
17
15
  const arg = path.get('arguments.0');
18
16
  return `Use 't.notOk(${arg})' instead of '${path}'`;
19
17
  };
20
18
 
21
- module.exports.match = () => ({
19
+ export const match = () => ({
22
20
  't.equal(__a, __b)': ({__b}, path) => {
23
21
  if (isBooleanLiteral(__b, {value: false}))
24
22
  return true;
@@ -47,7 +45,7 @@ module.exports.match = () => ({
47
45
  },
48
46
  });
49
47
 
50
- module.exports.replace = () => ({
48
+ export const replace = () => ({
51
49
  't.equal(__a, __b)': 't.notOk(__a)',
52
50
  't.equal(__a, null, __b)': 't.notOk(__a, __b)',
53
51
  't.equal(__a, false, __b)': 't.notOk(__a, __b)',
@@ -1,17 +1,15 @@
1
- 'use strict';
2
-
3
- const {operator, types} = require('putout');
1
+ import {operator, types} from 'putout';
4
2
 
5
3
  const isBool = (a) => typeof a === 'boolean';
6
4
  const {compute} = operator;
7
5
  const {isBooleanLiteral} = types;
8
6
 
9
- module.exports.report = (path) => {
7
+ export const report = (path) => {
10
8
  const arg = path.get('arguments.0');
11
9
  return `Use 't.ok(${arg})' instead of '${path}'`;
12
10
  };
13
11
 
14
- module.exports.match = () => ({
12
+ export const match = () => ({
15
13
  't.equal(__a, __b)': ({__b}, path) => {
16
14
  if (isBooleanLiteral(__b, {value: true}))
17
15
  return true;
@@ -25,7 +23,7 @@ module.exports.match = () => ({
25
23
  },
26
24
  });
27
25
 
28
- module.exports.replace = () => ({
26
+ export const replace = () => ({
29
27
  't.equal(__a, __b)': 't.ok(__a)',
30
28
  't.equal(__a, true, __b)': 't.ok(__a, __b)',
31
29
  't.deepEqual(__a, true)': 't.ok(__a)',
@@ -1,7 +1,5 @@
1
- 'use strict';
1
+ export const report = () => `Use 't.equal()' instead of 't.equals()''`;
2
2
 
3
- module.exports.report = () => `Use 't.equal()' instead of 't.equals()''`;
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  't.equals(__a, __b, __c)': 't.equal(__a, __b, __c)',
7
5
  });
@@ -1,13 +1,12 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {isSimpleRegExp} = operator;
5
4
  const checkRegExp = ({__b}) => isSimpleRegExp(RegExp(__b.pattern));
6
5
  const checkStr = ({__b}) => isSimpleRegExp(RegExp(__b.value));
7
6
 
8
- module.exports.report = () => 't.match should be used with string pattern';
7
+ export const report = () => 't.match should be used with string pattern';
9
8
 
10
- module.exports.match = () => ({
9
+ export const match = () => ({
11
10
  't.match(__a, RegExp(__b))': checkStr,
12
11
  't.match(__a, RegExp(__b), __c)': checkStr,
13
12
  't.match(__a, /__b/)': checkRegExp,
@@ -18,7 +17,7 @@ module.exports.match = () => ({
18
17
  't.notMatch(__a, /__b/, __c)': checkRegExp,
19
18
  });
20
19
 
21
- module.exports.replace = () => ({
20
+ export const replace = () => ({
22
21
  't.match(__a, RegExp(__b))': 't.match(__a, __b)',
23
22
  't.match(__a, RegExp(__b), __c)': 't.match(__a, __b, __c)',
24
23
  't.match(__a, /__b/)': ({__b}) => `t.match(__a, '${__b.pattern}')`,
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const {operator, template} = require('putout');
1
+ import {operator, template} from 'putout';
4
2
 
5
3
  const {
6
4
  remove,
@@ -10,9 +8,9 @@ const {
10
8
 
11
9
  const initStopAll = template.ast(`const {stopAll} = createMockImport(import.meta.url)`);
12
10
 
13
- module.exports.report = () => '"mockImport" should be used instead of "mockRequire"';
11
+ export const report = () => '"mockImport" should be used instead of "mockRequire"';
14
12
 
15
- module.exports.replace = () => ({
13
+ export const replace = () => ({
16
14
  'mockRequire(__a, __b)': 'mockImport(__a, __b)',
17
15
  'reRequire(__a)': (vars, path) => {
18
16
  const {scope} = path;
@@ -1,16 +1,15 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {compare} = operator;
5
4
 
6
- module.exports.report = (path) => {
5
+ export const report = (path) => {
7
6
  if (compare(path, 't.ok(__args)'))
8
7
  return `Use 't.calledWith()' instead of 't.ok()'`;
9
8
 
10
9
  return `Use 't.notCalledWith()' instead of 't.notOk()'`;
11
10
  };
12
11
 
13
- module.exports.replace = () => ({
12
+ export const replace = () => ({
14
13
  't.ok(__a.calledWith(__args))': 't.calledWith(__a, [__args])',
15
14
  't.ok(__a.calledWith(__args), __b)': 't.calledWith(__a, [__args], __b)',
16
15
 
@@ -1,12 +1,10 @@
1
- 'use strict';
1
+ export const report = () => `Use 't.match()' instead of 't.ok()'`;
2
2
 
3
- module.exports.report = () => `Use 't.match()' instead of 't.ok()'`;
4
-
5
- module.exports.exclude = () => [
3
+ export const exclude = () => [
6
4
  't.ok(keys(__a).includes(__b))',
7
5
  ];
8
6
 
9
- module.exports.replace = () => ({
7
+ export const replace = () => ({
10
8
  't.ok(__a.includes(__b))': 't.match(__a, __b)',
11
9
  't.ok(__a.includes(__b), __c)': 't.match(__a, __b, __c)',
12
10
  't.ok(__a.test(__b))': 't.match(__b, __a)',
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => '"supertape" should be used';
2
2
 
3
- module.exports.report = () => '"supertape" should be used';
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  'const tryTo = __': '',
7
5
  'const tryToTape = __': '',
8
6
  'tryTo(__a)': '__a',
@@ -1,11 +1,10 @@
1
- 'use strict';
1
+ import {template, operator} from 'putout';
2
2
 
3
- const {template, operator} = require('putout');
4
3
  const {insertBefore} = operator;
5
4
 
6
- module.exports.report = () => 'try-catch should be used instead of t.throws';
5
+ export const report = () => 'try-catch should be used instead of t.throws';
7
6
 
8
- module.exports.replace = () => ({
7
+ export const replace = () => ({
9
8
  't.throws(__a, __b)': ({__a}, path) => {
10
9
  putTryCatch(__a, path);
11
10
  return `t.ok(error, __b)`;
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.declare = () => ({
1
+ export const declare = () => ({
4
2
  test: 'import {test} from "supertape"',
5
3
  stub: 'import {stub} from "supertape"',
6
4
  Test: 'import {Test} from "supertape"',
package/lib/index.js CHANGED
@@ -1,49 +1,46 @@
1
- 'use strict';
1
+ import * as applyStub from './apply-stub/index.js';
2
+ import * as applyDestructuring from './apply-destructuring/index.js';
3
+ import * as applyWithName from './apply-with-name/index.js';
4
+ import * as addAwaitToReImport from './add-await-to-re-import/index.js';
5
+ import * as jest from './jest/index.js';
6
+ import * as syncWithName from './sync-with-name/index.js';
7
+ import * as convertTapeToSupertape from './convert-tape-to-supertape/index.js';
8
+ import * as convertThrowsToTryCatch from './convert-throws-to-try-catch/index.js';
9
+ import * as convertDoesNotThrowToTryCatch from './convert-does-not-throw-to-try-catch/index.js';
10
+ import * as convertCalledWithToCalledWithNoArgs from './convert-called-with-to-called-with-no-args/index.js';
11
+ import * as convertCalledWithArgs from './convert-called-with-args/index.js';
12
+ import * as convertCalledWithNoArgsToCalledWith from './convert-called-with-no-args-to-called-with/index.js';
13
+ import * as convertEmitterToPromise from './convert-emitter-to-promise/index.js';
14
+ import * as convertOkToMatch from './convert-ok-to-match/index.js';
15
+ import * as convertOkToCalledWith from './convert-ok-to-called-with/index.js';
16
+ import * as convertMatchRegexpToString from './convert-match-regexp-to-string/index.js';
17
+ import * as convertEqualToNotOk from './convert-equal-to-not-ok/index.js';
18
+ import * as convertEqualToDeepEqual from './convert-equal-to-deep-equal/index.js';
19
+ import * as convertEqualToOk from './convert-equal-to-ok/index.js';
20
+ import * as convertEqualToCalledOnce from './convert-equal-to-called-once/index.js';
21
+ import * as convertDeepEqualToEqual from './convert-deep-equal-to-equal/index.js';
22
+ import * as convertMockRequireToMockImport from './convert-mock-require-to-mock-import/index.js';
23
+ import * as addArgs from './add-args/index.js';
24
+ import * as declare from './declare/index.js';
25
+ import * as removeDefaultMessages from './remove-default-messages/index.js';
26
+ import * as removeUselessNotCalledArgs from './remove-useless-not-called-args/index.js';
27
+ import * as switchExpectedWithResult from './switch-expected-with-result/index.js';
28
+ import * as addTEnd from './add-t-end/index.js';
29
+ import * as addStopAll from './add-stop-all/index.js';
30
+ import * as removeStopAll from './remove-stop-all/index.js';
31
+ import * as removeUselessTEnd from './remove-useless-t-end/index.js';
32
+ import * as removeOnly from './remove-only/index.js';
33
+ import * as removeSkip from './remove-skip/index.js';
34
+ import * as convertEqualsToEqual from './convert-equals-to-equal/index.js';
35
+ import * as addNodePrefixToMockRequire from './add-node-prefix-to-mock-require/index.js';
2
36
 
3
- const applyStub = require('./apply-stub');
4
- const applyDestructuring = require('./apply-destructuring');
5
- const applyWithName = require('./apply-with-name');
6
- const addAwaitToReImport = require('./add-await-to-re-import');
7
- const jest = require('./jest');
8
- const syncWithName = require('./sync-with-name');
9
- const convertTapeToSupertape = require('./convert-tape-to-supertape');
10
- const convertThrowsToTryCatch = require('./convert-throws-to-try-catch');
11
- const convertDoesNotThrowToTryCatch = require('./convert-does-not-throw-to-try-catch');
12
- const convertCalledWithToCalledWithNoArgs = require('./convert-called-with-to-called-with-no-args');
13
- const convertCalledWithArgs = require('./convert-called-with-args');
14
- const convertCalledWithNoArgsToCalledWith = require('./convert-called-with-no-args-to-called-with');
15
- const convertEmitterToPromise = require('./convert-emitter-to-promise');
16
- const convertOkToMatch = require('./convert-ok-to-match');
17
- const convertOkToCalledWith = require('./convert-ok-to-called-with');
18
- const convertMatchRegexpToString = require('./convert-match-regexp-to-string');
19
- const convertEqualToNotOk = require('./convert-equal-to-not-ok');
20
- const convertEqualToDeepEqual = require('./convert-equal-to-deep-equal');
21
- const convertEqualToOk = require('./convert-equal-to-ok');
22
- const convertEqualToCalledOnce = require('./convert-equal-to-called-once');
23
- const convertDeepEqualToEqual = require('./convert-deep-equal-to-equal');
24
- const convertMockRequireToMockImport = require('./convert-mock-require-to-mock-import');
25
- const addArgs = require('./add-args');
26
- const declare = require('./declare');
27
- const removeDefaultMessages = require('./remove-default-messages');
28
- const removeUselessNotCalledArgs = require('./remove-useless-not-called-args');
29
- const switchExpectedWithResult = require('./switch-expected-with-result');
30
- const addTEnd = require('./add-t-end');
31
- const addStopAll = require('./add-stop-all');
32
- const removeStopAll = require('./remove-stop-all');
33
- const removeUselessTEnd = require('./remove-useless-t-end');
34
- const removeOnly = require('./remove-only');
35
- const removeSkip = require('./remove-skip');
36
- const convertEqualsToEqual = require('./convert-equals-to-equal');
37
- const addNodePrefixToMockRequire = require('./add-node-prefix-to-mock-require');
38
-
39
- module.exports.rules = {
37
+ export const rules = {
40
38
  'convert-mock-require-to-mock-import': ['off', convertMockRequireToMockImport],
41
-
42
39
  'apply-stub': applyStub,
43
40
  'apply-destructuring': applyDestructuring,
44
41
  'apply-with-name': applyWithName,
45
42
  'add-await-to-re-import': addAwaitToReImport,
46
- jest,
43
+ 'jest': jest,
47
44
  'sync-with-name': syncWithName,
48
45
  'convert-tape-to-supertape': convertTapeToSupertape,
49
46
  'convert-throws-to-try-catch': convertThrowsToTryCatch,
@@ -62,7 +59,7 @@ module.exports.rules = {
62
59
  'convert-equals-to-equal': convertEqualsToEqual,
63
60
  'convert-deep-equal-to-equal': convertDeepEqualToEqual,
64
61
  'add-args': addArgs,
65
- declare,
62
+ 'declare': declare,
66
63
  'remove-default-messages': removeDefaultMessages,
67
64
  'remove-useless-not-called-args': removeUselessNotCalledArgs,
68
65
  'switch-expected-with-result': switchExpectedWithResult,
package/lib/jest/index.js CHANGED
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => `Use 📼 Supertape instead of 🃏Jest`;
2
2
 
3
- module.exports.report = () => `Use 📼 Supertape instead of 🃏Jest`;
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  'it': 'test',
7
5
  'expect(__a).toEqual(__b)': 't.equal(__a, __b)',
8
6
  });
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => 'Avoid passing default messages to operators';
2
2
 
3
- module.exports.report = () => 'Avoid passing default messages to operators';
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  't.ok(__a, "should be truthy")': 't.ok(__a)',
7
5
  't.notOk(__a, "should be falsy")': 't.notOk(__a)',
8
6
  't.match(__a, __b, "should match")': 't.match(__a, __b)',
@@ -1,13 +1,11 @@
1
- 'use strict';
1
+ export const report = () => `Remove 'test.only'`;
2
2
 
3
- module.exports.report = () => `Remove 'test.only'`;
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  '__a.only(__b, __c)': '__a(__b, __c)',
7
5
  '__a.only(__b, __c, __d)': '__a(__b, __c, __d)',
8
6
  });
9
7
 
10
- module.exports.filter = (path) => {
8
+ export const filter = (path) => {
11
9
  const objectPath = path.get('callee.object');
12
10
 
13
11
  if (!objectPath.isIdentifier())
@@ -1,16 +1,15 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {isIdentifier} = types;
5
4
 
6
- module.exports.report = () => 'Remove "test.skip"';
5
+ export const report = () => 'Remove "test.skip"';
7
6
 
8
- module.exports.replace = () => ({
7
+ export const replace = () => ({
9
8
  '__a.skip(__b, __c)': '__a(__b, __c)',
10
9
  '__a.skip(__b, __c, __d)': '__a(__b, __c, __d)',
11
10
  });
12
11
 
13
- module.exports.filter = (path) => {
12
+ export const filter = (path) => {
14
13
  return isIdentifier(path.node.callee.object, {
15
14
  name: 'test',
16
15
  });
@@ -1,25 +1,22 @@
1
- 'use strict';
2
-
3
- const {operator} = require('putout');
4
-
5
- const {
1
+ import {operator} from 'putout';
2
+ import {
6
3
  TEST,
7
4
  TEST_ONLY,
8
5
  TEST_SKIP,
9
6
  TEST_ASYNC,
10
7
  TEST_ASYNC_ONLY,
11
8
  TEST_ASYNC_SKIP,
12
- } = require('../test-signatures');
9
+ } from '../test-signatures.js';
13
10
 
14
- const {traverse, remove} = operator;
11
+ const {remove} = operator;
15
12
 
16
- module.exports.report = () => `Remove 'stopAll()' when you not calling 'reImport()'`;
13
+ export const report = () => `Remove 'stopAll()' when you not calling 'reImport()'`;
17
14
 
18
- module.exports.fix = (path) => {
15
+ export const fix = (path) => {
19
16
  remove(path);
20
17
  };
21
18
 
22
- module.exports.traverse = ({push}) => ({
19
+ export const traverse = ({push}) => ({
23
20
  [TEST]: createTraverse(push),
24
21
  [TEST_ONLY]: createTraverse(push),
25
22
  [TEST_SKIP]: createTraverse(push),
@@ -52,7 +49,7 @@ function check(path) {
52
49
  let hasMockImport = false;
53
50
  let stopAllPath = null;
54
51
 
55
- traverse(path, {
52
+ operator.traverse(path, {
56
53
  'reImport(__a)': () => {
57
54
  hasReImport = true;
58
55
  },
@@ -1,7 +1,5 @@
1
- 'use strict';
1
+ export const report = () => 'Remove useless "notCalled" args';
2
2
 
3
- module.exports.report = () => 'Remove useless "notCalled" args';
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  't.notCalled(__a, __array)': 't.notCalled(__a)',
7
5
  });
@@ -1,21 +1,20 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
- const {traverse, remove} = operator;
3
+ const {remove} = operator;
5
4
 
6
- module.exports.report = () => `Avoid useless 't.end()'`;
5
+ export const report = () => `Avoid useless 't.end()'`;
7
6
 
8
- module.exports.fix = (path) => {
7
+ export const fix = (path) => {
9
8
  remove(path);
10
9
  };
11
10
 
12
11
  const TEST = 'test("__a", (t) => __body)';
13
12
 
14
- module.exports.traverse = ({push}) => ({
13
+ export const traverse = ({push}) => ({
15
14
  [TEST]: (path) => {
16
15
  const paths = [];
17
16
 
18
- traverse(path, {
17
+ operator.traverse(path, {
19
18
  't.end()': (path) => {
20
19
  paths.push(path);
21
20
  },
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => '"result" should be before "expected"';
2
2
 
3
- module.exports.report = () => '"result" should be before "expected"';
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  't.equal(expected, __a)': 't.equal(__a, expected)',
7
5
  't.equal(expected, __a, __b)': 't.equal(__a, expected, __b)',
8
6
  't.deepEqual(expected, __a)': 't.deepEqual(__a, expected)',
@@ -1,12 +1,10 @@
1
- 'use strict';
1
+ export const report = () => `'stub().withName(name)' should synced with variable name`;
2
2
 
3
- module.exports.report = () => `'stub().withName(name)' should synced with variable name`;
4
-
5
- module.exports.match = () => ({
3
+ export const match = () => ({
6
4
  'const __a = stub().withName(__b)': ({__a, __b}) => __b.value !== __a.name,
7
5
  });
8
6
 
9
- module.exports.replace = () => ({
7
+ export const replace = () => ({
10
8
  'const __a = stub().withName(__b)': ({__a, __b}, path) => {
11
9
  __b.value = __a.name;
12
10
  return path;
@@ -1,8 +1,6 @@
1
- 'use strict';
2
-
3
- module.exports.TEST = 'test("__a", (t) => __body)';
4
- module.exports.TEST_ASYNC = 'test("__a", async (t) => __body)';
5
- module.exports.TEST_ONLY = 'test.only("__a", (t) => __body)';
6
- module.exports.TEST_ASYNC_ONLY = 'test.only("__a", async (t) => __body)';
7
- module.exports.TEST_SKIP = 'test.skip("__a", (t) => __body)';
8
- module.exports.TEST_ASYNC_SKIP = 'test.skip("__a", async (t) => __body)';
1
+ export const TEST = 'test("__a", (t) => __body)';
2
+ export const TEST_ASYNC = 'test("__a", async (t) => __body)';
3
+ export const TEST_ONLY = 'test.only("__a", (t) => __body)';
4
+ export const TEST_ASYNC_ONLY = 'test.only("__a", async (t) => __body)';
5
+ export const TEST_SKIP = 'test.skip("__a", (t) => __body)';
6
+ export const TEST_ASYNC_SKIP = 'test.skip("__a", async (t) => __body)';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "16.1.0",
4
- "type": "commonjs",
3
+ "version": "18.0.0",
4
+ "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with tests",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-tape#readme",
@@ -27,27 +27,25 @@
27
27
  "keywords": [
28
28
  "putout",
29
29
  "putout-plugin",
30
- "plugin",
31
- "putout"
30
+ "plugin"
32
31
  ],
33
32
  "devDependencies": {
34
33
  "@putout/plugin-putout": "*",
35
- "@putout/test": "^11.0.0",
34
+ "@putout/test": "^13.0.0",
36
35
  "c8": "^10.0.0",
37
36
  "eslint": "^9.0.0",
38
37
  "eslint-plugin-n": "^17.0.0",
39
- "eslint-plugin-putout": "^23.0.0",
40
- "lerna": "^6.0.1",
41
- "madrun": "^10.0.0",
38
+ "eslint-plugin-putout": "^26.0.0",
39
+ "madrun": "^11.0.0",
42
40
  "montag": "^1.2.1",
43
41
  "nodemon": "^3.0.1"
44
42
  },
45
43
  "peerDependencies": {
46
- "putout": ">=37"
44
+ "putout": ">=39"
47
45
  },
48
46
  "license": "MIT",
49
47
  "engines": {
50
- "node": ">=18.6"
48
+ "node": ">=20"
51
49
  },
52
50
  "publishConfig": {
53
51
  "access": "public"