(plugins, parserName)
| 11 | } from "./front-matter/index.js"; |
| 12 | |
| 13 | function 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 | |
| 38 | function getPrinterPluginByAstFormat(plugins, astFormat) { |
| 39 | if (!astFormat) { |
no outgoing calls
no test coverage detected
searching dependent graphs…