@putout/engine-parser 6.5.1 → 7.1.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 +7 -17
- package/lib/parse.js +1 -1
- package/lib/parsers/babel/move-out-directives.js +1 -4
- package/lib/parsers/babel/plugins.js +1 -0
- package/lib/print.js +1 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -23,27 +23,17 @@ Any parser should be installed before use, but you can be sure that `@babel/pars
|
|
|
23
23
|
|
|
24
24
|
## API
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
By default [`@putout/printer`](https://github.com/putoutjs/printer) used. It formats code according to [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme) rules but without using **ESLint**.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
const ast = parse(source, {
|
|
30
|
-
printer: 'babel',
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const code = print(ast, {
|
|
34
|
-
printer: 'babel',
|
|
35
|
-
});
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
You can use brand new [`@putout/printer`](https://github.com/putoutjs/printer) which formats code according to [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#readme) rules but without using **ESLint**.
|
|
28
|
+
But you can also use [`recast`](https://github.com/putoutjs/recast) or `babel` with:
|
|
39
29
|
|
|
40
30
|
```js
|
|
41
31
|
const ast = parse(source, {
|
|
42
|
-
printer: '
|
|
32
|
+
printer: 'recast',
|
|
43
33
|
});
|
|
44
34
|
|
|
45
35
|
const code = print(ast, {
|
|
46
|
-
printer: '
|
|
36
|
+
printer: 'recast',
|
|
47
37
|
});
|
|
48
38
|
```
|
|
49
39
|
|
|
@@ -92,10 +82,12 @@ You have two ways to benefit from source map generation:
|
|
|
92
82
|
const source = `const hello = 'world';`;
|
|
93
83
|
|
|
94
84
|
const ast = parse(source, {
|
|
85
|
+
printer: 'recast',
|
|
95
86
|
sourceFileName: 'hello.js',
|
|
96
87
|
});
|
|
97
88
|
|
|
98
89
|
print(ast, {
|
|
90
|
+
printer: 'recast',
|
|
99
91
|
sourceMapName: 'hello.map',
|
|
100
92
|
});
|
|
101
93
|
|
|
@@ -117,9 +109,7 @@ const ast = babel.parse(source, {
|
|
|
117
109
|
sourceFilename: 'hello.js',
|
|
118
110
|
});
|
|
119
111
|
|
|
120
|
-
generate(ast, {
|
|
121
|
-
sourceMaps: true,
|
|
122
|
-
}, {
|
|
112
|
+
generate(ast, {sourceMaps: true}, {
|
|
123
113
|
'hello.js': source,
|
|
124
114
|
});
|
|
125
115
|
|
package/lib/parse.js
CHANGED
package/lib/print.js
CHANGED
|
@@ -16,8 +16,7 @@ const fixStrictMode = (a) => a.replace(`\n\n\n'use strict'`, `\n\n'use strict'`)
|
|
|
16
16
|
|
|
17
17
|
module.exports = (ast, options = {}) => {
|
|
18
18
|
const {sourceMapName} = options;
|
|
19
|
-
|
|
20
|
-
const [printer = 'recast', printerOptions] = maybeArray(options.printer);
|
|
19
|
+
const [printer = 'putout', printerOptions] = maybeArray(options.printer);
|
|
21
20
|
|
|
22
21
|
if (printer === 'recast') {
|
|
23
22
|
const printOptions = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout parser",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"acorn": "^8.1.1",
|
|
53
53
|
"acorn-jsx": "^5.0.2",
|
|
54
54
|
"acorn-stage3": "^4.0.0",
|
|
55
|
-
"c8": "^
|
|
55
|
+
"c8": "^8.0.0",
|
|
56
56
|
"eslint": "^8.0.1",
|
|
57
57
|
"eslint-plugin-n": "^16.0.0",
|
|
58
|
-
"eslint-plugin-putout": "^
|
|
58
|
+
"eslint-plugin-putout": "^18.0.0",
|
|
59
59
|
"espree": "^9.0.0",
|
|
60
60
|
"esprima": "^4.0.1",
|
|
61
|
-
"hermes-parser": "^0.
|
|
61
|
+
"hermes-parser": "^0.14.0",
|
|
62
62
|
"just-camel-case": "^4.0.2",
|
|
63
63
|
"lerna": "^6.0.1",
|
|
64
64
|
"madrun": "^9.0.0",
|