@putout/engine-runner 12.5.0 → 12.6.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/lib/replace/index.js +9 -2
- package/package.json +1 -1
package/lib/replace/index.js
CHANGED
|
@@ -119,7 +119,7 @@ const getFix = (items) => (path) => {
|
|
|
119
119
|
const getFilter = (match = stubMatch, options) => (path) => {
|
|
120
120
|
const all = entries(match({options}));
|
|
121
121
|
|
|
122
|
-
for (const [from,
|
|
122
|
+
for (const [from, matchProperty] of all) {
|
|
123
123
|
const nodeFrom = template.ast(from);
|
|
124
124
|
|
|
125
125
|
if (!compare(path.node, nodeFrom)) {
|
|
@@ -134,7 +134,9 @@ const getFilter = (match = stubMatch, options) => (path) => {
|
|
|
134
134
|
node,
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
validateMatchProperty(matchProperty);
|
|
138
|
+
|
|
139
|
+
return matchProperty(values, path);
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
return true;
|
|
@@ -155,6 +157,11 @@ function parseTo(to, values, path) {
|
|
|
155
157
|
return template.ast.fresh(toStr);
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
function validateMatchProperty(match) {
|
|
161
|
+
if (!isFn(match))
|
|
162
|
+
throw Error(`☝️ Looks like 'match' property value is not a 'function', but '${typeof match}' with value '${match}'.`);
|
|
163
|
+
}
|
|
164
|
+
|
|
158
165
|
const validateTemplateValues = (a, b) => {
|
|
159
166
|
for (const key of keys(a)) {
|
|
160
167
|
if (!b[key])
|