| 10 | const FLOW_TESTS_DIR = path.join(__dirname, "../tests/format/flow/flow-repo"); |
| 11 | |
| 12 | function 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 | |
| 38 | function syncTests(syncDir) { |
| 39 | const specFiles = fastGlob.sync( |