Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Salesforce APEX not getting formatted by Prettier past VSCode version 1.91 #3574

Open
BJDaul opened this issue Nov 20, 2024 · 0 comments
Open

Comments

@BJDaul
Copy link

BJDaul commented Nov 20, 2024

Summary

Version 1.91.1 of Visual Studio Code looks like it was the last version to work with Salesforce APEX formatting using Prettier.

When a downgrade of VSCode to version 1.91.1 is executed then Prettier does work as expected.

Github Repository to Reproduce Issue

This is the link to our GITHUB repository. We do not work directly in the repository.
We work locally in VSCode. https://gitlab.com/wisconsindhs/access/accessmain

Steps To Reproduce:

  1. Modify the document.
  2. Save the document.
  3. Prettier Icon turns red and no checkboxes are on it.

Expected result

  1. Modify the document.
  2. Save the document.
  3. Prettier Icon contains double checkboxes at the bottom of VSCode. Document is formatted.

Actual result

  1. Modify the document.
  2. Save the document.
  3. Prettier Icon turns red and no checkboxes at the bottom of VSCode. Document is not formatted.

Additional information

Bad Prettier
Format
Another Bad Prettier

VS Code Version:

Version: 1.93.0 (user setup)
Commit: 4849ca9bdf9666755eb463db297b69e5385090e3
Date: 2024-09-04T13:02:38.431Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

Prettier Extension Version:
V11.0.0

OS and version:
OS: Windows_NT x64 10.0.22631

Prettier Log Output

