MCPcopy
hub / github.com/prettier/prettier / getParserPluginByParserName

Function getParserPluginByParserName

src/main/parser-and-printer.js:13–36  ·  view source on GitHub ↗
(plugins, parserName)

Source from the content-addressed store, hash-verified

11} from "./front-matter/index.js";
12
13function getParserPluginByParserName(plugins, parserName) {
14 if (!parserName) {
15 throw new Error("parserName is required.");
16 }
17
18 /*
19 Loop from end to allow plugins override builtin plugins,
20 this is how `resolveParser` works in v2.
21 This is a temporarily solution, see #13729
22 */
23 const plugin = plugins.findLast(
24 (plugin) => plugin.parsers && Object.hasOwn(plugin.parsers, parserName),
25 );
26 if (plugin) {
27 return plugin;
28 }
29
30 let message = `Couldn't resolve parser "${parserName}".`;
31 if (process.env.PRETTIER_TARGET === "universal") {
32 message += " Plugins must be explicitly added to the standalone bundle.";
33 }
34
35 throw new ConfigError(message);
36}
37
38function getPrinterPluginByAstFormat(plugins, astFormat) {
39 if (!astFormat) {

Callers 4

normalizeFormatOptionsFunction · 0.90
funcFunction · 0.90
resolveParserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…