@sun-asterisk/sunlint 1.2.2 → 1.3.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.
Files changed (124) hide show
  1. package/CHANGELOG.md +107 -1
  2. package/CONTRIBUTING.md +1654 -66
  3. package/README.md +19 -6
  4. package/config/ci-cd.json +54 -0
  5. package/config/development.json +56 -0
  6. package/config/engines/engines-enhanced.json +86 -0
  7. package/config/engines/semantic-config.json +114 -0
  8. package/config/eslint-rule-mapping.json +50 -38
  9. package/config/large-project.json +143 -0
  10. package/config/presets/all.json +0 -1
  11. package/config/release.json +70 -0
  12. package/config/rule-analysis-strategies.js +23 -4
  13. package/config/rules/S027-categories.json +122 -0
  14. package/config/rules/enhanced-rules-registry.json +2564 -0
  15. package/config/rules/rules-registry-generated.json +785 -837
  16. package/config/rules/rules-registry.json +13 -1
  17. package/core/adapters/sunlint-rule-adapter.js +25 -30
  18. package/core/analysis-orchestrator.js +42 -2
  19. package/core/categories.js +52 -0
  20. package/core/category-constants.js +39 -0
  21. package/core/cli-action-handler.js +53 -32
  22. package/core/cli-program.js +11 -3
  23. package/core/config-manager.js +111 -0
  24. package/core/config-merger.js +88 -0
  25. package/core/constants/categories.js +168 -0
  26. package/core/constants/defaults.js +165 -0
  27. package/core/constants/engines.js +185 -0
  28. package/core/constants/index.js +30 -0
  29. package/core/constants/rules.js +215 -0
  30. package/core/enhanced-rules-registry.js +3 -3
  31. package/core/file-targeting-service.js +128 -7
  32. package/core/interfaces/rule-plugin.interface.js +207 -0
  33. package/core/plugin-manager.js +448 -0
  34. package/core/rule-selection-service.js +42 -15
  35. package/core/semantic-engine.js +658 -0
  36. package/core/semantic-rule-base.js +433 -0
  37. package/core/unified-rule-registry.js +484 -0
  38. package/docs/COMMAND-EXAMPLES.md +134 -0
  39. package/docs/CONSTANTS-ARCHITECTURE.md +288 -0
  40. package/docs/LARGE-PROJECT-GUIDE.md +324 -0
  41. package/engines/core/base-engine.js +249 -0
  42. package/engines/engine-factory.js +275 -0
  43. package/engines/eslint-engine.js +171 -19
  44. package/engines/heuristic-engine.js +569 -78
  45. package/integrations/eslint/plugin/index.js +26 -28
  46. package/origin-rules/common-en.md +8 -8
  47. package/package.json +10 -6
  48. package/rules/common/C003_no_vague_abbreviations/analyzer.js +1 -1
  49. package/rules/common/C017_constructor_logic/analyzer.js +254 -17
  50. package/rules/common/C017_constructor_logic/semantic-analyzer.js +340 -0
  51. package/rules/common/C029_catch_block_logging/analyzer.js +17 -5
  52. package/rules/common/C033_separate_service_repository/README.md +78 -0
  53. package/rules/common/C033_separate_service_repository/analyzer.js +160 -0
  54. package/rules/common/C033_separate_service_repository/config.json +50 -0
  55. package/rules/common/C033_separate_service_repository/regex-based-analyzer.js +585 -0
  56. package/rules/common/C033_separate_service_repository/symbol-based-analyzer.js +368 -0
  57. package/rules/common/C035_error_logging_context/STRATEGY.md +99 -0
  58. package/rules/common/C035_error_logging_context/analyzer.js +230 -0
  59. package/rules/common/C035_error_logging_context/config.json +54 -0
  60. package/rules/common/C035_error_logging_context/regex-based-analyzer.js +299 -0
  61. package/rules/common/C035_error_logging_context/symbol-based-analyzer.js +454 -0
  62. package/rules/common/C040_centralized_validation/analyzer.js +165 -0
  63. package/rules/common/C040_centralized_validation/config.json +46 -0
  64. package/rules/common/C040_centralized_validation/regex-based-analyzer.js +243 -0
  65. package/rules/common/C040_centralized_validation/symbol-based-analyzer.js +416 -0
  66. package/rules/common/C047_no_duplicate_retry_logic/c047-semantic-rule.js +278 -0
  67. package/rules/common/C047_no_duplicate_retry_logic/symbol-analyzer-enhanced.js +968 -0
  68. package/rules/common/C047_no_duplicate_retry_logic/symbol-config.json +71 -0
  69. package/rules/common/{C076_single_test_behavior → C072_single_test_behavior}/analyzer.js +6 -6
  70. package/rules/common/C076_explicit_function_types/README.md +30 -0
  71. package/rules/common/C076_explicit_function_types/analyzer.js +172 -0
  72. package/rules/common/C076_explicit_function_types/config.json +15 -0
  73. package/rules/common/C076_explicit_function_types/semantic-analyzer.js +341 -0
  74. package/rules/index.js +8 -0
  75. package/rules/parser/rule-parser.js +13 -2
  76. package/rules/security/S005_no_origin_auth/README.md +226 -0
  77. package/rules/security/S005_no_origin_auth/analyzer.js +184 -0
  78. package/rules/security/S005_no_origin_auth/ast-analyzer.js +406 -0
  79. package/rules/security/S005_no_origin_auth/config.json +85 -0
  80. package/rules/security/S006_no_plaintext_recovery_codes/README.md +139 -0
  81. package/rules/security/S006_no_plaintext_recovery_codes/analyzer.js +306 -0
  82. package/rules/security/S006_no_plaintext_recovery_codes/config.json +48 -0
  83. package/rules/security/S007_no_plaintext_otp/README.md +198 -0
  84. package/rules/security/S007_no_plaintext_otp/analyzer.js +406 -0
  85. package/rules/security/S007_no_plaintext_otp/config.json +79 -0
  86. package/rules/security/S007_no_plaintext_otp/semantic-analyzer.js +609 -0
  87. package/rules/security/S007_no_plaintext_otp/semantic-config.json +195 -0
  88. package/rules/security/S007_no_plaintext_otp/semantic-wrapper.js +280 -0
  89. package/rules/security/S027_no_hardcoded_secrets/analyzer.js +180 -366
  90. package/rules/security/S027_no_hardcoded_secrets/categories.json +153 -0
  91. package/rules/security/S027_no_hardcoded_secrets/categorized-analyzer.js +250 -0
  92. package/scripts/category-manager.js +150 -0
  93. package/scripts/generate-rules-registry.js +88 -0
  94. package/scripts/migrate-rule-registry.js +157 -0
  95. package/scripts/prepare-release.sh +1 -1
  96. package/scripts/validate-system.js +48 -0
  97. package/.sunlint.json +0 -35
  98. package/config/README.md +0 -88
  99. package/config/engines/eslint-rule-mapping.json +0 -74
  100. package/config/schemas/sunlint-schema.json +0 -0
  101. package/config/testing/test-s005-working.ts +0 -22
  102. package/core/multi-rule-runner.js +0 -0
  103. package/docs/ESLINT-INTEGRATION-STRATEGY.md +0 -392
  104. package/docs/FUTURE_PACKAGES.md +0 -83
  105. package/docs/HEURISTIC_VS_AI.md +0 -113
  106. package/docs/PRODUCTION_DEPLOYMENT_ANALYSIS.md +0 -112
  107. package/docs/PRODUCTION_SIZE_IMPACT.md +0 -183
  108. package/docs/RELEASE_GUIDE.md +0 -230
  109. package/docs/STANDARDIZED-CATEGORY-FILTERING.md +0 -156
  110. package/engines/tree-sitter-parser.js +0 -0
  111. package/engines/universal-ast-engine.js +0 -0
  112. package/integrations/eslint/plugin/rules/common/c076-single-behavior-per-test.js +0 -254
  113. package/rules/common/C029_catch_block_logging/analyzer-backup.js +0 -426
  114. package/rules/common/C029_catch_block_logging/analyzer-fixed.js +0 -130
  115. package/rules/common/C029_catch_block_logging/analyzer-multi-tech.js +0 -487
  116. package/rules/common/C029_catch_block_logging/analyzer-simple.js +0 -110
  117. package/rules/common/C029_catch_block_logging/ast-analyzer-backup.js +0 -441
  118. package/rules/common/C029_catch_block_logging/ast-analyzer-new.js +0 -127
  119. package/rules/common/C029_catch_block_logging/ast-analyzer.js +0 -133
  120. package/rules/common/C029_catch_block_logging/cfg-analyzer.js +0 -408
  121. package/rules/common/C029_catch_block_logging/dataflow-analyzer.js +0 -454
  122. package/rules/common/C029_catch_block_logging/multi-language-ast-engine.js +0 -700
  123. package/rules/common/C029_catch_block_logging/pattern-learning-analyzer.js +0 -568
  124. package/rules/common/C029_catch_block_logging/semantic-analyzer.js +0 -459
