Skip to content

loose-envify doesn't play nice with prettier #9

Closed
@dgoldstein0

Description

@dgoldstein0

we have been using loose-envify for a while, and are pretty happy with it. We are now trying to add prettier to our toolchain, to run on all of our typescript files. We compile our typescript to ES5, and then run loose-envify on the result of that.

In testing this, we've discovered that we have a few lines of code like

preview_url: `https://${process.env.WEBSERVER}/scl/fo/hk7w48fbgw9j6ikfl4202/AAC_QACHIcZPuKOX9C9L8g6Ea`,

which works fine.

However, prettier converts this code to

preview_url: `https://${process.env
    .WEBSERVER}/scl/fo/hk7w48fbgw9j6ikfl4202/AAC_QACHIcZPuKOX9C9L8g6Ea`,

which compiles to

preview_url: "https://" + process.env
    .WEBSERVER + "/scl/fo/hk7w48fbgw9j6ikfl4202/AAC_QACHIcZPuKOX9C9L8g6Ea",

loose-envify cannot handle the whitespace between process.env and .WEBSERVER; at the moment the only workaround is to add // prettier-ignore to these cases, and I'd rather not have to educate my teammates about that. Is there any chance we could get this limitation fixed? Would upstream be amenable to a pull request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions