hermes-parser 0.9.0 → 0.10.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/dist/HermesASTAdapter.js +13 -0
- package/dist/HermesASTAdapter.js.flow +20 -0
- package/dist/HermesParserNodeDeserializers.js +28 -3
- package/dist/HermesParserWASM.js +1 -1
- package/dist/HermesToBabelAdapter.js +34 -2
- package/dist/HermesToBabelAdapter.js.flow +29 -2
- package/dist/HermesToESTreeAdapter.js +4 -9
- package/dist/HermesToESTreeAdapter.js.flow +5 -11
- package/dist/generated/visitor-keys.js +10 -1
- package/dist/getModuleDocblock.js +2 -1
- package/dist/getModuleDocblock.js.flow +3 -1
- package/dist/getVisitorKeys.js +1 -0
- package/dist/getVisitorKeys.js.flow +0 -0
- package/dist/index.js +41 -0
- package/dist/index.js.flow +5 -0
- package/dist/transform/SimpleTransform.js +92 -0
- package/dist/transform/SimpleTransform.js.flow +104 -0
- package/dist/transform/astArrayMutationHelpers.js +62 -0
- package/dist/transform/astArrayMutationHelpers.js.flow +71 -0
- package/dist/transform/astNodeMutationHelpers.js +186 -0
- package/dist/transform/astNodeMutationHelpers.js.flow +205 -0
- package/dist/traverse/SimpleTraverser.js +138 -0
- package/dist/traverse/SimpleTraverser.js.flow +132 -0
- package/dist/traverse/getVisitorKeys.js +33 -0
- package/dist/traverse/getVisitorKeys.js.flow +35 -0
- package/package.json +3 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import type {ESNode} from 'hermes-estree';
|
|
14
|
+
|
|
15
|
+
import {VisitorKeys as FlowVisitorKeys} from 'hermes-eslint';
|
|
16
|
+
|
|
17
|
+
export function isNode(thing: mixed): boolean %checks {
|
|
18
|
+
return (
|
|
19
|
+
typeof thing === 'object' && thing != null && typeof thing.type === 'string'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type VisitorKeysType = $ReadOnly<{[string]: $ReadOnlyArray<string>}>;
|
|
24
|
+
export function getVisitorKeys<T: ESNode>(
|
|
25
|
+
node: T,
|
|
26
|
+
visitorKeys?: ?VisitorKeysType,
|
|
27
|
+
): $ReadOnlyArray<$Keys<T>> {
|
|
28
|
+
const keys = (visitorKeys ?? FlowVisitorKeys)[node.type];
|
|
29
|
+
if (keys == null) {
|
|
30
|
+
throw new Error(`No visitor keys found for node type "${node.type}".`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// $FlowExpectedError[prop-missing]
|
|
34
|
+
return keys;
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "A JavaScript parser built from the Hermes engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
"url": "git@github.com:facebook/hermes.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"hermes-estree": "0.
|
|
12
|
+
"hermes-estree": "0.10.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@babel/parser": "7.7.4",
|
|
16
|
-
"espree": "9.3.2"
|
|
17
|
-
"hermes-transform": "0.9.0"
|
|
16
|
+
"espree": "9.3.2"
|
|
18
17
|
},
|
|
19
18
|
"files": [
|
|
20
19
|
"dist",
|