avatarAbdelfattah Sekak

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2765

Abstract

iguration example</span> <span class="hljs-keyword">module</span>.<span class="hljs-keyword">exports</span> = { trailingComma: <span class="hljs-string">"es5"</span>, tabWidth: <span class="hljs-number">2</span>, semi: <span class="hljs-literal">true</span>, singleQuote: <span class="hljs-literal">true</span>, };</pre></div><h2 id="4d10">Imagining the ideal config landscape</h2><p id="8ebe">Following my extensive, and quite frankly, arduous journey to setting up ESLint configs, I've imagined what an ideal config landscape might look like.</p><p id="e1f5">For starters, an all-encompassing <code>.config</code> folder. This magical directory would hold all necessary config files, creating a seamless and organized hierarchy for your repo.</p><p id="f3e0">Within this wonderland, you could spread out subfolders for Docker, Node, Sentry, or whatever else catches your fancy. Not only would it provide a harmonious layout, but it would also spare developers from config fatigue.</p><p id="de84">Next, I envision that top-level libraries such as Prettier, Tailwind, and others would start supporting the check for a <code>.config</code> folder.</p><div id="0879"><pre>. └── .<span class="hljs-built_in">config</span> ├── docker │ └── dockerfile ├── sentry │ └── sentry.properties └── node └── <span class="hljs-built_in">package</span>.json</pre></div><p id="85f0">I also anticipate that the ultimate source of truth, the package.json, would serve as a universal config file for JavaScript.</p><div id="0038"><pre><span class="hljs-comment">// package.json</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"app"</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"version"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"1.0.0"</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"description"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">""</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"main"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"app.js"</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"scripts"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span><span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"dependencies"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span><span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"devDependencies"</span><span class="hljs-punct

Options

uation">:</span> <span class="hljs-punctuation">{</span><span class="hljs-punctuation">}</span> <span class="hljs-punctuation">}</span></pre></div><p id="7600">Sadly, projects mature enough to read package.json for specific config values are a rare breed, and tools outside the JavaScript ecosystem could never fathom working this way.</p><p id="3340">For more complex configurations, like Sentry, which encourage you to create a JavaScript file embedded in the shipped app, we need a stand-in defense layer –– and that, dear reader, is where our config folder returns to the rescue.</p><h2 id="eb70">Deciding on a Solution</h2><p id="a10e">In conclusion, we need to settle down on a definitive resolution to support these structures in diverse projects. A combination of improved defaults, smart usage of <code>packag.json</code>where possible, and efficiently using a config folder should be our guiding principles.</p><p id="ea88">Yes, Deno has made strides toward that goal by creating an environment with default settings and no configuration required.</p><p id="d5d9">It's time that we recognize configuration complications as a problem, and work diligently towards solving it.</p><p id="77cc">The future of our codebase could very well depend on it.</p><p id="ae85"><i>Check this useful blog post published by Deno team :</i></p><div id="c40c" class="link-block"> <a href="https://deno.com/blog/node-config-hell"> <div> <div> <h2>Node.js's Config Hell Problem</h2> <div><h3>Why a Next.js project has over 30 configuration files and what we can do to avoid it.</h3></div> <div><p>deno.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*arnrXOWpZVjKkkuc)"></div> </div> </div> </a> </div><h1 id="c5da">In Plain English</h1><p id="2110"><i>Thank you for being a part of our community! Before you go:</i></p><ul><li><i>Be sure to <b>clap</b> and <b>follow</b> the writer! 👏</i></li><li><i>You can find even more content at <a href="https://plainenglish.io/"><b>PlainEnglish.io</b></a><b> 🚀</b></i></li><li><i>Sign up for our <a href="http://newsletter.plainenglish.io/"><b>free weekly newsletter</b></a>. 🗞️</i></li><li><i>Follow us on <a href="https://twitter.com/inPlainEngHQ"><b>Twitter</b></a><b>(X</b></i>), <a href="https://www.linkedin.com/company/inplainenglish/"><b><i>LinkedIn</i></b></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><b><i>YouTube</i></b></a>, and <a href="https://discord.gg/in-plain-english-709094664682340443"><b><i>Discord</i></b></a><b><i>.</i></b></li></ul></article></body>

