@putout/plugin-tape 21.9.1 → 21.10.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 +33 -0
- package/lib/index.js +2 -0
- package/lib/remove-t-from-async/index.js +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ npm i @putout/plugin-tape -D
|
|
|
49
49
|
- ✅ [remove-useless-not-called-args](#remove-useless-not-called-args);
|
|
50
50
|
- ✅ [remove-useless-t-end](#remove-useless-t-end);
|
|
51
51
|
- ✅ [remove-useless-undefined](#remove-useless-undefined);
|
|
52
|
+
- ✅ [remove-t-from-async](#remove-t-from-async);
|
|
52
53
|
- ✅ [switch-expected-with-result](#switch-expected-with-result);
|
|
53
54
|
- ✅ [sync-with-name](#sync-with-name);
|
|
54
55
|
- ✅ [move-out-result-from-assertion](#move-out-result-from-assertion);
|
|
@@ -88,6 +89,7 @@ npm i @putout/plugin-tape -D
|
|
|
88
89
|
"tape/remove-default-messages": "on",
|
|
89
90
|
"tape/remove-useless-not-called-args": "on",
|
|
90
91
|
"tape/remove-useless-undefined": "on",
|
|
92
|
+
"tape/remove-t-from-async": "on",
|
|
91
93
|
"tape/remove-only": ["on", {
|
|
92
94
|
"allowed": ["test"]
|
|
93
95
|
}],
|
|
@@ -640,6 +642,37 @@ test('test: remove me', () => {
|
|
|
640
642
|
});
|
|
641
643
|
```
|
|
642
644
|
|
|
645
|
+
## remove-t-from-async
|
|
646
|
+
|
|
647
|
+
### ❌ Example of incorrect code
|
|
648
|
+
|
|
649
|
+
```js
|
|
650
|
+
test('sqlite: all returns empty array', async (t) => {
|
|
651
|
+
const db = await createDb();
|
|
652
|
+
await db.exec('CREATE TABLE t (id INTEGER PRIMARY KEY, x TEXT)');
|
|
653
|
+
const rows = await db.all('SELECT x FROM t WHERE x = :x', {
|
|
654
|
+
x: 'missing',
|
|
655
|
+
});
|
|
656
|
+
await t.dbAll(rows, []);
|
|
657
|
+
|
|
658
|
+
t.end();
|
|
659
|
+
});
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### ✅ Example of correct code
|
|
663
|
+
|
|
664
|
+
```js
|
|
665
|
+
test('sqlite: all returns empty array', async ({dbAll}) => {
|
|
666
|
+
const db = await createDb();
|
|
667
|
+
await db.exec('CREATE TABLE t (id INTEGER PRIMARY KEY, x TEXT)');
|
|
668
|
+
const rows = await db.all('SELECT x FROM t WHERE x = :x', {
|
|
669
|
+
x: 'missing',
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
await dbAll(rows, []);
|
|
673
|
+
});
|
|
674
|
+
```
|
|
675
|
+
|
|
643
676
|
## remove-useless-undefined
|
|
644
677
|
|
|
645
678
|
### ❌ Example of incorrect code
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as removeTFromAsync from './remove-t-from-async/index.js';
|
|
1
2
|
import * as applyStringify from './apply-stringify/index.js';
|
|
2
3
|
import * as movOutResultFromAssertion from './move-out-result-from-assertion/index.js';
|
|
3
4
|
import * as applyAssertionsOrder from './apply-assertions-order/index.js';
|
|
@@ -72,4 +73,5 @@ export const rules = {
|
|
|
72
73
|
'apply-assertions-order': applyAssertionsOrder,
|
|
73
74
|
'move-out-result-from-assertion': movOutResultFromAssertion,
|
|
74
75
|
'apply-stringify': applyStringify,
|
|
76
|
+
'remove-t-from-async': removeTFromAsync,
|
|
75
77
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {types, operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {remove} = operator;
|
|
4
|
+
const {objectProperty, objectPattern} = types;
|
|
5
|
+
|
|
6
|
+
export const report = () => `Use 'if condition' instead of 'ternary expression'`;
|
|
7
|
+
|
|
8
|
+
export const replace = () => ({
|
|
9
|
+
'await t.__a(__args)': ({__a}, path) => {
|
|
10
|
+
const next = path.parentPath.getNextSibling();
|
|
11
|
+
|
|
12
|
+
path.scope.block.params = [
|
|
13
|
+
objectPattern([
|
|
14
|
+
objectProperty(__a, __a),
|
|
15
|
+
]),
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
remove(next);
|
|
19
|
+
|
|
20
|
+
return 'await __a(__args)';
|
|
21
|
+
},
|
|
22
|
+
});
|