flow-parser 0.322.0 → 0.324.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 +25 -32
- package/dist/FlowParserWASM.js +1 -1
- package/dist/estree/TransformComponentSyntax.js +1 -0
- package/dist/estree/TransformComponentSyntax.js.flow +1 -0
- package/package.json +2 -2
- package/dist/transform/print/comments/comments.js +0 -196
- package/dist/transform/print/comments/comments.js.flow +0 -330
- package/dist/transform/print/comments/prettier/common/util.js +0 -186
- package/dist/transform/print/comments/prettier/language-js/comments.js +0 -552
- package/dist/transform/print/comments/prettier/language-js/loc.js +0 -24
- package/dist/transform/print/comments/prettier/language-js/printer-estree.js +0 -20
- package/dist/transform/print/comments/prettier/language-js/utils.js +0 -69
- package/dist/transform/print/comments/prettier/main/comments.js +0 -313
- package/dist/transform/print/comments/prettier/utils/get-last.js +0 -4
- package/dist/transform/print/detachedNodeTypes.js +0 -1
- package/dist/transform/print/detachedNodeTypes.js.flow +0 -24
- package/dist/transform/print/print.js +0 -52
- package/dist/transform/print/print.js.flow +0 -87
package/README.md
CHANGED
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# flow-parser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A JavaScript parser built from the Flow's parser compiled to WebAssembly. Can parse ES6, Flow, and JSX syntax.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What is Flow
|
|
6
6
|
|
|
7
7
|
See [flow.org](https://flow.org/). The code for the Flow parser [lives on GitHub](https://github.com/facebook/flow/tree/master/src/parser).
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
The Flow Parser is a JavaScript parser for Flow syntax. It produces an AST that conforms to the [ESTree spec](https://github.com/estree/estree).
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Language features
|
|
33
|
-
* `enableEnums` (boolean, default `true`) - enable parsing of [enums](https://flow.org/en/docs/enums/)
|
|
34
|
-
* `enableExperimentalFlowMatchSyntax` (boolean, default `true`) - enable parsing of [match expressions and match statements](https://flow.org/en/docs/match/)
|
|
35
|
-
* `enableExperimentalComponentSyntax` (boolean, default `true`) - enable parsing of [component syntax](https://flow.org/en/docs/react/component-syntax/)
|
|
36
|
-
* `assertOperator` (boolean, default `false`) - enable parsing of the assert operator
|
|
37
|
-
* `enableExperimentalDecorators` (boolean, default `true`) - enable parsing of decorators
|
|
9
|
+
## What is the Flow Parser
|
|
10
|
+
|
|
11
|
+
The Flow Parser is a JavaScript parser for Flow syntax. It produces an AST that conforms to the [ESTree spec](https://github.com/estree/estree).
|
|
12
|
+
|
|
13
|
+
## API
|
|
14
|
+
The Flow parser exposes a single `parse(code, [options])` function, where `code` is the source code to parse as a string, and `options` is an optional object that may contain the following properties:
|
|
15
|
+
- **babel**: `boolean`, defaults to `false`. If `true`, output an AST conforming to Babel's AST format. If `false`, output an AST conforming to the ESTree AST format.
|
|
16
|
+
- **allowReturnOutsideFunction**: `boolean`, defaults to `false`. If `true`, do not error on return statements found outside functions.
|
|
17
|
+
- **assertOperator**: `boolean`, defaults to `false`. If `true`, enable Flow's postfix non-null assertion syntax (`value!`).
|
|
18
|
+
- **flow**: `"all"` or `"detect"`, defaults to `"detect"`. If `"detect"`, only parse syntax as Flow syntax where it is ambiguous whether it is a Flow feature or regular JavaScript when the `@flow` pragma is present in the file. Otherwise if `"all"`, always parse ambiguous syntax as Flow syntax regardless of the presence of an `@flow` pragma. For example `foo<T>(x)` in a file without an `@flow` pragma will be parsed as two comparisons if set to `"detect"`, otherwise if set to `"all"` or the `@flow` pragma is included it will be parsed as a call expression with a type argument.
|
|
19
|
+
- **enableExperimentalComponentSyntax**: `boolean`, defaults to `true`. Controls parsing of Flow component syntax.
|
|
20
|
+
- **enableExperimentalFlowMatchSyntax**: `boolean`, defaults to `true`. Controls parsing of Flow match syntax.
|
|
21
|
+
- **enableExperimentalFlowRecordSyntax**: `boolean`, defaults to `true`. Controls parsing of Flow record syntax.
|
|
22
|
+
- **reactRuntimeTarget**: `"18"` or `"19"`, defaults to `"18"`. Controls how component `ref` parameters are lowered when `babel` is `true`. React 18 treats `ref` as a separate parameter; React 19 treats it as a regular prop.
|
|
23
|
+
- **sourceFilename**: `string`, defaults to `null`. The filename corresponding to the code that is to be parsed. If non-null, the filename will be added to all source locations in the output AST.
|
|
24
|
+
- **sourceType**: `"module"`, `"script"`, or `"unambiguous"` (default). If `"unambiguous"`, source type will be automatically detected and set to `"module"` if any ES6 imports or exports are present in the code, otherwise source type will be set to `"script"`.
|
|
25
|
+
- **throwOnParseErrors**: `boolean`, defaults to `true`. If `true`, throw a `SyntaxError` for the first parse error. If `false`, return the partial AST with parse errors in the root node's `errors` property.
|
|
26
|
+
- **tokens**: `boolean`, defaults to `false`. If `true`, add all tokens to a `tokens` property on the root node.
|
|
27
|
+
- **transformOptions**: `object`. Options to be supplied to relevant transforms.
|
|
28
|
+
- `TransformEnumSyntax`
|
|
29
|
+
- `enable`: `boolean` - Whether to enable the transform. By default, `false`.
|
|
30
|
+
- `getRuntime` (optional): `() => Expression` - The expression which should be a reference to the Flow Enums runtime. By default, is `require('flow-enums-runtime')`.
|