@putout/plugin-tape 21.4.0 → 21.6.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.
package/README.md CHANGED
@@ -19,6 +19,7 @@ npm i @putout/plugin-tape -D
19
19
 
20
20
  - ✅ [add-args](#add-args);
21
21
  - ✅ [add-t-end](#add-t-end);
22
+ - ✅ [apply-assertions-order](#apply-assertions-order);
22
23
  - ✅ [apply-destructuring](#apply-destructuring);
23
24
  - ✅ [apply-stub](#apply-stub);
24
25
  - ✅ [apply-with-name](#apply-with-name);
@@ -46,6 +47,7 @@ npm i @putout/plugin-tape -D
46
47
  - ✅ [remove-skip](#remove-skip);
47
48
  - ✅ [remove-useless-not-called-args](#remove-useless-not-called-args);
48
49
  - ✅ [remove-useless-t-end](#remove-useless-t-end);
50
+ - ✅ [remove-useless-undefined](#remove-useless-undefined);
49
51
  - ✅ [switch-expected-with-result](#switch-expected-with-result);
50
52
  - ✅ [sync-with-name](#sync-with-name);
51
53
 
@@ -56,6 +58,7 @@ npm i @putout/plugin-tape -D
56
58
  "rules": {
57
59
  "tape/jest": "on",
58
60
  "tape/apply-stub": "on",
61
+ "tape/apply-assertions-order": "on",
59
62
  "tape/apply-destructuring": "on",
60
63
  "tape/apply-with-name": "on",
61
64
  "tape/add-t-end": "on",
@@ -81,6 +84,7 @@ npm i @putout/plugin-tape -D
81
84
  "tape/extract-args-from-called-with": "on",
82
85
  "tape/remove-default-messages": "on",
83
86
  "tape/remove-useless-not-called-args": "on",
87
+ "tape/remove-useless-undefined": "on",
84
88
  "tape/remove-only": ["on", {
85
89
  "allowed": ["test"]
86
90
  }],
@@ -395,6 +399,27 @@ test('copymitter', async (t) => {
395
399
  });
396
400
  ```
397
401
 
402
+ ## apply-assertions-order
403
+
404
+ Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/0c0adae586448bd0921129275fb08891/c2f031920a3f1eb119c71b5ac3ba3c27ce1710ea).
405
+
406
+ ### ❌ Example of incorrect code
407
+
408
+ ```js
409
+ t.equal(result, expected);
410
+ cleanup();
411
+ t.end();
412
+ ```
413
+
414
+ ### ✅ Example of correct code
415
+
416
+ ```js
417
+ cleanup();
418
+
419
+ t.equal(result, expected);
420
+ t.end();
421
+ ````
422
+
398
423
  ## apply-destructuring
399
424
 
400
425
  Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/adf238850271c0a4ad917e71bab8757c/4ff416c3d9f3de0930339c7a4929eb4b62461d1a).
@@ -593,6 +618,22 @@ test('test: remove me', () => {
593
618
  });
594
619
  ```
595
620
 
621
+ ## remove-useless-undefined
622
+
623
+ ### ❌ Example of incorrect code
624
+
625
+ ```js
626
+ stub().returns(undefined);
627
+ stub().resolves(undefined);
628
+ ```
629
+
630
+ ### ✅ Example of correct code
631
+
632
+ ```js
633
+ stub();
634
+ stub().resolves();
635
+ ```
636
+
596
637
  ## convert-ok-to-match
597
638
 
598
639
  ### ❌ Example of incorrect code
@@ -0,0 +1,42 @@
1
+ import {operator, print} from 'putout';
2
+
3
+ const {
4
+ compare,
5
+ insertBefore,
6
+ remove,
7
+ } = operator;
8
+
9
+ const printNode = (a) => print(a, {
10
+ printer: ['putout', {
11
+ format: {
12
+ newline: '',
13
+ },
14
+ }],
15
+ });
16
+
17
+ export const report = ({prev, prevPrev}) => {
18
+ return `Use '${printNode(prev)}' before '${printNode(prevPrev)}'`;
19
+ };
20
+
21
+ export const fix = ({prev, prevPrev}) => {
22
+ const prevNode = prev.node;
23
+
24
+ remove(prev);
25
+ insertBefore(prevPrev, prevNode);
26
+ };
27
+
28
+ export const traverse = ({push}) => ({
29
+ 't.end()': (path) => {
30
+ const prev = path.parentPath.getPrevSibling();
31
+ const prevPrev = prev.getPrevSibling();
32
+
33
+ if (compare(prev, 't.__a(__args)'))
34
+ return;
35
+
36
+ push({
37
+ path,
38
+ prev,
39
+ prevPrev,
40
+ });
41
+ },
42
+ });
package/lib/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import * as applyAssertionsOrder from './apply-assertions-order/index.js';
2
+ import * as removeUselessUndefined from './remove-useless-undefined/index.js';
1
3
  import * as extractArgsFromCalledWith from './extract-args-from-called-with/index.js';
2
4
  import * as applyStub from './apply-stub/index.js';
3
5
  import * as applyDestructuring from './apply-destructuring/index.js';
@@ -64,4 +66,6 @@ export const rules = {
64
66
  'remove-only': removeOnly,
65
67
  'remove-skip': removeSkip,
66
68
  'extract-args-from-called-with': extractArgsFromCalledWith,
69
+ 'remove-useless-undefined': removeUselessUndefined,
70
+ 'apply-assertions-order': applyAssertionsOrder,
67
71
  };
@@ -0,0 +1,6 @@
1
+ export const report = () => `Avoid useless 'returns/resolves(undefined)'`;
2
+
3
+ export const replace = () => ({
4
+ 'stub().returns(undefined)': 'stub()',
5
+ 'stub().resolves(undefined)': 'stub().resolves()',
6
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "21.4.0",
3
+ "version": "21.6.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",