Description
Self-Troubleshooting Checklist
- Are you running Prettier Apex >= 2.0.0? If Yes, have you gone through the Upgrade Guide?
- Are you running VSCode and recently upgraded Prettier or Prettier Apex? If Yes, have you restarted VSCode after the upgrade?
Describe your issue
While running formatting it returns me back following error:
TypeError: Cannot read properties of undefined (reading 'startIndex')
at locStart (node_modules/prettier-plugin-apex/dist/src/index.js:24:21)
at nodeContainsCursor (node_modules/prettier/index.mjs:20212:40)
at isMatchedNode (node_modules/prettier/index.mjs:18792:64)
at getChildren (node_modules/prettier/index.mjs:18801:16)
at getChildren.next ()
at getDescendants (node_modules/prettier/index.mjs:18810:16)
at getDescendants.next ()
at getCursorLocation (node_modules/prettier/index.mjs:20215:14)
at coreFormat (node_modules/prettier/index.mjs:20535:10)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Process finished with exit code -1
I'm using Webstorm + Illuminated Cloud plugin.
Issues started to happen after updates.
I already did install of all of the dependencies from the scratch.(Removed node_modules, updated node.js, updated java to 24v and etc).
Prettier options (if any)
{
"printWidth": 160,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "auto",
"plugins": ["prettier-plugin-apex"],
"apexInsertFinalNewline": false,
"overrides": [
{
"files": "**/lwc/**/*.html",
"options": { "parser": "lwc" }
},
{
"files": "**/*.{cmp,page,component}",
"options": { "parser": "html" }
}
]
}
System Info
System:
OS: macOS 15.4.1
CPU: (8) arm64 Apple M1 Pro
Memory: 2.97 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.15.0 - /usr/local/bin/node
npm: 11.3.0 - /usr/local/bin/npm
Languages:
Bash: 3.2.57 - /bin/bash
Java: 24.0.1 - /usr/bin/javac
Perl: 5.34.1 - /usr/bin/perl
Python3: 3.9.6 - /usr/bin/python3
Ruby: 2.6.10 - /usr/bin/ruby
npmPackages:
@prettier-apex/apex-ast-serializer-darwin-arm64: 2.2.6
@prettier/plugin-xml: ^3.4.1 => 3.4.1
prettier: ^3.5.3 => 3.5.3
prettier-plugin-apex: ^2.2.6 => 2.2.6