Rajath Ramakrishna

Make Helix use your workspace prettier config

Posted on — | 2 min read

I’ve been trying out Helix Editor recently and loving it. I wanted to see if it could be my primary IDE and one thing I wish it did was format the file on save. By this, I don’t just mean fixing indentation, but also applying eslint fixes and running prettier. And I wanted this formatting to be applied based on the rules defined for that package. For example, I was in a nodejs workspace with typescript files and a prettier config that had rules like singleQuote, trailingComma, etc.

I tried a few prettier configs on the web for Helix and none of them worked. This post is to document what did work so that the next time I run into the same situation I don’t start from scratch and end up trying a bunch of things to no avail.

So, here’s what worked. I found this line of code as a comment on one of the GitHub issues:

formatter = { command = "npx", args = ["prettier", "--parser", "typescript"] }

This fixed the prettier issue for me and now any double quotes in the file are converted to single quotes. Any semi-colons that were missed at the end of statements get automatically added, just like how it’s configured in the prettier config for the project.