@putout/plugin-tape 18.0.0 → 19.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.
@@ -1,7 +1,8 @@
1
1
  import {operator} from 'putout';
2
2
 
3
3
  const {addArgs} = operator;
4
- const {
4
+
5
+ export const {
5
6
  report,
6
7
  fix,
7
8
  traverse,
@@ -15,9 +16,3 @@ const {
15
16
  'test.skip("__a", async (__args) => __body)',
16
17
  ]],
17
18
  });
18
-
19
- export {
20
- report,
21
- fix,
22
- traverse,
23
- };
@@ -4,8 +4,12 @@ import {
4
4
  operator,
5
5
  } from 'putout';
6
6
 
7
- const {compare, traverse} = operator;
8
- const {expressionStatement} = types;
7
+ const {compare} = operator;
8
+ const {
9
+ expressionStatement,
10
+ isCallExpression,
11
+ isFunction,
12
+ } = types;
9
13
 
10
14
  export const report = () => `'t.end()' is missing at the end of the test`;
11
15
 
@@ -19,32 +23,29 @@ export const replace = () => ({
19
23
  'test(__a, async (t) => __body)': transform,
20
24
  });
21
25
 
22
- function check({__body}, path) {
26
+ function check({__body}) {
23
27
  const {body} = __body;
24
28
  const {length} = body;
25
29
 
26
30
  if (!length)
27
31
  return true;
28
32
 
29
- for (const element of body) {
30
- if (compare(element, 't.end()'))
31
- return false;
32
- }
33
+ const last = body.at(-1);
34
+
35
+ if (compare(last, 't.end()'))
36
+ return false;
33
37
 
34
- let found = false;
38
+ if (compare(last, 'await t.__(__args)'))
39
+ return false;
35
40
 
36
- traverse(path, {
37
- 'await t.__(__args)': () => {
38
- found = true;
39
- path.stop();
40
- },
41
- 't.end()': (path) => {
42
- found = true;
43
- path.stop();
44
- },
45
- });
41
+ const {expression} = last;
42
+
43
+ if (isCallExpression(expression)) {
44
+ const lastArg = expression.arguments.at(-1);
45
+ return !isFunction(lastArg);
46
+ }
46
47
 
47
- return !found;
48
+ return true;
48
49
  }
49
50
 
50
51
  function transform({__body}, path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "18.0.0",
3
+ "version": "19.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with tests",
@@ -41,7 +41,7 @@
41
41
  "nodemon": "^3.0.1"
42
42
  },
43
43
  "peerDependencies": {
44
- "putout": ">=39"
44
+ "putout": ">=40"
45
45
  },
46
46
  "license": "MIT",
47
47
  "engines": {