@putout/engine-parser 12.4.0 → 12.6.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/lib/parse.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const toBabel = require('estree-to-babel');
4
4
  const customParser = require('./custom-parser');
5
+ const {tryThrowWithReason} = require('./try-throw-with-reason');
5
6
  const {assign} = Object;
6
7
 
7
8
  module.exports = (source, options) => {
@@ -12,14 +13,14 @@ module.exports = (source, options) => {
12
13
  isJSX,
13
14
  } = options || {};
14
15
 
15
- const cookedParser = getParser({
16
+ const {parse} = getParser({
16
17
  printer,
17
18
  parser,
18
19
  isTS,
19
20
  isJSX,
20
21
  });
21
22
 
22
- return cookedParser.parse(source);
23
+ return tryThrowWithReason(parse, source);
23
24
  };
24
25
 
25
26
  const getParser = ({parser = 'babel', isTS, isJSX, printer}) => ({
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const tryCatch = require('try-catch');
4
+
5
+ module.exports.tryThrowWithReason = (fn, ...args) => {
6
+ const [error, result] = tryCatch(fn, ...args);
7
+
8
+ if (error) {
9
+ error.reason = 'parse';
10
+ throw error;
11
+ }
12
+
13
+ return result;
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-parser",
3
- "version": "12.4.0",
3
+ "version": "12.6.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout parser",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@putout/babel": "^3.0.0",
37
- "@putout/printer": "^12.0.0",
37
+ "@putout/printer": "^13.0.0",
38
38
  "align-spaces": "^2.0.0",
39
39
  "estree-to-babel": "^10.0.0",
40
40
  "nano-memoize": "^3.0.11",
@@ -46,18 +46,18 @@
46
46
  "putout-engine"
47
47
  ],
48
48
  "devDependencies": {
49
+ "@putout/eslint-flat": "^2.0.0",
49
50
  "acorn": "^8.1.1",
50
51
  "acorn-stage3": "^4.0.0",
51
52
  "acorn-typescript": "^1.4.13",
52
53
  "c8": "^10.0.0",
53
54
  "eslint": "^9.0.0",
54
55
  "eslint-plugin-n": "^17.0.0",
55
- "eslint-plugin-putout": "^24.0.0",
56
+ "eslint-plugin-putout": "^25.0.1",
56
57
  "espree": "^10.0.0",
57
58
  "esprima": "^4.0.1",
58
59
  "hermes-parser": "^0.26.0",
59
60
  "just-camel-case": "^6.2.0",
60
- "lerna": "^6.0.1",
61
61
  "madrun": "^10.0.0",
62
62
  "mock-require": "^3.0.3",
63
63
  "montag": "^1.0.0",