@putout/test 7.6.0 → 7.7.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 +0 -1
- package/lib/is-correct-plugin.js +7 -1
- package/lib/pre-test.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/is-correct-plugin.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const isFn = (a) => typeof a === 'function';
|
|
4
4
|
|
|
5
|
-
module.exports = (
|
|
5
|
+
module.exports.getIsCorrectPluginMessage = () => `should export 'replace', 'find', 'traverse', 'include', 'exclude', 'declare' or 'scan' function`;
|
|
6
|
+
|
|
7
|
+
module.exports.isCorrectPlugin = (plugin) => {
|
|
6
8
|
const {
|
|
7
9
|
find,
|
|
8
10
|
fix,
|
|
@@ -11,6 +13,7 @@ module.exports = (plugin) => {
|
|
|
11
13
|
exclude,
|
|
12
14
|
replace,
|
|
13
15
|
declare,
|
|
16
|
+
scan,
|
|
14
17
|
} = plugin;
|
|
15
18
|
|
|
16
19
|
const isFix = isFn(fix);
|
|
@@ -25,6 +28,9 @@ module.exports = (plugin) => {
|
|
|
25
28
|
if (!isFix)
|
|
26
29
|
return false;
|
|
27
30
|
|
|
31
|
+
if (isFn(scan))
|
|
32
|
+
return true;
|
|
33
|
+
|
|
28
34
|
const isFind = isFn(find);
|
|
29
35
|
const isTraverse = isFn(traverse);
|
|
30
36
|
|
package/lib/pre-test.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const {
|
|
4
|
+
isCorrectPlugin,
|
|
5
|
+
getIsCorrectPluginMessage,
|
|
6
|
+
} = require('./is-correct-plugin');
|
|
7
|
+
|
|
4
8
|
const {entries} = Object;
|
|
5
9
|
const {isArray} = Array;
|
|
6
10
|
|
|
@@ -23,6 +27,7 @@ module.exports.preTest = function preTest(test, plugin) {
|
|
|
23
27
|
filter,
|
|
24
28
|
match,
|
|
25
29
|
declare,
|
|
30
|
+
scan,
|
|
26
31
|
}] = maybeEntries(plugin);
|
|
27
32
|
|
|
28
33
|
const options = {
|
|
@@ -54,7 +59,7 @@ module.exports.preTest = function preTest(test, plugin) {
|
|
|
54
59
|
t.end();
|
|
55
60
|
}, options);
|
|
56
61
|
|
|
57
|
-
test(`${name}: plugins should be of type:
|
|
62
|
+
test(`${name}: plugins should be of type: Replacer, Includer, Traverser, Scanner, Declarator or Finder`, (t) => {
|
|
58
63
|
const result = isCorrectPlugin({
|
|
59
64
|
find,
|
|
60
65
|
fix,
|
|
@@ -69,9 +74,10 @@ module.exports.preTest = function preTest(test, plugin) {
|
|
|
69
74
|
replace,
|
|
70
75
|
|
|
71
76
|
declare,
|
|
77
|
+
scan,
|
|
72
78
|
});
|
|
73
79
|
|
|
74
|
-
t.ok(result,
|
|
80
|
+
t.ok(result, getIsCorrectPluginMessage());
|
|
75
81
|
t.end();
|
|
76
82
|
}, options);
|
|
77
83
|
};
|