@putout/plugin-tape 21.16.0 β†’ 21.17.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
@@ -920,6 +920,30 @@ const expected = {
920
920
  t.deepEqual(result, expected);
921
921
  ```
922
922
 
923
+ ## convert-equal-length-to-match-string
924
+
925
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/df8cdc1545ac527b79ecc9bbca98f0d5/167216bb0f2228f1d4214f2d55ef5acef2d96447).
926
+
927
+ ### ❌ Example of incorrect code
928
+
929
+ ```js
930
+ test('hello: world', (t) => {
931
+ const count = (written.match(/## my-rule/) || []).length;
932
+
933
+ t.equal(count, 1);
934
+ t.end();
935
+ });
936
+ ```
937
+
938
+ ### βœ… Example of correct code
939
+
940
+ ```js
941
+ test('hello: world', (t) => {
942
+ t.match(written, /## my-rule/);
943
+ t.end();
944
+ });
945
+ ```
946
+
923
947
  ## License
924
948
 
925
949
  MIT
@@ -0,0 +1,22 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {remove, compare} = operator;
4
+
5
+ export const report = () => `Use 't.match()' instead of 't.equal()'`;
6
+
7
+ export const match = () => ({
8
+ 'const __a = (__b.match(__c) ?? []).length': (vars, path) => {
9
+ const next = path.getNextSibling();
10
+ return compare(next, 't.equal(__a, __b)');
11
+ },
12
+ });
13
+
14
+ export const replace = () => ({
15
+ 'const __a = (__b.match(__c) ?? []).length': (vars, path) => {
16
+ const next = path.getNextSibling();
17
+
18
+ remove(next);
19
+
20
+ return `t.match(__b, __c)`;
21
+ },
22
+ });
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as convertEqualLengthToMatchString from './convert-equal-length-to-match-string/index.js';
1
2
  import * as removeTFromAsync from './remove-t-from-async/index.js';
2
3
  import * as applyStringify from './apply-stringify/index.js';
3
4
  import * as applyAssertionsOrder from './apply-assertions-order/index.js';
@@ -74,4 +75,5 @@ export const rules = {
74
75
  'apply-assertions-order': applyAssertionsOrder,
75
76
  'apply-stringify': applyStringify,
76
77
  'remove-t-from-async': removeTFromAsync,
78
+ 'convert-equal-length-to-match-string': convertEqualLengthToMatchString,
77
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "21.16.0",
3
+ "version": "21.17.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with tests",