How To Escape Node.js Config Chaos

Let’s take a look behind the scenes at a truth everyone ignores: Config files are awkward and difficult to manage.

Welcome to Node.js’s config chaos — generated by the author via text-to-image tool

Config files are overwhelming, and sometimes, they downright suck. You're probably familiar with the sight of a chaotic root directory filled with 10+ config files, which leaves your codebase looking like an abstract painting that only the brave could decipher.

Are all these config files necessary?

Or have some been left stale from packages no longer in use?

To add to the calamity, once Docker and Sentry get involved, you're left wrestling with more than five files each, all piling up into what can be best described as "Config Hell".

Diving deep into the chaos

The issue we’re facing is not exclusive to JavaScript, but rather to software development as a whole. As a real-life example, let’s consider a situation where you have your Dockerignore, editor config, local environment example, a slew of VS Lint stuff, Git ignore ….

Screenshots of numerous config files in a single project.

Let's take a closer look at this situation, where the effort to synchronize the melody of all these packages working together may lead you down into the rabbit hole of config confusion.

Chaos theory maintains that the effects of disorder grow exponentially.

Unpacking the ‘Defaults Dilemma’

JavaScript tools, greatly unrestrained by personal bias, lack opinionated defaults, often leading developers into heavy configuration.

Imagine one's first encounter with Gmail's settings – overwhelmed by the configuration, they may abandon the mailbox altogether!

Screenshot of Gmail settings page

The demand for better default settings is, therefore, the first line of defense in preventing our descent into the abyss of configuration. And though some modern tools like Prettier do a commendable job, more still remains to be done.

// Prettier configuration example
module.exports = {
  trailingComma: "es5",
  tabWidth: 2,
  semi: true,
  singleQuote: true,
};

Imagining the ideal config landscape

Following my extensive, and quite frankly, arduous journey to setting up ESLint configs, I've imagined what an ideal config landscape might look like.

For starters, an all-encompassing .config folder. This magical directory would hold all necessary config files, creating a seamless and organized hierarchy for your repo.

Within this wonderland, you could spread out subfolders for Docker, Node, Sentry, or whatever else catches your fancy. Not only would it provide a harmonious layout, but it would also spare developers from config fatigue.

Next, I envision that top-level libraries such as Prettier, Tailwind, and others would start supporting the check for a .config folder.

.
└── .config
    ├── docker
    │   └── dockerfile
    ├── sentry
    │   └── sentry.properties
    └── node
        └── package.json

I also anticipate that the ultimate source of truth, the package.json, would serve as a universal config file for JavaScript.

// package.json
{
  "name": "app",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {},
  "dependencies": {},
  "devDependencies": {}
}

Sadly, projects mature enough to read package.json for specific config values are a rare breed, and tools outside the JavaScript ecosystem could never fathom working this way.

For more complex configurations, like Sentry, which encourage you to create a JavaScript file embedded in the shipped app, we need a stand-in defense layer –– and that, dear reader, is where our config folder returns to the rescue.

Deciding on a Solution

In conclusion, we need to settle down on a definitive resolution to support these structures in diverse projects. A combination of improved defaults, smart usage of packag.jsonwhere possible, and efficiently using a config folder should be our guiding principles.

Yes, Deno has made strides toward that goal by creating an environment with default settings and no configuration required.

It's time that we recognize configuration complications as a problem, and work diligently towards solving it.

The future of our codebase could very well depend on it.

Check this useful blog post published by Deno team :

In Plain English

Thank you for being a part of our community! Before you go:

Programming
JavaScript
Front End Development
Web Development
Software Development
Recommended from ReadMedium