@putout/plugin-tape 21.15.1 β 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/lib/remove-skip/index.js
CHANGED
|
@@ -6,12 +6,17 @@ const {isIdentifier} = types;
|
|
|
6
6
|
|
|
7
7
|
export const report = () => 'Remove "test.skip"';
|
|
8
8
|
|
|
9
|
+
export const match = ({options}) => ({
|
|
10
|
+
'__a.skip(__b, __c)': check(options),
|
|
11
|
+
'__a.skip(__b, __c, __d)': check(options),
|
|
12
|
+
});
|
|
13
|
+
|
|
9
14
|
export const replace = () => ({
|
|
10
15
|
'__a.skip(__b, __c)': '__a(__b, __c)',
|
|
11
16
|
'__a.skip(__b, __c, __d)': '__a(__b, __c, __d)',
|
|
12
17
|
});
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
const check = (options) => ({__a}) => {
|
|
15
20
|
const {allowed = []} = options;
|
|
16
21
|
const all = [
|
|
17
22
|
'test',
|
|
@@ -19,7 +24,7 @@ export const filter = (path, {options}) => {
|
|
|
19
24
|
];
|
|
20
25
|
|
|
21
26
|
for (const name of all) {
|
|
22
|
-
const is = isIdentifier(
|
|
27
|
+
const is = isIdentifier(__a, {
|
|
23
28
|
name,
|
|
24
29
|
});
|
|
25
30
|
|
package/package.json
CHANGED