@putout/plugin-tape 9.10.0 → 9.13.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.
|
@@ -5,13 +5,21 @@ const {
|
|
|
5
5
|
operator,
|
|
6
6
|
} = require('putout');
|
|
7
7
|
|
|
8
|
+
const isNull = (a) => !a && typeof a === 'object';
|
|
9
|
+
|
|
10
|
+
const isUndefined = (a) => typeof a === 'undefined';
|
|
11
|
+
const isBool = (a) => typeof a === 'boolean';
|
|
12
|
+
|
|
13
|
+
const isNumber = (a) => typeof a === 'number';
|
|
8
14
|
const isString = (a) => typeof a === 'string';
|
|
15
|
+
const isPrimitive = (a) => isString(a) || isNumber(a) || isBool(a) || isNull(a) || isUndefined(a);
|
|
9
16
|
|
|
10
17
|
const {compute} = operator;
|
|
11
18
|
|
|
12
19
|
const {
|
|
13
20
|
isLiteral,
|
|
14
21
|
isRegExpLiteral,
|
|
22
|
+
isIdentifier,
|
|
15
23
|
} = types;
|
|
16
24
|
|
|
17
25
|
module.exports.report = (path) => {
|
|
@@ -30,13 +38,17 @@ const check = ({__b}, path) => {
|
|
|
30
38
|
if (isLiteral(__b))
|
|
31
39
|
return true;
|
|
32
40
|
|
|
41
|
+
if (isIdentifier(__b, {name: 'undefined'}))
|
|
42
|
+
return true;
|
|
43
|
+
|
|
33
44
|
const expectedPath = path.get('arguments.1');
|
|
34
|
-
const [, value] = compute(expectedPath);
|
|
35
45
|
|
|
36
|
-
if (
|
|
46
|
+
if (checkExpected(expectedPath))
|
|
37
47
|
return true;
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
const [is, value] = compute(expectedPath);
|
|
50
|
+
|
|
51
|
+
if (is && isPrimitive(value))
|
|
40
52
|
return true;
|
|
41
53
|
|
|
42
54
|
return false;
|
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
operator,
|
|
5
|
+
types,
|
|
6
|
+
} = require('putout');
|
|
7
|
+
|
|
8
|
+
const isBool = (a) => typeof a === 'boolean';
|
|
9
|
+
|
|
10
|
+
const {compute} = operator;
|
|
11
|
+
|
|
12
|
+
const {isBooleanLiteral} = types;
|
|
13
|
+
|
|
3
14
|
module.exports.report = (path) => {
|
|
4
15
|
const arg = path.get('arguments.0');
|
|
5
16
|
return `Use 't.ok(${arg})' instead of '${path}'`;
|
|
6
17
|
};
|
|
7
18
|
|
|
19
|
+
module.exports.match = () => ({
|
|
20
|
+
't.equal(__a, __b)': ({__b}, path) => {
|
|
21
|
+
if (isBooleanLiteral(__b, {value: true}))
|
|
22
|
+
return true;
|
|
23
|
+
|
|
24
|
+
const [is, value] = compute(path.get('arguments.1'));
|
|
25
|
+
|
|
26
|
+
if (!is)
|
|
27
|
+
return false;
|
|
28
|
+
|
|
29
|
+
return isBool(value) && value;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
8
33
|
module.exports.replace = () => ({
|
|
9
|
-
't.equal(__a,
|
|
34
|
+
't.equal(__a, __b)': 't.ok(__a)',
|
|
10
35
|
't.equal(__a, true, __b)': 't.ok(__a, __b)',
|
|
11
36
|
|
|
12
37
|
't.deepEqual(__a, true)': 't.ok(__a)',
|
package/package.json
CHANGED