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

Update Prettier to 1.19.x and implement XML support #104

Closed
muenzpraeger opened this issue Nov 27, 2019 · 7 comments · Fixed by #108
Closed

Update Prettier to 1.19.x and implement XML support #104

muenzpraeger opened this issue Nov 27, 2019 · 7 comments · Fixed by #108
Labels
enhancement New feature or request

Comments

@muenzpraeger
Copy link
Contributor

What is missing from the application? Please describe.
XML formatting is currently not enforced.

Describe the solution you'd like
With Prettier 1.19.x and forward XML support got added. For that the Pretter XML Plugin needs to be added as dev dependency, and the scripts need to be updated.

@pozil pozil added the enhancement New feature or request label Nov 27, 2019
@pozil
Copy link
Contributor

pozil commented Nov 28, 2019

@muenzpraeger I just tried that and the outcome is not so good.
Prettier modifies about 150 *-meta.xml files and that causes a series of deployment errors.
Ignoring *-meta.xml only prettifies /mdapiDeploy/unpackaged/package.xml. All in all, the added value of prettifying xml is rather limited for this project.
Let me know if you want to proceed anyway.

@muenzpraeger
Copy link
Contributor Author

Please assess the reason of deployment errors, and raise issues accordingly to the team.

@pozil
Copy link
Contributor

pozil commented Nov 29, 2019

Found a first issue that could be the source: prettier introduces line breaks in tag content and our Metadata API doesn't like that for certain types like booleans.

Example in force-app/main/default/sites/E_Bikes.site-meta.xml:

<referrerPolicyOriginWhenCrossOrigin>true</referrerPolicyOriginWhenCrossOrigin>

is prettified to:

<referrerPolicyOriginWhenCrossOrigin>
  true
</referrerPolicyOriginWhenCrossOrigin>

This causes the following error when pushing source (scroll right to see the error message):

Error parsing file: '
                                                                                           true
                                                                                       ' is not valid for type xsd:boolean, should be '0', '1', 'true' or 'false' (23:43)

I assume that values are not trimmed when parsed by our Metadata API backend.

@pozil
Copy link
Contributor

pozil commented Nov 29, 2019

There's no Prettier rule to prevent that from happening in XML so the only option would be to ask the Metadata API team to change their parsing code. TBH I'm not willing to dedicate more energy to this because these files are auto generated and should generally not be hand edited.
Feel free to push that as a bug but I think that we can proceed with *-meta.xml in .prettierignore.

@muenzpraeger
Copy link
Contributor Author

I opened a bug on that repo. Ignoring the files is not an option, we should work with the plugin author to resolve these kinds of issues.

@pozil
Copy link
Contributor

pozil commented Dec 9, 2019

Ok, sorry, I thought that you wanted to change things on the metadata API parser.
It looks like we aren't the only ones having issues with whitespaces formatting so there's a change that this can be addressed by the prettier plugin.

@pozil
Copy link
Contributor

pozil commented Jan 22, 2020

Prettier xml plugin bug is now fixed. PR #108 is updated with the new plugin version and it works fine.
Please review @muenzpraeger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants