Skip to content

Plugin crashes in combination with prettier-plugin-tailwindcss #240

@adammakesthingsdev

Description

@adammakesthingsdev

This took me a long time to figure out so it would be great if something could be added to the README.
I have prettier-plugin-tailwind and -jsdoc installed, and for whatever reason, Prettier will crash if prettier-plugin-tailwindcss is before prettier-plugin-jsdoc.

Based on an error I got at one point and do not currently know how to reproduce, here's my guess of what's happening (with absolutely no idea how the prettier-plugin system works):

  • Prettier first does its core format, then maps every defined plugin to its respective formatting function
  • Each formatter is expected to pass back a "formatted document" object of some kind with fields defined by the prettier initial formatting
  • One of these is a "comments" field which contains some representation of all of the comments in the document
  • The TailwindCSS plugin does not include this field in the object it returns, or strips it
  • prettier-plugin-jsdoc spits out an error because it's undefined (Cannot read properties of undefined (reading 'map'))

Another easier-to-reproduce error that often occured was the much less specific

["ERROR" - 2:30:52 PM] Error formatting document.
["ERROR" - 2:30:52 PM] Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at Object.originalParser (file:///<mypath>/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:1329:22902)
    at preprocess (file:///<mypath>/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:1329:26956)

This is noticeably different from a recent issue #212 , which claims the opposite. This suggests to me that this module is likely also not returning all of the original formatted object.

Again, this is just my $0.02 as someone with no understanding of this framework, but some kind of warning in the README would be great so people like me don't spend an hour uninstalling and reinstalling packages and having smoke billow from their ears.

- Adam

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions