fix: prevent call stack overflow when used with prettier-plugin-tailwindcss#255
Conversation
|
LGTM, please update the README adding a note about this behavior. |
…-plugin-tailwindcss for now waiting for fardad-dev/prettier-plugin-jsdoc/pull/255.
|
@shun-shobon @danielpza Any update on when this will be merged/released? |
|
Thanks for working on this. I looked at this while I was working on #254, and I think this PR is pointing at the right problem: I think the ordering-based fix here is a bit narrower than we want, though. It avoids one Tailwind path by only looking at plugins before I tested this branch by copying over my tests from #254, and it still overflows when the chaining plugin is first. The fix over there handles this at the parser boundary instead: cache the merged parser, track active So I think this PR identified the right area, but I’d prefer the guard-based approach with regression tests over the plugin-order heuristic. Thanks again for digging into it. |
fix #254
The root cause was that
prettier-plugin-jsdocdelegates parse/preprocess to “another plugin that provides the same parser” by scanning options.plugins, but it could accidentally pick a plugin that appears afterprettier-plugin-jsdoc(e.g. tailwindcss). Since tailwindcss wraps other parsers, delegating back to it from inside jsdoc creates a circular call chain like tailwind.preprocess -> jsdoc.preprocess -> tailwind.preprocess -> ..., eventually overflowing the call stack.To prevent this,
findPluginByParser()now only considers plugins that appear beforeprettier-plugin-jsdocinoptions.plugins, avoiding delegation back into wrapper plugins while preserving compatibility with earlier parser plugins.