@putout/bundle 1.7.1 → 1.8.1
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 +211 -78
- package/bundle/putout-iife.js +104 -104
- package/bundle/putout.js +43957 -40139
- package/package.json +7 -8
package/bundle/plugin-putout.js
CHANGED
|
@@ -30,22 +30,17 @@ function requireAddArgs () {
|
|
|
30
30
|
'test("__a", async (__args) => __body)',
|
|
31
31
|
'test.skip("__a", async (__args) => __body)',
|
|
32
32
|
'test.only("__a", async (__args) => __body)',
|
|
33
|
-
],
|
|
34
|
-
],
|
|
35
|
-
|
|
33
|
+
]],
|
|
36
34
|
process: ['{process}', [
|
|
37
35
|
'test("__a", async (__args) => __body)',
|
|
38
36
|
'test.skip("__a", async (__args) => __body)',
|
|
39
37
|
'test.only("__a", async (__args) => __body)',
|
|
40
|
-
],
|
|
41
|
-
],
|
|
42
|
-
|
|
38
|
+
]],
|
|
43
39
|
noProcess: ['{noProcess}', [
|
|
44
40
|
'test("__a", async (__args) => __body)',
|
|
45
41
|
'test.skip("__a", async (__args) => __body)',
|
|
46
42
|
'test.only("__a", async (__args) => __body)',
|
|
47
|
-
],
|
|
48
|
-
],
|
|
43
|
+
]],
|
|
49
44
|
});
|
|
50
45
|
return addArgs_1;
|
|
51
46
|
}
|
|
@@ -171,6 +166,22 @@ function requireApplyCreateTest () {
|
|
|
171
166
|
return applyCreateTest;
|
|
172
167
|
}
|
|
173
168
|
|
|
169
|
+
var applyDeclare = {};
|
|
170
|
+
|
|
171
|
+
var hasRequiredApplyDeclare;
|
|
172
|
+
|
|
173
|
+
function requireApplyDeclare () {
|
|
174
|
+
if (hasRequiredApplyDeclare) return applyDeclare;
|
|
175
|
+
hasRequiredApplyDeclare = 1;
|
|
176
|
+
|
|
177
|
+
applyDeclare.report = () => `Use 'Declarator' instead of 'operator.declare()'`;
|
|
178
|
+
|
|
179
|
+
applyDeclare.replace = () => ({
|
|
180
|
+
'module.exports = declare(__a)': 'module.exports.declare = () => __a',
|
|
181
|
+
});
|
|
182
|
+
return applyDeclare;
|
|
183
|
+
}
|
|
184
|
+
|
|
174
185
|
var applyProcessorsDestructuring = {};
|
|
175
186
|
|
|
176
187
|
var hasRequiredApplyProcessorsDestructuring;
|
|
@@ -185,7 +196,6 @@ function requireApplyProcessorsDestructuring () {
|
|
|
185
196
|
'async (t) => {await t.process(__args)}': 'async ({process}) => {await process(__args)}',
|
|
186
197
|
'async (t) => {await t.noProcess(__args)}': 'async ({noProcess}) => {await noProcess(__args)}',
|
|
187
198
|
'async (t) => {await t.comparePlaces(__args)}': 'async ({comparePlaces}) => {await comparePlaces(__args)}',
|
|
188
|
-
|
|
189
199
|
'async (t) => {await t.process(__args); t.end();}': 'async ({process}) => {await process(__args)}',
|
|
190
200
|
'async (t) => {await t.noProcess(__args); t.end();}': 'async ({noProcess}) => {await noProcess(__args)}',
|
|
191
201
|
'async (t) => {await t.comparePlaces(__args); t.end();}': 'async ({comparePlaces}) => {await comparePlaces(__args)}',
|
|
@@ -237,9 +247,15 @@ function requireGenerateCode () {
|
|
|
237
247
|
|
|
238
248
|
const putout = require$$0$1;
|
|
239
249
|
const tryCatch = requireTryCatch();
|
|
250
|
+
const noop = () => {};
|
|
251
|
+
|
|
252
|
+
const {
|
|
253
|
+
types,
|
|
254
|
+
operator,
|
|
255
|
+
} = putout;
|
|
240
256
|
|
|
241
|
-
const {types, operator} = putout;
|
|
242
257
|
const {replaceWith} = operator;
|
|
258
|
+
|
|
243
259
|
const {
|
|
244
260
|
ArrayPattern,
|
|
245
261
|
ObjectPattern,
|
|
@@ -249,12 +265,13 @@ function requireGenerateCode () {
|
|
|
249
265
|
|
|
250
266
|
generateCode = (rootPath, key) => {
|
|
251
267
|
const getVar = createVarStore(rootPath);
|
|
268
|
+
|
|
252
269
|
const [transformError, result] = tryCatch(putout, key, {
|
|
253
270
|
fix: true,
|
|
254
271
|
isTS: true,
|
|
255
272
|
plugins: [
|
|
256
273
|
['generate', {
|
|
257
|
-
report:
|
|
274
|
+
report: noop,
|
|
258
275
|
include: () => [
|
|
259
276
|
'Identifier',
|
|
260
277
|
'StringLiteral',
|
|
@@ -308,7 +325,10 @@ function requireGenerateCode () {
|
|
|
308
325
|
],
|
|
309
326
|
});
|
|
310
327
|
|
|
311
|
-
return [
|
|
328
|
+
return [
|
|
329
|
+
transformError,
|
|
330
|
+
result?.code,
|
|
331
|
+
];
|
|
312
332
|
};
|
|
313
333
|
|
|
314
334
|
function createVarStore(path) {
|
|
@@ -346,11 +366,9 @@ function requireCheckReplaceCode () {
|
|
|
346
366
|
|
|
347
367
|
const putout = require$$0$1;
|
|
348
368
|
const tryCatch = requireTryCatch();
|
|
349
|
-
|
|
350
369
|
const generateCode = requireGenerateCode();
|
|
351
|
-
|
|
370
|
+
const noop = () => {};
|
|
352
371
|
const {operator} = putout;
|
|
353
|
-
|
|
354
372
|
const {
|
|
355
373
|
compare,
|
|
356
374
|
extract,
|
|
@@ -358,7 +376,6 @@ function requireCheckReplaceCode () {
|
|
|
358
376
|
} = operator;
|
|
359
377
|
|
|
360
378
|
const name = '__putout_plugin_check_replace_code';
|
|
361
|
-
|
|
362
379
|
const get = (path) => path[name];
|
|
363
380
|
const set = (path) => path[name] = true;
|
|
364
381
|
|
|
@@ -404,6 +421,7 @@ function requireCheckReplaceCode () {
|
|
|
404
421
|
mainPath: path,
|
|
405
422
|
path: propertyPath,
|
|
406
423
|
});
|
|
424
|
+
|
|
407
425
|
return;
|
|
408
426
|
}
|
|
409
427
|
|
|
@@ -416,6 +434,7 @@ function requireCheckReplaceCode () {
|
|
|
416
434
|
mainPath: path,
|
|
417
435
|
path: propertyPath,
|
|
418
436
|
});
|
|
437
|
+
|
|
419
438
|
return;
|
|
420
439
|
}
|
|
421
440
|
|
|
@@ -424,7 +443,7 @@ function requireCheckReplaceCode () {
|
|
|
424
443
|
isTS: true,
|
|
425
444
|
plugins: [
|
|
426
445
|
['evaluate', {
|
|
427
|
-
report:
|
|
446
|
+
report: noop,
|
|
428
447
|
replace: () => ({
|
|
429
448
|
[key]: template,
|
|
430
449
|
}),
|
|
@@ -438,6 +457,7 @@ function requireCheckReplaceCode () {
|
|
|
438
457
|
mainPath: path,
|
|
439
458
|
path: propertyPath,
|
|
440
459
|
});
|
|
460
|
+
|
|
441
461
|
return;
|
|
442
462
|
}
|
|
443
463
|
|
|
@@ -459,13 +479,19 @@ function requireCheckReplaceCode () {
|
|
|
459
479
|
const [isComputed, key] = compute(keyPath);
|
|
460
480
|
|
|
461
481
|
if (!isComputed)
|
|
462
|
-
return [
|
|
482
|
+
return [
|
|
483
|
+
Error(`Replace key cannot be computed: '${keyPath.toString()}'`),
|
|
484
|
+
];
|
|
463
485
|
|
|
464
|
-
return [
|
|
486
|
+
return [
|
|
487
|
+
null,
|
|
488
|
+
key,
|
|
489
|
+
];
|
|
465
490
|
}
|
|
466
491
|
|
|
467
492
|
function hasMatch(path) {
|
|
468
|
-
const {body} = path.scope
|
|
493
|
+
const {body} = path.scope
|
|
494
|
+
.getProgramParent().path.node;
|
|
469
495
|
|
|
470
496
|
for (const current of body) {
|
|
471
497
|
if (compare(current, 'module.exports.match = __a'))
|
|
@@ -521,16 +547,17 @@ function requireConvertBabelTypes () {
|
|
|
521
547
|
|
|
522
548
|
function isRequire(path) {
|
|
523
549
|
return path
|
|
524
|
-
.get('callee')
|
|
525
|
-
|
|
550
|
+
.get('callee').isIdentifier({
|
|
551
|
+
name: 'require',
|
|
552
|
+
});
|
|
526
553
|
}
|
|
527
554
|
|
|
528
555
|
function isBabelTypes(path) {
|
|
529
556
|
return path
|
|
530
|
-
.get('arguments.0')
|
|
531
|
-
|
|
557
|
+
.get('arguments.0').isStringLiteral({
|
|
558
|
+
value: '@babel/types',
|
|
559
|
+
});
|
|
532
560
|
}
|
|
533
|
-
|
|
534
561
|
convertBabelTypes.traverse = ({push}) => ({
|
|
535
562
|
CallExpression(path) {
|
|
536
563
|
if (!isRequire(path))
|
|
@@ -616,7 +643,11 @@ function requireConvertFindToTraverse () {
|
|
|
616
643
|
if (hasRequiredConvertFindToTraverse) return convertFindToTraverse;
|
|
617
644
|
hasRequiredConvertFindToTraverse = 1;
|
|
618
645
|
|
|
619
|
-
const {
|
|
646
|
+
const {
|
|
647
|
+
types,
|
|
648
|
+
operator,
|
|
649
|
+
} = require$$0$1;
|
|
650
|
+
|
|
620
651
|
const {replaceWith} = operator;
|
|
621
652
|
|
|
622
653
|
const {
|
|
@@ -640,11 +671,9 @@ function requireConvertFindToTraverse () {
|
|
|
640
671
|
isMemberExpression: (path) => {
|
|
641
672
|
path.get('property').node.name = 'traverse';
|
|
642
673
|
},
|
|
643
|
-
|
|
644
674
|
isFunction: (path) => {
|
|
645
675
|
path.node.params = [path.node.params[1]];
|
|
646
676
|
},
|
|
647
|
-
|
|
648
677
|
isCallExpression: (path) => {
|
|
649
678
|
replaceWith(path, ReturnStatement(path.node.arguments[1]));
|
|
650
679
|
},
|
|
@@ -662,7 +691,6 @@ function requireConvertFindToTraverse () {
|
|
|
662
691
|
return;
|
|
663
692
|
|
|
664
693
|
const traverseCallPath = getTraverseCall(rightPath);
|
|
665
|
-
|
|
666
694
|
push(traverseCallPath);
|
|
667
695
|
push(leftPath);
|
|
668
696
|
push(rightPath);
|
|
@@ -688,10 +716,13 @@ function requireConvertFindToTraverse () {
|
|
|
688
716
|
|
|
689
717
|
path.traverse({
|
|
690
718
|
CallExpression(path) {
|
|
691
|
-
if (!path.get('callee').isIdentifier({
|
|
719
|
+
if (!path.get('callee').isIdentifier({
|
|
720
|
+
name: 'traverse',
|
|
721
|
+
}))
|
|
692
722
|
return;
|
|
693
723
|
|
|
694
724
|
result = path;
|
|
725
|
+
|
|
695
726
|
path.stop();
|
|
696
727
|
},
|
|
697
728
|
});
|
|
@@ -735,7 +766,9 @@ function requireConvertMethodToProperty () {
|
|
|
735
766
|
|
|
736
767
|
convertMethodToProperty.report = () => 'Object Property should be used instead of Method';
|
|
737
768
|
|
|
738
|
-
convertMethodToProperty.include = () => [
|
|
769
|
+
convertMethodToProperty.include = () => [
|
|
770
|
+
'ObjectMethod',
|
|
771
|
+
];
|
|
739
772
|
|
|
740
773
|
convertMethodToProperty.filter = (path) => {
|
|
741
774
|
if (!path.node.params.length)
|
|
@@ -751,6 +784,7 @@ function requireConvertMethodToProperty () {
|
|
|
751
784
|
|
|
752
785
|
convertMethodToProperty.fix = (path) => {
|
|
753
786
|
const keyPath = path.get('key');
|
|
787
|
+
|
|
754
788
|
path.node.type = 'ArrowFunctionExpression';
|
|
755
789
|
path.node.id = null;
|
|
756
790
|
|
|
@@ -802,7 +836,6 @@ function requireConvertNodeToPathInGetTemplateValues () {
|
|
|
802
836
|
'getTemplateValues(__a, __b)': (path) => {
|
|
803
837
|
const {scope} = path;
|
|
804
838
|
const {bindings} = scope;
|
|
805
|
-
|
|
806
839
|
const __aPath = path.get('arguments.0');
|
|
807
840
|
|
|
808
841
|
if (__aPath.isMemberExpression()) {
|
|
@@ -924,7 +957,6 @@ function requireConvertPutoutTestToCreateTest () {
|
|
|
924
957
|
const {assign} = Object;
|
|
925
958
|
|
|
926
959
|
convertPutoutTestToCreateTest.report = () => `Use 'createTest' instead of 'putoutTest'`;
|
|
927
|
-
|
|
928
960
|
convertPutoutTestToCreateTest.filter = ({scope}) => !scope.bindings.createTest;
|
|
929
961
|
|
|
930
962
|
convertPutoutTestToCreateTest.include = () => [
|
|
@@ -1045,8 +1077,7 @@ function requireConvertReplaceWith () {
|
|
|
1045
1077
|
const id = Identifier('replaceWith');
|
|
1046
1078
|
const varPath = getVarPath(bindings);
|
|
1047
1079
|
|
|
1048
|
-
varPath.node.id.properties
|
|
1049
|
-
.unshift(ObjectProperty(id, id, false, true));
|
|
1080
|
+
varPath.node.id.properties.unshift(ObjectProperty(id, id, false, true));
|
|
1050
1081
|
};
|
|
1051
1082
|
|
|
1052
1083
|
function getVarPath(bindings) {
|
|
@@ -1060,7 +1091,6 @@ function requireConvertReplaceWith () {
|
|
|
1060
1091
|
|
|
1061
1092
|
return insertAfter.path;
|
|
1062
1093
|
}
|
|
1063
|
-
|
|
1064
1094
|
convertReplaceWith.traverse = ({push}) => {
|
|
1065
1095
|
const isInserted = fullstore();
|
|
1066
1096
|
|
|
@@ -1071,7 +1101,10 @@ function requireConvertReplaceWith () {
|
|
|
1071
1101
|
if (!calleePath.isMemberExpression())
|
|
1072
1102
|
return;
|
|
1073
1103
|
|
|
1074
|
-
const {
|
|
1104
|
+
const {
|
|
1105
|
+
object,
|
|
1106
|
+
property,
|
|
1107
|
+
} = calleePath.node;
|
|
1075
1108
|
|
|
1076
1109
|
if (property.name !== 'replaceWith')
|
|
1077
1110
|
return;
|
|
@@ -1138,10 +1171,9 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1138
1171
|
return insertAfter(strictModePath, replaceWithAST);
|
|
1139
1172
|
|
|
1140
1173
|
const id = Identifier('replaceWithMultiple');
|
|
1141
|
-
|
|
1142
1174
|
const varPath = getVarPath(bindings);
|
|
1143
|
-
|
|
1144
|
-
|
|
1175
|
+
|
|
1176
|
+
varPath.node.id.properties.push(ObjectProperty(id, id, false, true));
|
|
1145
1177
|
};
|
|
1146
1178
|
|
|
1147
1179
|
function getVarPath(bindings) {
|
|
@@ -1155,7 +1187,6 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1155
1187
|
|
|
1156
1188
|
return insertAfter.path;
|
|
1157
1189
|
}
|
|
1158
|
-
|
|
1159
1190
|
convertReplaceWithMultiple.traverse = ({push}) => ({
|
|
1160
1191
|
CallExpression(path) {
|
|
1161
1192
|
const calleePath = path.get('callee');
|
|
@@ -1163,7 +1194,10 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1163
1194
|
if (!calleePath.isMemberExpression())
|
|
1164
1195
|
return;
|
|
1165
1196
|
|
|
1166
|
-
const {
|
|
1197
|
+
const {
|
|
1198
|
+
object,
|
|
1199
|
+
property,
|
|
1200
|
+
} = calleePath.node;
|
|
1167
1201
|
|
|
1168
1202
|
if (property.name !== 'replaceWithMultiple')
|
|
1169
1203
|
return;
|
|
@@ -1232,7 +1266,10 @@ function requireConvertToNoTransformCode () {
|
|
|
1232
1266
|
if (!calleePath.isMemberExpression())
|
|
1233
1267
|
return;
|
|
1234
1268
|
|
|
1235
|
-
const {
|
|
1269
|
+
const {
|
|
1270
|
+
object,
|
|
1271
|
+
property,
|
|
1272
|
+
} = calleePath.node;
|
|
1236
1273
|
|
|
1237
1274
|
if (object.name !== 't' || property.name !== 'transformCode')
|
|
1238
1275
|
return;
|
|
@@ -1272,12 +1309,14 @@ function requireConvertTraverseToInclude () {
|
|
|
1272
1309
|
template,
|
|
1273
1310
|
operator,
|
|
1274
1311
|
} = require$$0$1;
|
|
1312
|
+
|
|
1275
1313
|
const {StringLiteral} = types;
|
|
1276
1314
|
const {compare} = operator;
|
|
1277
1315
|
|
|
1278
|
-
const isPush = (path) => path
|
|
1279
|
-
|
|
1280
|
-
|
|
1316
|
+
const isPush = (path) => path
|
|
1317
|
+
.get('value').isIdentifier({
|
|
1318
|
+
name: 'push',
|
|
1319
|
+
});
|
|
1281
1320
|
|
|
1282
1321
|
convertTraverseToInclude.report = () => 'Includer should be used instead of Traverser';
|
|
1283
1322
|
|
|
@@ -1358,6 +1397,7 @@ function requireConvertTraverseToReplace () {
|
|
|
1358
1397
|
convertTraverseToReplace.match = () => ({
|
|
1359
1398
|
'module.exports.traverse = (__args) => __a': ({__args}, path) => {
|
|
1360
1399
|
const program = path.scope.getProgramParent().path;
|
|
1400
|
+
|
|
1361
1401
|
const withFix = contains(program, [
|
|
1362
1402
|
'module.exports.fix = __a',
|
|
1363
1403
|
]);
|
|
@@ -1401,6 +1441,7 @@ function requireConvertTraverseToReplace () {
|
|
|
1401
1441
|
return;
|
|
1402
1442
|
|
|
1403
1443
|
hasTraverseMethod = true;
|
|
1444
|
+
|
|
1404
1445
|
path.stop();
|
|
1405
1446
|
},
|
|
1406
1447
|
'push(__a)': (path) => {
|
|
@@ -1437,6 +1478,97 @@ function requireConvertUrlToDirname () {
|
|
|
1437
1478
|
return convertUrlToDirname;
|
|
1438
1479
|
}
|
|
1439
1480
|
|
|
1481
|
+
var createTest = {};
|
|
1482
|
+
|
|
1483
|
+
var hasRequiredCreateTest;
|
|
1484
|
+
|
|
1485
|
+
function requireCreateTest () {
|
|
1486
|
+
if (hasRequiredCreateTest) return createTest;
|
|
1487
|
+
hasRequiredCreateTest = 1;
|
|
1488
|
+
|
|
1489
|
+
const {
|
|
1490
|
+
operator,
|
|
1491
|
+
types,
|
|
1492
|
+
} = require$$0$1;
|
|
1493
|
+
|
|
1494
|
+
const {
|
|
1495
|
+
StringLiteral,
|
|
1496
|
+
ArrayExpression,
|
|
1497
|
+
Identifier,
|
|
1498
|
+
ObjectProperty,
|
|
1499
|
+
ObjectExpression,
|
|
1500
|
+
isIdentifier,
|
|
1501
|
+
} = types;
|
|
1502
|
+
|
|
1503
|
+
const {
|
|
1504
|
+
replaceWith,
|
|
1505
|
+
getProperty,
|
|
1506
|
+
} = operator;
|
|
1507
|
+
|
|
1508
|
+
const selector = 'createTest(__dirname, __object)';
|
|
1509
|
+
|
|
1510
|
+
createTest.report = () => `Apply modifications to 'createTest()' options`;
|
|
1511
|
+
|
|
1512
|
+
createTest.include = () => [
|
|
1513
|
+
selector,
|
|
1514
|
+
];
|
|
1515
|
+
|
|
1516
|
+
createTest.fix = (path, {options}) => {
|
|
1517
|
+
const objectPath = path.get('arguments.1');
|
|
1518
|
+
|
|
1519
|
+
if (!getProperty(objectPath, 'plugins'))
|
|
1520
|
+
convert(objectPath);
|
|
1521
|
+
|
|
1522
|
+
for (const [name, value] of options.add) {
|
|
1523
|
+
if (getProperty(objectPath, name))
|
|
1524
|
+
continue;
|
|
1525
|
+
|
|
1526
|
+
const property = ObjectProperty(Identifier(name), StringLiteral(value));
|
|
1527
|
+
objectPath.node.properties.unshift(property);
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
|
|
1531
|
+
createTest.filter = (path, {options}) => {
|
|
1532
|
+
if (!options.add)
|
|
1533
|
+
return false;
|
|
1534
|
+
|
|
1535
|
+
const objectPath = path.get('arguments.1');
|
|
1536
|
+
|
|
1537
|
+
for (const [name] of options.add) {
|
|
1538
|
+
if (!getProperty(objectPath, name))
|
|
1539
|
+
return true;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
return false;
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
const maybeLiteral = (a) => {
|
|
1546
|
+
if (isIdentifier(a))
|
|
1547
|
+
return StringLiteral(a.name);
|
|
1548
|
+
|
|
1549
|
+
return a;
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
function convert(objectPath) {
|
|
1553
|
+
const {
|
|
1554
|
+
key,
|
|
1555
|
+
value,
|
|
1556
|
+
} = objectPath.node.properties[0];
|
|
1557
|
+
|
|
1558
|
+
replaceWith(objectPath, ObjectExpression([
|
|
1559
|
+
ObjectProperty(Identifier('plugins'), ArrayExpression([
|
|
1560
|
+
ArrayExpression([
|
|
1561
|
+
maybeLiteral(key),
|
|
1562
|
+
value,
|
|
1563
|
+
]),
|
|
1564
|
+
])),
|
|
1565
|
+
]));
|
|
1566
|
+
}
|
|
1567
|
+
return createTest;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
var declare = {};
|
|
1571
|
+
|
|
1440
1572
|
var types = "import {types} from 'putout'";
|
|
1441
1573
|
var is = "const {is} = types";
|
|
1442
1574
|
var isBinding = "const {isBinding} = types";
|
|
@@ -2743,38 +2875,22 @@ function requireOperator () {
|
|
|
2743
2875
|
return operator;
|
|
2744
2876
|
}
|
|
2745
2877
|
|
|
2746
|
-
var
|
|
2747
|
-
var hasRequiredDeclarations;
|
|
2878
|
+
var hasRequiredDeclare;
|
|
2748
2879
|
|
|
2749
|
-
function
|
|
2750
|
-
if (
|
|
2751
|
-
|
|
2880
|
+
function requireDeclare () {
|
|
2881
|
+
if (hasRequiredDeclare) return declare;
|
|
2882
|
+
hasRequiredDeclare = 1;
|
|
2752
2883
|
|
|
2753
2884
|
const types = require$$0;
|
|
2754
2885
|
const operator = requireOperator();
|
|
2755
2886
|
|
|
2756
|
-
|
|
2887
|
+
declare.declare = () => ({
|
|
2757
2888
|
template: `import {template} from 'putout'`,
|
|
2758
2889
|
createTest: `import {createTest} from '@putout/test'`,
|
|
2759
2890
|
...operator,
|
|
2760
2891
|
...types,
|
|
2761
|
-
};
|
|
2762
|
-
return
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
|
-
var declare_1;
|
|
2766
|
-
var hasRequiredDeclare;
|
|
2767
|
-
|
|
2768
|
-
function requireDeclare () {
|
|
2769
|
-
if (hasRequiredDeclare) return declare_1;
|
|
2770
|
-
hasRequiredDeclare = 1;
|
|
2771
|
-
|
|
2772
|
-
const {operator} = require$$0$1;
|
|
2773
|
-
const declarations = requireDeclarations();
|
|
2774
|
-
const {declare} = operator;
|
|
2775
|
-
|
|
2776
|
-
declare_1 = declare(declarations);
|
|
2777
|
-
return declare_1;
|
|
2892
|
+
});
|
|
2893
|
+
return declare;
|
|
2778
2894
|
}
|
|
2779
2895
|
|
|
2780
2896
|
var includer = {};
|
|
@@ -2790,10 +2906,8 @@ function requireIncluder () {
|
|
|
2790
2906
|
includer.replace = () => ({
|
|
2791
2907
|
'module.exports.include = () => "__a"': 'module.exports.include = ["__a"]',
|
|
2792
2908
|
'module.exports.exclude = () => "__a"': 'module.exports.exclude = ["__a"]',
|
|
2793
|
-
|
|
2794
2909
|
'module.exports.include = ["__a"]': 'module.exports.include = () => ["__a"]',
|
|
2795
2910
|
'module.exports.exclude = ["__a"]': 'module.exports.exclude = () => ["__a"]',
|
|
2796
|
-
|
|
2797
2911
|
'module.exports.include = "__a"': 'module.exports.include = ["__a"]',
|
|
2798
2912
|
'module.exports.exclude = "__a"': 'module.exports.exclude= ["__a"]',
|
|
2799
2913
|
});
|
|
@@ -2856,6 +2970,7 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2856
2970
|
hasRequiredMoveRequireOnTopLevel = 1;
|
|
2857
2971
|
|
|
2858
2972
|
const justCamelCase = requireJustCamelCase();
|
|
2973
|
+
|
|
2859
2974
|
const {
|
|
2860
2975
|
types,
|
|
2861
2976
|
template,
|
|
@@ -2877,13 +2992,14 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2877
2992
|
Identifier,
|
|
2878
2993
|
isIdentifier,
|
|
2879
2994
|
isObjectExpression,
|
|
2995
|
+
isMemberExpression,
|
|
2880
2996
|
} = types;
|
|
2881
2997
|
|
|
2882
2998
|
moveRequireOnTopLevel.report = () => 'Move require on top level';
|
|
2883
2999
|
|
|
2884
3000
|
moveRequireOnTopLevel.match = () => ({
|
|
2885
3001
|
[TEST]: ({__b}) => !isIdentifier(__b),
|
|
2886
|
-
[TRANSFORM]: ({__b}) => !isIdentifier(__b) && !isObjectExpression(__b),
|
|
3002
|
+
[TRANSFORM]: ({__b}) => !isIdentifier(__b) && !isObjectExpression(__b) && !isMemberExpression(__b),
|
|
2887
3003
|
});
|
|
2888
3004
|
|
|
2889
3005
|
moveRequireOnTopLevel.replace = () => ({
|
|
@@ -2914,8 +3030,11 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2914
3030
|
const buildRequire = template(`const NAME = REQUIRE`);
|
|
2915
3031
|
|
|
2916
3032
|
function declareRequire({__a, __b}, path) {
|
|
2917
|
-
const shortName =
|
|
3033
|
+
const shortName = __a.value || __a.name
|
|
3034
|
+
.split('/').pop();
|
|
3035
|
+
|
|
2918
3036
|
const name = justCamelCase(shortName);
|
|
3037
|
+
|
|
2919
3038
|
const requireNode = buildRequire({
|
|
2920
3039
|
NAME: Identifier(name),
|
|
2921
3040
|
REQUIRE: __b,
|
|
@@ -2924,7 +3043,9 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2924
3043
|
if (path.scope.hasBinding(name))
|
|
2925
3044
|
return name;
|
|
2926
3045
|
|
|
2927
|
-
const programPath = path.scope
|
|
3046
|
+
const programPath = path.scope
|
|
3047
|
+
.getProgramParent().path;
|
|
3048
|
+
|
|
2928
3049
|
programPath.node.body.unshift(requireNode);
|
|
2929
3050
|
|
|
2930
3051
|
return name;
|
|
@@ -2984,7 +3105,6 @@ function requireReplaceTestMessage () {
|
|
|
2984
3105
|
hasRequiredReplaceTestMessage = 1;
|
|
2985
3106
|
|
|
2986
3107
|
const {types} = require$$0$1;
|
|
2987
|
-
|
|
2988
3108
|
const {isCallExpression} = types;
|
|
2989
3109
|
|
|
2990
3110
|
replaceTestMessage.report = ({correct, operatorPath}) => {
|
|
@@ -3042,17 +3162,24 @@ function requireReplaceTestMessage () {
|
|
|
3042
3162
|
const calleePath = path.findParent(isCallExpression);
|
|
3043
3163
|
|
|
3044
3164
|
if (!calleePath)
|
|
3045
|
-
return [
|
|
3165
|
+
return [
|
|
3166
|
+
CORRECT,
|
|
3167
|
+
];
|
|
3046
3168
|
|
|
3047
3169
|
const messagePath = calleePath.get('arguments.0');
|
|
3048
3170
|
|
|
3049
3171
|
if (!messagePath.isStringLiteral())
|
|
3050
|
-
return [
|
|
3172
|
+
return [
|
|
3173
|
+
CORRECT,
|
|
3174
|
+
];
|
|
3051
3175
|
|
|
3052
3176
|
const {value} = messagePath.node;
|
|
3053
3177
|
const is = !incorrect.test(value);
|
|
3054
3178
|
|
|
3055
|
-
return [
|
|
3179
|
+
return [
|
|
3180
|
+
is,
|
|
3181
|
+
messagePath,
|
|
3182
|
+
];
|
|
3056
3183
|
}
|
|
3057
3184
|
return replaceTestMessage;
|
|
3058
3185
|
}
|
|
@@ -3086,6 +3213,8 @@ function getDynamicModules() {
|
|
|
3086
3213
|
"/node_modules/@putout/plugin-putout/lib/apply-async-formatter/index.js": requireApplyAsyncFormatter,
|
|
3087
3214
|
"/node_modules/@putout/plugin-putout/lib/apply-create-test": requireApplyCreateTest,
|
|
3088
3215
|
"/node_modules/@putout/plugin-putout/lib/apply-create-test/index.js": requireApplyCreateTest,
|
|
3216
|
+
"/node_modules/@putout/plugin-putout/lib/apply-declare": requireApplyDeclare,
|
|
3217
|
+
"/node_modules/@putout/plugin-putout/lib/apply-declare/index.js": requireApplyDeclare,
|
|
3089
3218
|
"/node_modules/@putout/plugin-putout/lib/apply-processors-destructuring": requireApplyProcessorsDestructuring,
|
|
3090
3219
|
"/node_modules/@putout/plugin-putout/lib/apply-processors-destructuring/index.js": requireApplyProcessorsDestructuring,
|
|
3091
3220
|
"/node_modules/@putout/plugin-putout/lib/apply-remove": requireApplyRemove,
|
|
@@ -3130,6 +3259,8 @@ function getDynamicModules() {
|
|
|
3130
3259
|
"/node_modules/@putout/plugin-putout/lib/convert-traverse-to-replace/index.js": requireConvertTraverseToReplace,
|
|
3131
3260
|
"/node_modules/@putout/plugin-putout/lib/convert-url-to-dirname": requireConvertUrlToDirname,
|
|
3132
3261
|
"/node_modules/@putout/plugin-putout/lib/convert-url-to-dirname/index.js": requireConvertUrlToDirname,
|
|
3262
|
+
"/node_modules/@putout/plugin-putout/lib/create-test": requireCreateTest,
|
|
3263
|
+
"/node_modules/@putout/plugin-putout/lib/create-test/index.js": requireCreateTest,
|
|
3133
3264
|
"/node_modules/@putout/plugin-putout/lib/declare": requireDeclare,
|
|
3134
3265
|
"/node_modules/@putout/plugin-putout/lib/declare/index.js": requireDeclare,
|
|
3135
3266
|
"/node_modules/@putout/plugin-putout/lib/includer": requireIncluder,
|
|
@@ -3242,6 +3373,7 @@ var rules = lib.rules = {
|
|
|
3242
3373
|
...getRule('apply-async-formatter'),
|
|
3243
3374
|
...getRule('apply-create-test'),
|
|
3244
3375
|
...getRule('apply-remove'),
|
|
3376
|
+
...getRule('apply-declare'),
|
|
3245
3377
|
...getRule('convert-putout-test-to-create-test'),
|
|
3246
3378
|
...getRule('convert-to-no-transform-code'),
|
|
3247
3379
|
...getRule('convert-find-to-traverse'),
|
|
@@ -3271,6 +3403,7 @@ var rules = lib.rules = {
|
|
|
3271
3403
|
...getRule('add-push'),
|
|
3272
3404
|
...getRule('move-require-on-top-level'),
|
|
3273
3405
|
...getRule('includer'),
|
|
3406
|
+
...getRule('create-test'),
|
|
3274
3407
|
};
|
|
3275
3408
|
|
|
3276
3409
|
var pluginPutout = /*#__PURE__*/_mergeNamespaces({
|