@putout/plugin-tape 21.5.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 +23 -0
- package/lib/apply-assertions-order/index.js +42 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
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);
|
|
@@ -57,6 +58,7 @@ npm i @putout/plugin-tape -D
|
|
|
57
58
|
"rules": {
|
|
58
59
|
"tape/jest": "on",
|
|
59
60
|
"tape/apply-stub": "on",
|
|
61
|
+
"tape/apply-assertions-order": "on",
|
|
60
62
|
"tape/apply-destructuring": "on",
|
|
61
63
|
"tape/apply-with-name": "on",
|
|
62
64
|
"tape/add-t-end": "on",
|
|
@@ -397,6 +399,27 @@ test('copymitter', async (t) => {
|
|
|
397
399
|
});
|
|
398
400
|
```
|
|
399
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
|
+
|
|
400
423
|
## apply-destructuring
|
|
401
424
|
|
|
402
425
|
Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/adf238850271c0a4ad917e71bab8757c/4ff416c3d9f3de0930339c7a4929eb4b62461d1a).
|
|
@@ -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,4 @@
|
|
|
1
|
+
import * as applyAssertionsOrder from './apply-assertions-order/index.js';
|
|
1
2
|
import * as removeUselessUndefined from './remove-useless-undefined/index.js';
|
|
2
3
|
import * as extractArgsFromCalledWith from './extract-args-from-called-with/index.js';
|
|
3
4
|
import * as applyStub from './apply-stub/index.js';
|
|
@@ -66,4 +67,5 @@ export const rules = {
|
|
|
66
67
|
'remove-skip': removeSkip,
|
|
67
68
|
'extract-args-from-called-with': extractArgsFromCalledWith,
|
|
68
69
|
'remove-useless-undefined': removeUselessUndefined,
|
|
70
|
+
'apply-assertions-order': applyAssertionsOrder,
|
|
69
71
|
};
|