@putout/plugin-tape 7.4.0 → 8.0.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
@@ -31,6 +31,7 @@ npm i @putout/plugin-tape -D
31
31
  "tape/convert-called-with-to-called-with-no-args": "on",
32
32
  "tape/convert-called-with-no-args-to-called-with": "on",
33
33
  "tape/convert-equal-to-called-once": "on",
34
+ "tape/convert-equal-to-deep-equal": "on",
34
35
  "tape/convert-deep-equal-to-equal": "on",
35
36
  "tape/expand-try-catch-arguments": "on",
36
37
  "tape/convert-emitter-to-promise": "on",
@@ -644,6 +645,30 @@ t.equal(result, true);
644
645
  t.ok(result);
645
646
  ```
646
647
 
648
+ ## convert-equal-to-deep-equal
649
+
650
+ ### ❌ Incorrect code example
651
+
652
+ ```js
653
+ const expected = {
654
+ hello: 'world',
655
+ };
656
+
657
+ t.equal(error, expected);
658
+ t.end();
659
+ ```
660
+
661
+ ### ✅ Correct code example
662
+
663
+ ```js
664
+ const expected = {
665
+ hello: 'world',
666
+ };
667
+
668
+ t.deepEqual(error, expected);
669
+ t.end();
670
+ ```
671
+
647
672
  ## convert-match-regexp-to-string
648
673
 
649
674
  ### ❌ Incorrect code example
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const {types} = require('putout');
4
+
5
+ const {
6
+ isArrayExpression,
7
+ isIdentifier,
8
+ isObjectExpression,
9
+ } = types;
10
+
11
+ module.exports.report = () => `Use 't.deepEqual()' when comparing Objects an Arrays`;
12
+
13
+ module.exports.match = () => ({
14
+ 't.equal(__a, __b)': check,
15
+ 't.notEqual(__a, __b)': check,
16
+ });
17
+
18
+ module.exports.replace = () => ({
19
+ 't.equal(__a, __b)': 't.deepEqual(__a, __b)',
20
+ 't.notEqual(__a, __b)': 't.notDeepEqual(__a, __b)',
21
+ });
22
+
23
+ function check({__b}, path) {
24
+ if (isObjectExpression(__b))
25
+ return true;
26
+
27
+ if (isArrayExpression(__b))
28
+ return true;
29
+
30
+ if (!isIdentifier(__b))
31
+ return false;
32
+
33
+ const __bDeclaration = path.scope.bindings[__b.name];
34
+
35
+ if (!__bDeclaration)
36
+ return false;
37
+
38
+ const {id, init} = __bDeclaration.path.node;
39
+
40
+ if (!isIdentifier(id, {name: 'expected'}))
41
+ return false;
42
+
43
+ return isObjectExpression(init) || isArrayExpression(init);
44
+ }
45
+
@@ -19,5 +19,8 @@ module.exports.replace = () => ({
19
19
  't.deepEqual(__a, undefined, __b)': 't.notOk(__a, __b)',
20
20
  't.deepEqual(__a, false)': 't.notOk(__a)',
21
21
  't.deepEqual(__a, false, __b)': 't.notOk(__a, __b)',
22
+
23
+ 't.equal(__a)': 't.notOk(__a)',
24
+ 't.notEqual(__a)': 't.ok(__a)',
22
25
  });
23
26
 
package/lib/index.js CHANGED
@@ -19,6 +19,7 @@ module.exports.rules = {
19
19
  ...getRule('convert-ok-to-called-with'),
20
20
  ...getRule('convert-match-regexp-to-string'),
21
21
  ...getRule('convert-equal-to-not-ok'),
22
+ ...getRule('convert-equal-to-deep-equal'),
22
23
  ...getRule('convert-equal-to-ok'),
23
24
  ...getRule('convert-equal-to-called-once'),
24
25
  ...getRule('convert-deep-equal-to-equal'),
@@ -33,7 +34,7 @@ module.exports.rules = {
33
34
  ...getRule('add-stop-all'),
34
35
  ...getRule('remove-stop-all'),
35
36
  ...getRule('remove-useless-t-end'),
36
- 'remove-only': require('@putout/plugin-remove-only'),
37
- 'remove-skip': require('@putout/plugin-remove-skip'),
37
+ ...getRule('remove-only'),
38
+ ...getRule('remove-skip'),
38
39
  };
39
40
 
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => '"test.only" should not be used';
4
+
5
+ module.exports.replace = () => ({
6
+ '__a.only(__b, __c)': '__a(__b, __c)',
7
+ '__a.only(__b, __c, __d)': '__a(__b, __c, __d)',
8
+ '__a["only"](__b, __c)': '__a(__b, __c)',
9
+ });
10
+
11
+ module.exports.filter = (path) => {
12
+ const {parentPath} = path.parentPath;
13
+ return parentPath.isProgram();
14
+ };
15
+
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => '"test.skip" should not be used';
4
+
5
+ module.exports.replace = () => ({
6
+ '__a.skip(__b, __c)': '__a(__b, __c)',
7
+ '__a.skip(__b, __c, __d)': '__a(__b, __c, __d)',
8
+ '__a["skip"](__b, __c)': '__a(__b, __c)',
9
+ });
10
+
11
+ module.exports.filter = (path) => {
12
+ const {parentPath} = path.parentPath;
13
+ return parentPath.isProgram();
14
+ };
15
+
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "7.4.0",
3
+ "version": "8.0.0",
4
+ "type": "commonjs",
4
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
6
  "description": "putout plugin helps with tests",
6
- "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-tape",
7
+ "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-tape#readme",
7
8
  "main": "lib/index.js",
8
9
  "release": false,
9
10
  "tag": false,
@@ -22,10 +23,7 @@
22
23
  "coverage": "madrun coverage",
23
24
  "report": "madrun report"
24
25
  },
25
- "dependencies": {
26
- "@putout/plugin-remove-only": "^5.0.0",
27
- "@putout/plugin-remove-skip": "^4.0.0"
28
- },
26
+ "dependencies": {},
29
27
  "keywords": [
30
28
  "putout",
31
29
  "putout-plugin",
@@ -37,14 +35,14 @@
37
35
  "c8": "^7.5.0",
38
36
  "eslint": "^8.0.1",
39
37
  "eslint-plugin-node": "^11.0.0",
40
- "eslint-plugin-putout": "^12.0.0",
38
+ "eslint-plugin-putout": "^13.0.0",
41
39
  "lerna": "^4.0.0",
42
40
  "madrun": "^8.0.1",
43
41
  "montag": "^1.2.1",
44
42
  "nodemon": "^2.0.1"
45
43
  },
46
44
  "peerDependencies": {
47
- "putout": ">=22.5"
45
+ "putout": ">=24"
48
46
  },
49
47
  "license": "MIT",
50
48
  "engines": {