chapbook icon indicating copy to clipboard operation
chapbook copied to clipboard

eslint-config-prettier but no prettier?

Open aleclarson opened this issue 10 months ago • 4 comments

Should prettier be a dev dependency? Or am I misunderstanding the purpose of eslint-config-prettier. Either way, the lack of auto-indentation is troubling me 😅

aleclarson avatar Apr 18 '24 04:04 aleclarson

@aleclarson The purpose of eslint-config-prettier, so far as I know, is to prevent eslint defaults from clashing with what Prettier does. I should port over the GH action which runs Prettier on PRs... my preference would be for people to set up Prettier in whatever editor they use instead of having a task to run it manually. But this isn't a strongly-held opinion.

klembot avatar Apr 19 '24 01:04 klembot

IIUC, the Prettier VSC extension doesn't run if prettier isn't installed in the project.

This setup is working well for me: https://github.com/aleclarson/chapbook/commit/3515fe8b18019138476b9d8a3154baa44f93ce86

It adds VSC workspace settings to Chapbook, enabling format-on-save behavior with ESLint running on save too. I needed Format Code Action VSC extension to get ESLint auto-fixing after Prettier. Also had to add some missing lint rules.

aleclarson avatar Apr 19 '24 01:04 aleclarson

@aleclarson Well, my own experience with VS Code is that it formats my code using Prettier without having it in package.json. Never really looked into this very deeply, but I'm using the official extension, and I think I remember having to tell VS Code to use Prettier as the formatter for the file extensions.

klembot avatar Apr 19 '24 01:04 klembot

having to tell VS Code to use Prettier as the formatter for the file extensions.

Not doing this is a common cause for Prettier (among others like modules/extension) not working. :)

greyelf avatar Apr 19 '24 06:04 greyelf