Ahmed El Gabri

Death by thousand config files

Today, a couple of hours ago Prettier released version 1.6.0 with support for .prettierrc & .prettierignore files. If you follow me on Twitter you might have noticed how much I love prettier. But at the same time, you might have noticed my growing pain of the endless stream for .*rc & .*ignore files.

One of the things that I really liked about prettier was the lack of config by any means, files, etc...

Here are a couple more that we might have in the next few days/weeks:

And of course:

honorary mention:

and more...

Not to mention that babel-env & autoprefixer now use the browserlist project, which allows you to pass which browsers you want to support so they can handle the polyfills & prefixes for you & guess what? It also has it's own files!

So that makes the total 14 files in our repo. Isn't this a bit too much for config files? Before everyone starts yelling at me that I can add most of these configs inside package.json - which I don't mind doing - and most probably will start doing. that's not the main issue.

The issue is

So I have a simple question here.

I know that not all of these .*rc files can be merged into one, but at least can we agree that many of them can? most of these configs are just JSON objects so why not store them all in one place?

Also, this way if a new tool comes out we just need to add a new key. It doesn't solve the whole problem but at least it keeps us a little bit saner.

What is wrong with this? And yes it must be a .js file:

// use this to toggle on/off some configs or switch them completely
const isPROD = process.env.NODE_ENV === 'production'

module.exports = {
    jest: { ... },
    babel: { ... },
    prettier: { ... },
    stylelint: { ... }
}

Or even better!

So people might say & how is this better than having multiple files?

The answer is, it's not much better but at least we can have these:

I do like all of these projects, they are amazing projects made by smarter people than I am. I never felt JavaScript fatigue, but I started to feel Config/rc files fatigue.

You can tweet this post or reach out directly to me @ahmedelgabri.

© 2024 Ahmed El Gabri