🧩 Summary
When formatting a JavaScript file using prettier-plugin-jsdoc with Prettier v3.6.0, the plugin crashes with:
TypeError: Cannot read properties of undefined (reading 'length')
This happens on every format attempt in a valid project with no syntax errors.
🧪 Environment
Node.js: 24.1.0
Prettier: 3.6.0
prettier-plugin-jsdoc: 1.3.2
prettier-plugin-organize-imports: 4.1.0
VS Code: v1.100.0 (Auto-format on save enabled)
OS: Linux 6.12.28-1-MANJARO (x64)
🧾 .prettierrc
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-jsdoc"]
}
🧱 Prettier Output Log (Redacted)
[INFO] Formatting file:///.../src/utility.js
[INFO] Using config file at .../.prettierrc
[INFO] PrettierInstance: { version: "3.6.0" }
[INFO] Prettier Options:
{
"filepath": ".../src/utility.js",
"parser": "babel",
"plugins": [
".../node_modules/prettier-plugin-organize-imports/index.js",
".../node_modules/prettier-plugin-jsdoc/dist/index.js"
]
}
[ERROR] Error formatting document.
[ERROR] Cannot read properties of undefined (reading 'length')
TypeError: Cannot read properties of undefined (reading 'length')
at norm (.../node_modules/binary-searching/search-bounds.js:93:27)
at Object.eq (.../node_modules/binary-searching/search-bounds.js:119:12)
at findTokenIndex (.../prettier-plugin-jsdoc/dist/utils.js:115:20)
at .../prettier-plugin-jsdoc/dist/parser.js:21:28
at Array.map (<anonymous>)
at Object.jsdocParser [as parse] (.../prettier-plugin-jsdoc/dist/parser.js:18:36)
✅ Steps to Reproduce
-
Use Prettier 3.6.0 with the .prettierrc config above.
-
Enable prettier-plugin-jsdoc.
-
Save any valid .js file with a JSDoc comment.
-
Observe crash.
✅ Expected Behavior
The plugin should not crash. File should be formatted or skipped gracefully.
🩹 Workaround
Downgrading to [email protected] resolves the issue:
📌 Notes
Looks like the bug might be due to findTokenIndex() receiving an unexpected undefined, possibly due to changes in the Prettier parser API in 3.6.0.
Let me know if a minimal reproducible repo would help — happy to provide one.
Thanks for your work on this plugin!
🧩 Summary
When formatting a JavaScript file using prettier-plugin-jsdoc with Prettier v3.6.0, the plugin crashes with:
This happens on every format attempt in a valid project with no syntax errors.
🧪 Environment
Node.js: 24.1.0
Prettier: 3.6.0
prettier-plugin-jsdoc: 1.3.2
prettier-plugin-organize-imports: 4.1.0
VS Code: v1.100.0 (Auto-format on save enabled)
OS: Linux 6.12.28-1-MANJARO (x64)
🧾 .prettierrc
{ "$schema": "https://json.schemastore.org/prettierrc.json", "plugins": ["prettier-plugin-organize-imports", "prettier-plugin-jsdoc"] }🧱 Prettier Output Log (Redacted)
✅ Steps to Reproduce
Use Prettier 3.6.0 with the .prettierrc config above.
Enable prettier-plugin-jsdoc.
Save any valid .js file with a JSDoc comment.
Observe crash.
✅ Expected Behavior
The plugin should not crash. File should be formatted or skipped gracefully.
🩹 Workaround
Downgrading to [email protected] resolves the issue:
📌 Notes
Looks like the bug might be due to findTokenIndex() receiving an unexpected undefined, possibly due to changes in the Prettier parser API in 3.6.0.
Let me know if a minimal reproducible repo would help — happy to provide one.
Thanks for your work on this plugin!