@putout/bundle 1.1.6 → 1.2.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 +1 -1
- package/bundle/plugin-putout.js +32 -24
- package/bundle/putout.js +7414 -4758
- package/package.json +5 -5
package/README.md
CHANGED
package/bundle/plugin-putout.js
CHANGED
|
@@ -507,8 +507,8 @@ function requireConvertBabelTypes () {
|
|
|
507
507
|
const {replaceWith} = operator;
|
|
508
508
|
|
|
509
509
|
const astRequire = template.ast(`
|
|
510
|
-
|
|
511
|
-
|
|
510
|
+
require('putout').types
|
|
511
|
+
`);
|
|
512
512
|
|
|
513
513
|
convertBabelTypes.report = () => {
|
|
514
514
|
return `"putout.types" should be used instead of "@babel/types"`;
|
|
@@ -846,8 +846,16 @@ function requireConvertNumberToNumeric () {
|
|
|
846
846
|
convertNumberToNumeric.report = () => `Use 'isNumericLiteral()' instead of 'isNumberLiteral()'`;
|
|
847
847
|
|
|
848
848
|
convertNumberToNumeric.fix = (path) => {
|
|
849
|
-
path.scope.
|
|
850
|
-
path.
|
|
849
|
+
const bindings = path.scope.getAllBindings();
|
|
850
|
+
const {name} = path.node.callee;
|
|
851
|
+
|
|
852
|
+
if (!bindings.isNumericLiteral)
|
|
853
|
+
path.scope.rename('isNumberLiteral', 'isNumericLiteral');
|
|
854
|
+
|
|
855
|
+
if (!bindings.NumericLiteral)
|
|
856
|
+
path.scope.rename('NumberLiteral', 'NumericLiteral');
|
|
857
|
+
|
|
858
|
+
path.node.callee.name = name.replace('Number', 'Numeric');
|
|
851
859
|
};
|
|
852
860
|
|
|
853
861
|
convertNumberToNumeric.traverse = ({push}) => ({
|
|
@@ -1017,8 +1025,8 @@ function requireConvertReplaceWith () {
|
|
|
1017
1025
|
|
|
1018
1026
|
if (!bindings.replaceWithMultiple && !bindings.insertAfter && !isInserted()) {
|
|
1019
1027
|
const replaceWithAST = template.ast.fresh(`
|
|
1020
|
-
|
|
1021
|
-
|
|
1028
|
+
const {replaceWith} = require('putout').operator;
|
|
1029
|
+
`);
|
|
1022
1030
|
|
|
1023
1031
|
const {types} = bindings;
|
|
1024
1032
|
const pathToInsertAfter = types ? types.path.parentPath : strictModePath;
|
|
@@ -1108,8 +1116,8 @@ function requireConvertReplaceWithMultiple () {
|
|
|
1108
1116
|
};
|
|
1109
1117
|
|
|
1110
1118
|
const replaceWithAST = template.ast(`
|
|
1111
|
-
|
|
1112
|
-
|
|
1119
|
+
const {replaceWithMultiple} = require('putout').operate;
|
|
1120
|
+
`);
|
|
1113
1121
|
|
|
1114
1122
|
convertReplaceWithMultiple.fix = ({path, calleePath, property, object, program}) => {
|
|
1115
1123
|
const strictModePath = program.get('body.0');
|
|
@@ -2836,16 +2844,16 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2836
2844
|
} = require$$0$1;
|
|
2837
2845
|
|
|
2838
2846
|
const TEST = `
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2847
|
+
const test = require('@putout/test')(__dirname, {
|
|
2848
|
+
__a: __b
|
|
2849
|
+
});
|
|
2850
|
+
`;
|
|
2843
2851
|
|
|
2844
2852
|
const TRANSFORM = `
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2853
|
+
t.transform(__c, {
|
|
2854
|
+
__a: __b
|
|
2855
|
+
});
|
|
2856
|
+
`;
|
|
2849
2857
|
|
|
2850
2858
|
const {
|
|
2851
2859
|
Identifier,
|
|
@@ -2867,10 +2875,10 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2867
2875
|
const value = __a.value || __a.name;
|
|
2868
2876
|
|
|
2869
2877
|
return `
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2878
|
+
const test = require('@putout/test')(__dirname, {
|
|
2879
|
+
'${value}': ${name},
|
|
2880
|
+
});
|
|
2881
|
+
`;
|
|
2874
2882
|
},
|
|
2875
2883
|
[TRANSFORM]: (vars, path) => {
|
|
2876
2884
|
const name = declareRequire(vars, path);
|
|
@@ -2878,10 +2886,10 @@ function requireMoveRequireOnTopLevel () {
|
|
|
2878
2886
|
const value = __a.value || __a.name;
|
|
2879
2887
|
|
|
2880
2888
|
return `
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2889
|
+
t.transform(__c, {
|
|
2890
|
+
'${value}': ${name},
|
|
2891
|
+
});
|
|
2892
|
+
`;
|
|
2885
2893
|
},
|
|
2886
2894
|
});
|
|
2887
2895
|
|