Skip to content

fix: add compatibility with prettier v3.6.0#246

Merged
danielpza merged 2 commits intofardad-dev:masterfrom
azat-io:fix/null-tokens
Jun 27, 2025
Merged

fix: add compatibility with prettier v3.6.0#246
danielpza merged 2 commits intofardad-dev:masterfrom
azat-io:fix/null-tokens

Conversation

@azat-io
Copy link
Copy Markdown
Contributor

@azat-io azat-io commented Jun 24, 2025

Closes #245.

Plugin crashes with TypeError: Cannot read properties of undefined (reading 'length') when using Prettier 3.6.0 due to changes in the AST structure where ast.tokens can be undefined.

Added defensive checks in two places:

  • parser.ts: Check if ast.tokens exists before calling findTokenIndex
  • utils.ts: Add null/undefined guards in findTokenIndex function
  • getParamsOrders: Handle case when tokenIndex is -1

@danielpza
Copy link
Copy Markdown
Collaborator

@azat-io can you add a test or update the prettier version in the package.json to the latest to check that it works on the latest prettier version?

@azat-io
Copy link
Copy Markdown
Contributor Author

azat-io commented Jun 26, 2025

Done!

@danielpza danielpza merged commit a50b62e into fardad-dev:master Jun 27, 2025
3 checks passed
@vincerubinetti
Copy link
Copy Markdown
Contributor

Thanks for the fix. Just curious, what's your release process? I.e., when can we expect this change to land on NPM?

@fardad-dev
Copy link
Copy Markdown
Owner

Released v1.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Crash on format using Prettier 3.6.0 with prettier-plugin-jsdoc

4 participants