eslint-plugin-putout 12.3.1 → 12.4.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.
@@ -6,10 +6,12 @@ const {
6
6
  transform,
7
7
  print,
8
8
  parse,
9
+ generate,
9
10
  } = require('putout');
10
11
 
11
12
  const v8 = require('v8');
12
13
  const toBabel = require('estree-to-babel');
14
+ const tryCatch = require('try-catch');
13
15
 
14
16
  const parseOptions = require('putout/parse-options');
15
17
 
@@ -86,8 +88,17 @@ const fix = ({ast, text, node, source, resultOptions}) => (fixer) => {
86
88
  transform(ast, text, resultOptions);
87
89
 
88
90
  const [, last] = lastToken.range;
89
- const code = print(ast);
91
+ const code = printCode(ast);
90
92
 
91
93
  return fixer.replaceTextRange([0, last], code);
92
94
  };
93
95
 
96
+ function printCode(ast) {
97
+ const [, code] = tryCatch(print, ast);
98
+
99
+ if (code)
100
+ return code;
101
+
102
+ return generate(ast).code;
103
+ }
104
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "12.3.1",
3
+ "version": "12.4.0",
4
4
  "description": "eslint plugin for putout",
5
5
  "release": false,
6
6
  "tag": false,