@putout/plugin-tape 9.5.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 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",
@@ -55,11 +56,18 @@ npm i @putout/plugin-tape -D
55
56
 
56
57
  ## switch-expected-with-result
57
58
 
59
+ πŸ“Ό**Supertape** uses more natural way of
60
+ comparing: first you pass `result` and then `expected`.
61
+
62
+ It gives you ability to use value instead of `expected` and
63
+ understand code faster: no need to search for a second argument.
64
+ While `result` is always a variable, so it most likely much shorter.
65
+
58
66
  ### ❌ Example of incorrect code
59
67
 
60
68
  ```js
61
69
  test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
62
- t.eqaul(expected, result);
70
+ t.equal(expected, result);
63
71
  t.end();
64
72
  });
65
73
  ```
@@ -68,7 +76,7 @@ test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
68
76
 
69
77
  ```js
70
78
  test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
71
- t.eqaul(result, expected);
79
+ t.equal(result, expected);
72
80
  t.end();
73
81
  });
74
82
  ```
@@ -334,6 +342,26 @@ test('copymitter', async (t) => {
334
342
  });
335
343
  ```
336
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
+
337
365
  ## apply-stub
338
366
 
339
367
  Apply [stub](https://github.com/cloudcmd/stub) functions created. Look how it works in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/d098a8c8d03a072a7f3981e3cfb1d7af/f1542bfa39513ac625b2a9cd9243cc06dee286c0).
@@ -463,7 +491,7 @@ mockImport('fs/promises', {
463
491
  });
464
492
  ```
465
493
 
466
- ### `tape`
494
+ ### `test`
467
495
 
468
496
  #### ❌ Example of incorrect code
469
497
 
@@ -604,7 +632,7 @@ t.ok(result.includes('hello'));
604
632
  t.match(result, /hello/);
605
633
  ```
606
634
 
607
- ## convert-ok-to-match
635
+ ## convert-ok-to-called-with
608
636
 
609
637
  ### ❌ Example of incorrect code
610
638
 
@@ -686,7 +714,7 @@ t.match(result, 'hello');
686
714
 
687
715
  ## remove-default-messages
688
716
 
689
- `supertape` will put this information for you, and it is always the same.
717
+ πŸ“Ό**Supertape** will put this information for you, and it is always the same.
690
718
  No need to repeat the same information twice on one line, better to avoid it.
691
719
 
692
720
  ### ❌ Example of incorrect code
@@ -742,7 +770,14 @@ test('some test', (t) => {
742
770
  test.skip('some test', (t) => {
743
771
  t.end();
744
772
  });
773
+ ```
745
774
 
775
+ ### βœ… Example of correct code
776
+
777
+ ```js
778
+ test('some test', (t) => {
779
+ t.end();
780
+ });
746
781
  ```
747
782
 
748
783
  ## remove-stop-all
@@ -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
+
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- module.exports.report = () => 't.match should be used instead of t.ok with includes';
3
+ module.exports.report = () => `Use 't.match()' instead of 't.ok()'`;
4
4
 
5
5
  module.exports.exclude = () => [
6
6
  't.ok(keys(__a).includes(__b))',
@@ -9,5 +9,7 @@ module.exports.exclude = () => [
9
9
  module.exports.replace = () => ({
10
10
  't.ok(__a.includes(__b))': 't.match(__a, __b)',
11
11
  't.ok(__a.includes(__b), __c)': 't.match(__a, __b, __c)',
12
+ 't.ok(__a.test(__b))': 't.match(__b, __a)',
13
+ 't.ok(__a.test(__b), __c)': 't.match(__b, __a, __c)',
12
14
  });
13
15
 
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@ const getRule = (a) => ({
6
6
 
7
7
  module.exports.rules = {
8
8
  ...getRule('apply-stub'),
9
+ ...getRule('apply-destructuring'),
9
10
  ...getRule('apply-with-name'),
10
11
  ...getRule('add-await-to-re-import'),
11
12
  ...getRule('sync-with-name'),
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "9.5.0",
3
+ "version": "9.8.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
- "description": "putout plugin helps with tests",
6
+ "description": "🐊Putout plugin helps with tests",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-tape#readme",
8
8
  "main": "lib/index.js",
9
9
  "release": false,
@@ -35,7 +35,7 @@
35
35
  "c8": "^7.5.0",
36
36
  "eslint": "^8.0.1",
37
37
  "eslint-plugin-node": "^11.0.0",
38
- "eslint-plugin-putout": "^14.0.0",
38
+ "eslint-plugin-putout": "^15.0.0",
39
39
  "lerna": "^4.0.0",
40
40
  "madrun": "^9.0.0",
41
41
  "montag": "^1.2.1",