File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,7 +277,25 @@ async function formatCode(
277277}
278278
279279const findPluginByParser = ( parserName : string , options : ParserOptions ) => {
280- const tsPlugin = options . plugins . find ( ( plugin ) => {
280+ const plugins = options . plugins ?? [ ] ;
281+
282+ // Only consider plugins that appear *before* prettier-plugin-jsdoc.
283+ // Plugins that appear after us typically wrap our parser; delegating to them
284+ // from our parse/preprocess hooks can create infinite recursion.
285+ const jsdocIndex = plugins . findIndex ( ( plugin ) => {
286+ return (
287+ typeof plugin === "object" &&
288+ plugin !== null &&
289+ ! ( plugin instanceof URL ) &&
290+ ( plugin as any ) . name &&
291+ ( plugin as any ) . name === "prettier-plugin-jsdoc"
292+ ) ;
293+ } ) ;
294+
295+ const searchPlugins =
296+ jsdocIndex === - 1 ? plugins : plugins . slice ( 0 , jsdocIndex ) ;
297+
298+ const tsPlugin = searchPlugins . find ( ( plugin ) => {
281299 return (
282300 typeof plugin === "object" &&
283301 plugin !== null &&
You can’t perform that action at this time.
0 commit comments