@@ -0,0 +1,288 @@
1
+ # SunLint Constants Architecture
2
+
3
+ ## Overview
4
+
5
+ SunLint now uses a centralized constants sub-package located at `core/constants/` to manage all constants and configuration values. This improves code organization, maintainability, and extensibility.
6
+
7
+ ## Structure
8
+
9
+ ```
10
+ core/
11
+ constants/
12
+ categories.js # Category-principle mappings and functions
13
+ defaults.js # Default configurations and values
14
+ engines.js # Engine capabilities and configurations
15
+ rules.js # Rule-related constants and utilities
16
+ index.js # Barrel export for all constants
17
+ ```
18
+
19
+ ## Migration Guide
20
+
21
+ ### Before (Old approach)
22
+ ```javascript
23
+ // Scattered constants across multiple files
24
+ const { getValidCategories } = require('./core/category-constants');
25
+ const defaultRules = ['C006', 'C019']; // Hardcoded in various files
26
+ const SUPPORTED_ENGINES = { /* scattered */ };
27
+ ```
28
+
29
+ ### After (New centralized approach)
30
+ ```javascript
31
+ // Option 1: Import specific module
32
+ const { getValidCategories } = require('./core/constants/categories');
33
+ const { getDefaultRuleSet } = require('./core/constants/defaults');
34
+ const { SUPPORTED_ENGINES } = require('./core/constants/engines');
35
+
36
+ // Option 2: Import from barrel export
37
+ const {
38
+ getValidCategories,
39
+ getDefaultRuleSet,
40
+ SUPPORTED_ENGINES
41
+ } = require('./core/constants');
42
+
43
+ // Option 3: Import entire module
44
+ const constants = require('./core/constants');
45
+ const categories = constants.getValidCategories();
46
+ ```
47
+
48
+ ## Modules
49
+
50
+ ### 1. Categories (`core/constants/categories.js`)
51
+
52
+ **Purpose**: Category-principle mappings, validation, and normalization.
53
+
54
+ **Key Exports**:
55
+ ```javascript
56
+ // Constants
57
+ SUNLINT_PRINCIPLES // Object with all principle constants
58
+ CATEGORY_PRINCIPLE_MAP // Category to principle mapping
59
+ CATEGORY_DESCRIPTIONS // Human-readable descriptions
60
+
61
+ // Functions
62
+ getValidCategories() // Get all valid categories
63
+ getCategoryPrinciples(category) // Get principles for category
64
+ isValidCategory(category) // Validate category
65
+ normalizeCategory(category) // Normalize and validate
66
+ getCategoryStats() // Get statistics
67
+ ```
68
+
69
+ **Example Usage**:
70
+ ```javascript
71
+ const { getValidCategories, normalizeCategory } = require('./core/constants/categories');
72
+
73
+ const validCategories = getValidCategories();
74
+ // ['security', 'quality', 'performance', ...]
75
+
76
+ const normalized = normalizeCategory('QUALITY');
77
+ // 'quality'
78
+ ```
79
+
80
+ ### 2. Defaults (`core/constants/defaults.js`)
81
+
82
+ **Purpose**: Default configurations, rule sets, and standard values.
83
+
84
+ **Key Exports**:
85
+ ```javascript
86
+ // Constants
87
+ DEFAULT_RULE_SETS // Predefined rule sets (MINIMAL, ESSENTIAL, etc.)
88
+ DEFAULT_CONFIG // Default configuration object
89
+ DEFAULT_SEVERITIES // Severity levels
90
+ DEFAULT_TIMEOUTS // Timeout configurations
91
+ DEFAULT_LIMITS // File size and processing limits
92
+
93
+ // Functions
94
+ getDefaultRuleSet(name) // Get predefined rule set
95
+ getDefaultConfig(overrides) // Get configuration with overrides
96
+ getLanguageExtensions(lang) // Get file extensions for language
97
+ isFileSizeValid(size) // Check file size limits
98
+ ```
99
+
100
+ **Example Usage**:
101
+ ```javascript
102
+ const { getDefaultRuleSet, getDefaultConfig } = require('./core/constants/defaults');
103
+
104
+ const essentialRules = getDefaultRuleSet('ESSENTIAL');
105
+ // ['C001', 'C002', 'C003', ...]
106
+
107
+ const config = getDefaultConfig({ verbose: true });
108
+ // { verbose: true, useRegistry: true, ... }
109
+ ```
110
+
111
+ ### 3. Engines (`core/constants/engines.js`)
112
+
113
+ **Purpose**: Engine capabilities, configurations, and language support.
114
+
115
+ **Key Exports**:
116
+ ```javascript
117
+ // Constants
118
+ SUPPORTED_ENGINES // Object with all supported engines
119
+ ENGINE_CAPABILITIES // Engine features and language support
120
+ ENGINE_MODES // Execution modes (sequential, parallel, etc.)
121
+ ENGINE_PERFORMANCE // Performance characteristics
122
+
123
+ // Functions
124
+ getEngineLanguages(engine) // Get supported languages
125
+ getEnginesForLanguage(language) // Get engines for language
126
+ getRecommendedEngine(language) // Get best engine for language
127
+ isLanguageSupported(engine, lang) // Check support
128
+ getEnginePerformance(engine) // Get performance info
129
+ ```
130
+
131
+ **Example Usage**:
132
+ ```javascript
133
+ const { getEnginesForLanguage, getRecommendedEngine } = require('./core/constants/engines');
134
+
135
+ const jsEngines = getEnginesForLanguage('javascript');
136
+ // [{ name: 'heuristic', priority: 1, features: [...] }, ...]
137
+
138
+ const recommended = getRecommendedEngine('typescript');
139
+ // 'heuristic'
140
+ ```
141
+
142
+ ### 4. Rules (`core/constants/rules.js`)
143
+
144
+ **Purpose**: Rule-related constants, metadata, and utilities.
145
+
146
+ **Key Exports**:
147
+ ```javascript
148
+ // Constants
149
+ RULE_SEVERITIES // Severity levels (ERROR, WARNING, etc.)
150
+ RULE_STATUS // Execution status values
151
+ RULE_TYPES // Analysis types (HEURISTIC, AST, etc.)
152
+ RULE_SCOPES // Operation scopes (FILE, PROJECT, etc.)
153
+ RULE_LANGUAGE_PATTERNS // Regex patterns for rule IDs
154
+ RULE_TIMEOUTS // Timeout values by rule type
155
+
156
+ // Functions
157
+ getLanguageFromRuleId(ruleId) // Extract language from rule ID
158
+ isValidRuleId(ruleId) // Validate rule ID format
159
+ getRuleTimeout(type) // Get timeout for rule type
160
+ getDefaultRuleMetadata(overrides) // Get rule metadata template
161
+ isValidSeverity(severity) // Validate severity level
162
+ ```
163
+
164
+ **Example Usage**:
165
+ ```javascript
166
+ const { getLanguageFromRuleId, isValidRuleId } = require('./core/constants/rules');
167
+
168
+ const language = getLanguageFromRuleId('C001');
169
+ // 'common'
170
+
171
+ const isValid = isValidRuleId('CUSTOM_RULE');
172
+ // true
173
+ ```
174
+
175
+ ## Backward Compatibility
176
+
177
+ The following files are maintained for backward compatibility but are deprecated:
178
+
179
+ - `core/category-constants.js` - Proxies to `core/constants/categories.js`
180
+ - `core/categories.js` - Proxies to `core/constants/categories.js`
181
+
182
+ **Migration Path**:
183
+ 1. Update imports to use `core/constants/*` directly
184
+ 2. Replace deprecated file imports gradually
185
+ 3. Legacy files will be removed in future versions
186
+
187
+ ## Benefits
188
+
189
+ ### 1. **Better Organization**
190
+ - Related constants grouped together
191
+ - Clear separation of concerns
192
+ - Easier to locate and modify constants
193
+
194
+ ### 2. **Improved Maintainability**
195
+ - Single source of truth for each type of constant
196
+ - Centralized documentation and examples
197
+ - Easier to add new constants or modify existing ones
198
+
199
+ ### 3. **Enhanced Extensibility**
200
+ - Modular structure supports new constant types
201
+ - Barrel export provides flexible import options
202
+ - Framework for adding new engines, rules, categories
203
+
204
+ ### 4. **Developer Experience**
205
+ - Clearer imports with specific module names
206
+ - Better IDE support and autocomplete
207
+ - Self-documenting code structure
208
+
209
+ ## Best Practices
210
+
211
+ ### 1. **Import Strategy**
212
+ ```javascript
213
+ // ✅ Good: Import specific functions
214
+ const { getValidCategories, normalizeCategory } = require('./core/constants/categories');
215
+
216
+ // ✅ Good: Import from barrel for multiple modules
217
+ const { getValidCategories, getDefaultRuleSet } = require('./core/constants');
218
+
219
+ // ❌ Avoid: Importing entire modules unnecessarily
220
+ const allConstants = require('./core/constants');
221
+ ```
222
+
223
+ ### 2. **Adding New Constants**
224
+ ```javascript
225
+ // Add to appropriate module (e.g., categories.js)
226
+ const NEW_CATEGORY_FEATURE = 'new-feature';
227
+
228
+ // Export in module
229
+ module.exports = {
230
+ NEW_CATEGORY_FEATURE,
231
+ // ... other exports
232
+ };
233
+
234
+ // Update barrel export (index.js) if needed
235
+ ```
236
+
237
+ ### 3. **Extending Functionality**
238
+ ```javascript
239
+ // Add utility functions to appropriate modules
240
+ function getAdvancedCategoryInfo(category) {
241
+ // Implementation
242
+ }
243
+
244
+ // Export with other functions
245
+ module.exports = {
246
+ // ... existing exports
247
+ getAdvancedCategoryInfo
248
+ };
249
+ ```
250
+
251
+ ## Testing
252
+
253
+ Each constants module includes comprehensive tests:
254
+
255
+ ```bash
256
+ # Test entire constants structure
257
+ node test-constants-structure.js
258
+
259
+ # Test backward compatibility
260
+ node test-centralized-categories.js
261
+ ```
262
+
263
+ ## Future Enhancements
264
+
265
+ ### Planned Features
266
+ 1. **Dynamic Configuration Loading** - Load constants from external files
267
+ 2. **Environment-specific Constants** - Different values for dev/prod
268
+ 3. **Validation Schemas** - JSON Schema validation for all constants
269
+ 4. **Hot Reloading** - Update constants without restarting
270
+
271
+ ### Extension Points
272
+ - Add new constant modules (e.g., `integrations.js`, `plugins.js`)
273
+ - Extend barrel export for new modules
274
+ - Add validation functions for new constant types
275
+
276
+ ---
277
+
278
+ ## Quick Reference
279
+
280
+ | Module | Purpose | Key Functions |
281
+ |--------|---------|---------------|
282
+ | `categories.js` | Category management | `getValidCategories()`, `normalizeCategory()` |
283
+ | `defaults.js` | Default values | `getDefaultConfig()`, `getDefaultRuleSet()` |
284
+ | `engines.js` | Engine configuration | `getEnginesForLanguage()`, `getRecommendedEngine()` |
285
+ | `rules.js` | Rule utilities | `getLanguageFromRuleId()`, `isValidRuleId()` |
286
+ | `index.js` | Barrel export | All functions from all modules |
287
+
288
+ For detailed API documentation, see the JSDoc comments in each module file.
@@ -0,0 +1,324 @@
1
+ # 🏗️ Large Project Analysis Guide
2
+
3
+ > **For projects with 1000+ files**: Complete strategies to optimize SunLint performance while maintaining comprehensive analysis coverage.
4
+
5
+ ## 📊 Overview
6
+
7
+ SunLint uses **semantic analysis** for advanced rules like `C047` (retry pattern detection). For large projects, you can control the scope of semantic analysis to balance accuracy vs performance.
8
+
9
+ ### 🎯 Key Benefits
10
+
11
+ - **Configurable file limits**: Control memory usage and analysis time
12
+ - **Smart defaults**: Automatic optimization for different project sizes
13
+ - **Multiple strategies**: Choose the best approach for your workflow
14
+ - **Full coverage options**: Ensure no violations are missed
15
+
16
+ ## ⚙️ Configuration Options
17
+
18
+ ### CLI Option: `--max-semantic-files`
19
+
20
+ Controls how many files are loaded for semantic analysis:
21
+
22
+ ```bash
23
+ # Default behavior (auto-detect)
24
+ node cli.js --all --input=.
25
+
26
+ # Conservative analysis (500 files)
27
+ node cli.js --all --input=. --max-semantic-files=500
28
+
29
+ # Balanced analysis (1000 files - default)
30
+ node cli.js --all --input=. --max-semantic-files=1000
31
+
32
+ # Comprehensive analysis (2000 files)
33
+ node cli.js --all --input=. --max-semantic-files=2000
34
+
35
+ # Unlimited analysis (all files)
36
+ node cli.js --all --input=. --max-semantic-files=-1
37
+
38
+ # Disable semantic analysis (heuristic only)
39
+ node cli.js --all --input=. --max-semantic-files=0
40
+ ```
41
+
42
+ ### 📋 Recommended Limits by Project Size
43
+
44
+ | Project Size | Files Count | Recommended Limit | Memory Usage | Analysis Time |
45
+ |-------------|-------------|-------------------|--------------|---------------|
46
+ | **Small** | < 100 files | `0` (all files) | Low | Fast |
47
+ | **Medium** | 100-500 files | `500` | Medium | Medium |
48
+ | **Large** | 500-2000 files | `1000` ⭐ | Medium-High | Medium |
49
+ | **Enterprise** | 2000-5000 files | `1500` | High | Slow |
50
+ | **Massive** | 5000+ files | `500-1000` | Controlled | Reasonable |
51
+
52
+ ⭐ **Default recommended setting**
53
+
54
+ ## 🚀 Analysis Strategies
55
+
56
+ ### Strategy 1: Incremental Development
57
+
58
+ Perfect for daily development work:
59
+
60
+ ```bash
61
+ # Focus on changed files only (fastest)
62
+ node cli.js --all --changed-files --max-semantic-files=300 --format=summary
63
+
64
+ # Target specific modules
65
+ node cli.js --all --input=src/auth --max-semantic-files=1000 --format=summary
66
+ node cli.js --all --input=src/api --max-semantic-files=1000 --format=summary
67
+
68
+ # Use file patterns to focus on critical code
69
+ node cli.js --all --include="src/**/*.ts" --exclude="**/*.test.*" --max-semantic-files=1500
70
+ ```
71
+
72
+ ### Strategy 2: CI/CD Pipeline Optimization
73
+
74
+ Optimize for different CI stages:
75
+
76
+ ```bash
77
+ # PR checks: Fast semantic analysis
78
+ node cli.js --all --changed-files --max-semantic-files=300 --format=github --no-ai
79
+
80
+ # Nightly builds: Medium coverage
81
+ node cli.js --all --input=. --max-semantic-files=1000 --format=json --output=nightly.json
82
+
83
+ # Weekly reports: Comprehensive analysis
84
+ node cli.js --all --input=. --max-semantic-files=-1 --format=detailed --output=weekly.json
85
+
86
+ # Release validation: Full coverage with baseline
87
+ node cli.js --all --input=. --max-semantic-files=2000 --baseline=last-release.json
88
+ ```
89
+
90
+ ### Strategy 3: Rule-Based Prioritization
91
+
92
+ Different limits for different rule types:
93
+
94
+ ```bash
95
+ # Phase 1: Critical security (fast heuristic rules)
96
+ node cli.js --security --input=. --max-semantic-files=0 --format=summary
97
+
98
+ # Phase 2: Code quality basics
99
+ node cli.js --rules=C006,C019,C029 --input=. --max-semantic-files=500 --format=summary
100
+
101
+ # Phase 3: Advanced semantic rules (targeted)
102
+ node cli.js --rules=C047 --input=src --max-semantic-files=1000 --format=summary
103
+
104
+ # Phase 4: Full comprehensive scan
105
+ node cli.js --all --input=. --max-semantic-files=-1 --format=detailed
106
+ ```
107
+
108
+ ### Strategy 4: Monorepo Management
109
+
110
+ For large monorepos with multiple packages:
111
+
112
+ ```bash
113
+ # Analyze each package separately
114
+ for package in packages/*/; do
115
+ node cli.js --all --input="$package" --max-semantic-files=1000 \
116
+ --format=json --output="${package//\//-}-report.json"
117
+ done
118
+
119
+ # Focus on core packages first
120
+ node cli.js --all --input=packages/core --max-semantic-files=2000 --format=summary
121
+ node cli.js --all --input=packages/api --max-semantic-files=1500 --format=summary
122
+ node cli.js --all --input=packages/ui --max-semantic-files=1000 --format=summary
123
+
124
+ # Changed files across the entire monorepo
125
+ node cli.js --all --changed-files --max-semantic-files=500 --format=summary
126
+ ```
127
+
128
+ ## 📈 Performance Monitoring
129
+
130
+ ### Memory & Time Tracking
131
+
132
+ ```bash
133
+ # Monitor performance with different limits
134
+ time node cli.js --all --input=. --max-semantic-files=500 --format=summary
135
+ time node cli.js --all --input=. --max-semantic-files=1000 --format=summary
136
+ time node cli.js --all --input=. --max-semantic-files=2000 --format=summary
137
+
138
+ # Memory-conscious analysis for CI
139
+ node cli.js --all --input=. --max-semantic-files=300 --max-concurrent=2 --format=summary
140
+
141
+ # Debug file loading behavior
142
+ node cli.js --all --input=. --max-semantic-files=1000 --verbose --debug
143
+ ```
144
+
145
+ ### Coverage Analysis
146
+
147
+ Check what percentage of your project is being analyzed:
148
+
149
+ ```bash
150
+ # Show file loading statistics
151
+ node cli.js --all --input=. --max-semantic-files=1000 --verbose --format=summary
152
+
153
+ # Compare different limits
154
+ node cli.js --all --input=. --max-semantic-files=500 --verbose --dry-run
155
+ node cli.js --all --input=. --max-semantic-files=1000 --verbose --dry-run
156
+ node cli.js --all --input=. --max-semantic-files=-1 --verbose --dry-run
157
+ ```
158
+
159
+ ## 🎛️ Configuration Files
160
+
161
+ ### sunlint.config.json
162
+
163
+ Create a configuration file for consistent settings:
164
+
165
+ ```json
166
+ {
167
+ "performance": {
168
+ "maxSemanticFiles": 1000,
169
+ "maxConcurrentRules": 5,
170
+ "timeoutMs": 30000
171
+ },
172
+ "input": ["src", "lib"],
173
+ "exclude": [
174
+ "**/*.test.*",
175
+ "**/*.d.ts",
176
+ "**/generated/**"
177
+ ],
178
+ "output": {
179
+ "format": "summary"
180
+ },
181
+ "engines": {
182
+ "semantic": {
183
+ "enabled": true,
184
+ "fileLimit": 1000
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ ### Environment-Specific Configs
191
+
192
+ Different configs for different environments:
193
+
194
+ ```bash
195
+ # Development (fast feedback)
196
+ cp config/sunlint.dev.json sunlint.config.json
197
+ node cli.js --all --input=.
198
+
199
+ # CI (balanced coverage)
200
+ cp config/sunlint.ci.json sunlint.config.json
201
+ node cli.js --all --changed-files
202
+
203
+ # Release (comprehensive)
204
+ cp config/sunlint.release.json sunlint.config.json
205
+ node cli.js --all --input=.
206
+ ```
207
+
208
+ ## 💡 Best Practices
209
+
210
+ ### 1. Start Conservative, Scale Up
211
+
212
+ ```bash
213
+ # Begin with conservative limits
214
+ node cli.js --all --input=. --max-semantic-files=500 --format=summary
215
+
216
+ # Gradually increase if performance allows
217
+ node cli.js --all --input=. --max-semantic-files=1000 --format=summary
218
+ node cli.js --all --input=. --max-semantic-files=1500 --format=summary
219
+ ```
220
+
221
+ ### 2. Use Different Limits for Different Contexts
222
+
223
+ ```bash
224
+ # Daily development: Focus on changed files
225
+ alias sunlint-dev="node cli.js --all --changed-files --max-semantic-files=300"
226
+
227
+ # Code review: Medium coverage
228
+ alias sunlint-review="node cli.js --all --changed-files --max-semantic-files=500"
229
+
230
+ # Release preparation: Full coverage
231
+ alias sunlint-release="node cli.js --all --input=. --max-semantic-files=-1"
232
+ ```
233
+
234
+ ### 3. Monitor and Adjust
235
+
236
+ Track your analysis performance over time:
237
+
238
+ ```bash
239
+ # Create performance baseline
240
+ echo "Project size: $(find . -name '*.ts' -o -name '*.js' | wc -l) files"
241
+ time node cli.js --all --input=. --max-semantic-files=1000 --format=summary
242
+
243
+ # Adjust based on CI constraints
244
+ if [[ $CI_MEMORY_LIMIT -lt 4096 ]]; then
245
+ SEMANTIC_LIMIT=500
246
+ else
247
+ SEMANTIC_LIMIT=1000
248
+ fi
249
+
250
+ node cli.js --all --input=. --max-semantic-files=$SEMANTIC_LIMIT --format=summary
251
+ ```
252
+
253
+ ### 4. Combine with File Targeting
254
+
255
+ Use semantic limits together with file patterns:
256
+
257
+ ```bash
258
+ # Focus semantic analysis on source files only
259
+ node cli.js --all --include="src/**/*.ts" --exclude="**/*.test.*" --max-semantic-files=1500
260
+
261
+ # Analyze tests separately with lower limits
262
+ node cli.js --all --include="**/*.test.*" --max-semantic-files=500
263
+
264
+ # Target critical modules with higher limits
265
+ node cli.js --all --input=src/security --max-semantic-files=2000
266
+ node cli.js --all --input=src/api --max-semantic-files=1500
267
+ ```
268
+
269
+ ## 🔍 Troubleshooting
270
+
271
+ ### Memory Issues
272
+
273
+ If you encounter out-of-memory errors:
274
+
275
+ ```bash
276
+ # Reduce semantic file limit
277
+ node cli.js --all --input=. --max-semantic-files=500
278
+
279
+ # Disable semantic analysis completely
280
+ node cli.js --all --input=. --max-semantic-files=0
281
+
282
+ # Reduce concurrent rules
283
+ node cli.js --all --input=. --max-semantic-files=1000 --max-concurrent=2
284
+ ```
285
+
286
+ ### Slow Analysis
287
+
288
+ If analysis takes too long:
289
+
290
+ ```bash
291
+ # Use incremental analysis
292
+ node cli.js --all --changed-files --max-semantic-files=300
293
+
294
+ # Focus on specific directories
295
+ node cli.js --all --input=src/critical --max-semantic-files=1000
296
+
297
+ # Use timeout limits
298
+ node cli.js --all --input=. --max-semantic-files=1000 --timeout=60000
299
+ ```
300
+
301
+ ### Missed Violations
302
+
303
+ If you suspect violations are being missed:
304
+
305
+ ```bash
306
+ # Run comprehensive analysis periodically
307
+ node cli.js --all --input=. --max-semantic-files=-1 --format=detailed
308
+
309
+ # Compare different limits
310
+ node cli.js --all --input=. --max-semantic-files=1000 --output=report-1k.json
311
+ node cli.js --all --input=. --max-semantic-files=-1 --output=report-full.json
312
+ diff report-1k.json report-full.json
313
+ ```
314
+
315
+ ## 📚 Related Documentation
316
+
317
+ - [Command Examples](./COMMAND-EXAMPLES.md) - Complete CLI usage examples
318
+ - [Configuration Guide](./CONFIGURATION.md) - Detailed configuration options
319
+ - [CI/CD Guide](./CI-CD-GUIDE.md) - Integration with CI/CD pipelines
320
+ - [Architecture](./ARCHITECTURE.md) - Technical implementation details
321
+
322
+ ---
323
+
324
+ **💡 Pro Tip**: For projects with 2000+ files, consider breaking analysis into modules and running them in parallel, rather than analyzing everything at once.