DEV Community

Cover image for Tame the Chaos: Introducing Homeostasis JS for Structuring Your JavaScript Projects
Mateo Santiago Zapata Maldonado
Mateo Santiago Zapata Maldonado

Posted on

Tame the Chaos: Introducing Homeostasis JS for Structuring Your JavaScript Projects

Tame the Chaos: Introducing HomeostasisJS for Structuring Your JavaScript Projects

As developers, we've all experienced the creeping chaos that comes with growing projects: files scattered everywhere, inconsistent naming conventions, and folder structures that make onboarding new developers a nightmare. What starts as an organized codebase can quickly spiral into entropy.

Meet HomeostasisJS, your new favorite linter for project structure. 🚀


What is HomeostasisJS?

HomeostasisJS is not your average linter. While typical linters check syntax or code style, HomeostasisJS enforces project organization rules. It ensures that your JavaScript projects stay maintainable and scalable as they grow, preventing the "spaghetti structure" that haunts so many teams.

With HomeostasisJS, you can:

  • 📁 Maintain Order: Define clear rules for directories and files to keep your project organized.
  • ✅ Automate Naming Conventions: Enforce consistent naming styles like kebab-case or camelCase.
  • 🗑️ Clean Up Automatically: Remove or rename files and folders that don't comply with your rules.

HomeostasisJS NPM

How Does It Work?

HomeostasisJS revolves around a descriptor file (descriptor.js) where you define the structure of your project. Here’s a sample:

const config = {
  directories: {
    strict_content: true,
    convention: "kebab-case",
    content: [
      { name: "components" },
      { name: "services" },
    ],
  },
  files: {
    allowedFormats: [".js", ".ts"],
    removeIfFormatIsInvalid: true,
  },
};

module.exports = config;

Enter fullscreen mode Exit fullscreen mode

Using this configuration, HomeostasisJS will:

  • Enforce kebab-case naming for directories.
  • Ensure only .js and .ts files exist.
  • Remove files that don’t match the rules, keeping your project clean.

Plugins for Advanced Control

Want more customization? HomeostasisJS supports plugins! Use hooks like onStrictContentValidation or onAutoFormatting to extend its functionality.

Example of a custom plugin:

class MyPlugin {
  name = "MyPlugin";

  onStrictContentValidation(args) {
    console.log(`[${this.name}] Validating:`, args.currentType);
  }
}

const config = {
  plugins: [new MyPlugin()],
  // ... other rules
};

module.exports = config;
Enter fullscreen mode Exit fullscreen mode

With plugins, you can react to validation events, enforce custom rules, or even integrate external tools.

Start Using HomeostasisJS Today!
Install it:

npm install -g homeostasis
Enter fullscreen mode Exit fullscreen mode

Run it:

homeostasis ./path/to/your/project
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs