@sun-asterisk/sunlint 1.3.1 → 1.3.3

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 (120) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/CONTRIBUTING.md +210 -1691
  3. package/README.md +5 -3
  4. package/config/rule-analysis-strategies.js +17 -1
  5. package/config/rules/enhanced-rules-registry.json +506 -1161
  6. package/config/rules/rules-registry-generated.json +1 -1
  7. package/core/analysis-orchestrator.js +167 -42
  8. package/core/auto-performance-manager.js +243 -0
  9. package/core/cli-action-handler.js +9 -1
  10. package/core/cli-program.js +19 -5
  11. package/core/constants/defaults.js +56 -0
  12. package/core/enhanced-rules-registry.js +2 -1
  13. package/core/performance-optimizer.js +271 -0
  14. package/core/semantic-engine.js +15 -3
  15. package/core/semantic-rule-base.js +4 -2
  16. package/docs/FILE_LIMITS_COMPLETION_REPORT.md +151 -0
  17. package/docs/FILE_LIMITS_EXPLANATION.md +190 -0
  18. package/docs/PERFORMANCE.md +311 -0
  19. package/docs/PERFORMANCE_MIGRATION_GUIDE.md +368 -0
  20. package/docs/PERFORMANCE_OPTIMIZATION_PLAN.md +255 -0
  21. package/docs/QUICK_FILE_LIMITS.md +64 -0
  22. package/docs/SIMPLIFIED_USAGE_GUIDE.md +208 -0
  23. package/engines/heuristic-engine.js +247 -9
  24. package/integrations/eslint/plugin/rules/common/c003-no-vague-abbreviations.js +59 -1
  25. package/integrations/eslint/plugin/rules/common/c006-function-name-verb-noun.js +26 -1
  26. package/integrations/eslint/plugin/rules/common/c030-use-custom-error-classes.js +54 -19
  27. package/origin-rules/common-en.md +11 -7
  28. package/package.json +2 -1
  29. package/rules/common/C002_no_duplicate_code/analyzer.js +334 -36
  30. package/rules/common/C003_no_vague_abbreviations/analyzer.js +220 -35
  31. package/rules/common/C006_function_naming/analyzer.js +29 -3
  32. package/rules/common/C010_limit_block_nesting/analyzer.js +181 -337
  33. package/rules/common/C010_limit_block_nesting/config.json +64 -0
  34. package/rules/common/C010_limit_block_nesting/regex-based-analyzer.js +379 -0
  35. package/rules/common/C010_limit_block_nesting/symbol-based-analyzer.js +231 -0
  36. package/rules/common/C013_no_dead_code/analyzer.js +75 -177
  37. package/rules/common/C013_no_dead_code/config.json +61 -0
  38. package/rules/common/C013_no_dead_code/regex-based-analyzer.js +345 -0
  39. package/rules/common/C013_no_dead_code/symbol-based-analyzer.js +640 -0
  40. package/rules/common/C014_dependency_injection/analyzer.js +48 -313
  41. package/rules/common/C014_dependency_injection/config.json +26 -0
  42. package/rules/common/C014_dependency_injection/symbol-based-analyzer.js +751 -0
  43. package/rules/common/C018_no_throw_generic_error/analyzer.js +232 -0
  44. package/rules/common/C018_no_throw_generic_error/config.json +50 -0
  45. package/rules/common/C018_no_throw_generic_error/regex-based-analyzer.js +387 -0
  46. package/rules/common/C018_no_throw_generic_error/symbol-based-analyzer.js +314 -0
  47. package/rules/common/C019_log_level_usage/analyzer.js +110 -317
  48. package/rules/common/C019_log_level_usage/pattern-analyzer.js +88 -0
  49. package/rules/common/C019_log_level_usage/system-log-analyzer.js +1267 -0
  50. package/rules/common/C023_no_duplicate_variable/analyzer.js +180 -0
  51. package/rules/common/C023_no_duplicate_variable/config.json +50 -0
  52. package/rules/common/C023_no_duplicate_variable/symbol-based-analyzer.js +158 -0
  53. package/rules/common/C024_no_scatter_hardcoded_constants/analyzer.js +180 -0
  54. package/rules/common/C024_no_scatter_hardcoded_constants/config.json +50 -0
  55. package/rules/common/C024_no_scatter_hardcoded_constants/symbol-based-analyzer.js +181 -0
  56. package/rules/common/C030_use_custom_error_classes/analyzer.js +200 -0
  57. package/rules/common/C035_error_logging_context/analyzer.js +3 -1
  58. package/rules/common/C048_no_bypass_architectural_layers/analyzer.js +180 -0
  59. package/rules/common/C048_no_bypass_architectural_layers/config.json +50 -0
  60. package/rules/common/C048_no_bypass_architectural_layers/symbol-based-analyzer.js +235 -0
  61. package/rules/common/C052_parsing_or_data_transformation/analyzer.js +180 -0
  62. package/rules/common/C052_parsing_or_data_transformation/config.json +50 -0
  63. package/rules/common/C052_parsing_or_data_transformation/symbol-based-analyzer.js +132 -0
  64. package/rules/index.js +7 -1
  65. package/rules/security/S009_no_insecure_encryption/README.md +158 -0
  66. package/rules/security/S009_no_insecure_encryption/analyzer.js +319 -0
  67. package/rules/security/S009_no_insecure_encryption/config.json +55 -0
  68. package/rules/security/S010_no_insecure_encryption/README.md +224 -0
  69. package/rules/security/S010_no_insecure_encryption/analyzer.js +493 -0
  70. package/rules/security/S010_no_insecure_encryption/config.json +48 -0
  71. package/rules/security/S016_no_sensitive_querystring/STRATEGY.md +149 -0
  72. package/rules/security/S016_no_sensitive_querystring/analyzer.js +276 -0
  73. package/rules/security/S016_no_sensitive_querystring/config.json +127 -0
  74. package/rules/security/S016_no_sensitive_querystring/regex-based-analyzer.js +258 -0
  75. package/rules/security/S016_no_sensitive_querystring/symbol-based-analyzer.js +495 -0
  76. package/rules/security/S017_use_parameterized_queries/README.md +128 -0
  77. package/rules/security/S017_use_parameterized_queries/analyzer.js +286 -0
  78. package/rules/security/S017_use_parameterized_queries/config.json +109 -0
  79. package/rules/security/S017_use_parameterized_queries/regex-based-analyzer.js +541 -0
  80. package/rules/security/S017_use_parameterized_queries/symbol-based-analyzer.js +777 -0
  81. package/rules/security/S031_secure_session_cookies/README.md +127 -0
  82. package/rules/security/S031_secure_session_cookies/analyzer.js +245 -0
  83. package/rules/security/S031_secure_session_cookies/config.json +86 -0
  84. package/rules/security/S031_secure_session_cookies/regex-based-analyzer.js +196 -0
  85. package/rules/security/S031_secure_session_cookies/symbol-based-analyzer.js +1084 -0
  86. package/rules/security/S032_httponly_session_cookies/FRAMEWORK_SUPPORT.md +209 -0
  87. package/rules/security/S032_httponly_session_cookies/README.md +184 -0
  88. package/rules/security/S032_httponly_session_cookies/analyzer.js +282 -0
  89. package/rules/security/S032_httponly_session_cookies/config.json +96 -0
  90. package/rules/security/S032_httponly_session_cookies/regex-based-analyzer.js +715 -0
  91. package/rules/security/S032_httponly_session_cookies/symbol-based-analyzer.js +1348 -0
  92. package/rules/security/S033_samesite_session_cookies/README.md +227 -0
  93. package/rules/security/S033_samesite_session_cookies/analyzer.js +242 -0
  94. package/rules/security/S033_samesite_session_cookies/config.json +87 -0
  95. package/rules/security/S033_samesite_session_cookies/regex-based-analyzer.js +703 -0
  96. package/rules/security/S033_samesite_session_cookies/symbol-based-analyzer.js +732 -0
  97. package/rules/security/S034_host_prefix_session_cookies/README.md +204 -0
  98. package/rules/security/S034_host_prefix_session_cookies/analyzer.js +290 -0
  99. package/rules/security/S034_host_prefix_session_cookies/config.json +62 -0
  100. package/rules/security/S034_host_prefix_session_cookies/regex-based-analyzer.js +478 -0
  101. package/rules/security/S034_host_prefix_session_cookies/symbol-based-analyzer.js +277 -0
  102. package/rules/security/S035_path_session_cookies/README.md +257 -0
  103. package/rules/security/S035_path_session_cookies/analyzer.js +316 -0
  104. package/rules/security/S035_path_session_cookies/config.json +99 -0
  105. package/rules/security/S035_path_session_cookies/regex-based-analyzer.js +724 -0
  106. package/rules/security/S035_path_session_cookies/symbol-based-analyzer.js +373 -0
  107. package/rules/security/S048_no_current_password_in_reset/README.md +222 -0
  108. package/rules/security/S048_no_current_password_in_reset/analyzer.js +366 -0
  109. package/rules/security/S048_no_current_password_in_reset/config.json +48 -0
  110. package/rules/security/S055_content_type_validation/README.md +176 -0
  111. package/rules/security/S055_content_type_validation/analyzer.js +312 -0
  112. package/rules/security/S055_content_type_validation/config.json +48 -0
  113. package/rules/utils/rule-helpers.js +140 -1
  114. package/scripts/batch-processing-demo.js +334 -0
  115. package/scripts/consolidate-config.js +116 -0
  116. package/scripts/performance-test.js +541 -0
  117. package/scripts/quick-performance-test.js +108 -0
  118. package/config/rules/S027-categories.json +0 -122
  119. package/config/rules/rules-registry.json +0 -777
  120. package/rules/common/C006_function_naming/smart-analyzer.js +0 -503
