@putout/bundle 1.8.3 → 1.10.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/bundle/plugin-putout.js +152 -127
- package/bundle/putout-iife.js +13 -13
- package/bundle/putout.js +59229 -59983
- package/package.json +10 -10
package/bundle/plugin-putout.js
CHANGED
|
@@ -53,10 +53,7 @@ function requireAddPush () {
|
|
|
53
53
|
if (hasRequiredAddPush) return addPush;
|
|
54
54
|
hasRequiredAddPush = 1;
|
|
55
55
|
|
|
56
|
-
const {
|
|
57
|
-
types,
|
|
58
|
-
operator,
|
|
59
|
-
} = require$$0$1;
|
|
56
|
+
const {types, operator} = require$$0$1;
|
|
60
57
|
|
|
61
58
|
const {traverse} = operator;
|
|
62
59
|
|
|
@@ -103,10 +100,7 @@ function requireApplyAsyncFormatter () {
|
|
|
103
100
|
if (hasRequiredApplyAsyncFormatter) return applyAsyncFormatter;
|
|
104
101
|
hasRequiredApplyAsyncFormatter = 1;
|
|
105
102
|
|
|
106
|
-
const {
|
|
107
|
-
operator,
|
|
108
|
-
types,
|
|
109
|
-
} = require$$0$1;
|
|
103
|
+
const {operator, types} = require$$0$1;
|
|
110
104
|
|
|
111
105
|
const computed = true;
|
|
112
106
|
const shorthand = true;
|
|
@@ -219,6 +213,70 @@ function requireApplyRemove () {
|
|
|
219
213
|
return applyRemove;
|
|
220
214
|
}
|
|
221
215
|
|
|
216
|
+
var checkMatch = {};
|
|
217
|
+
|
|
218
|
+
var hasRequiredCheckMatch;
|
|
219
|
+
|
|
220
|
+
function requireCheckMatch () {
|
|
221
|
+
if (hasRequiredCheckMatch) return checkMatch;
|
|
222
|
+
hasRequiredCheckMatch = 1;
|
|
223
|
+
|
|
224
|
+
const {operator, types} = require$$0$1;
|
|
225
|
+
|
|
226
|
+
const {
|
|
227
|
+
getTemplateValues,
|
|
228
|
+
traverse,
|
|
229
|
+
} = operator;
|
|
230
|
+
|
|
231
|
+
const {isStringLiteral} = types;
|
|
232
|
+
|
|
233
|
+
const PATTERN_MATCH = 'module.exports.match = () => __object';
|
|
234
|
+
const PATTERN_REPLACE = 'module.exports.replace = () => __object';
|
|
235
|
+
|
|
236
|
+
checkMatch.report = () => `☝️ Looks like 'match()' template absent in 'replace()'`;
|
|
237
|
+
|
|
238
|
+
checkMatch.replace = () => ({
|
|
239
|
+
[PATTERN_MATCH]: PATTERN_MATCH,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
checkMatch.match = () => ({
|
|
243
|
+
[PATTERN_MATCH]: ({__object}, path) => {
|
|
244
|
+
const namesMatch = [];
|
|
245
|
+
|
|
246
|
+
for (const prop of __object.properties) {
|
|
247
|
+
if (!isStringLiteral(prop.key))
|
|
248
|
+
continue;
|
|
249
|
+
|
|
250
|
+
namesMatch.push(prop.key.value);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const namesReplace = [];
|
|
254
|
+
|
|
255
|
+
traverse(path.parentPath.parentPath, {
|
|
256
|
+
[PATTERN_REPLACE]: (path) => {
|
|
257
|
+
const {__object} = getTemplateValues(path, PATTERN_REPLACE);
|
|
258
|
+
|
|
259
|
+
for (const prop of __object.properties) {
|
|
260
|
+
if (!isStringLiteral(prop.key))
|
|
261
|
+
continue;
|
|
262
|
+
|
|
263
|
+
namesReplace.push(prop.key.value);
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
for (const name of namesMatch) {
|
|
269
|
+
if (!namesReplace.includes(name)) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return false;
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
return checkMatch;
|
|
278
|
+
}
|
|
279
|
+
|
|
222
280
|
var checkReplaceCode = {};
|
|
223
281
|
|
|
224
282
|
var tryCatch;
|
|
@@ -249,11 +307,7 @@ function requireGenerateCode () {
|
|
|
249
307
|
const tryCatch = requireTryCatch();
|
|
250
308
|
const noop = () => {};
|
|
251
309
|
|
|
252
|
-
const {
|
|
253
|
-
types,
|
|
254
|
-
operator,
|
|
255
|
-
} = putout;
|
|
256
|
-
|
|
310
|
+
const {types, operator} = putout;
|
|
257
311
|
const {replaceWith} = operator;
|
|
258
312
|
|
|
259
313
|
const {
|
|
@@ -267,6 +321,7 @@ function requireGenerateCode () {
|
|
|
267
321
|
const getVar = createVarStore(rootPath);
|
|
268
322
|
|
|
269
323
|
const [transformError, result] = tryCatch(putout, key, {
|
|
324
|
+
printer: 'putout',
|
|
270
325
|
fix: true,
|
|
271
326
|
isTS: true,
|
|
272
327
|
plugins: [
|
|
@@ -279,10 +334,7 @@ function requireGenerateCode () {
|
|
|
279
334
|
fix: (path) => {
|
|
280
335
|
const {node} = path;
|
|
281
336
|
|
|
282
|
-
const {
|
|
283
|
-
value,
|
|
284
|
-
name,
|
|
285
|
-
} = node;
|
|
337
|
+
const {value, name} = node;
|
|
286
338
|
|
|
287
339
|
if (path.isStringLiteral() && /^__[a-z]$/.test(value)) {
|
|
288
340
|
path.node.value = getVar(name);
|
|
@@ -299,6 +351,11 @@ function requireGenerateCode () {
|
|
|
299
351
|
return;
|
|
300
352
|
}
|
|
301
353
|
|
|
354
|
+
if (/__args/.test(name)) {
|
|
355
|
+
path.node.name = getVar(name);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
302
359
|
if (name === '__array') {
|
|
303
360
|
if (path.parentPath.isVariableDeclarator())
|
|
304
361
|
return replaceWith(path, ArrayPattern([]));
|
|
@@ -439,6 +496,7 @@ function requireCheckReplaceCode () {
|
|
|
439
496
|
}
|
|
440
497
|
|
|
441
498
|
const [transformError, result] = tryCatch(putout, keyCode, {
|
|
499
|
+
printer: 'putout',
|
|
442
500
|
fix: true,
|
|
443
501
|
isTS: true,
|
|
444
502
|
plugins: [
|
|
@@ -461,7 +519,7 @@ function requireCheckReplaceCode () {
|
|
|
461
519
|
return;
|
|
462
520
|
}
|
|
463
521
|
|
|
464
|
-
const
|
|
522
|
+
const code = result.code.slice(0, -1);
|
|
465
523
|
const [error, is] = tryCatch(compare, rmSemi(code), template);
|
|
466
524
|
|
|
467
525
|
if (error || !is)
|
|
@@ -483,10 +541,7 @@ function requireCheckReplaceCode () {
|
|
|
483
541
|
Error(`Replace key cannot be computed: '${keyPath.toString()}'`),
|
|
484
542
|
];
|
|
485
543
|
|
|
486
|
-
return [
|
|
487
|
-
null,
|
|
488
|
-
key,
|
|
489
|
-
];
|
|
544
|
+
return [null, key];
|
|
490
545
|
}
|
|
491
546
|
|
|
492
547
|
function hasMatch(path) {
|
|
@@ -510,11 +565,16 @@ function requireConvertAddArgumentToAddArgs () {
|
|
|
510
565
|
if (hasRequiredConvertAddArgumentToAddArgs) return convertAddArgumentToAddArgs;
|
|
511
566
|
hasRequiredConvertAddArgumentToAddArgs = 1;
|
|
512
567
|
|
|
568
|
+
const {operator} = require$$0$1;
|
|
569
|
+
const {rename} = operator;
|
|
570
|
+
|
|
513
571
|
convertAddArgumentToAddArgs.report = () => 'Use addArgs instead of addArgument';
|
|
514
572
|
|
|
515
573
|
convertAddArgumentToAddArgs.replace = () => ({
|
|
516
574
|
'addArgument(__args)': (vars, path) => {
|
|
517
|
-
path.scope.
|
|
575
|
+
const program = path.scope.getProgramParent().path;
|
|
576
|
+
rename(program, 'addArgument', 'addArgs');
|
|
577
|
+
|
|
518
578
|
return path;
|
|
519
579
|
},
|
|
520
580
|
});
|
|
@@ -529,10 +589,7 @@ function requireConvertBabelTypes () {
|
|
|
529
589
|
if (hasRequiredConvertBabelTypes) return convertBabelTypes;
|
|
530
590
|
hasRequiredConvertBabelTypes = 1;
|
|
531
591
|
|
|
532
|
-
const {
|
|
533
|
-
operator,
|
|
534
|
-
template,
|
|
535
|
-
} = require$$0$1;
|
|
592
|
+
const {operator, template} = require$$0$1;
|
|
536
593
|
|
|
537
594
|
const {replaceWith} = operator;
|
|
538
595
|
|
|
@@ -645,10 +702,7 @@ function requireConvertFindToTraverse () {
|
|
|
645
702
|
if (hasRequiredConvertFindToTraverse) return convertFindToTraverse;
|
|
646
703
|
hasRequiredConvertFindToTraverse = 1;
|
|
647
704
|
|
|
648
|
-
const {
|
|
649
|
-
types,
|
|
650
|
-
operator,
|
|
651
|
-
} = require$$0$1;
|
|
705
|
+
const {types, operator} = require$$0$1;
|
|
652
706
|
|
|
653
707
|
const {replaceWith} = operator;
|
|
654
708
|
|
|
@@ -756,10 +810,7 @@ function requireConvertMethodToProperty () {
|
|
|
756
810
|
if (hasRequiredConvertMethodToProperty) return convertMethodToProperty;
|
|
757
811
|
hasRequiredConvertMethodToProperty = 1;
|
|
758
812
|
|
|
759
|
-
const {
|
|
760
|
-
types,
|
|
761
|
-
operator,
|
|
762
|
-
} = require$$0$1;
|
|
813
|
+
const {types, operator} = require$$0$1;
|
|
763
814
|
|
|
764
815
|
const {replaceWith} = operator;
|
|
765
816
|
const {ObjectProperty} = types;
|
|
@@ -801,10 +852,7 @@ function requireConvertNodeToPathInGetTemplateValues () {
|
|
|
801
852
|
if (hasRequiredConvertNodeToPathInGetTemplateValues) return convertNodeToPathInGetTemplateValues;
|
|
802
853
|
hasRequiredConvertNodeToPathInGetTemplateValues = 1;
|
|
803
854
|
|
|
804
|
-
const {
|
|
805
|
-
types,
|
|
806
|
-
operator,
|
|
807
|
-
} = require$$0$1;
|
|
855
|
+
const {types, operator} = require$$0$1;
|
|
808
856
|
|
|
809
857
|
const {
|
|
810
858
|
compare,
|
|
@@ -881,29 +929,29 @@ function requireConvertNumberToNumeric () {
|
|
|
881
929
|
if (hasRequiredConvertNumberToNumeric) return convertNumberToNumeric;
|
|
882
930
|
hasRequiredConvertNumberToNumeric = 1;
|
|
883
931
|
|
|
932
|
+
const {operator} = require$$0$1;
|
|
933
|
+
const {rename} = operator;
|
|
934
|
+
|
|
884
935
|
convertNumberToNumeric.report = () => `Use 'isNumericLiteral()' instead of 'isNumberLiteral()'`;
|
|
885
936
|
|
|
886
937
|
convertNumberToNumeric.fix = (path) => {
|
|
887
938
|
const bindings = path.scope.getAllBindings();
|
|
888
939
|
const {name} = path.node.callee;
|
|
940
|
+
const program = path.scope.getProgramParent().path;
|
|
889
941
|
|
|
890
942
|
if (!bindings.isNumericLiteral)
|
|
891
|
-
|
|
943
|
+
rename(program, 'isNumberLiteral', 'isNumericLiteral');
|
|
892
944
|
|
|
893
945
|
if (!bindings.NumericLiteral)
|
|
894
|
-
|
|
946
|
+
rename(program, 'NumberLiteral', 'NumericLiteral');
|
|
895
947
|
|
|
896
948
|
path.node.callee.name = name.replace('Number', 'Numeric');
|
|
897
949
|
};
|
|
898
950
|
|
|
899
|
-
convertNumberToNumeric.
|
|
900
|
-
'isNumberLiteral(__a)'
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
'NumberLiteral(__a)': (path) => {
|
|
904
|
-
push(path);
|
|
905
|
-
},
|
|
906
|
-
});
|
|
951
|
+
convertNumberToNumeric.include = () => [
|
|
952
|
+
'isNumberLiteral(__a)',
|
|
953
|
+
'NumberLiteral(__a)',
|
|
954
|
+
];
|
|
907
955
|
return convertNumberToNumeric;
|
|
908
956
|
}
|
|
909
957
|
|
|
@@ -1035,15 +1083,12 @@ function requireConvertReplaceWith () {
|
|
|
1035
1083
|
|
|
1036
1084
|
const fullstore = requireFullstore();
|
|
1037
1085
|
|
|
1038
|
-
const {
|
|
1039
|
-
|
|
1040
|
-
ObjectProperty,
|
|
1041
|
-
} = types;
|
|
1086
|
+
const {Identifier, ObjectProperty} = types;
|
|
1087
|
+
const {replaceWith, insertAfter} = operator;
|
|
1042
1088
|
|
|
1043
|
-
const {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
} = operator;
|
|
1089
|
+
const isRecast = (program) => program.get('body.0.expression').isStringLiteral({
|
|
1090
|
+
value: 'use strict',
|
|
1091
|
+
});
|
|
1047
1092
|
|
|
1048
1093
|
convertReplaceWith.report = () => {
|
|
1049
1094
|
return `"operator.replaceWith" should be called instead of "path.replaceWith"`;
|
|
@@ -1051,9 +1096,7 @@ function requireConvertReplaceWith () {
|
|
|
1051
1096
|
|
|
1052
1097
|
convertReplaceWith.fix = ({path, calleePath, property, object, program, isInserted}) => {
|
|
1053
1098
|
replaceWith(calleePath, property);
|
|
1054
|
-
|
|
1055
|
-
const strictModePath = program.get('body.0');
|
|
1056
|
-
const {bindings} = strictModePath.scope;
|
|
1099
|
+
const {bindings} = program.scope;
|
|
1057
1100
|
|
|
1058
1101
|
path.node.arguments.unshift(object);
|
|
1059
1102
|
|
|
@@ -1066,10 +1109,17 @@ function requireConvertReplaceWith () {
|
|
|
1066
1109
|
`);
|
|
1067
1110
|
|
|
1068
1111
|
const {types} = bindings;
|
|
1069
|
-
const
|
|
1112
|
+
const first = program.get('body.0');
|
|
1113
|
+
const pathToInsert = types ? types.path.parentPath : first;
|
|
1114
|
+
|
|
1115
|
+
if (isRecast(program))
|
|
1116
|
+
insertAfter(pathToInsert, replaceWithAST);
|
|
1117
|
+
else if (types)
|
|
1118
|
+
insertAfter(pathToInsert, replaceWithAST);
|
|
1119
|
+
else
|
|
1120
|
+
pathToInsert.insertBefore(replaceWithAST);
|
|
1070
1121
|
|
|
1071
1122
|
isInserted(true);
|
|
1072
|
-
insertAfter(pathToInsertAfter, replaceWithAST);
|
|
1073
1123
|
|
|
1074
1124
|
return;
|
|
1075
1125
|
}
|
|
@@ -1102,15 +1152,12 @@ function requireConvertReplaceWith () {
|
|
|
1102
1152
|
if (!calleePath.isMemberExpression())
|
|
1103
1153
|
return;
|
|
1104
1154
|
|
|
1105
|
-
const {
|
|
1106
|
-
object,
|
|
1107
|
-
property,
|
|
1108
|
-
} = calleePath.node;
|
|
1155
|
+
const {object, property} = calleePath.node;
|
|
1109
1156
|
|
|
1110
1157
|
if (property.name !== 'replaceWith')
|
|
1111
1158
|
return;
|
|
1112
1159
|
|
|
1113
|
-
const program = path.
|
|
1160
|
+
const program = path.scope.getProgramParent().path;
|
|
1114
1161
|
|
|
1115
1162
|
push({
|
|
1116
1163
|
isInserted,
|
|
@@ -1140,15 +1187,13 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1140
1187
|
types,
|
|
1141
1188
|
} = require$$0$1;
|
|
1142
1189
|
|
|
1143
|
-
const {
|
|
1144
|
-
|
|
1145
|
-
replaceWith,
|
|
1146
|
-
} = operator;
|
|
1190
|
+
const {insertAfter, replaceWith} = operator;
|
|
1191
|
+
const {Identifier, ObjectProperty} = types;
|
|
1147
1192
|
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1193
|
+
const isRecast = (program) => program.get('body.0').get('expression')
|
|
1194
|
+
.isStringLiteral({
|
|
1195
|
+
value: 'use strict',
|
|
1196
|
+
});
|
|
1152
1197
|
|
|
1153
1198
|
convertReplaceWithMultiple.report = () => {
|
|
1154
1199
|
return `"operate.replaceWithMultiple" should be called instead of "path.replaceWithMultiple"`;
|
|
@@ -1159,8 +1204,8 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1159
1204
|
`);
|
|
1160
1205
|
|
|
1161
1206
|
convertReplaceWithMultiple.fix = ({path, calleePath, property, object, program}) => {
|
|
1162
|
-
const
|
|
1163
|
-
const {bindings} =
|
|
1207
|
+
const first = program.get('body.0');
|
|
1208
|
+
const {bindings} = program.scope;
|
|
1164
1209
|
|
|
1165
1210
|
replaceWith(calleePath, property);
|
|
1166
1211
|
path.node.arguments.unshift(object);
|
|
@@ -1168,8 +1213,12 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1168
1213
|
if (bindings.replaceWithMultiple)
|
|
1169
1214
|
return;
|
|
1170
1215
|
|
|
1171
|
-
if (!bindings.replaceWith && !bindings.insertAfter)
|
|
1172
|
-
|
|
1216
|
+
if (!bindings.replaceWith && !bindings.insertAfter) {
|
|
1217
|
+
if (isRecast(program))
|
|
1218
|
+
return insertAfter(first, replaceWithAST);
|
|
1219
|
+
|
|
1220
|
+
return first.insertBefore(replaceWithAST);
|
|
1221
|
+
}
|
|
1173
1222
|
|
|
1174
1223
|
const id = Identifier('replaceWithMultiple');
|
|
1175
1224
|
const varPath = getVarPath(bindings);
|
|
@@ -1178,10 +1227,7 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1178
1227
|
};
|
|
1179
1228
|
|
|
1180
1229
|
function getVarPath(bindings) {
|
|
1181
|
-
const {
|
|
1182
|
-
replaceWith,
|
|
1183
|
-
insertAfter,
|
|
1184
|
-
} = bindings;
|
|
1230
|
+
const {replaceWith, insertAfter} = bindings;
|
|
1185
1231
|
|
|
1186
1232
|
if (replaceWith)
|
|
1187
1233
|
return replaceWith.path;
|
|
@@ -1196,15 +1242,12 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1196
1242
|
if (!calleePath.isMemberExpression())
|
|
1197
1243
|
return;
|
|
1198
1244
|
|
|
1199
|
-
const {
|
|
1200
|
-
object,
|
|
1201
|
-
property,
|
|
1202
|
-
} = calleePath.node;
|
|
1245
|
+
const {object, property} = calleePath.node;
|
|
1203
1246
|
|
|
1204
1247
|
if (property.name !== 'replaceWithMultiple')
|
|
1205
1248
|
return;
|
|
1206
1249
|
|
|
1207
|
-
const program = path.
|
|
1250
|
+
const program = path.scope.getProgramParent().path;
|
|
1208
1251
|
|
|
1209
1252
|
push({
|
|
1210
1253
|
path,
|
|
@@ -1252,10 +1295,7 @@ function requireConvertToNoTransformCode () {
|
|
|
1252
1295
|
if (hasRequiredConvertToNoTransformCode) return convertToNoTransformCode;
|
|
1253
1296
|
hasRequiredConvertToNoTransformCode = 1;
|
|
1254
1297
|
|
|
1255
|
-
const {
|
|
1256
|
-
isIdentifier,
|
|
1257
|
-
Identifier,
|
|
1258
|
-
} = require$$0$1.types;
|
|
1298
|
+
const {isIdentifier, Identifier} = require$$0$1.types;
|
|
1259
1299
|
|
|
1260
1300
|
convertToNoTransformCode.report = () => {
|
|
1261
1301
|
return `"noTransformCode" should be called instead of using same arguments twice in "transformCode"`;
|
|
@@ -1268,10 +1308,7 @@ function requireConvertToNoTransformCode () {
|
|
|
1268
1308
|
if (!calleePath.isMemberExpression())
|
|
1269
1309
|
return;
|
|
1270
1310
|
|
|
1271
|
-
const {
|
|
1272
|
-
object,
|
|
1273
|
-
property,
|
|
1274
|
-
} = calleePath.node;
|
|
1311
|
+
const {object, property} = calleePath.node;
|
|
1275
1312
|
|
|
1276
1313
|
if (object.name !== 't' || property.name !== 'transformCode')
|
|
1277
1314
|
return;
|
|
@@ -1388,10 +1425,7 @@ function requireConvertTraverseToReplace () {
|
|
|
1388
1425
|
hasRequiredConvertTraverseToReplace = 1;
|
|
1389
1426
|
|
|
1390
1427
|
const {operator} = require$$0$1;
|
|
1391
|
-
const {
|
|
1392
|
-
contains,
|
|
1393
|
-
traverse,
|
|
1394
|
-
} = operator;
|
|
1428
|
+
const {contains, traverse} = operator;
|
|
1395
1429
|
|
|
1396
1430
|
convertTraverseToReplace.report = () => 'Replacer should be used instead of Traverser (https://git.io/JqcMn)';
|
|
1397
1431
|
|
|
@@ -1483,10 +1517,7 @@ function requireCreateTest () {
|
|
|
1483
1517
|
if (hasRequiredCreateTest) return createTest;
|
|
1484
1518
|
hasRequiredCreateTest = 1;
|
|
1485
1519
|
|
|
1486
|
-
const {
|
|
1487
|
-
operator,
|
|
1488
|
-
types,
|
|
1489
|
-
} = require$$0$1;
|
|
1520
|
+
const {operator, types} = require$$0$1;
|
|
1490
1521
|
|
|
1491
1522
|
const {
|
|
1492
1523
|
StringLiteral,
|
|
@@ -1497,10 +1528,7 @@ function requireCreateTest () {
|
|
|
1497
1528
|
isIdentifier,
|
|
1498
1529
|
} = types;
|
|
1499
1530
|
|
|
1500
|
-
const {
|
|
1501
|
-
replaceWith,
|
|
1502
|
-
getProperty,
|
|
1503
|
-
} = operator;
|
|
1531
|
+
const {replaceWith, getProperty} = operator;
|
|
1504
1532
|
|
|
1505
1533
|
createTest.report = () => `Apply modifications to 'createTest()' options`;
|
|
1506
1534
|
|
|
@@ -1546,10 +1574,7 @@ function requireCreateTest () {
|
|
|
1546
1574
|
};
|
|
1547
1575
|
|
|
1548
1576
|
function convert(objectPath) {
|
|
1549
|
-
const {
|
|
1550
|
-
key,
|
|
1551
|
-
value,
|
|
1552
|
-
} = objectPath.node.properties[0];
|
|
1577
|
+
const {key, value} = objectPath.node.properties[0];
|
|
1553
1578
|
|
|
1554
1579
|
replaceWith(objectPath, ObjectExpression([
|
|
1555
1580
|
ObjectProperty(Identifier('plugins'), ArrayExpression([
|
|
@@ -2855,6 +2880,8 @@ function requireOperator () {
|
|
|
2855
2880
|
compute: `const {compute} = operator`,
|
|
2856
2881
|
contains: `const {contains} = operator`,
|
|
2857
2882
|
declare: `const {declare} = operator`,
|
|
2883
|
+
rename: `const {rename} = operator`,
|
|
2884
|
+
renameProperty: `const {renameProperty} = operator`,
|
|
2858
2885
|
extract: `const {extract} = operator`,
|
|
2859
2886
|
getPathAfterImports: `const {getPathAfterImports} = operator`,
|
|
2860
2887
|
traverse: `const {traverse} = operator`,
|
|
@@ -2867,6 +2894,7 @@ function requireOperator () {
|
|
|
2867
2894
|
isESM: `const {isESM} = operator`,
|
|
2868
2895
|
getProperty: `const {getProperty} = operator`,
|
|
2869
2896
|
getProperties: `const {getProperties} = operator`,
|
|
2897
|
+
isSimple: `const {isSimple} = operator`,
|
|
2870
2898
|
};
|
|
2871
2899
|
return operator;
|
|
2872
2900
|
}
|
|
@@ -2967,10 +2995,7 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2967
2995
|
|
|
2968
2996
|
const justCamelCase = requireJustCamelCase();
|
|
2969
2997
|
|
|
2970
|
-
const {
|
|
2971
|
-
types,
|
|
2972
|
-
template,
|
|
2973
|
-
} = require$$0$1;
|
|
2998
|
+
const {types, template} = require$$0$1;
|
|
2974
2999
|
|
|
2975
3000
|
const TEST = `
|
|
2976
3001
|
const test = require('@putout/test')(__dirname, {
|
|
@@ -3055,11 +3080,12 @@ function requireRenameOperateToOperator () {
|
|
|
3055
3080
|
if (hasRequiredRenameOperateToOperator) return renameOperateToOperator;
|
|
3056
3081
|
hasRequiredRenameOperateToOperator = 1;
|
|
3057
3082
|
|
|
3083
|
+
const {operator} = require$$0$1;
|
|
3084
|
+
const {rename} = operator;
|
|
3085
|
+
|
|
3058
3086
|
renameOperateToOperator.report = () => '"operator" should be used instead of "operate"';
|
|
3059
3087
|
|
|
3060
|
-
renameOperateToOperator.include = () => [
|
|
3061
|
-
'Program',
|
|
3062
|
-
];
|
|
3088
|
+
renameOperateToOperator.include = () => ['Program'];
|
|
3063
3089
|
|
|
3064
3090
|
renameOperateToOperator.filter = (path) => {
|
|
3065
3091
|
const noOperator = !path.scope.bindings.operator;
|
|
@@ -3069,7 +3095,7 @@ function requireRenameOperateToOperator () {
|
|
|
3069
3095
|
};
|
|
3070
3096
|
|
|
3071
3097
|
renameOperateToOperator.fix = (path) => {
|
|
3072
|
-
|
|
3098
|
+
rename(path, 'operate', 'operator');
|
|
3073
3099
|
};
|
|
3074
3100
|
return renameOperateToOperator;
|
|
3075
3101
|
}
|
|
@@ -3157,16 +3183,12 @@ function requireReplaceTestMessage () {
|
|
|
3157
3183
|
const calleePath = path.findParent(isCallExpression);
|
|
3158
3184
|
|
|
3159
3185
|
if (!calleePath)
|
|
3160
|
-
return [
|
|
3161
|
-
CORRECT,
|
|
3162
|
-
];
|
|
3186
|
+
return [CORRECT];
|
|
3163
3187
|
|
|
3164
3188
|
const messagePath = calleePath.get('arguments.0');
|
|
3165
3189
|
|
|
3166
3190
|
if (!messagePath.isStringLiteral())
|
|
3167
|
-
return [
|
|
3168
|
-
CORRECT,
|
|
3169
|
-
];
|
|
3191
|
+
return [CORRECT];
|
|
3170
3192
|
|
|
3171
3193
|
const {value} = messagePath.node;
|
|
3172
3194
|
const is = !incorrect.test(value);
|
|
@@ -3211,6 +3233,8 @@ function getDynamicModules() {
|
|
|
3211
3233
|
"/node_modules/@putout/plugin-putout/lib/apply-processors-destructuring/index.js": requireApplyProcessorsDestructuring,
|
|
3212
3234
|
"/node_modules/@putout/plugin-putout/lib/apply-remove": requireApplyRemove,
|
|
3213
3235
|
"/node_modules/@putout/plugin-putout/lib/apply-remove/index.js": requireApplyRemove,
|
|
3236
|
+
"/node_modules/@putout/plugin-putout/lib/check-match": requireCheckMatch,
|
|
3237
|
+
"/node_modules/@putout/plugin-putout/lib/check-match/index.js": requireCheckMatch,
|
|
3214
3238
|
"/node_modules/@putout/plugin-putout/lib/check-replace-code": requireCheckReplaceCode,
|
|
3215
3239
|
"/node_modules/@putout/plugin-putout/lib/check-replace-code/index.js": requireCheckReplaceCode,
|
|
3216
3240
|
"/node_modules/@putout/plugin-putout/lib/convert-add-argument-to-add-args": requireConvertAddArgumentToAddArgs,
|
|
@@ -3366,6 +3390,8 @@ var rules = lib.rules = {
|
|
|
3366
3390
|
...getRule('apply-create-test'),
|
|
3367
3391
|
...getRule('apply-remove'),
|
|
3368
3392
|
...getRule('apply-declare'),
|
|
3393
|
+
...getRule('check-replace-code'),
|
|
3394
|
+
...getRule('check-match'),
|
|
3369
3395
|
...getRule('convert-putout-test-to-create-test'),
|
|
3370
3396
|
...getRule('convert-to-no-transform-code'),
|
|
3371
3397
|
...getRule('convert-find-to-traverse'),
|
|
@@ -3389,7 +3415,6 @@ var rules = lib.rules = {
|
|
|
3389
3415
|
...getRule('rename-operate-to-operator'),
|
|
3390
3416
|
...getRule('replace-operate-with-operator'),
|
|
3391
3417
|
...getRule('shorten-imports'),
|
|
3392
|
-
...getRule('check-replace-code'),
|
|
3393
3418
|
...getRule('declare'),
|
|
3394
3419
|
...getRule('add-args'),
|
|
3395
3420
|
...getRule('add-push'),
|