prettier / plugin-xml

Prettier XML plugin
MIT License
234 stars 33 forks source link

Plugin doesn't work with latest version of prettier #780

Closed cnwork closed 6 months ago

cnwork commented 6 months ago

I've updated my package.json with the latest version of the plugin and although I added the plugin in the .prettierrc file like so:

{
  "trailingComma": "none",
  "plugins": ["@prettier/plugin-xml"],
  "overrides": [
    {
      "files": "*.xml",
      "options": { "parser": "xml" }
    }
  ]
}

when running (as per documentation) ./node_modules/.bin/prettier --plugin=@prettier/plugin-xml --write '*.xml' the files get parsed but the result is (unchanged) and in fact, the actual file isn't formatted. I modified it to be completely unformatted and the above command, although it does complete, it just don't do anything to the file.

"prettier": "^3.2.5",
"@prettier/plugin-xml": "^3.4.1",

When trying to use it in VSCode, this is what I get as output:

["INFO" - 4:20:04 PM] Using config file at /home/ubnt2204/workspace/.../.prettierrc
["INFO" - 4:20:11 PM] Formatting file:///home/ubnt2204/workspace/.../test.xml
["INFO" - 4:20:11 PM] Using config file at /home/ubnt2204/workspace/.../.prettierrc
["INFO" - 4:20:11 PM] PrettierInstance:
{
  "modulePath": "/home/ubnt2204/workspace/.../node_modules/prettier/index.cjs",
  "importResolver": {},
  "callMethodResolvers": {},
  "currentCallMethodId": 39,
  "version": "3.2.5"
}
["INFO" - 4:20:11 PM] Using ignore file (if present) at /home/ubnt2204/workspace/.../.prettierignore
["INFO" - 4:20:11 PM] File Info:
{
  "ignored": false,
  "inferredParser": "xml"
}
["INFO" - 4:20:11 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 4:20:11 PM] Prettier Options:
{
  "filepath": "/home/ubnt2204/workspace/.../test.xml",
  "parser": "xml",
  "trailingComma": "none",
  "plugins": [
    "/home/ubnt2204/workspace/.../node_modules/@prettier/plugin-xml/src/plugin.js",
    "/home/ubnt2204/workspace/.../node_modules/prettier-plugin-apex/dist/src/index.js"
  ]
}
["INFO" - 4:20:11 PM] Formatting completed in 14ms.

Contents of the test.xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>59.0</apiVersion>
    <packageVersions>
        <majorNumber>1</majorNumber>
        <minorNumber>630</minorNumber>
        <namespace>TEST</namespace> </packageVersions>  <packageVersions>
     <majorNumber>4</majorNumber>   <minorNumber>29</minorNumber>
 <namespace>TestSpace</namespace>
    </packageVersions>
    <status>Active</status>
</ApexClass>

Any help would be greatly appreciated!

Thanks, C

kddnewton commented 6 months ago

Please read the README https://github.com/prettier/plugin-xml?tab=readme-ov-file#whitespace