@@ -0,0 +1,255 @@
1
+ # 🚀 SunLint Performance Optimization Plan
2
+
3
+ ## 📊 Current Performance Challenges
4
+
5
+ ### **Critical Issues Identified**
6
+ 1. **Timeout Issues**: `Engine heuristic failed: Engine undefined timed out after 30000ms`
7
+ 2. **Memory Exhaustion**: `Maximum call stack size exceeded` with large projects
8
+ 3. **Symbol Table Bottleneck**: Loading 73 rules × large file count = performance disaster
9
+ 4. **Batch Processing Gap**: No intelligent rule batching for large projects
10
+
11
+ ### **Performance Metrics (Current)**
12
+ - **Total Rules**: 100 (Common: 34, Security: 49, Others: 17)
13
+ - **SunLint Rules**: 73 rules with analyzers (3x growth from ~22)
14
+ - **AST-Powered**: 65+ rules requiring semantic analysis
15
+ - **Memory Impact**: Symbol table × file count × rule count = O(n³) complexity
16
+
17
+ ---
18
+
19
+ ## 🎯 Optimization Strategy
20
+
21
+ ### **Phase 1: Immediate Performance Fixes**
22
+
23
+ #### **1.1 Timeout Management**
24
+ ```bash
25
+ # Current: Fixed 30s timeout
26
+ # Solution: Dynamic timeout based on project size
27
+ --timeout=60000 # 60s for large projects
28
+ --timeout=120000 # 120s for enterprise projects
29
+ --adaptive-timeout # Auto-scale based on file count
30
+ ```
31
+
32
+ #### **1.2 File Filtering Enhancement**
33
+ ```bash
34
+ # Current: Basic exclude patterns
35
+ # Solution: Smart exclusion patterns
36
+ --exclude-patterns="node_modules/**,.next/**,dist/**,build/**"
37
+ --max-files=1000 # Hard limit for safety
38
+ --smart-sampling # Intelligent file sampling for large projects
39
+ ```
40
+
41
+ #### **1.3 Rule Batching**
42
+ ```bash
43
+ # Current: All rules processed together
44
+ # Solution: Intelligent rule batching
45
+ --batch-size=10 # Process 10 rules at a time
46
+ --priority-rules=C019,S027,C041 # High-priority rules first
47
+ --parallel-batches=2 # Parallel batch processing
48
+ ```
49
+
50
+ ### **Phase 2: Memory Optimization**
51
+
52
+ #### **2.1 Symbol Table Streaming**
53
+ ```javascript
54
+ // Current: Load all files into memory
55
+ const symbolTable = await loadAllFiles(); // ❌ Memory explosion
56
+
57
+ // Solution: Streaming symbol table
58
+ const symbolTable = new StreamingSymbolTable({
59
+ maxMemoryFiles: 100, // Keep max 100 files in memory
60
+ swapToTemp: true, // Swap to temp files when needed
61
+ lazyLoading: true // Load files on-demand
62
+ });
63
+ ```
64
+
65
+ #### **2.2 Rule-Specific Analysis**
66
+ ```javascript
67
+ // Current: All rules analyze all files
68
+ rules.forEach(rule => files.forEach(file => rule.analyze(file))); // ❌ O(n²)
69
+
70
+ // Solution: Smart rule targeting
71
+ const fileToRulesMap = buildFileRuleMapping(files, rules);
72
+ fileToRulesMap.forEach((rules, file) => {
73
+ rules.forEach(rule => rule.analyze(file)); // ✅ Optimized
74
+ });
75
+ ```
76
+
77
+ ### **Phase 3: Architecture Optimization**
78
+
79
+ #### **3.1 Worker Process Architecture**
80
+ ```javascript
81
+ // Solution: Multi-process rule execution
82
+ const workers = {
83
+ syntaxRules: createWorker('./workers/syntax-rules.js'),
84
+ securityRules: createWorker('./workers/security-rules.js'),
85
+ semanticRules: createWorker('./workers/semantic-rules.js')
86
+ };
87
+
88
+ // Distribute rules across workers
89
+ const results = await Promise.all([
90
+ workers.syntaxRules.analyze(files, syntaxRules),
91
+ workers.securityRules.analyze(files, securityRules),
92
+ workers.semanticRules.analyze(files, semanticRules)
93
+ ]);
94
+ ```
95
+
96
+ #### **3.2 Progressive Analysis**
97
+ ```javascript
98
+ // Solution: Progressive disclosure of violations
99
+ const analyzer = new ProgressiveAnalyzer({
100
+ fastRules: ['C002', 'C003', 'C006'], // Quick regex rules first
101
+ mediumRules: ['C019', 'C041', 'S027'], // Moderate AST rules
102
+ slowRules: ['C033', 'C047', 'C076'] // Heavy semantic rules last
103
+ });
104
+
105
+ // Show results progressively
106
+ analyzer.on('fastComplete', (violations) => {
107
+ console.log(`Quick scan: ${violations.length} issues found`);
108
+ });
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 🛠️ Implementation Roadmap
114
+
115
+ ### **Week 1: Critical Fixes**
116
+ - [ ] **Dynamic timeout configuration**
117
+ - [ ] **Enhanced file exclusion patterns**
118
+ - [ ] **Memory limit safeguards**
119
+ - [ ] **Rule batching implementation**
120
+
121
+ ### **Week 2: Memory Optimization**
122
+ - [ ] **Streaming symbol table**
123
+ - [ ] **File-to-rule mapping optimization**
124
+ - [ ] **Lazy loading for AST analysis**
125
+ - [ ] **Memory monitoring & alerts**
126
+
127
+ ### **Week 3: Architecture Enhancement**
128
+ - [ ] **Worker process architecture**
129
+ - [ ] **Progressive analysis pipeline**
130
+ - [ ] **Parallel rule execution**
131
+ - [ ] **Result caching system**
132
+
133
+ ### **Week 4: Testing & Validation**
134
+ - [ ] **Performance benchmarking**
135
+ - [ ] **Large project testing**
136
+ - [ ] **Memory leak detection**
137
+ - [ ] **Timeout scenario testing**
138
+
139
+ ---
140
+
141
+ ## 📈 Expected Performance Improvements
142
+
143
+ ### **Target Metrics**
144
+ | **Scenario** | **Current** | **Target** | **Improvement** |
145
+ |--------------|-------------|------------|-----------------|
146
+ | **Small Project** (< 100 files) | 30s | 10s | **3x faster** |
147
+ | **Medium Project** (100-500 files) | Timeout | 45s | **Functional** |
148
+ | **Large Project** (500+ files) | Memory crash | 120s | **Functional** |
149
+ | **Enterprise Project** (1000+ files) | Impossible | 300s | **Breakthrough** |
150
+
151
+ ### **Memory Usage**
152
+ | **Project Size** | **Current** | **Target** | **Reduction** |
153
+ |------------------|-------------|------------|---------------|
154
+ | **100 files** | 2GB | 500MB | **75% reduction** |
155
+ | **500 files** | Crash | 1.5GB | **Functional** |
156
+ | **1000+ files** | Crash | 3GB | **Controlled** |
157
+
158
+ ---
159
+
160
+ ## 🚦 Performance Monitoring
161
+
162
+ ### **Key Performance Indicators (KPIs)**
163
+ ```javascript
164
+ const performanceMetrics = {
165
+ // Analysis Speed
166
+ rulesPerSecond: target >= 5,
167
+ filesPerSecond: target >= 20,
168
+ violationsPerSecond: target >= 100,
169
+
170
+ // Memory Efficiency
171
+ memoryUsage: target <= '2GB',
172
+ memoryGrowthRate: target <= '10MB/min',
173
+ garbageCollectionFreq: target <= '5/min',
174
+
175
+ // Reliability
176
+ timeoutRate: target <= '1%',
177
+ crashRate: target <= '0.1%',
178
+ successRate: target >= '99%'
179
+ };
180
+ ```
181
+
182
+ ### **Performance Alerts**
183
+ ```bash
184
+ # Memory warnings
185
+ if (memoryUsage > 1.5GB) warn("High memory usage detected");
186
+ if (memoryUsage > 2.5GB) error("Memory limit approaching");
187
+
188
+ # Timeout warnings
189
+ if (analysisTime > 60s) warn("Analysis taking longer than expected");
190
+ if (analysisTime > 120s) error("Consider using --max-files or --batch-size");
191
+
192
+ # Progress indicators
193
+ echo "⚡ Processing batch 1/5 (20 rules)..."
194
+ echo "📊 Analyzed 245/1000 files (24.5%)"
195
+ echo "🎯 Found 23 violations so far..."
196
+ ```
197
+
198
+ ---
199
+
200
+ ## 🔧 CLI Enhancement
201
+
202
+ ### **New Performance Options**
203
+ ```bash
204
+ # Timeout Management
205
+ sunlint --timeout=120000 # 2 minutes timeout
206
+ sunlint --adaptive-timeout # Auto-scale timeout
207
+ sunlint --no-timeout # Disable timeout (careful!)
208
+
209
+ # Memory Management
210
+ sunlint --max-memory=2GB # Memory limit
211
+ sunlint --max-files=1000 # File count limit
212
+ sunlint --streaming-analysis # Use streaming mode
213
+
214
+ # Batch Processing
215
+ sunlint --batch-size=10 # Rules per batch
216
+ sunlint --parallel-batches=2 # Parallel processing
217
+ sunlint --progressive-results # Show results as available
218
+
219
+ # Performance Profiles
220
+ sunlint --performance-profile=fast # Quick scan (30 rules)
221
+ sunlint --performance-profile=balanced # Standard scan (50 rules)
222
+ sunlint --performance-profile=comprehensive # Full scan (73 rules)
223
+ ```
224
+
225
+ ### **Smart Defaults Based on Project Size**
226
+ ```javascript
227
+ const performanceProfiles = {
228
+ small: { files: '<100', timeout: 30000, batchSize: 20, rules: 'fast' },
229
+ medium: { files: '100-500', timeout: 60000, batchSize: 15, rules: 'balanced' },
230
+ large: { files: '500-1000', timeout: 120000, batchSize: 10, rules: 'essential' },
231
+ enterprise: { files: '>1000', timeout: 300000, batchSize: 5, rules: 'critical' }
232
+ };
233
+ ```
234
+
235
+ ---
236
+
237
+ ## 🏆 Success Criteria
238
+
239
+ ### **Performance Goals**
240
+ - ✅ **Zero timeouts** on projects < 1000 files
241
+ - ✅ **Predictable memory usage** (linear growth, not exponential)
242
+ - ✅ **Progressive results** (show violations as they're found)
243
+ - ✅ **Graceful degradation** (intelligent fallbacks for large projects)
244
+
245
+ ### **User Experience Goals**
246
+ - ✅ **Clear progress indicators** during long analyses
247
+ - ✅ **Meaningful performance warnings** before problems occur
248
+ - ✅ **Smart defaults** based on project size
249
+ - ✅ **Escape hatches** for power users (custom timeouts, batch sizes)
250
+
251
+ ---
252
+
253
+ **Performance optimization is critical for SunLint adoption at scale. With 73 heuristic rules and growing, we must proactively address performance bottlenecks to maintain developer experience quality.**
254
+
255
+ *Engineering Excellence • Performance • Scalability*
@@ -0,0 +1,64 @@
1
+ # 🎯 Quick Reference: File Limits
2
+
3
+ ## **TL;DR: When to Use Each Option**
4
+
5
+ ### **🤖 Most Users (90%)**
6
+ ```bash
7
+ # ✅ Just use auto-detection - no manual limits needed
8
+ sunlint --all --input=src
9
+ ```
10
+
11
+ ### **⚡ Performance Tuning (10%)**
12
+ ```bash
13
+ # ✅ Both limits for different purposes
14
+ sunlint --all --input=src --max-files=1000 --max-semantic-files=300
15
+ ```
16
+
17
+ ---
18
+
19
+ ## **Quick Decision Matrix**
20
+
21
+ | **Situation** | **Use `--max-files`** | **Use `--max-semantic-files`** |
22
+ |---------------|----------------------|---------------------------------|
23
+ | 🐌 **Slow analysis** | ✅ YES - Limit total work | ❌ Not needed |
24
+ | 💾 **Memory issues** | ✅ YES - Reduce base memory | ✅ YES - Reduce symbol table |
25
+ | 🔍 **TypeScript heavy** | ❌ Not main issue | ✅ YES - Limit ts-morph memory |
26
+ | 🚀 **CI/CD timeout** | ✅ YES - Faster completion | ✅ YES - Less parsing |
27
+
28
+ ---
29
+
30
+ ## **📊 Memory Impact**
31
+
32
+ ### **Analysis Files (`--max-files`)**
33
+ - **50MB** → 1000 files
34
+ - **100MB** → 2000 files
35
+ - **Impact**: Base memory + file reading
36
+
37
+ ### **Symbol Table Files (`--max-semantic-files`)**
38
+ - **200MB** → 100 TypeScript files
39
+ - **1GB** → 500 TypeScript files
40
+ - **Impact**: AST parsing + type information
41
+
42
+ ---
43
+
44
+ ## **🎛️ Common Patterns**
45
+
46
+ ```bash
47
+ # 🏢 Enterprise (safe defaults)
48
+ --max-files=800 --max-semantic-files=200
49
+
50
+ # 🚀 CI/CD (fast & reliable)
51
+ --max-files=500 --max-semantic-files=100
52
+
53
+ # 🔍 TypeScript focus (more symbol table)
54
+ --max-files=600 --max-semantic-files=400
55
+
56
+ # 📦 JavaScript mainly (less symbol table)
57
+ --max-files=1500 --max-semantic-files=50
58
+ ```
59
+
60
+ ---
61
+
62
+ **💡 Key Insight: Symbol table limit should typically be smaller than analysis limit due to higher memory usage per file.**
63
+
64
+ *See [FILE_LIMITS_EXPLANATION.md](./FILE_LIMITS_EXPLANATION.md) for detailed explanation.*
@@ -0,0 +1,208 @@
1
+ # 🚀 SunLint Performance - Simplified Usage Guide
2
+
3
+ ## 🎯 **TÓM TẮT: 3 Commands Duy Nhất Bạn Cần Biết**
4
+
5
+ ### **1. 🏃‍♂️ Quick Start (90% use cases)**
6
+ ```bash
7
+ sunlint --all --input=src
8
+ ```
9
+ ✅ **Auto-detects** project size và chọn settings tối ưu
10
+ ✅ **Zero configuration** - chỉ cần chỉ định input folder
11
+ ✅ **Works everywhere** - small projects đến enterprise
12
+
13
+ ### **2. ⚡ Performance Modes (khi cần tùy chỉnh)**
14
+ ```bash
15
+ # Fast scan (for testing/development)
16
+ sunlint --all --input=src --performance=fast
17
+
18
+ # Thorough analysis (for CI/CD)
19
+ sunlint --all --input=src --performance=careful
20
+ ```
21
+
22
+ ### **3. 🛠️ Custom Timeout (khi project rất lớn)**
23
+ ```bash
24
+ sunlint --all --input=src --timeout=120000 # 2 minutes
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 🤖 **Auto Performance Detection**
30
+
31
+ SunLint **tự động phát hiện** project size và chọn settings tối ưu:
32
+
33
+ | **Project Size** | **Files** | **Auto Settings** | **Timeout** |
34
+ |------------------|-----------|-------------------|-------------|
35
+ | **Small** | < 100 | Fast analysis | 30s |
36
+ | **Medium** | 100-500 | Balanced | 60s |
37
+ | **Large** | 500-1000 | Careful + progressive | 120s |
38
+ | **Enterprise** | 1000+ | Conservative + streaming | 300s |
39
+
40
+ ### **Auto-Detection Logic**
41
+ ```bash
42
+ # ✅ SunLint tự động:
43
+ # - Đếm số files trong input folder
44
+ # - Phát hiện TypeScript, Node.js project
45
+ # - Chọn timeout và batch size phù hợp
46
+ # - Bật progressive results cho large projects
47
+
48
+ sunlint --all --input=src # Làm tất cả tự động!
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 📋 **Common Usage Patterns**
54
+
55
+ ### **Development (hàng ngày)**
56
+ ```bash
57
+ # Quick feedback loop
58
+ sunlint --rules=C019,C041,S027 --input=src
59
+
60
+ # Check specific files
61
+ sunlint --all --input=src/components --performance=fast
62
+ ```
63
+
64
+ ### **Code Review/PR**
65
+ ```bash
66
+ # Check changed files only
67
+ sunlint --all --changed-files
68
+
69
+ # Quick but comprehensive
70
+ sunlint --all --input=src --performance=fast --verbose
71
+ ```
72
+
73
+ ### **CI/CD Pipeline**
74
+ ```bash
75
+ # Thorough analysis with auto-optimization
76
+ sunlint --all --input=src --format=json --output=results.json
77
+
78
+ # For large projects in CI
79
+ sunlint --all --input=src --performance=careful --quiet
80
+ ```
81
+
82
+ ### **Weekly Code Quality Review**
83
+ ```bash
84
+ # Full analysis with detailed reporting
85
+ sunlint --all --input=src --verbose --format=table
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 🚨 **Troubleshooting Simplified**
91
+
92
+ ### **❌ Getting Timeouts?**
93
+ ```bash
94
+ # Try longer timeout
95
+ sunlint --all --input=src --timeout=120000
96
+
97
+ # Or limit files
98
+ sunlint --all --input=src --max-files=500
99
+ ```
100
+
101
+ ### **❌ Taking Too Long?**
102
+ ```bash
103
+ # Use fast mode
104
+ sunlint --all --input=src --performance=fast
105
+
106
+ # Or check specific rules
107
+ sunlint --rules=C002,C019,S027 --input=src
108
+ ```
109
+
110
+ ### **❌ Memory Issues?**
111
+ ```bash
112
+ # Automatic handling - just use auto mode
113
+ sunlint --all --input=src --performance=auto
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 🎛️ **Migration from Complex Commands**
119
+
120
+ ### **BEFORE (v3.x - Complex)**
121
+ ```bash
122
+ # ❌ Too many options to remember
123
+ sunlint --all --input=src \
124
+ --performance-profile=balanced \
125
+ --adaptive-timeout \
126
+ --max-memory=2GB \
127
+ --batch-size=10 \
128
+ --progressive-results \
129
+ --verbose
130
+ ```
131
+
132
+ ### **AFTER (v4.x - Simplified)**
133
+ ```bash
134
+ # ✅ Simple and effective
135
+ sunlint --all --input=src --verbose
136
+ ```
137
+
138
+ ### **Advanced Users Can Still Customize**
139
+ ```bash
140
+ # For power users who need control
141
+ sunlint --all --input=src --performance=careful --timeout=180000
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 📊 **Performance Comparison**
147
+
148
+ | **Command** | **Small Project** | **Large Project** | **Enterprise** |
149
+ |-------------|-------------------|-------------------|----------------|
150
+ | `--performance=auto` | ~10s | ~60s | ~120s |
151
+ | `--performance=fast` | ~5s | ~30s | ~60s |
152
+ | `--performance=careful` | ~15s | ~90s | ~180s |
153
+
154
+ ---
155
+
156
+ ## ✅ **Best Practices**
157
+
158
+ ### **🎯 DO (Recommended)**
159
+ ```bash
160
+ ✅ sunlint --all --input=src # Let auto-detection work
161
+ ✅ sunlint --all --input=src --verbose # See what's happening
162
+ ✅ sunlint --quality --input=src --performance=fast # Quick quality check
163
+ ✅ sunlint --all --changed-files # Only check changes
164
+ ```
165
+
166
+ ### **❌ DON'T (Avoid)**
167
+ ```bash
168
+ ❌ sunlint --all --input=src --performance-profile=conservative --batch-size=5 --streaming-analysis
169
+ # Too complex - just use --performance=careful
170
+
171
+ ❌ sunlint --all --input=src --timeout=5000
172
+ # Too short - let auto-detection choose
173
+
174
+ ❌ sunlint --all --input=huge-project
175
+ # Missing performance hint - add --performance=careful
176
+ ```
177
+
178
+ ---
179
+
180
+ ## 🏆 **Success Metrics**
181
+
182
+ ### **✅ Simplified CLI Achieved**
183
+ - **3 main commands** cover 90% of use cases
184
+ - **Auto-detection** eliminates guesswork
185
+ - **Zero configuration** for most projects
186
+ - **Predictable performance** across project sizes
187
+
188
+ ### **✅ Backward Compatibility**
189
+ - Old commands still work but show deprecation warnings
190
+ - Gradual migration path for existing users
191
+ - Advanced options available for power users
192
+
193
+ ---
194
+
195
+ ## 🚀 **Quick Start Checklist**
196
+
197
+ - [ ] **Update to SunLint v4.x** with auto-performance
198
+ - [ ] **Use basic command**: `sunlint --all --input=src`
199
+ - [ ] **Add --verbose** if you want to see progress
200
+ - [ ] **Use --performance=fast** for quick checks
201
+ - [ ] **Use --performance=careful** for thorough analysis
202
+ - [ ] **Test with your project** to validate performance
203
+
204
+ ---
205
+
206
+ **🎯 Bottom Line: Chỉ cần nhớ `sunlint --all --input=src` - mọi thứ khác được tự động optimize!**
207
+
208
+ *🚀 Simple • ⚡ Fast • 🎯 Effective*