eslint-plugin-folder-name-convention
v1.1.0
Published
ESLint plugin to enforce folder naming conventions (kebab-case, camelCase, etc.)
Maintainers
Readme
📁 eslint-plugin-folder-name-convention
🔍 An ESLint plugin to enforce consistent folder naming conventions like
kebab-case,camelCase,PascalCase, and more.
📦 Installation
npm install eslint-plugin-folder-name-convention --save-dev⚙️ Configuration
Add the plugin and rule to your ESLint config:
// eslint.config.js
const pluginFolderName = require('eslint-plugin-folder-name-convention');
const path = require('path');
/** @type {import("eslint").FlatConfig[]} */
module.exports = [
{
files: ['**/*.js', '**/*.ts'],
plugins: {
'folder-name-convention': pluginFolderName,
},
rules: {
'folder-name-convention/enforce': [
'error',
{
pattern: 'kebab-case',
rootDir: path.resolve(__dirname), // Ensures project root only
ignore: ['node_modules', '.git'],
},
],
},
},
];
npx eslint . --config eslint.config.js🔧 Rule Options
| Option | Type | Default | Description |
|------------|------------|---------------|-----------------------------------------------------------------------------|
| pattern | string | "kebab-case"| Allowed values: kebab-case, camelCase, PascalCase, snake_case, or a custom RegExp |
| ignore | string[] | [] | Folder names to ignore (supports RegExp if wrapped in /.../) |
| rootDir | string | "." | Directory from which to begin folder checks |
✅ Supported Patterns
| Pattern | Example |
|---------------|-------------------|
| kebab-case | user-profile/ |
| camelCase | userProfile/ |
| PascalCase | UserProfile/ |
| snake_case | user_profile/ |
| /regex/ | /^prefix-[a-z]+$/ |
🧪 Example Project Structure
root/
├── user-profile/ ✅ valid (kebab-case)
├── utils/ ✅ valid
├── BadFolderName/ ❌ invalid (PascalCase)🔴 ESLint Error
❌ Folder name "BadFolderName" does not match pattern "kebab-case".🎯 Why Use This?
- 🧹 Enforces consistent folder naming
- 🐛 Prevents case-sensitive import bugs on UNIX systems
- 🤝 Improves project readability and maintainability
Run ESLint:
npx eslint . --config eslint.config.js
OR
npx eslint .📜 License
MIT © Raza
