@putout/plugin-tape 9.7.0 β 9.8.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 +21 -0
- package/lib/apply-destructuring/index.js +15 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ npm i @putout/plugin-tape -D
|
|
|
21
21
|
{
|
|
22
22
|
"rules": {
|
|
23
23
|
"tape/apply-stub": "on",
|
|
24
|
+
"tape/apply-destructuring": "on",
|
|
24
25
|
"tape/apply-stub-operator": "on",
|
|
25
26
|
"tape/apply-with-name": "on",
|
|
26
27
|
"tape/add-t-end": "on",
|
|
@@ -341,6 +342,26 @@ test('copymitter', async (t) => {
|
|
|
341
342
|
});
|
|
342
343
|
```
|
|
343
344
|
|
|
345
|
+
## apply-destructuring
|
|
346
|
+
|
|
347
|
+
Check out in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/adf238850271c0a4ad917e71bab8757c/4ff416c3d9f3de0930339c7a4929eb4b62461d1a).
|
|
348
|
+
|
|
349
|
+
### β Example of incorrect code
|
|
350
|
+
|
|
351
|
+
```js
|
|
352
|
+
const test = require('supertape');
|
|
353
|
+
const {stub} = test;
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### β
Example of correct code
|
|
357
|
+
|
|
358
|
+
```js
|
|
359
|
+
const {
|
|
360
|
+
test,
|
|
361
|
+
stub,
|
|
362
|
+
} = require('supertape');
|
|
363
|
+
```
|
|
364
|
+
|
|
344
365
|
## apply-stub
|
|
345
366
|
|
|
346
367
|
Apply [stub](https://github.com/cloudcmd/stub) functions created. Look how it works in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/d098a8c8d03a072a7f3981e3cfb1d7af/f1542bfa39513ac625b2a9cd9243cc06dee286c0).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.report = () => `Use destructuring when using 'stub()' in 'test()'`;
|
|
4
|
+
|
|
5
|
+
module.exports.match = () => ({
|
|
6
|
+
'const test = require("supertape")': (vars, path) => path.scope.bindings.stub,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
module.exports.replace = () => ({
|
|
10
|
+
'const test = require("supertape")': (vars, path) => {
|
|
11
|
+
path.scope.bindings.stub.path.remove();
|
|
12
|
+
return 'const {test, stub} = require("supertape")';
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
package/lib/index.js
CHANGED
package/package.json
CHANGED