DEV Community

Discussion on: Automatically lint & format your code on commit when using Next.js

Collapse
 
jonasmerlin profile image
Jonas Schumacher • Edited

As with most things in software development, there are multiple ways to achieve similar results, true. But I would say that in most cases, using the VSCode Prettier extension is something you should do in addition to, not instead of, what I described here.

For one thing, the method described runs next lint as well. Something you could do as a VSCode script for example, but that would still be more work than just installing one extension and in general, using VSCode scripts for these kind of things doesn't scale too well in my experience.

Also, when setting up everything via npm scripts and hooks, this will run in the same way for everyone on your team. No need to commit recommended VSCode plugins, scripts and settings. No need even to use VSCode at all, everyone can use what they want. That way, even that one weirdo on your team who only ever uses emacs will be happy! 😉

Collapse
 
wentallout profile image
Nguyen Dang Khoa

I actually did not know setting up Prettier with npm would add more features like these. Back then I thought installing all those lint and prettier would be enough for everything. Thank you for the awesome post!

Thread Thread
 
jonasmerlin profile image
Jonas Schumacher

Glad you found the post useful. 🙂 The difference between using VSCode and npm is easy to overlook, especially when you're just getting started or learning on your own. But many of these things become obvious when you work on a team - especially when some members use different setups.

But I would also say that it's perfectly fine to use whatever works for you in your circumstances. If the plugins are enough right now and you prefer using them, by all means continue to do so. It's something that is easy to change once there's the need for it.