["INFO" - 12:56:34 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 12:56:34 PM] Extension Version: 11.0.0.
["DEBUG" - 12:56:34 PM] Enabling Prettier globally
{
"languageSelector": [
{
"language": "javascript"
},
{
"language": "mongo"
},
{
"language": "javascriptreact"
},
{
"language": "typescript"
},
{
"language": "typescriptreact"
},
{
"language": "json"
},
{
"language": "jsonc"
},
{
"language": "json5"
},
{
"language": "css"
},
{
"language": "postcss"
},
{
"language": "less"
},
{
"language": "scss"
},
{
"language": "handlebars"
},
{
"language": "graphql"
},
{
"language": "markdown"
},
{
"language": "mdx"
},
{
"language": "html"
},
{
"language": "vue"
},
{
"language": "yaml"
},
{
"language": "ansible"
},
{
"language": "home-assistant"
},
{
"language": "jsonc",
"scheme": "vscode-userdata"
}
],
"rangeLanguageSelector": [
{
"language": "javascript"
},
{
"language": "javascriptreact"
},
{
"language": "typescript"
},
{
"language": "typescriptreact"
},
{
"language": "json"
},
{
"language": "jsonc"
},
{
"language": "graphql"
}
]
}
["DEBUG" - 12:56:59 PM] Local prettier module path: c:__Deloitte\accessmain\node_modules\prettier\index.js
["DEBUG" - 12:56:59 PM] Using prettier version 2.7.1
["DEBUG" - 12:56:59 PM] Enabling Prettier for Workspace c:__Deloitte\accessmain
{
"languageSelector": [
{
"pattern": "c:\__Deloitte\accessmain/**/*.{js,_js,bones,cjs,es,es6,frag,gs,jake,javascript,jsb,jscad,jsfl,jslib,jsm,jspre,jss,mjs,njs,pac,sjs,ssjs,xsjs,xsjslib,wxs,js.flow,jsx,ts,cts,mts,tsx,importmap,json,4DForm,4DProject,avsc,geojson,gltf,har,ice,JSON-tmLanguage,mcmeta,tfstate,tfstate.backup,topojson,webapp,webmanifest,yy,yyp,jsonc,code-snippets,sublime-build,sublime-commands,sublime-completions,sublime-keymap,sublime-macro,sublime-menu,sublime-mousemap,sublime-project,sublime-settings,sublime-theme,sublime-workspace,sublime_metrics,sublime_session,json5,css,wxss,pcss,postcss,less,scss,handlebars,hbs,graphql,gql,graphqls,md,livemd,markdown,mdown,mdwn,mkd,mkdn,mkdown,ronn,scd,workbook,mdx,component.html,html,hta,htm,html.hl,inc,xht,xhtml,mjml,vue,yml,mir,reek,rviz,sublime-syntax,syntax,yaml,yaml-tmlanguage,yaml.sed,yml.mysql,cls,trigger,apex}",
"scheme": "file"
},
{
"language": "javascript"
},
{
"language": "mongo"
},
{
"language": "javascriptreact"
},
{
"language": "typescript"
},
{
"language": "typescriptreact"
},
{
"language": "json"
},
{
"language": "jsonc"
},
{
"language": "json5"
},
{
"language": "css"
},
{
"language": "postcss"
},
{
"language": "less"
},
{
"language": "scss"
},
{
"language": "handlebars"
},
{
"language": "graphql"
},
{
"language": "markdown"
},
{
"language": "mdx"
},
{
"language": "html"
},
{
"language": "vue"
},
{
"language": "yaml"
},
{
"language": "ansible"
},
{
"language": "home-assistant"
},
{
"language": "apex"
},
{
"language": "apex-anon"
},
{
"language": "jsonc",
"scheme": "vscode-userdata"
}
],
"rangeLanguageSelector": [
{
"language": "javascript"
},
{
"language": "javascriptreact"
},
{
"language": "typescript"
},
{
"language": "typescriptreact"
},
{
"language": "json"
},
{
"language": "jsonc"
},
{
"language": "graphql"
}
]
}
["INFO" - 12:57:21 PM] Formatting file:///c%3A/__Deloitte/accessmain/force-app/main/default/classes/HMOProviderSearchUtility.cls
["DEBUG" - 12:57:21 PM] Local prettier module path: c:__Deloitte\accessmain\node_modules\prettier\index.js
["DEBUG" - 12:57:21 PM] Using prettier version 2.7.1
["INFO" - 12:57:21 PM] Using config file at c:__Deloitte\accessmain.prettierrc
["DEBUG" - 12:57:21 PM] Local prettier module path: c:__Deloitte\accessmain\node_modules\prettier\index.js
["INFO" - 12:57:21 PM] PrettierInstance:
{
"modulePath": "c:\__Deloitte\accessmain\node_modules\prettier\index.js",
"version": "2.7.1",
"prettierModule": {
"doc": {
"builders": {
"line": {
"type": "line"
},
"softline": {
"type": "line",
"soft": true
},
"hardline": {
"type": "concat",
"parts": [
{
"type": "line",
"hard": true
},
{
"type": "break-parent"
}
]
},
"literalline": {
"type": "concat",
"parts": [
{
"type": "line",
"hard": true,
"literal": true
},
{
"type": "break-parent"
}
]
},
"lineSuffixBoundary": {
"type": "line-suffix-boundary"
},
"cursor": {
"type": "cursor"
},
"breakParent": {
"type": "break-parent"
},
"trim": {
"type": "trim"
},
"hardlineWithoutBreakParent": {
"type": "line",
"hard": true
},
"literallineWithoutBreakParent": {
"type": "line",
"hard": true,
"literal": true
}
},
"printer": {},
"utils": {},
"debug": {}
},
"version": "2.7.1",
"util": {},
"__internal": {
"errors": {},
"coreOptions": {
"CATEGORY_CONFIG": "Config",
"CATEGORY_EDITOR": "Editor",
"CATEGORY_FORMAT": "Format",
"CATEGORY_OTHER": "Other",
"CATEGORY_OUTPUT": "Output",
"CATEGORY_GLOBAL": "Global",
"CATEGORY_SPECIAL": "Special",
"options": {
"cursorOffset": {
"since": "1.4.0",
"category": "Special",
"type": "int",
"default": -1,
"range": {
"start": -1,
"end": null,
"step": 1
},
"description": "Print (to stderr) where a cursor at the given position would move to after formatting.\nThis option cannot be used with --range-start and --range-end.",
"cliCategory": "Editor"
},
"endOfLine": {
"since": "1.15.0",
"category": "Global",
"type": "choice",
"default": [
{
"since": "1.15.0",
"value": "auto"
},
{
"since": "2.0.0",
"value": "lf"
}
],
"description": "Which end of line characters to apply.",
"choices": [
{
"value": "lf",
"description": "Line Feed only (\n), common on Linux and macOS as well as inside git repos"
},
{
"value": "crlf",
"description": "Carriage Return + Line Feed characters (\r\n), common on Windows"
},
{
"value": "cr",
"description": "Carriage Return character only (\r), used very rarely"
},
{
"value": "auto",
"description": "Maintain existing\n(mixed values within one file are normalised by looking at what's used after the first line)"
}
]
},
"filepath": {
"since": "1.4.0",
"category": "Special",
"type": "path",
"description": "Specify the input filepath. This will be used to do parser inference.",
"cliName": "stdin-filepath",
"cliCategory": "Other",
"cliDescription": "Path to the file to pretend that stdin comes from."
},
"insertPragma": {
"since": "1.8.0",
"category": "Special",
"type": "boolean",
"default": false,
"description": "Insert @Format pragma into file's first docblock comment.",
"cliCategory": "Other"
},
"parser": {
"since": "0.0.10",
"category": "Global",
"type": "choice",
"default": [
{
"since": "0.0.10",
"value": "babylon"
},
{
"since": "1.13.0"
}
],
"description": "Which parser to use.",
"choices": [
{
"value": "flow",
"description": "Flow"
},
{
"value": "babel",
"since": "1.16.0",
"description": "JavaScript"
},
{
"value": "babel-flow",
"since": "1.16.0",
"description": "Flow"
},
{
"value": "babel-ts",
"since": "2.0.0",
"description": "TypeScript"
},
{
"value": "typescript",
"since": "1.4.0",
"description": "TypeScript"
},
{
"value": "acorn",
"since": "2.6.0",
"description": "JavaScript"
},
{
"value": "espree",
"since": "2.2.0",
"description": "JavaScript"
},
{
"value": "meriyah",
"since": "2.2.0",
"description": "JavaScript"
},
{
"value": "css",
"since": "1.7.1",
"description": "CSS"
},
{
"value": "less",
"since": "1.7.1",
"description": "Less"
},
{
"value": "scss",
"since": "1.7.1",
"description": "SCSS"
},
{
"value": "json",
"since": "1.5.0",
"description": "JSON"
},
{
"value": "json5",
"since": "1.13.0",
"description": "JSON5"
},
{
"value": "json-stringify",
"since": "1.13.0",
"description": "JSON.stringify"
},
{
"value": "graphql",
"since": "1.5.0",
"description": "GraphQL"
},
{
"value": "markdown",
"since": "1.8.0",
"description": "Markdown"
},
{
"value": "mdx",
"since": "1.15.0",
"description": "MDX"
},
{
"value": "vue",
"since": "1.10.0",
"description": "Vue"
},
{
"value": "yaml",
"since": "1.14.0",
"description": "YAML"
},
{
"value": "glimmer",
"since": "2.3.0",
"description": "Ember / Handlebars"
},
{
"value": "html",
"since": "1.15.0",
"description": "HTML"
},
{
"value": "angular",
"since": "1.15.0",
"description": "Angular"
},
{
"value": "lwc",
"since": "1.17.0",
"description": "Lightning Web Components"
}
]
},
"plugins": {
"since": "1.10.0",
"type": "path",
"array": true,
"default": [
{
"value": []
}
],
"category": "Global",
"description": "Add a plugin. Multiple plugins can be passed as separate --plugins.",
"cliName": "plugin",
"cliCategory": "Config"
},
"pluginSearchDirs": {
"since": "1.13.0",
"type": "path",
"array": true,
"default": [
{
"value": []
}
],
"category": "Global",
"description": "Custom directory that contains prettier plugins in node_modules subdirectory.\nOverrides default behavior when plugins are searched relatively to the location of Prettier.\nMultiple values are accepted.",
"cliName": "plugin-search-dir",
"cliCategory": "Config"
},
"printWidth": {
"since": "0.0.0",
"category": "Global",
"type": "int",
"default": 80,
"description": "The line length where Prettier will try wrap.",
"range": {
"start": 0,
"end": null,
"step": 1
}
},
"rangeEnd": {
"since": "1.4.0",
"category": "Special",
"type": "int",
"default": null,
"range": {
"start": 0,
"end": null,
"step": 1
},
"description": "Format code ending at a given character offset (exclusive).\nThe range will extend forwards to the end of the selected statement.\nThis option cannot be used with --cursor-offset.",
"cliCategory": "Editor"
},
"rangeStart": {
"since": "1.4.0",
"category": "Special",
"type": "int",
"default": 0,
"range": {
"start": 0,
"end": null,
"step": 1
},
"description": "Format code starting at a given character offset.\nThe range will extend backwards to the start of the first line containing the selected statement.\nThis option cannot be used with --cursor-offset.",
"cliCategory": "Editor"
},
"requirePragma": {
"since": "1.7.0",
"category": "Special",
"type": "boolean",
"default": false,
"description": "Require either '@prettier' or '@Format' to be present in the file's first docblock comment\nin order for it to be formatted.",
"cliCategory": "Other"
},
"tabWidth": {
"type": "int",
"category": "Global",
"default": 2,
"description": "Number of spaces per indentation level.",
"range": {
"start": 0,
"end": null,
"step": 1
}
},
"useTabs": {
"since": "1.0.0",
"category": "Global",
"type": "boolean",
"default": false,
"description": "Indent with tabs instead of spaces."
},
"embeddedLanguageFormatting": {
"since": "2.1.0",
"category": "Global",
"type": "choice",
"default": [
{
"since": "2.1.0",
"value": "auto"
}
],
"description": "Control how Prettier formats quoted code embedded in the file.",
"choices": [
{
"value": "auto",
"description": "Format embedded code if Prettier can automatically identify it."
},
{
"value": "off",
"description": "Never automatically format embedded code."
}
]
}
}
},
"optionsModule": {
"hiddenDefaults": {
"astFormat": "estree",
"printer": {},
"locStart": null,
"locEnd": null
}
},
"optionsNormalizer": {},
"utils": {}
},
"__debug": {}
}
}
["INFO" - 12:57:21 PM] Using ignore file (if present) at c:__Deloitte\accessmain.prettierignore
["INFO" - 12:57:21 PM] File Info:
{
"ignored": false,
"inferredParser": "apex"
}
["INFO" - 12:57:21 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 12:57:21 PM] Prettier Options:
{
"filepath": "c:\__Deloitte\accessmain\force-app\main\default\classes\HMOProviderSearchUtility.cls",
"parser": "apex",
"trailingComma": "none",
"useTabs": true,
"tabWidth": 4,
"bracketSpacing": true,
"printWidth": 120,
"singleQuote": true,
"arrowParens": "always"
}
["ERROR" - 12:57:21 PM] Error formatting document.
Error: spawnSync c:__Deloitte\accessmain\node_modules\prettier-plugin-apex\vendor\apex-ast-serializer\bin\apex-ast-serializer.bat EINVAL
at Object.spawnSync (node:internal/child_process:1124:20)
at spawnSync (node:child_process:915:24)
at parseTextWithSpawn (c:__Deloitte\accessmain\node_modules\prettier-plugin-apex\dist\src\parser.js:47:59)
at Object.parse (c:__Deloitte\accessmain\node_modules\prettier-plugin-apex\dist\src\parser.js:472:25)
at Object.parse (c:__Deloitte\accessmain\node_modules\prettier\index.js:7334:23)
at coreFormat (c:__Deloitte\accessmain\node_modules\prettier\index.js:8645:18)
at formatWithCursor2 (c:__Deloitte\accessmain\node_modules\prettier\index.js:8837:18)
at c:__Deloitte\accessmain\node_modules\prettier\index.js:37229:12
at Object.format (c:__Deloitte\accessmain\node_modules\prettier\index.js:37243:12)
at t.PrettierMainThreadInstance.format (c:\Users\bdaul.vscode\extensions\esbenp.prettier-vscode-11.0.0\dist\extension.js:1:18388)
at t.default.format (c:\Users\bdaul.vscode\extensions\esbenp.prettier-vscode-11.0.0\dist\extension.js:1:16431)
at async t.PrettierEditProvider.provideEdits (c:\Users\bdaul.vscode\extensions\esbenp.prettier-vscode-11.0.0\dist\extension.js:1:12989)
at async j.provideDocumentFormattingEdits (c:\Users\bdaul\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:161:112552)
["INFO" - 12:57:21 PM] Formatting completed in 251ms.

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

No branches or pull requests

1 participant