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
orcamelCase
. - ποΈ Clean Up Automatically: Remove or rename files and folders that don't comply with your rules.
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;
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;
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
Run it:
homeostasis ./path/to/your/project
Top comments (0)