DEV Community

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

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

Top comments (0)