@putout/plugin-tape 21.16.0 → 21.17.1
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 +26 -0
- package/lib/convert-equal-length-to-match-string/index.js +22 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ npm i @putout/plugin-tape -D
|
|
|
35
35
|
- ✅ [convert-equal-to-not-ok](#convert-equal-to-not-ok);
|
|
36
36
|
- ✅ [convert-equal-to-ok](#convert-equal-to-ok);
|
|
37
37
|
- ✅ [convert-equals-to-equal](#convert-equals-to-equal);
|
|
38
|
+
- ✅ [convert-equal-length-to-match-string](#convert-equal-length-to-match-string);
|
|
38
39
|
- ✅ [convert-match-regexp-to-string](#convert-match-regexp-to-string);
|
|
39
40
|
- ✅ [convert-ok-to-called-with](#convert-ok-to-called-with);
|
|
40
41
|
- ✅ [convert-ok-to-match](#convert-ok-to-match);
|
|
@@ -78,6 +79,7 @@ npm i @putout/plugin-tape -D
|
|
|
78
79
|
"tape/convert-equal-to-called-once": "on",
|
|
79
80
|
"tape/convert-equal-to-deep-equal": "on",
|
|
80
81
|
"tape/convert-equals-to-equal": "on",
|
|
82
|
+
"tape/convert-equal-length-to-match-string": "on",
|
|
81
83
|
"tape/convert-deep-equal-to-equal": "on",
|
|
82
84
|
"tape/convert-emitter-to-promise": "on",
|
|
83
85
|
"tape/convert-ok-to-match": "on",
|
|
@@ -920,6 +922,30 @@ const expected = {
|
|
|
920
922
|
t.deepEqual(result, expected);
|
|
921
923
|
```
|
|
922
924
|
|
|
925
|
+
## convert-equal-length-to-match-string
|
|
926
|
+
|
|
927
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/df8cdc1545ac527b79ecc9bbca98f0d5/167216bb0f2228f1d4214f2d55ef5acef2d96447).
|
|
928
|
+
|
|
929
|
+
### ❌ Example of incorrect code
|
|
930
|
+
|
|
931
|
+
```js
|
|
932
|
+
test('hello: world', (t) => {
|
|
933
|
+
const count = (written.match(/## my-rule/) || []).length;
|
|
934
|
+
|
|
935
|
+
t.equal(count, 1);
|
|
936
|
+
t.end();
|
|
937
|
+
});
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
### ✅ Example of correct code
|
|
941
|
+
|
|
942
|
+
```js
|
|
943
|
+
test('hello: world', (t) => {
|
|
944
|
+
t.match(written, /## my-rule/);
|
|
945
|
+
t.end();
|
|
946
|
+
});
|
|
947
|
+
```
|
|
948
|
+
|
|
923
949
|
## License
|
|
924
950
|
|
|
925
951
|
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