" RangeError: Maximum call stack size exceeded" with prettier-plugin-jsdoc
What version of prettier-plugin-tailwindcss are you using?
v0.7.2
What version of Tailwind CSS are you using?
v4.1.7
What version of Node.js are you using?
v22.18.0
What package manager are you using?
pnpm
What operating system are you using?
macOS
Reproduction URL
A public GitHub repo that includes a minimal reproduction of the bug. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private/confidential, since we want a link to a separate, isolated reproduction anyways. Unfortunately we can't provide support without a reproduction, and your issue will be closed with no comment if this is not provided.
Describe your issue
ESLint v3.38.0, 3.39.0, 3.39.1 Prettier v3.74 prettier-plugin-jsdoc v1.7.1, 1.8.0
When it uses with "prettier-plugin-jsdoc" then, has below errors.
$ eslint .
Oops! Something went wrong! :(
ESLint: 9.39.1
RangeError: Maximum call stack size exceeded
at findPluginByParser (file:///.../sample/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-jsdoc/dist/utils.js:162:28)
at Object.jsDocPreprocess [as preprocess] (file:///.../sample/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-jsdoc/dist/index.js:257:36)
at preprocess (file:///.../sample/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
at Object.jsDocPreprocess [as preprocess] (file:///.../sample/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
at preprocess (file:///.../sample/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
at Object.jsDocPreprocess [as preprocess] (file:///.../sample/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
at preprocess (file:///Volumes/Data%20HD/Projects/SPTek/sec_jip/nextssp/web/host/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
at Object.jsDocPreprocess [as preprocess] (file:///Volumes/Data%20HD/Projects/SPTek/sec_jip/nextssp/web/host/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
at preprocess (file:///.../sample/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
at Object.jsDocPreprocess [as preprocess] (file:///.../sample/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
ELIFECYCLE Command failed with exit code 2.
Process finished with exit code 2
- prettier.config.mjs
const config = {
singleQuote: true,
semi: true,
trailingComma: 'all',
printWidth: 180,
tabWidth: 2,
useTabs: false,
endOfLine: 'lf',
bracketSpacing: true,
arrowParens: 'always',
plugins: [
'prettier-plugin-jsdoc',
'prettier-plugin-tailwindcss',
],
// but there is no different
plugins: [
'prettier-plugin-tailwindcss',
'prettier-plugin-jsdoc',
],
};
So I looked into this some and it stopped working with v1.7 or v1.8 of the jsdoc plugin.
The core of the problem is caused by a bit of a perfect storm.
- We already had support for
prettier-plugin-jsdoc - They added support for pulling in compatible plugins by parser
The way both of these work is by pulling in the appropriate parser(s) from options.plugins in case you have other plugins registered with those parsers.
This should be fine because the parser would normally be the same instance however prettier-plugin-jsdoc has their setup such that parsers.babel is a getter and every time you access that property it recreates the parser. This means the infinite loop check inside prettier-plugin-jsdoc never runs because their internal call to mergeParsers(…) happens over and over again.
I'll need to think about this. We need to find a way to guard against plugins that might call us and can't preserve state because of lazy getters.
So I looked into this some more and even if prettier-plugin-jsdoc stopped using lazy getters their parse() would be infinitely recursive with ours as long as we try to load their plugin and they load ours. Unfortunately, this means that there's nothing we can do to directly support that plugin any longer.
I'll need to think about this a bit more but I think my course of action looks like this:
- We'll drop explicit compatibility support for
prettier-plugin-jsdoc - Tag a new release
- You will have to make sure you're on v1.8 or higher of that plugin
prettier-plugin-jsdocMUST be listed last — not our plugin — because we're now relying on them to enable plugin compatibility with our plugin instead of the other way around.
I've already tested this internally and it appears to work.
Aside: all of this plugin loading work is a bit of a hack anyway and very easily broken (as you've experienced). A better solution would for Prettier itself to support multiple plugins for the same parser but I believe that's an explicit non-goal of Prettier.
Have we found a solution to this problem, I'm still facing the same issue and I'm not sure if it's a problem on my side or not.
.prettierrc.mjs:
import preset from '@sanity/prettier-config';
/**
* @see https://prettier.io/docs/configuration
* @type {import("prettier").Config}
*/
const config = {
...preset,
plugins: [...preset.plugins, 'prettier-plugin-tailwindcss', 'prettier-plugin-jsdoc'],
// Overrides
printWidth: 120,
singleAttributePerLine: true,
semi: true,
};
export default config;
@sanity/prettier-config:
const overridableDefaults = {
endOfLine: "lf",
tabWidth: 2,
useTabs: !1
}, json5 = {
files: ["*.json5"],
options: {
quoteProps: "preserve",
singleQuote: !1
}
}, yaml = {
files: ["*.yml"],
options: {
singleQuote: !1
}
}, config = {
...overridableDefaults,
printWidth: 100,
semi: !1,
singleQuote: !0,
quoteProps: "consistent",
bracketSpacing: !1,
plugins: ["prettier-plugin-packagejson"],
overrides: [json5, yaml]
};
export {
config as default
};
//# sourceMappingURL=index.js.map
Error:
RangeError: Maximum call stack size exceeded
at Object.originalParser (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:8105)
at preprocess (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11087)
at Object.jsDocPreprocess [as preprocess] (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
at preprocess (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
at Object.jsDocPreprocess [as preprocess] (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
at preprocess (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
at Object.jsDocPreprocess [as preprocess] (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
at preprocess (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
at Object.jsDocPreprocess [as preprocess] (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-jsdoc/dist/index.js:264:33)
at preprocess (file:///home/omardiaa/Dev/Projects/website/test-omardiaa.dev/node_modules/prettier-plugin-tailwindcss/dist/index.mjs:3512:11129)
Versions:
"prettier": "^3.8.1"
"prettier-plugin-jsdoc": "^1.8.0"
"prettier-plugin-tailwindcss": "^0.7.2"