@sun-asterisk/sunlint
Version:
☀️ SunLint - Multi-language static analysis tool for code quality and security | Sun* Engineering Standards
60 lines (47 loc) • 1.79 kB
Markdown
All rule folders follow the consistent pattern: `C{ID}_{descriptive_name}`
```
rules/
├── C006_function_naming/
│ ├── analyzer.js
│ └── config.json
├── C019_log_level_usage/
│ ├── analyzer.js
│ └── config.json
├── C029_catch_block_logging/
│ ├── analyzer.js
│ └── config.json
└── C031_validation_separation/
├── analyzer.js
└── config.json
```
1. **Consistency** - All folders follow the same pattern
2. **Resilience** - If rule IDs change, descriptive names provide context
3. **Readability** - Easy to understand rule purpose from folder name
4. **Maintainability** - Clear organization for developers
When adding a new rule, follow this pattern:
1. Create folder: `C{ID}_{snake_case_description}/`
2. Add `analyzer.js` with rule implementation
3. Add `config.json` with rule configuration
4. Update `rules-registry.json` with correct paths
5. Add tests in `test/fixtures/`
For a new rule C040 about "API Response Format":
```
rules/C040_api_response_format/
├── analyzer.js
└── config.json
```
Registry entry:
```json
"C040": {
"name": "API Response Format",
"description": "Hàm xử lý API nên return response object chuẩn",
"analyzer": "./rules/C040_api_response_format/analyzer.js",
"config": "./rules/C040_api_response_format/config.json"
}
```