@putout/engine-parser 6.5.0 → 7.0.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 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
- You can avoid using [`recast`](https://github.com/putoutjs/recast) and speed up parsing and printing a bit using only Babel using:
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
- ```js
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: 'putout',
32
+ printer: 'recast',
43
33
  });
44
34
 
45
35
  const code = print(ast, {
46
- printer: 'putout',
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
@@ -7,7 +7,7 @@ const customParser = require('./custom-parser');
7
7
  module.exports = (source, options) => {
8
8
  const {
9
9
  parser,
10
- printer = 'recast',
10
+ printer = 'putout',
11
11
  isTS,
12
12
  isFlow,
13
13
  isJSX,
@@ -6,10 +6,7 @@ const {
6
6
  } = require('@babel/types');
7
7
 
8
8
  module.exports = (ast) => {
9
- const {
10
- body,
11
- directives,
12
- } = ast.program;
9
+ const {body, directives} = ast.program;
13
10
 
14
11
  if (!directives.length)
15
12
  return ast;
package/lib/print.js CHANGED
@@ -17,7 +17,7 @@ const fixStrictMode = (a) => a.replace(`\n\n\n'use strict'`, `\n\n'use strict'`)
17
17
  module.exports = (ast, options = {}) => {
18
18
  const {sourceMapName} = options;
19
19
 
20
- const [printer = 'recast', printerOptions] = maybeArray(options.printer);
20
+ const [printer = 'putout', printerOptions] = maybeArray(options.printer);
21
21
 
22
22
  if (printer === 'recast') {
23
23
  const printOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-parser",
3
- "version": "6.5.0",
3
+ "version": "7.0.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout parser",
@@ -37,7 +37,7 @@
37
37
  "@babel/parser": "^7.19.0",
38
38
  "@babel/template": "^7.18.10",
39
39
  "@babel/types": "^7.19.0",
40
- "@putout/printer": "^1.20.0",
40
+ "@putout/printer": "^2.0.0",
41
41
  "@putout/recast": "^1.12.1",
42
42
  "estree-to-babel": "^5.0.0",
43
43
  "nano-memoize": "^3.0.11",
@@ -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": "^7.5.0",
55
+ "c8": "^8.0.0",
56
56
  "eslint": "^8.0.1",
57
57
  "eslint-plugin-n": "^16.0.0",
58
58
  "eslint-plugin-putout": "^17.0.0",
59
59
  "espree": "^9.0.0",
60
60
  "esprima": "^4.0.1",
61
- "hermes-parser": "^0.9.0",
61
+ "hermes-parser": "^0.12.1",
62
62
  "just-camel-case": "^4.0.2",
63
63
  "lerna": "^6.0.1",
64
64
  "madrun": "^9.0.0",