Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does Prettier wrap my anonymous function with another anonymous function call and how do I turn it off?

Here is the original code:

namespace.namespace2 = new function() {/* logic here*/}

After using Prettier:

namespace.namespace2 = new (function() {/* logic here*/})();

Why? I want an option to disable this, but can’t find it documented anywhere.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I went into the Prettier playground area on their site, put in the code from the example above, and fiddled around with all settings, nothing worked.

I’ve then searched through the Prettier documentation, obviously tried to search for an answer, but I could only find posts unrelated to my issue.

>Solution :

This works as intended and was introduced with prettier v1.17.0. For more information about the reasons, see the pull request and linked issues. To summarize: It enforces a consistent syntax. There is no configuration option to change this behavior, and prettier won’t add such an option, see prettier’s option philosophy.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading