The Folder Validator package is a powerful tool designed to ensure consistency in your application's folder structure across different developers. With this package, you can maintain a uniform folder layout, preventing any structural changes that might lead to application breaks.
"I've created this package because I was tired of having to check the folder structure of my application every time another developer was working on it. I wanted to make sure that the folder structure of my application was consistent and that it was not changed by another developer preventing breaks in the application, so I created this package." - Daniel Rosa
- Structure Validation: Automatically validates your project's folder structure against a predefined configuration
- Real-time Monitoring: Watch mode for continuous folder structure validation during development
- Flexible Configuration: Simple and intuitive configuration file to define your desired folder structure
- Required vs Optional: Specify which folders are mandatory and which are optional
- Nested Structures: Support for deep nested folder hierarchies
- Developer Friendly: Clear error messages and validation feedback
- Zero Runtime Dependencies: Lightweight and fast execution
- Maintain Consistency: Ensure all team members follow the same project structure
- Prevent Breaking Changes: Catch structural inconsistencies before they cause issues
- Improve Onboarding: New developers can quickly understand and maintain the correct project structure
- CI/CD Integration: Easy to integrate into your continuous integration pipeline
- Framework Agnostic: Works with any JavaScript/TypeScript project structure
npm install folder-validator -D
- Create a
folder.config.js
file in your project root:
module.exports = [
{
name: "src",
required: true,
children: [
{
name: "components",
required: true,
},
{
name: "pages",
required: true,
},
],
},
{
name: "public",
required: true,
},
{
name: "styles",
required: false,
},
];
- Add validation scripts to your
package.json
:
{
"scripts": {
"validate": "folder-validator",
"validate:watch": "folder-validator --watch"
}
}
- Run the validator:
# Run a one-time validation on the folder structure of your project
npm run validate
# Watch the folder structure for changes that might break the application or is not allowed on the configuration defined by the folder.config.js file
npm run validate:watch
Property | Type | Description |
---|---|---|
name | string | Name of the folder |
required | boolean | Whether the folder must exist |
children | array | Nested folder definitions (optional) |
module.exports = [
{
name: "src",
required: true,
},
];
module.exports = [
{
name: "src",
required: true,
children: [
{
name: "components",
required: true,
children: [
{
name: "common",
required: true,
},
{
name: "layouts",
required: false,
},
],
},
],
},
];
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Daniel Rosa