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

Function parseEmptyJson

src/language-json/parse/json.js:16–32  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

14};
15
16function parseEmptyJson(text) {
17 const file = parse(text, babelParseOptions);
18
19 const { program } = file;
20
21 // Not an empty JSON
22 /* c8 ignore next */
23 if (!(
24 program.body.length === 0 &&
25 program.directives.length === 0 &&
26 !program.interpreter
27 )) {
28 return;
29 }
30
31 return { comments: file.comments };
32}
33
34function parseJson(text, options = {}) {
35 const { allowComments = true, allowEmpty = false } = options;

Callers 1

parseJsonFunction · 0.85

Calls 1

parseFunction · 0.90

Tested by

no test coverage detected