DEV Community

Cover image for Setting up a Minimal, Yet Useful JavaScript Dev Environment

Setting up a Minimal, Yet Useful JavaScript Dev Environment

Kamil Ogórek on November 21, 2016

In an era of omnipresent frameworks, libraries and tooling, it may be hard to decide what tool to use and when. I know from experience, that the f...
Collapse
 
kamilogorek profile image
Kamil Ogórek

The only thing precommit package do, is running all the scripts listed in package.json, eg. "pre-commit": ["test", "lint"] before every git commit command.
When you install it, it sets up everything for you, so that you don't need to do or remember anything.

Collapse
 
dimpiax profile image
Dmytro Pylypenko

Sounds good, does it cancel operation commit in case of not successful command execution, like 'test' etc?

Thread Thread
 
kamilogorek profile image
Kamil Ogórek

That's exactly how it works. There is --no-verify flag (which is a default git flag, rather than any other library thing), but I doesn't recommend using it if you wish to push your commits :)

Collapse
 
dynamo6 profile image
Dev @ Dynamo6

Great article, although ironically I've now wasted 30 minutes trying to get StandardJS to work. It appears to install fine but just cries "command not found" when I try and run it :/ I use plenty of other npm libraries on a daily basis so no idea whats wrong with this one ... Shame

Collapse
 
kamilogorek profile image
Kamil Ogórek

It's because I don't use npm global installation in this article. If you want it to be accessible from anywhere, you have to write npm install -g standard.
However, if you use it withing package.json scripts, then it can be installed locally, without -g flag and it will still run when done through npm run lint or any other npm script.

Collapse
 
stasgavrylov profile image
Stas Gavrylov

Great post, thanks for advice. It would be really nice if there was an easy way to add ES6 imports/exports to the flow.

Collapse
 
kamilogorek profile image
Kamil Ogórek

There is, but why would you need an ES6 modules in Node.js? It doesn't support it natively anyway. Or do you want to use ES6 modules and just be able to test them like I described in an article?

Collapse
 
stasgavrylov profile image
Stas Gavrylov

I know that they're not supported yet, but I hope we'll get it soon. I am a front-end dev, and so in general I have to spend a lot of time tuning webpack/babel before I start a project. And as you probably know, ES6 modules are commonly used in front-end nowadays.
Testing would also be nice.

Thread Thread
 
kamilogorek profile image
Kamil Ogórek

I got you covered! ;)

gist.github.com/kamilogorek/0a2d7f...

And then you can use ES6 modules in your tests as well as in your code :)

Thread Thread
 
stasgavrylov profile image
Stas Gavrylov

Thanks a lot, Kamil,
you're a real MVP :)

Collapse
 
horstn profile image
horst

Very helpful! I set it up with the support for ES6-Modules a few posts down! Just starting to write (serious) JS-code, and never used npm / node before. So this covers a lot for me! (TDD, git and more).
<3 <3 <3

Collapse
 
kamilogorek profile image
Kamil Ogórek

Glad I could help! :)

Collapse
 
yowainwright profile image
Jeff Wainwright

Thanks! This is great post!!! 🙏

Collapse
 
eoinmurphy profile image
Eoin Murphy

Dude, thank you so much! I've been attempting getting a modern JS-based development environment working smoothly for a little while now. This is exactly what I was looking for!

Collapse
 
marines profile image
Mariusz Kujawski

Except only minority of devs use mentioned tools. There are modern tools out there that have much greater support.

Collapse
 
kamilogorek profile image
Kamil Ogórek

Glad I could help! :)

Collapse
 
luriodevz profile image
lvrxx~dvz

"Because the environment assumes you’ll work in TDD style"

What does TDD mean ?

Collapse
 
busata profile image
Dries De Smet

Test Driven Development, a practice where you write tests first, and the implementation afterwards.

Can read more online, or Test Driven Development: By Example by Kent Beck

Collapse
 
kamilogorek profile image
Kamil Ogórek

Test Driven Development – en.wikipedia.org/wiki/Test-driven_...

Collapse
 
luriodevz profile image
lvrxx~dvz

Thank you !

Collapse
 
koriolis profile image
Nuno Ferreira

Looks nice, apart from Standard. XO achieves the same goal.

Collapse
 
kamilogorek profile image
Kamil Ogórek

Thanks. It's just a matter of a preference, as they both achieve then same thing, as you just said.

Collapse
 
nitishdayal profile image
Nitish Dayal

Valuable post. Where's the damn like/heart/+1 button on this thing? Need2bookmark