MCPcopy Create free account
hub / github.com/prettier/prettier / tryParse

Function tryParse

scripts/sync-flow-tests.cjs:12–36  ·  view source on GitHub ↗
(file, content)

Source from the content-addressed store, hash-verified

10const FLOW_TESTS_DIR = path.join(__dirname, "../tests/format/flow/flow-repo");
11
12function tryParse(file, content) {
13 // Keep this sync with `/src/language-js/parse/flow.js`
14 const ast = flowParse(content, {
15 sourceFilename: file,
16 flow: "all",
17 babel: false,
18 tokens: false,
19 allowReturnOutsideFunction: true,
20 enableEnums: true,
21 enableExperimentalFlowMatchSyntax: true,
22 enableExperimentalComponentSyntax: true,
23 // assertOperator: true,
24 enableExperimentalDecorators: true,
25 enableExperimentalFlowRecordSyntax: true,
26 throwOnParseErrors: false,
27 });
28
29 if (ast.errors.length > 0) {
30 const { line, column } = ast.errors[0].loc.start;
31 const { message } = ast.errors[0];
32 return `${file}:${line}:${column}: ${message}`;
33 }
34
35 return null;
36}
37
38function syncTests(syncDir) {
39 const specFiles = fastGlob.sync(

Callers 1

syncTestsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected