putout 41.4.4 → 41.5.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/ChangeLog +11 -0
- package/lib/index.cjs +35 -0
- package/lib/index.js +20 -0
- package/lib/lint/json.js +1 -1
- package/lib/operator.js +15 -0
- package/lib/putout.js +91 -3
- package/package.json +4 -4
- package/lib/putout.cjs +0 -142
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2026.01.03, v41.5.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- bea1d5138 eslint-plugin-putout: migrate putout to ESM
|
|
5
|
+
- 7c4c2adbc putout: migrate to ESM
|
|
6
|
+
- 340a4feba putout: @putout/processor-css v12.0.0
|
|
7
|
+
- 1e529e70d @putout/processor-css: drop support of node < 22
|
|
8
|
+
- 18d6bec9f @putout/plugin-nodejs: convert-commonjs-to-esm: require: export const = require
|
|
9
|
+
- 19a3d1a0a @putout/plugin-esm: merge-export-declarations: improve numbering
|
|
10
|
+
- 451e899de @putout/engine-parser: migrate to ESM
|
|
11
|
+
|
|
1
12
|
2026.01.03, v41.4.4
|
|
2
13
|
|
|
3
14
|
fix:
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
const {
|
|
5
|
+
template,
|
|
6
|
+
generate,
|
|
7
|
+
print,
|
|
8
|
+
parse,
|
|
9
|
+
} = require('@putout/engine-parser');
|
|
10
|
+
|
|
11
|
+
const {putout, putoutAsync} = require('./putout.js');
|
|
12
|
+
const {
|
|
13
|
+
findPlacesAsync,
|
|
14
|
+
findPlaces,
|
|
15
|
+
} = require('./find-places.js');
|
|
16
|
+
|
|
17
|
+
const {transformAsync, transform} = require('./transform.js');
|
|
18
|
+
const operator = require('./operator.js');
|
|
19
|
+
|
|
20
|
+
const {codeframe} = require('./codeframe.js');
|
|
21
|
+
|
|
22
|
+
module.exports = putout;
|
|
23
|
+
module.exports.putout = putout;
|
|
24
|
+
module.exports.putoutAsync = putoutAsync;
|
|
25
|
+
module.exports.operator = operator;
|
|
26
|
+
module.exports.codeframe = codeframe;
|
|
27
|
+
module.exports.template = template;
|
|
28
|
+
module.exports.generate = generate;
|
|
29
|
+
module.exports.print = print;
|
|
30
|
+
module.exports.parse = parse;
|
|
31
|
+
module.exports.transform = transform;
|
|
32
|
+
module.exports.transformAsync = transformAsync;
|
|
33
|
+
module.exports.types = types;
|
|
34
|
+
module.exports.findPlaces = findPlaces;
|
|
35
|
+
module.exports.findPlacesAsync = findPlacesAsync;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {putout} from './putout.js';
|
|
2
|
+
|
|
3
|
+
export {putoutAsync} from './putout.js';
|
|
4
|
+
export {types, traverse} from '@putout/babel';
|
|
5
|
+
export {
|
|
6
|
+
template,
|
|
7
|
+
generate,
|
|
8
|
+
print,
|
|
9
|
+
parse,
|
|
10
|
+
} from '@putout/engine-parser';
|
|
11
|
+
export {transformAsync, transform} from './transform.js';
|
|
12
|
+
export * as operator from './operator.js';
|
|
13
|
+
export {findPlacesAsync, findPlaces} from './find-places.js';
|
|
14
|
+
export {codeframe} from './codeframe.js';
|
|
15
|
+
|
|
16
|
+
export default putout;
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
putout,
|
|
20
|
+
};
|
package/lib/lint/json.js
CHANGED
package/lib/operator.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from '@putout/operate';
|
|
2
|
+
export * from '@putout/compare';
|
|
3
|
+
export * from '@putout/traverse';
|
|
4
|
+
export * from '@putout/operator-json';
|
|
5
|
+
export * from '@putout/operator-jsx';
|
|
6
|
+
export * from '@putout/operator-declare';
|
|
7
|
+
export * from '@putout/operator-regexp';
|
|
8
|
+
export * from '@putout/operator-add-args';
|
|
9
|
+
export * from '@putout/operator-filesystem';
|
|
10
|
+
export * from '@putout/operator-keyword';
|
|
11
|
+
export * from '@putout/operator-match-files';
|
|
12
|
+
export * from '@putout/operator-rename-files';
|
|
13
|
+
export * from '@putout/operator-ignore';
|
|
14
|
+
export * from '@putout/operator-parens';
|
|
15
|
+
|
package/lib/putout.js
CHANGED
|
@@ -1,4 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {parse, print} from '@putout/engine-parser';
|
|
2
|
+
import {cutShebang, mergeShebang} from './shebang.js';
|
|
3
|
+
import {defaultOptions} from './default-options.js';
|
|
4
|
+
import {transform, transformAsync} from './transform.js';
|
|
2
5
|
|
|
3
|
-
export
|
|
4
|
-
|
|
6
|
+
export const putout = (source, opts) => {
|
|
7
|
+
check(source);
|
|
8
|
+
opts = defaultOptions(opts);
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
parser,
|
|
12
|
+
isTS,
|
|
13
|
+
isJSX,
|
|
14
|
+
printer,
|
|
15
|
+
} = opts;
|
|
16
|
+
|
|
17
|
+
const [clearSource, shebang] = cutShebang(source);
|
|
18
|
+
|
|
19
|
+
const ast = parse(clearSource, {
|
|
20
|
+
parser,
|
|
21
|
+
isTS,
|
|
22
|
+
isJSX,
|
|
23
|
+
printer,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const places = transform(ast, source, opts);
|
|
27
|
+
|
|
28
|
+
if (!opts.fix)
|
|
29
|
+
return {
|
|
30
|
+
code: source,
|
|
31
|
+
places,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const printed = print(ast, {
|
|
35
|
+
printer,
|
|
36
|
+
source,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const code = mergeShebang(shebang, printed);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
code,
|
|
43
|
+
places,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const putoutAsync = async (source, opts) => {
|
|
48
|
+
check(source);
|
|
49
|
+
opts = defaultOptions(opts);
|
|
50
|
+
|
|
51
|
+
const {
|
|
52
|
+
parser,
|
|
53
|
+
isTS,
|
|
54
|
+
isJSX,
|
|
55
|
+
printer,
|
|
56
|
+
} = opts;
|
|
57
|
+
|
|
58
|
+
const [clearSource, shebang] = cutShebang(source);
|
|
59
|
+
|
|
60
|
+
const ast = parse(clearSource, {
|
|
61
|
+
parser,
|
|
62
|
+
isTS,
|
|
63
|
+
isJSX,
|
|
64
|
+
printer,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const places = await transformAsync(ast, source, opts);
|
|
68
|
+
|
|
69
|
+
if (!opts.fix)
|
|
70
|
+
return {
|
|
71
|
+
code: source,
|
|
72
|
+
places,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const printed = print(ast, {
|
|
76
|
+
printer,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const code = mergeShebang(shebang, printed);
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
code,
|
|
83
|
+
places,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const isString = (a) => typeof a === 'string';
|
|
88
|
+
|
|
89
|
+
function check(source) {
|
|
90
|
+
if (!isString(source))
|
|
91
|
+
throw Error(`☝️ Looks like 'source' has type '${typeof source}', expected: 'string'`);
|
|
92
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"main": "./lib/putout.js",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"require": "./lib/
|
|
12
|
-
"import": "./lib/
|
|
11
|
+
"require": "./lib/index.cjs",
|
|
12
|
+
"import": "./lib/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./parse-error": "./lib/parse-error.js",
|
|
15
15
|
"./parse-options": "./lib/parse-options/index.js",
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
"@putout/plugin-typescript": "^12.0.0",
|
|
173
173
|
"@putout/plugin-variables": "^1.0.0",
|
|
174
174
|
"@putout/plugin-webpack": "^4.0.0",
|
|
175
|
-
"@putout/processor-css": "^
|
|
175
|
+
"@putout/processor-css": "^12.0.0",
|
|
176
176
|
"@putout/processor-filesystem": "^7.0.0",
|
|
177
177
|
"@putout/processor-ignore": "^6.0.0",
|
|
178
178
|
"@putout/processor-javascript": "^5.0.0",
|
package/lib/putout.cjs
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {traverse, types} = require('@putout/babel');
|
|
4
|
-
const {
|
|
5
|
-
parse,
|
|
6
|
-
print,
|
|
7
|
-
generate,
|
|
8
|
-
template,
|
|
9
|
-
} = require('@putout/engine-parser');
|
|
10
|
-
|
|
11
|
-
const {cutShebang, mergeShebang} = require('./shebang');
|
|
12
|
-
const {defaultOptions} = require('./default-options');
|
|
13
|
-
const {transform, transformAsync} = require('./transform');
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
findPlaces,
|
|
17
|
-
findPlacesAsync,
|
|
18
|
-
} = require('./find-places');
|
|
19
|
-
|
|
20
|
-
module.exports = putout;
|
|
21
|
-
module.exports.putout = putout;
|
|
22
|
-
|
|
23
|
-
function putout(source, opts) {
|
|
24
|
-
check(source);
|
|
25
|
-
opts = defaultOptions(opts);
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
parser,
|
|
29
|
-
isTS,
|
|
30
|
-
isJSX,
|
|
31
|
-
printer,
|
|
32
|
-
} = opts;
|
|
33
|
-
|
|
34
|
-
const [clearSource, shebang] = cutShebang(source);
|
|
35
|
-
|
|
36
|
-
const ast = parse(clearSource, {
|
|
37
|
-
parser,
|
|
38
|
-
isTS,
|
|
39
|
-
isJSX,
|
|
40
|
-
printer,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const places = transform(ast, source, opts);
|
|
44
|
-
|
|
45
|
-
if (!opts.fix)
|
|
46
|
-
return {
|
|
47
|
-
code: source,
|
|
48
|
-
places,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const printed = print(ast, {
|
|
52
|
-
printer,
|
|
53
|
-
source,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const code = mergeShebang(shebang, printed);
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
code,
|
|
60
|
-
places,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
module.exports.putoutAsync = async (source, opts) => {
|
|
65
|
-
check(source);
|
|
66
|
-
opts = defaultOptions(opts);
|
|
67
|
-
|
|
68
|
-
const {
|
|
69
|
-
parser,
|
|
70
|
-
isTS,
|
|
71
|
-
isJSX,
|
|
72
|
-
printer,
|
|
73
|
-
} = opts;
|
|
74
|
-
|
|
75
|
-
const [clearSource, shebang] = cutShebang(source);
|
|
76
|
-
|
|
77
|
-
const ast = parse(clearSource, {
|
|
78
|
-
parser,
|
|
79
|
-
isTS,
|
|
80
|
-
isJSX,
|
|
81
|
-
printer,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const places = await transformAsync(ast, source, opts);
|
|
85
|
-
|
|
86
|
-
if (!opts.fix)
|
|
87
|
-
return {
|
|
88
|
-
code: source,
|
|
89
|
-
places,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const printed = print(ast, {
|
|
93
|
-
printer,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const code = mergeShebang(shebang, printed);
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
code,
|
|
100
|
-
places,
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
module.exports.transform = transform;
|
|
105
|
-
module.exports.transformAsync = transformAsync;
|
|
106
|
-
|
|
107
|
-
module.exports.findPlaces = findPlaces;
|
|
108
|
-
module.exports.findPlacesAsync = findPlacesAsync;
|
|
109
|
-
|
|
110
|
-
module.exports.parse = parse;
|
|
111
|
-
module.exports.print = print;
|
|
112
|
-
module.exports.traverse = traverse;
|
|
113
|
-
module.exports.types = types;
|
|
114
|
-
module.exports.template = template;
|
|
115
|
-
module.exports.generate = generate;
|
|
116
|
-
|
|
117
|
-
module.exports.operator = {
|
|
118
|
-
...require('@putout/operate'),
|
|
119
|
-
...require('@putout/compare'),
|
|
120
|
-
...require('@putout/traverse'),
|
|
121
|
-
...require('@putout/operator-json'),
|
|
122
|
-
...require('@putout/operator-jsx'),
|
|
123
|
-
...require('@putout/operator-declare'),
|
|
124
|
-
...require('@putout/operator-regexp'),
|
|
125
|
-
...require('@putout/operator-add-args'),
|
|
126
|
-
...require('@putout/operator-filesystem'),
|
|
127
|
-
...require('@putout/operator-keyword'),
|
|
128
|
-
...require('@putout/operator-match-files'),
|
|
129
|
-
...require('@putout/operator-rename-files'),
|
|
130
|
-
...require('@putout/operator-ignore'),
|
|
131
|
-
...require('@putout/operator-parens'),
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const {codeframe} = require('./codeframe');
|
|
135
|
-
const isString = (a) => typeof a === 'string';
|
|
136
|
-
|
|
137
|
-
module.exports.codeframe = codeframe;
|
|
138
|
-
|
|
139
|
-
function check(source) {
|
|
140
|
-
if (!isString(source))
|
|
141
|
-
throw Error(`☝️ Looks like 'source' has type '${typeof source}', expected: 'string'`);
|
|
142
|
-
}
|