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

Function createParseError

src/language-js/parse/flow.js:28–48  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

26};
27
28function createParseError(error) {
29 let { message, loc } = error;
30
31 /* c8 ignore next 3 */
32 if (!loc) {
33 return error;
34 }
35
36 const { line, column } = loc;
37 const suffix = ` (${line}:${column})`;
38 if (message.endsWith(suffix)) {
39 message = message.slice(0, -suffix.length);
40 }
41
42 return createError(message, {
43 loc: {
44 start: { line, column: column + 1 },
45 },
46 cause: error,
47 });
48}
49
50function parse(text, options) {
51 const filepath = options?.filepath;

Callers 1

parseFunction · 0.70

Calls 1

createErrorFunction · 0.85

Tested by

no test coverage detected