project-structure-lint 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.validate-structurerc.example.json +45 -0
- package/CHANGELOG.md +42 -0
- package/CONTRIBUTING.md +142 -0
- package/LICENSE +21 -0
- package/PROJECT_SUMMARY.md +252 -0
- package/QUICK_START.md +164 -0
- package/README.md +330 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +121 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/loader.d.ts +4 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +71 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/core/validator.d.ts +16 -0
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/core/validator.js +231 -0
- package/dist/core/validator.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/presets/index.d.ts +5 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +17 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/react.d.ts +3 -0
- package/dist/presets/react.d.ts.map +1 -0
- package/dist/presets/react.js +94 -0
- package/dist/presets/react.js.map +1 -0
- package/dist/reporters/consoleReporter.d.ts +9 -0
- package/dist/reporters/consoleReporter.d.ts.map +1 -0
- package/dist/reporters/consoleReporter.js +98 -0
- package/dist/reporters/consoleReporter.js.map +1 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/fileScanner.d.ts +20 -0
- package/dist/utils/fileScanner.d.ts.map +1 -0
- package/dist/utils/fileScanner.js +166 -0
- package/dist/utils/fileScanner.js.map +1 -0
- package/dist/utils/naming.d.ts +4 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/dist/utils/naming.js +75 -0
- package/dist/utils/naming.js.map +1 -0
- package/jest.config.js +17 -0
- package/package.json +48 -0
- package/src/cli.ts +106 -0
- package/src/config/loader.ts +79 -0
- package/src/core/validator.ts +242 -0
- package/src/index.ts +6 -0
- package/src/presets/index.ts +16 -0
- package/src/presets/react.ts +93 -0
- package/src/reporters/consoleReporter.ts +116 -0
- package/src/types/index.ts +67 -0
- package/src/types/micromatch.d.ts +41 -0
- package/src/utils/__tests__/naming.test.ts +107 -0
- package/src/utils/fileScanner.ts +162 -0
- package/src/utils/naming.ts +99 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"preset": "react",
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"rules": {
|
|
5
|
+
"componentColocation": {
|
|
6
|
+
"enabled": true,
|
|
7
|
+
"componentDirs": ["components", "pages", "features"],
|
|
8
|
+
"requiredFiles": [
|
|
9
|
+
{
|
|
10
|
+
"pattern": "*.test.{ts,tsx,js,jsx}",
|
|
11
|
+
"required": true,
|
|
12
|
+
"description": "Test file for component"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"pattern": "*.stories.{ts,tsx,js,jsx}",
|
|
16
|
+
"required": true,
|
|
17
|
+
"description": "Storybook story file"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"namingConvention": "PascalCase"
|
|
21
|
+
},
|
|
22
|
+
"fileNaming": {
|
|
23
|
+
"components/**/*.{tsx,jsx}": {
|
|
24
|
+
"convention": "PascalCase",
|
|
25
|
+
"severity": "error"
|
|
26
|
+
},
|
|
27
|
+
"hooks/**/*.{ts,tsx,js,jsx}": {
|
|
28
|
+
"convention": "camelCase",
|
|
29
|
+
"severity": "error"
|
|
30
|
+
},
|
|
31
|
+
"utils/**/*.{ts,js}": {
|
|
32
|
+
"convention": "camelCase",
|
|
33
|
+
"severity": "error"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"ignore": [
|
|
38
|
+
"**/node_modules/**",
|
|
39
|
+
"**/dist/**",
|
|
40
|
+
"**/build/**",
|
|
41
|
+
"**/.next/**",
|
|
42
|
+
"**/coverage/**"
|
|
43
|
+
],
|
|
44
|
+
"severity": "error"
|
|
45
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2024-12-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of project-structure-lint
|
|
12
|
+
- Component co-location validation
|
|
13
|
+
- File naming convention enforcement (PascalCase, camelCase, kebab-case, snake_case, UPPER_CASE)
|
|
14
|
+
- Folder structure validation
|
|
15
|
+
- React preset with sensible defaults
|
|
16
|
+
- CLI commands: `check`, `init`, `presets`
|
|
17
|
+
- Configurable rules via `.validate-structurerc.json`
|
|
18
|
+
- Detailed error reporting with suggestions
|
|
19
|
+
- Support for ignore patterns
|
|
20
|
+
- Programmatic API for integration
|
|
21
|
+
- Comprehensive documentation and examples
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
- ✅ Validates component files are co-located with tests and stories
|
|
25
|
+
- ✅ Enforces naming conventions across different file types
|
|
26
|
+
- ✅ Validates project folder structure
|
|
27
|
+
- ✅ Configurable severity levels (error/warning)
|
|
28
|
+
- ✅ CI/CD integration support
|
|
29
|
+
- ✅ Colored console output
|
|
30
|
+
- ✅ Glob pattern support for file matching
|
|
31
|
+
|
|
32
|
+
## [Unreleased]
|
|
33
|
+
|
|
34
|
+
### Planned
|
|
35
|
+
- Vue.js preset
|
|
36
|
+
- Angular preset
|
|
37
|
+
- Node.js/Express preset
|
|
38
|
+
- Auto-fix capability
|
|
39
|
+
- JSON/HTML report formats
|
|
40
|
+
- VS Code extension
|
|
41
|
+
- GitHub Action
|
|
42
|
+
- More granular configuration options
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Contributing to project-structure-lint
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! This document provides guidelines for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. **Clone the repository**
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/yourusername/project-structure-lint.git
|
|
10
|
+
cd project-structure-lint
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. **Install dependencies**
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
3. **Build the project**
|
|
19
|
+
```bash
|
|
20
|
+
npm run build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
4. **Run tests**
|
|
24
|
+
```bash
|
|
25
|
+
npm test
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Project Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
project-structure-lint/
|
|
32
|
+
├── src/
|
|
33
|
+
│ ├── core/ # Core validation logic
|
|
34
|
+
│ ├── config/ # Configuration loading
|
|
35
|
+
│ ├── presets/ # Built-in presets
|
|
36
|
+
│ ├── reporters/ # Output formatters
|
|
37
|
+
│ ├── utils/ # Utility functions
|
|
38
|
+
│ ├── types/ # TypeScript types
|
|
39
|
+
│ ├── cli.ts # CLI entry point
|
|
40
|
+
│ └── index.ts # Library entry point
|
|
41
|
+
├── tests/ # Test files
|
|
42
|
+
└── dist/ # Compiled output
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Adding a New Preset
|
|
46
|
+
|
|
47
|
+
To add a new preset (e.g., Vue, Angular):
|
|
48
|
+
|
|
49
|
+
1. Create a new file in `src/presets/`:
|
|
50
|
+
```typescript
|
|
51
|
+
// src/presets/vue.ts
|
|
52
|
+
import { Preset } from '../types';
|
|
53
|
+
|
|
54
|
+
export const vuePreset: Preset = {
|
|
55
|
+
name: 'vue',
|
|
56
|
+
description: 'Vue.js project structure',
|
|
57
|
+
config: {
|
|
58
|
+
// Your configuration here
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. Export it in `src/presets/index.ts`:
|
|
64
|
+
```typescript
|
|
65
|
+
import { vuePreset } from './vue';
|
|
66
|
+
|
|
67
|
+
export const presets: Record<string, Preset> = {
|
|
68
|
+
react: reactPreset,
|
|
69
|
+
vue: vuePreset // Add your preset
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
3. Add tests for your preset
|
|
74
|
+
|
|
75
|
+
4. Update documentation
|
|
76
|
+
|
|
77
|
+
## Adding New Validation Rules
|
|
78
|
+
|
|
79
|
+
1. Add the rule type to `src/types/index.ts`
|
|
80
|
+
2. Implement the validation logic in `src/core/validator.ts`
|
|
81
|
+
3. Add tests in `src/core/__tests__/`
|
|
82
|
+
4. Update documentation
|
|
83
|
+
|
|
84
|
+
## Testing
|
|
85
|
+
|
|
86
|
+
- Write unit tests for all new features
|
|
87
|
+
- Ensure all tests pass before submitting PR
|
|
88
|
+
- Aim for high test coverage
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm test # Run tests
|
|
92
|
+
npm test -- --coverage # Run with coverage
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Code Style
|
|
96
|
+
|
|
97
|
+
- Use TypeScript for all new code
|
|
98
|
+
- Follow existing code style
|
|
99
|
+
- Run linter before committing:
|
|
100
|
+
```bash
|
|
101
|
+
npm run lint
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Commit Messages
|
|
105
|
+
|
|
106
|
+
Use clear, descriptive commit messages:
|
|
107
|
+
- `feat: add Vue preset`
|
|
108
|
+
- `fix: correct naming validation for hooks`
|
|
109
|
+
- `docs: update README with examples`
|
|
110
|
+
- `test: add tests for file scanner`
|
|
111
|
+
|
|
112
|
+
## Pull Request Process
|
|
113
|
+
|
|
114
|
+
1. Fork the repository
|
|
115
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
116
|
+
3. Make your changes
|
|
117
|
+
4. Add tests for your changes
|
|
118
|
+
5. Ensure all tests pass
|
|
119
|
+
6. Update documentation
|
|
120
|
+
7. Commit your changes
|
|
121
|
+
8. Push to your fork
|
|
122
|
+
9. Open a Pull Request
|
|
123
|
+
|
|
124
|
+
## Pull Request Guidelines
|
|
125
|
+
|
|
126
|
+
- Provide a clear description of the changes
|
|
127
|
+
- Reference any related issues
|
|
128
|
+
- Include screenshots for UI changes
|
|
129
|
+
- Ensure CI passes
|
|
130
|
+
- Request review from maintainers
|
|
131
|
+
|
|
132
|
+
## Questions?
|
|
133
|
+
|
|
134
|
+
Feel free to open an issue for:
|
|
135
|
+
- Bug reports
|
|
136
|
+
- Feature requests
|
|
137
|
+
- Questions about the code
|
|
138
|
+
- Documentation improvements
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kiran Badave
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Project Summary: project-structure-lint
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
A fully functional CLI tool and npm package for validating project folder structure and file naming conventions with configurable presets.
|
|
6
|
+
|
|
7
|
+
## ✅ Completed Features
|
|
8
|
+
|
|
9
|
+
### Core Functionality
|
|
10
|
+
- ✅ **Component Co-location Validation** - Ensures related files (tests, stories) are in the same folder
|
|
11
|
+
- ✅ **File Naming Convention Enforcement** - Supports 5 conventions (PascalCase, camelCase, kebab-case, snake_case, UPPER_CASE)
|
|
12
|
+
- ✅ **Folder Structure Validation** - Enforces project directory organization
|
|
13
|
+
- ✅ **React Preset** - Pre-configured rules for React projects
|
|
14
|
+
- ✅ **Configurable Rules** - Fully customizable via JSON configuration
|
|
15
|
+
- ✅ **Ignore Patterns** - Glob-based file/directory exclusion
|
|
16
|
+
|
|
17
|
+
### CLI Commands
|
|
18
|
+
- ✅ `validate-structure check` - Run validation
|
|
19
|
+
- ✅ `validate-structure init` - Initialize configuration
|
|
20
|
+
- ✅ `validate-structure presets` - List available presets
|
|
21
|
+
|
|
22
|
+
### Developer Experience
|
|
23
|
+
- ✅ **Detailed Error Reporting** - Clear messages with suggestions
|
|
24
|
+
- ✅ **Colored Console Output** - Easy-to-read results
|
|
25
|
+
- ✅ **Exit Codes** - CI/CD integration support
|
|
26
|
+
- ✅ **Programmatic API** - Use as a library
|
|
27
|
+
|
|
28
|
+
### Quality Assurance
|
|
29
|
+
- ✅ **TypeScript** - Full type safety
|
|
30
|
+
- ✅ **Unit Tests** - Jest test suite (15 tests passing)
|
|
31
|
+
- ✅ **Build System** - TypeScript compilation
|
|
32
|
+
- ✅ **Type Declarations** - Generated .d.ts files
|
|
33
|
+
|
|
34
|
+
### Documentation
|
|
35
|
+
- ✅ **README.md** - Comprehensive documentation
|
|
36
|
+
- ✅ **QUICK_START.md** - 5-minute getting started guide
|
|
37
|
+
- ✅ **CONTRIBUTING.md** - Contribution guidelines
|
|
38
|
+
- ✅ **CHANGELOG.md** - Version history
|
|
39
|
+
- ✅ **Example Config** - Sample configuration file
|
|
40
|
+
|
|
41
|
+
## 📁 Project Structure
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
project-structure-lint-lint/
|
|
45
|
+
├── src/
|
|
46
|
+
│ ├── cli.ts # CLI entry point
|
|
47
|
+
│ ├── index.ts # Library entry point
|
|
48
|
+
│ ├── config/
|
|
49
|
+
│ │ └── loader.ts # Configuration loading & merging
|
|
50
|
+
│ ├── core/
|
|
51
|
+
│ │ └── validator.ts # Main validation engine
|
|
52
|
+
│ ├── presets/
|
|
53
|
+
│ │ ├── index.ts # Preset registry
|
|
54
|
+
│ │ └── react.ts # React preset configuration
|
|
55
|
+
│ ├── reporters/
|
|
56
|
+
│ │ └── consoleReporter.ts # Console output formatter
|
|
57
|
+
│ ├── types/
|
|
58
|
+
│ │ ├── index.ts # TypeScript type definitions
|
|
59
|
+
│ │ └── micromatch.d.ts # Third-party type declarations
|
|
60
|
+
│ └── utils/
|
|
61
|
+
│ ├── fileScanner.ts # File system operations
|
|
62
|
+
│ ├── naming.ts # Naming convention validation
|
|
63
|
+
│ └── __tests__/
|
|
64
|
+
│ └── naming.test.ts # Unit tests
|
|
65
|
+
├── dist/ # Compiled JavaScript output
|
|
66
|
+
├── package.json # Package configuration
|
|
67
|
+
├── tsconfig.json # TypeScript configuration
|
|
68
|
+
├── jest.config.js # Jest test configuration
|
|
69
|
+
├── .gitignore # Git ignore rules
|
|
70
|
+
├── LICENSE # MIT License
|
|
71
|
+
├── README.md # Main documentation
|
|
72
|
+
├── QUICK_START.md # Quick start guide
|
|
73
|
+
├── CONTRIBUTING.md # Contribution guide
|
|
74
|
+
├── CHANGELOG.md # Version history
|
|
75
|
+
└── .validate-structurerc.example.json # Example config
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 🎯 Key Components
|
|
79
|
+
|
|
80
|
+
### 1. Validation Engine (`src/core/validator.ts`)
|
|
81
|
+
- Scans project directory structure
|
|
82
|
+
- Validates component co-location
|
|
83
|
+
- Checks file naming conventions
|
|
84
|
+
- Validates folder structure rules
|
|
85
|
+
- Generates detailed error reports
|
|
86
|
+
|
|
87
|
+
### 2. File Scanner (`src/utils/fileScanner.ts`)
|
|
88
|
+
- Recursive directory scanning
|
|
89
|
+
- Glob pattern matching
|
|
90
|
+
- Ignore pattern support
|
|
91
|
+
- Component directory detection
|
|
92
|
+
|
|
93
|
+
### 3. Naming Validator (`src/utils/naming.ts`)
|
|
94
|
+
- 5 naming convention validators
|
|
95
|
+
- Name conversion utilities
|
|
96
|
+
- Extension handling
|
|
97
|
+
- Test/spec file support
|
|
98
|
+
|
|
99
|
+
### 4. Configuration System (`src/config/loader.ts`)
|
|
100
|
+
- Cosmiconfig integration
|
|
101
|
+
- Preset merging
|
|
102
|
+
- Configuration validation
|
|
103
|
+
- Default React preset
|
|
104
|
+
|
|
105
|
+
### 5. Console Reporter (`src/reporters/consoleReporter.ts`)
|
|
106
|
+
- Colored output (chalk)
|
|
107
|
+
- Error/warning formatting
|
|
108
|
+
- Suggestions display
|
|
109
|
+
- Summary statistics
|
|
110
|
+
|
|
111
|
+
## 📦 Package Details
|
|
112
|
+
|
|
113
|
+
- **Name**: project-structure-lint
|
|
114
|
+
- **Version**: 1.0.0
|
|
115
|
+
- **License**: MIT
|
|
116
|
+
- **Main**: dist/index.js
|
|
117
|
+
- **Binary**: dist/cli.js
|
|
118
|
+
- **TypeScript**: Full support with declarations
|
|
119
|
+
|
|
120
|
+
## 🔧 Dependencies
|
|
121
|
+
|
|
122
|
+
### Runtime
|
|
123
|
+
- `chalk@^4.1.2` - Terminal colors
|
|
124
|
+
- `commander@^11.1.0` - CLI framework
|
|
125
|
+
- `cosmiconfig@^9.0.0` - Configuration loading
|
|
126
|
+
- `glob@^10.3.10` - File pattern matching
|
|
127
|
+
- `micromatch@^4.0.5` - Advanced pattern matching
|
|
128
|
+
|
|
129
|
+
### Development
|
|
130
|
+
- `typescript@^5.3.3` - TypeScript compiler
|
|
131
|
+
- `jest@^29.7.0` - Testing framework
|
|
132
|
+
- `ts-jest@^29.1.1` - TypeScript Jest integration
|
|
133
|
+
- `eslint@^8.56.0` - Code linting
|
|
134
|
+
|
|
135
|
+
## 🧪 Testing
|
|
136
|
+
|
|
137
|
+
- **Framework**: Jest with ts-jest
|
|
138
|
+
- **Coverage**: Unit tests for naming utilities
|
|
139
|
+
- **Status**: All 15 tests passing ✅
|
|
140
|
+
|
|
141
|
+
## 📝 Configuration Example
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"preset": "react",
|
|
146
|
+
"rootDir": "src",
|
|
147
|
+
"rules": {
|
|
148
|
+
"componentColocation": {
|
|
149
|
+
"enabled": true,
|
|
150
|
+
"componentDirs": ["components", "pages"],
|
|
151
|
+
"requiredFiles": [
|
|
152
|
+
{
|
|
153
|
+
"pattern": "*.test.{ts,tsx}",
|
|
154
|
+
"required": true
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"namingConvention": "PascalCase"
|
|
158
|
+
},
|
|
159
|
+
"fileNaming": {
|
|
160
|
+
"components/**/*.tsx": {
|
|
161
|
+
"convention": "PascalCase",
|
|
162
|
+
"severity": "error"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"ignore": ["**/node_modules/**"]
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 🚀 Usage Examples
|
|
171
|
+
|
|
172
|
+
### CLI Usage
|
|
173
|
+
```bash
|
|
174
|
+
# Initialize configuration
|
|
175
|
+
npx validate-structure init
|
|
176
|
+
|
|
177
|
+
# Run validation
|
|
178
|
+
npx validate-structure check
|
|
179
|
+
|
|
180
|
+
# List presets
|
|
181
|
+
npx validate-structure presets
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Programmatic Usage
|
|
185
|
+
```typescript
|
|
186
|
+
import { ProjectValidator, loadConfig } from 'project-structure-lint';
|
|
187
|
+
|
|
188
|
+
const config = await loadConfig();
|
|
189
|
+
const validator = new ProjectValidator(config);
|
|
190
|
+
const result = await validator.validate();
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 🎨 Output Example
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
Project Structure Validation Results
|
|
197
|
+
──────────────────────────────────────────────────
|
|
198
|
+
Files scanned: 45
|
|
199
|
+
Directories scanned: 12
|
|
200
|
+
|
|
201
|
+
✗ 2 Errors
|
|
202
|
+
|
|
203
|
+
1. Missing required file: Test file for component
|
|
204
|
+
Directory: components/Button
|
|
205
|
+
Expected: Button.test.tsx
|
|
206
|
+
💡 Create Button.test.tsx in components/Button/
|
|
207
|
+
|
|
208
|
+
2. File name doesn't follow PascalCase convention
|
|
209
|
+
File: components/myComponent/myComponent.tsx
|
|
210
|
+
Actual: myComponent.tsx
|
|
211
|
+
Expected: MyComponent.tsx
|
|
212
|
+
💡 Rename to MyComponent.tsx
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## 🔮 Future Enhancements
|
|
216
|
+
|
|
217
|
+
- Additional presets (Vue, Angular, Node.js)
|
|
218
|
+
- Auto-fix capability
|
|
219
|
+
- JSON/HTML report formats
|
|
220
|
+
- VS Code extension
|
|
221
|
+
- GitHub Action
|
|
222
|
+
- Watch mode
|
|
223
|
+
- Custom rule plugins
|
|
224
|
+
|
|
225
|
+
## 📊 Project Status
|
|
226
|
+
|
|
227
|
+
- ✅ **Build**: Successful
|
|
228
|
+
- ✅ **Tests**: All passing (15/15)
|
|
229
|
+
- ✅ **TypeScript**: No errors
|
|
230
|
+
- ✅ **Documentation**: Complete
|
|
231
|
+
- ✅ **Ready**: For npm publish
|
|
232
|
+
|
|
233
|
+
## 🎓 Learning Outcomes
|
|
234
|
+
|
|
235
|
+
This project demonstrates:
|
|
236
|
+
- CLI tool development with Commander.js
|
|
237
|
+
- TypeScript project structure
|
|
238
|
+
- Configuration management with Cosmiconfig
|
|
239
|
+
- File system operations in Node.js
|
|
240
|
+
- Pattern matching with glob and micromatch
|
|
241
|
+
- Test-driven development with Jest
|
|
242
|
+
- Professional documentation practices
|
|
243
|
+
- npm package publishing workflow
|
|
244
|
+
|
|
245
|
+
## 📄 License
|
|
246
|
+
|
|
247
|
+
MIT License - See LICENSE file for details
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
**Status**: ✅ Production Ready
|
|
252
|
+
**Last Updated**: 2024-12-24
|
package/QUICK_START.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Quick Start Guide
|
|
2
|
+
|
|
3
|
+
Get started with `project-structure-lint` in 5 minutes!
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev project-structure-lint
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Step 1: Initialize Configuration
|
|
12
|
+
|
|
13
|
+
Run the init command to create a configuration file:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx validate-structure init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This creates `.validate-structurerc.json` with the React preset:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"preset": "react",
|
|
24
|
+
"rules": {
|
|
25
|
+
"componentColocation": {
|
|
26
|
+
"enabled": true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Step 2: Run Validation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx validate-structure check
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Step 3: Add to package.json Scripts
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"scripts": {
|
|
43
|
+
"validate": "validate-structure check",
|
|
44
|
+
"precommit": "validate-structure check"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Example Project Structure
|
|
50
|
+
|
|
51
|
+
For a React project, the tool validates this structure:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
src/
|
|
55
|
+
├── components/
|
|
56
|
+
│ ├── Button/
|
|
57
|
+
│ │ ├── Button.tsx ✓ Component file
|
|
58
|
+
│ │ ├── Button.test.tsx ✓ Test file
|
|
59
|
+
│ │ ├── Button.stories.tsx ✓ Story file
|
|
60
|
+
│ │ └── index.ts ✓ Export file
|
|
61
|
+
│ └── Card/
|
|
62
|
+
│ ├── Card.tsx
|
|
63
|
+
│ ├── Card.test.tsx
|
|
64
|
+
│ └── Card.stories.tsx
|
|
65
|
+
├── hooks/
|
|
66
|
+
│ ├── useAuth.ts ✓ camelCase
|
|
67
|
+
│ └── useAuth.test.ts
|
|
68
|
+
└── utils/
|
|
69
|
+
├── formatDate.ts ✓ camelCase
|
|
70
|
+
└── formatDate.test.ts
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Common Validation Errors
|
|
74
|
+
|
|
75
|
+
### Missing Test File
|
|
76
|
+
```
|
|
77
|
+
✗ Missing required file: Test file for component
|
|
78
|
+
Directory: components/Button
|
|
79
|
+
Expected: Button.test.tsx
|
|
80
|
+
💡 Create Button.test.tsx in components/Button/
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Wrong Naming Convention
|
|
84
|
+
```
|
|
85
|
+
✗ File name doesn't follow PascalCase convention
|
|
86
|
+
File: components/button/button.tsx
|
|
87
|
+
Actual: button.tsx
|
|
88
|
+
Expected: Button.tsx
|
|
89
|
+
💡 Rename to Button.tsx
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Customization
|
|
93
|
+
|
|
94
|
+
Edit `.validate-structurerc.json` to customize:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"preset": "react",
|
|
99
|
+
"rules": {
|
|
100
|
+
"componentColocation": {
|
|
101
|
+
"enabled": true,
|
|
102
|
+
"componentDirs": ["components", "pages", "features"],
|
|
103
|
+
"requiredFiles": [
|
|
104
|
+
{
|
|
105
|
+
"pattern": "*.test.{ts,tsx}",
|
|
106
|
+
"required": true
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"pattern": "*.stories.{ts,tsx}",
|
|
110
|
+
"required": false
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"ignore": [
|
|
116
|
+
"**/node_modules/**",
|
|
117
|
+
"**/dist/**"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## CI/CD Integration
|
|
123
|
+
|
|
124
|
+
### GitHub Actions
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
name: Validate Structure
|
|
128
|
+
on: [push, pull_request]
|
|
129
|
+
|
|
130
|
+
jobs:
|
|
131
|
+
validate:
|
|
132
|
+
runs-on: ubuntu-latest
|
|
133
|
+
steps:
|
|
134
|
+
- uses: actions/checkout@v3
|
|
135
|
+
- uses: actions/setup-node@v3
|
|
136
|
+
- run: npm ci
|
|
137
|
+
- run: npx validate-structure check
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Pre-commit Hook
|
|
141
|
+
|
|
142
|
+
Using Husky:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"husky": {
|
|
147
|
+
"hooks": {
|
|
148
|
+
"pre-commit": "validate-structure check"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Next Steps
|
|
155
|
+
|
|
156
|
+
- Read the full [README.md](README.md) for detailed documentation
|
|
157
|
+
- Check [CONTRIBUTING.md](CONTRIBUTING.md) to add new presets
|
|
158
|
+
- View [CHANGELOG.md](CHANGELOG.md) for version history
|
|
159
|
+
|
|
160
|
+
## Need Help?
|
|
161
|
+
|
|
162
|
+
- 📖 [Full Documentation](README.md)
|
|
163
|
+
- 🐛 [Report Issues](https://github.com/yourusername/project-structure-lint/issues)
|
|
164
|
+
- 💬 [Discussions](https://github.com/yourusername/project-structure-lint/discussions)
|