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

Function parse

src/language-js/parse/espree.js:40–56  ·  view source on GitHub ↗
(text, options)

Source from the content-addressed store, hash-verified

38}
39
40function parse(text, options) {
41 const sourceType = getSourceType(options?.filepath);
42 const combinations = (
43 sourceType ? [sourceType] : SOURCE_TYPE_COMBINATIONS
44 ).map(
45 (sourceType) => () => espreeParse(text, { ...parseOptions, sourceType }),
46 );
47
48 let ast;
49 try {
50 ast = tryCombinationsSync(combinations);
51 } catch (/** @type {any} */ { errors: [error] }) {
52 throw createParseError(error);
53 }
54
55 return postprocess(ast, { text, astType: "espree" });
56}
57
58export const espree = /* @__PURE__ */ createParser(parse);

Callers

nothing calls this directly

Calls 5

getSourceTypeFunction · 0.90
tryCombinationsSyncFunction · 0.90
createParseErrorFunction · 0.70
postprocessFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected