@sun-asterisk/sunlint 1.3.26 → 1.3.28

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 (69) hide show
  1. package/config/rules/enhanced-rules-registry.json +101 -17
  2. package/config/rules/rules-registry-generated.json +22 -22
  3. package/origin-rules/security-en.md +351 -338
  4. package/package.json +1 -1
  5. package/rules/common/C003_no_vague_abbreviations/analyzer.js +73 -21
  6. package/rules/common/C017_constructor_logic/symbol-based-analyzer.js +206 -2
  7. package/rules/common/C024_no_scatter_hardcoded_constants/symbol-based-analyzer.js +553 -58
  8. package/rules/common/C029_catch_block_logging/analyzer.js +47 -12
  9. package/rules/common/C033_separate_service_repository/symbol-based-analyzer.js +35 -15
  10. package/rules/common/C041_no_sensitive_hardcode/symbol-based-analyzer.js +9 -5
  11. package/rules/security/S003_open_redirect_protection/README.md +371 -0
  12. package/rules/security/S003_open_redirect_protection/analyzer.js +135 -0
  13. package/rules/security/S003_open_redirect_protection/config.json +58 -0
  14. package/rules/security/S003_open_redirect_protection/symbol-based-analyzer.js +884 -0
  15. package/rules/security/S004_sensitive_data_logging/analyzer.js +135 -0
  16. package/rules/security/S004_sensitive_data_logging/config.json +62 -0
  17. package/rules/security/S004_sensitive_data_logging/symbol-based-analyzer.js +592 -0
  18. package/rules/security/S005_no_origin_auth/analyzer.js +97 -148
  19. package/rules/security/S005_no_origin_auth/config.json +28 -67
  20. package/rules/security/S005_no_origin_auth/symbol-based-analyzer.js +708 -0
  21. package/rules/security/S006_no_plaintext_recovery_codes/symbol-based-analyzer.js +170 -31
  22. package/rules/security/S010_no_insecure_encryption/analyzer.js +8 -2
  23. package/rules/security/S012_hardcoded_secrets/analyzer.js +149 -0
  24. package/rules/security/S012_hardcoded_secrets/config.json +75 -0
  25. package/rules/security/S012_hardcoded_secrets/symbol-based-analyzer.js +1204 -0
  26. package/rules/security/S013_tls_enforcement/symbol-based-analyzer.js +87 -0
  27. package/rules/security/S017_use_parameterized_queries/analyzer.js +11 -78
  28. package/rules/security/S017_use_parameterized_queries/symbol-based-analyzer.js +1146 -1
  29. package/rules/security/S019_smtp_injection_protection/analyzer.js +120 -0
  30. package/rules/security/S019_smtp_injection_protection/config.json +35 -0
  31. package/rules/security/S019_smtp_injection_protection/symbol-based-analyzer.js +687 -0
  32. package/rules/security/S020_no_eval_dynamic_code/analyzer.js +55 -130
  33. package/rules/security/S020_no_eval_dynamic_code/symbol-based-analyzer.js +4 -19
  34. package/rules/security/S022_escape_output_context/README.md +254 -0
  35. package/rules/security/S022_escape_output_context/analyzer.js +510 -0
  36. package/rules/security/S022_escape_output_context/config.json +229 -0
  37. package/rules/security/S023_no_json_injection/analyzer.js +15 -0
  38. package/rules/security/S023_no_json_injection/ast-analyzer.js +18 -3
  39. package/rules/security/S023_no_json_injection/config.json +133 -0
  40. package/rules/security/S024_xpath_xxe_protection/regex-based-analyzer.js +41 -0
  41. package/rules/security/S027_no_hardcoded_secrets/analyzer.js +67 -8
  42. package/rules/security/S027_no_hardcoded_secrets/categorized-analyzer.js +29 -6
  43. package/rules/security/S029_csrf_protection/config.json +127 -0
  44. package/rules/security/S030_directory_browsing_protection/regex-based-analyzer.js +160 -28
  45. package/rules/security/S030_directory_browsing_protection/symbol-based-analyzer.js +81 -19
  46. package/rules/security/S031_secure_session_cookies/analyzer.js +20 -2
  47. package/rules/security/S031_secure_session_cookies/regex-based-analyzer.js +100 -0
  48. package/rules/security/S031_secure_session_cookies/symbol-based-analyzer.js +8 -1
  49. package/rules/security/S032_httponly_session_cookies/analyzer.js +2 -2
  50. package/rules/security/S032_httponly_session_cookies/regex-based-analyzer.js +115 -0
  51. package/rules/security/S032_httponly_session_cookies/symbol-based-analyzer.js +39 -10
  52. package/rules/security/S036_lfi_rfi_protection/analyzer.js +224 -0
  53. package/rules/security/S036_lfi_rfi_protection/config.json +20 -0
  54. package/rules/security/S040_session_fixation_protection/analyzer.js +153 -0
  55. package/rules/security/S040_session_fixation_protection/config.json +20 -0
  56. package/rules/security/S042_require_re_authentication_for_long_lived/README.md +83 -0
  57. package/rules/security/S042_require_re_authentication_for_long_lived/analyzer.js +153 -0
  58. package/rules/security/S042_require_re_authentication_for_long_lived/config.json +41 -0
  59. package/rules/security/S042_require_re_authentication_for_long_lived/symbol-based-analyzer.js +1139 -0
  60. package/rules/security/S043_password_changes_invalidate_all_sessions/README.md +107 -0
  61. package/rules/security/S043_password_changes_invalidate_all_sessions/analyzer.js +153 -0
  62. package/rules/security/S043_password_changes_invalidate_all_sessions/config.json +41 -0
  63. package/rules/security/S043_password_changes_invalidate_all_sessions/symbol-based-analyzer.js +541 -0
  64. package/docs/COMMAND-EXAMPLES.md +0 -390
  65. package/docs/FILE_LIMITS_COMPLETION_REPORT.md +0 -151
  66. package/docs/FOLDER_STRUCTURE.md +0 -59
  67. package/docs/SIMPLIFIED_USAGE_GUIDE.md +0 -208
  68. package/rules/security/S017_use_parameterized_queries/regex-based-analyzer.js +0 -541
  69. package/rules/security/S020_no_eval_dynamic_code/regex-based-analyzer.js +0 -307
@@ -1,390 +0,0 @@
1
- # 🎮 SunLint Command Examples & Demos
2
-
3
- ## 📋 **Tổng hợp đầy đủ các chức năng CLI đã hỗ trợ**
4
-
5
- ### ✅ **1. Phạm vi kiểm tra (Input Scope)**
6
-
7
- ```bash
8
- # Kiểm tra 1 file cụ thể
9
- node cli.js --all --input=cli.js --format=summary --no-ai
10
-
11
- # Kiểm tra 1 folder/directory
12
- node cli.js --all --input=core --format=summary --no-ai
13
-
14
- # Kiểm tra toàn bộ project/workspace
15
- node cli.js --all --input=. --format=summary --no-ai
16
-
17
- # Kiểm tra nhiều folders (comma-separated)
18
- node cli.js --all --input=core,rules --format=summary --no-ai
19
-
20
- # Kiểm tra chỉ files đã thay đổi (Git integration)
21
- node cli.js --all --changed-files --format=summary --no-ai
22
-
23
- # Kiểm tra chỉ files đã staged (Pre-commit)
24
- node cli.js --all --staged-files --format=summary --no-ai
25
-
26
- # Kiểm tra files thay đổi so với branch cụ thể
27
- node cli.js --all --changed-files --diff-base=origin/main --format=summary
28
- ```
29
-
30
- ### ✅ **2. Lựa chọn Rules**
31
-
32
- ```bash
33
- # Kiểm tra 1 rule cụ thể
34
- node cli.js --rule=C019 --input=. --format=summary --no-ai
35
-
36
- # Kiểm tra nhiều rules cụ thể
37
- node cli.js --rules=C019,C006,C029 --input=. --format=summary --no-ai
38
-
39
- # Kiểm tra tất cả rules
40
- node cli.js --all --input=. --format=summary --no-ai
41
-
42
- # Kiểm tra theo category (quality rules)
43
- node cli.js --quality --input=. --format=summary --no-ai
44
-
45
- # Kiểm tra theo category (security rules)
46
- node cli.js --security --input=. --format=summary --no-ai
47
-
48
- # Loại trừ một số rules cụ thể
49
- node cli.js --all --exclude-rules=C031 --input=. --format=summary --no-ai
50
- ```
51
-
52
- ### ✅ **3. Phương pháp phân tích**
53
-
54
- ```bash
55
- # Pattern-based analysis (free, fast)
56
- node cli.js --all --input=. --format=summary --no-ai
57
-
58
- # AI-powered analysis (cost, more accurate)
59
- node cli.js --all --input=. --format=summary --ai
60
-
61
- # Hybrid: AI cho rules cụ thể, pattern cho còn lại
62
- node cli.js --rule=C019 --input=. --ai --format=summary
63
- ```
64
-
65
- ### ✅ **4. Output Formats**
66
-
67
- ```bash
68
- # Human-readable summary
69
- node cli.js --all --input=. --format=summary --no-ai
70
-
71
- # ESLint-compatible JSON (for IDEs)
72
- node cli.js --all --input=. --format=eslint --no-ai
73
-
74
- # Structured JSON (for processing)
75
- node cli.js --all --input=. --format=json --no-ai
76
-
77
- # Table format (for reports)
78
- node cli.js --all --input=. --format=table --no-ai
79
-
80
- # GitHub Actions format (for CI)
81
- node cli.js --all --input=. --format=github --no-ai
82
-
83
- # Save to file
84
- node cli.js --all --input=. --format=json --output=report.json --no-ai
85
- ```
86
-
87
- ### ✅ **5. CI/CD Features**
88
-
89
- ```bash
90
- # PR Mode: Chỉ check violations mới
91
- node cli.js --all --changed-files --fail-on-new-violations --format=summary
92
-
93
- # Baseline comparison
94
- node cli.js --all --input=. --save-baseline=baseline.json --format=json --no-ai
95
- node cli.js --all --changed-files --baseline=baseline.json --fail-on-new-violations
96
-
97
- # Severity filtering
98
- node cli.js --all --input=. --severity=error --format=summary --no-ai
99
-
100
- # Language filtering
101
- node cli.js --all --input=. --languages=typescript,javascript --format=summary
102
- ```
103
-
104
- ### ✅ **6. Performance & Advanced Options**
105
-
106
- ```bash
107
- # Control concurrent execution
108
- node cli.js --all --input=. --max-concurrent=10 --format=summary --no-ai
109
-
110
- # Set timeout for rules
111
- node cli.js --all --input=. --timeout=60000 --format=summary --no-ai
112
-
113
- # Disable caching
114
- node cli.js --all --input=. --no-cache --format=summary --no-ai
115
-
116
- # **Control semantic analysis for large projects**
117
- # Default limit: 1000 files for performance balance
118
- node cli.js --all --input=. --max-semantic-files=1000 --format=summary
119
-
120
- # For small projects: Analyze all files
121
- node cli.js --all --input=. --max-semantic-files=0 --format=summary
122
-
123
- # For large projects: Conservative analysis
124
- node cli.js --all --input=. --max-semantic-files=500 --format=summary
125
-
126
- # For massive projects: Minimal semantic analysis
127
- node cli.js --all --input=. --max-semantic-files=100 --format=summary
128
-
129
- # Unlimited semantic analysis (use with caution!)
130
- node cli.js --all --input=. --max-semantic-files=-1 --format=summary
131
-
132
- # Verbose logging
133
- node cli.js --all --input=. --verbose --format=summary --no-ai
134
-
135
- # Quiet mode (errors only)
136
- node cli.js --all --input=. --quiet --format=summary --no-ai
137
-
138
- # Debug mode
139
- node cli.js --all --input=. --debug --format=summary --no-ai
140
-
141
- # Dry run (show what would be analyzed)
142
- node cli.js --all --input=. --dry-run --format=summary --no-ai
143
- ```
144
-
145
- ## 🚀 **Use Cases & Scenarios**
146
-
147
- ### **Local Development** 🏠
148
-
149
- ```bash
150
- # Quick check before commit
151
- node cli.js --all --staged-files --format=summary --no-ai
152
-
153
- # Check current work
154
- node cli.js --all --changed-files --format=summary --no-ai
155
-
156
- # Focus on specific issue type
157
- node cli.js --rule=C019 --input=. --format=summary --no-ai
158
-
159
- # Deep analysis with AI
160
- node cli.js --quality --input=src --ai --format=detailed
161
- ```
162
-
163
- ### **Code Review** 👀
164
-
165
- ```bash
166
- # Check PR changes
167
- node cli.js --all --changed-files --diff-base=origin/main --format=github
168
-
169
- # Focus on security for sensitive changes
170
- node cli.js --security --changed-files --format=summary --no-ai
171
-
172
- # New violations only
173
- node cli.js --all --changed-files --baseline=baseline.json --fail-on-new-violations
174
- ```
175
-
176
- ### **CI/CD Pipeline** 🔄
177
-
178
- ```bash
179
- # Fast PR check
180
- node cli.js --all --changed-files --format=github --no-ai --timeout=30000
181
-
182
- # Full scan for main branch
183
- node cli.js --all --input=. --format=json --output=report.json --no-ai
184
-
185
- # Security-critical check
186
- node cli.js --security --input=. --severity=error --format=summary --no-ai
187
-
188
- # Quality gate
189
- node cli.js --quality --changed-files --max-new-violations=5 --format=summary
190
- ```
191
-
192
- ### **Project Health Monitoring** 📊
193
-
194
- ```bash
195
- # Full project assessment
196
- node cli.js --all --input=. --format=detailed --output=health-report.json --no-ai
197
-
198
- # Trend analysis
199
- node cli.js --all --input=. --baseline=last-month.json --format=trend --no-ai
200
-
201
- # Focus areas
202
- node cli.js --rules=C019,C029 --input=core --format=table --no-ai
203
- ```
204
-
205
- ## 🎯 **Practical Examples**
206
-
207
- ### **Example 1: New Feature Development**
208
- ```bash
209
- # Day 1: Start development
210
- node cli.js --all --staged-files --format=summary --no-ai
211
-
212
- # Day 2: Check progress
213
- node cli.js --all --changed-files --format=summary --no-ai
214
-
215
- # Day 3: Pre-review check
216
- node cli.js --all --changed-files --diff-base=origin/main --format=github --no-ai
217
-
218
- # Day 4: Final validation
219
- node cli.js --all --changed-files --ai --format=detailed
220
- ```
221
-
222
- ## 🏗️ **Large Project Strategies**
223
-
224
- > **⚡ Performance Note**: SunLint uses semantic analysis for advanced rules (like C047). For projects with 1000+ files, you can control semantic analysis scope to balance accuracy vs performance.
225
-
226
- ### **Strategy 1: Incremental Analysis** 📈
227
- ```bash
228
- # Start with changed files only (fastest)
229
- node cli.js --all --changed-files --format=summary --no-ai
230
-
231
- # Focus on specific directories
232
- node cli.js --all --input=src/critical --max-semantic-files=2000 --format=summary
233
-
234
- # Target important file patterns only
235
- node cli.js --all --include="src/**/*.ts" --exclude="**/*.test.*,**/*.d.ts" --input=.
236
-
237
- # Use directory-based analysis
238
- node cli.js --all --input=src/auth --format=summary # Most critical module first
239
- node cli.js --all --input=src/api --format=summary # Then API layer
240
- node cli.js --all --input=src/utils --format=summary # Finally utilities
241
- ```
242
-
243
- ### **Strategy 2: Semantic Analysis Tuning** 🔧
244
- ```bash
245
- # Conservative: 500 files for faster analysis
246
- node cli.js --all --input=. --max-semantic-files=500 --format=summary
247
-
248
- # Balanced: 1000 files (default) for medium projects
249
- node cli.js --all --input=. --max-semantic-files=1000 --format=summary
250
-
251
- # Comprehensive: 2000+ files for complete analysis
252
- node cli.js --all --input=. --max-semantic-files=2000 --format=summary
253
-
254
- # Unlimited: All files (use for final validation)
255
- node cli.js --all --input=. --max-semantic-files=-1 --format=summary
256
-
257
- # Disable semantic analysis completely (heuristic only)
258
- node cli.js --all --input=. --max-semantic-files=0 --format=summary
259
- ```
260
-
261
- ### **Strategy 3: Rule-Based Prioritization** 🎯
262
- ```bash
263
- # Phase 1: Critical security issues (fast heuristic rules)
264
- node cli.js --security --input=. --max-semantic-files=0 --format=summary
265
-
266
- # Phase 2: Code quality basics
267
- node cli.js --rules=C006,C019,C029 --input=. --max-semantic-files=500 --format=summary
268
-
269
- # Phase 3: Advanced semantic rules (targeted)
270
- node cli.js --rules=C047 --input=src --max-semantic-files=1000 --format=summary
271
-
272
- # Phase 4: Full comprehensive scan
273
- node cli.js --all --input=. --max-semantic-files=-1 --format=detailed
274
- ```
275
-
276
- ### **Strategy 4: CI/CD Optimization** ⚡
277
- ```bash
278
- # PR checks: Fast semantic analysis
279
- node cli.js --all --changed-files --max-semantic-files=300 --format=github --no-ai
280
-
281
- # Nightly builds: Medium semantic analysis
282
- node cli.js --all --input=. --max-semantic-files=1000 --format=json --output=nightly.json
283
-
284
- # Weekly reports: Full semantic analysis
285
- node cli.js --all --input=. --max-semantic-files=-1 --format=detailed --output=weekly.json
286
-
287
- # Release validation: Comprehensive with baselines
288
- node cli.js --all --input=. --max-semantic-files=2000 --baseline=last-release.json
289
- ```
290
-
291
- ### **Strategy 5: Memory & Performance Monitoring** 📊
292
- ```bash
293
- # Monitor file loading (debug mode)
294
- node cli.js --all --input=. --max-semantic-files=1000 --verbose --debug
295
-
296
- # Track performance with different limits
297
- time node cli.js --all --input=. --max-semantic-files=500 --format=summary
298
- time node cli.js --all --input=. --max-semantic-files=1000 --format=summary
299
- time node cli.js --all --input=. --max-semantic-files=2000 --format=summary
300
-
301
- # Memory-conscious analysis for CI
302
- node cli.js --all --input=. --max-semantic-files=300 --max-concurrent=2 --format=summary
303
- ```
304
-
305
- ### **📋 Recommended Limits by Project Size**
306
-
307
- | Project Size | Files Count | Recommended Limit | Use Case |
308
- |-------------|-------------|-------------------|----------|
309
- | Small | < 100 files | `--max-semantic-files=0` (all) | Complete analysis |
310
- | Medium | 100-500 files | `--max-semantic-files=500` | Balanced |
311
- | Large | 500-2000 files | `--max-semantic-files=1000` | Default recommended |
312
- | Enterprise | 2000-5000 files | `--max-semantic-files=1500` | Conservative |
313
- | Massive | 5000+ files | `--max-semantic-files=500` | Targeted analysis |
314
-
315
- > **💡 Pro Tips for Large Projects:**
316
- > 1. Use `--changed-files` for daily development
317
- > 2. Use `--max-semantic-files=500` for CI/CD pipelines
318
- > 3. Use `--max-semantic-files=-1` for release validation
319
- > 4. Combine with `--include` patterns to focus on critical code
320
- > 5. Monitor analysis time and adjust limits accordingly
321
-
322
- ### **Example 1: Monorepo with 5000+ Files**
323
- ```bash
324
- # Daily development: Changed files only
325
- node cli.js --all --changed-files --max-semantic-files=300 --format=summary
326
-
327
- # Module-specific analysis
328
- node cli.js --all --input=packages/core --max-semantic-files=1000 --format=summary
329
- node cli.js --all --input=packages/api --max-semantic-files=1000 --format=summary
330
-
331
- # CI pipeline: Conservative semantic analysis
332
- node cli.js --all --changed-files --max-semantic-files=500 --format=github
333
-
334
- # Release validation: Full analysis by modules
335
- for dir in packages/*/; do
336
- node cli.js --all --input="$dir" --max-semantic-files=2000 --format=json --output="${dir//\//-}-report.json"
337
- done
338
- ```
339
-
340
- ### **Example 2: Legacy Code Improvement**
341
- ```bash
342
- # Step 1: Baseline assessment
343
- node cli.js --all --input=legacy-module --save-baseline=legacy-baseline.json --no-ai
344
-
345
- # Step 2: Focus on critical issues
346
- node cli.js --security --input=legacy-module --severity=error --format=summary
347
-
348
- # Step 3: Incremental improvement
349
- node cli.js --rule=C019 --input=legacy-module --format=summary --no-ai
350
-
351
- # Step 4: Track progress
352
- node cli.js --all --input=legacy-module --baseline=legacy-baseline.json --format=trend
353
- ```
354
-
355
- ### **Example 3: Team Onboarding**
356
- ```bash
357
- # Level 1: Basic checks
358
- node cli.js --rules=C006,C019 --input=. --format=summary --no-ai
359
-
360
- # Level 2: Quality focus
361
- node cli.js --quality --input=. --format=table --no-ai
362
-
363
- # Level 3: Full analysis
364
- node cli.js --all --input=. --format=detailed --no-ai
365
-
366
- # Level 4: AI-assisted learning
367
- node cli.js --all --input=. --ai --verbose --format=detailed
368
- ```
369
-
370
- ## 📝 **Command Cheat Sheet**
371
-
372
- | Task | Command |
373
- |------|---------|
374
- | Quick pre-commit check | `node cli.js --all --staged-files --format=summary --no-ai` |
375
- | PR review | `node cli.js --all --changed-files --diff-base=origin/main --format=github` |
376
- | Full project scan | `node cli.js --all --input=. --format=json --output=report.json --no-ai` |
377
- | Security audit | `node cli.js --security --input=. --severity=error --format=summary` |
378
- | New violations only | `node cli.js --all --changed-files --baseline=baseline.json --fail-on-new-violations` |
379
- | AI deep analysis | `node cli.js --quality --input=src --ai --format=detailed` |
380
- | Performance test | `node cli.js --all --input=. --max-concurrent=1 --timeout=10000 --no-ai` |
381
- | Debug issues | `node cli.js --rule=C019 --input=problematic-file.js --debug --verbose` |
382
-
383
- ## 💡 **Pro Tips**
384
-
385
- 1. **Start with `--no-ai`** for faster feedback, use `--ai` for complex issues
386
- 2. **Use `--changed-files`** in development, `--input=.` for comprehensive checks
387
- 3. **Save baselines** for large projects to track progress over time
388
- 4. **Combine `--severity=error`** with CI to focus on critical issues
389
- 5. **Use `--dry-run`** to understand what will be analyzed before running
390
- 6. **Set `--timeout`** appropriately based on project size and CI time limits
@@ -1,151 +0,0 @@
1
- # ✅ SunLint File Limits Implementation - COMPLETED
2
-
3
- ## 📋 **Implementation Summary**
4
-
5
- ### **🎯 Original Request**
6
- - User confusion: "Có cần đến `--max-files` không khi đã có `--max-semantic-files`?"
7
- - Need clarity between two file limit options
8
- - Request for simplification and documentation
9
-
10
- ### **✅ Solution Delivered**
11
-
12
- #### **1. Clear Distinction Established**
13
- - **`--max-files`**: Controls total analysis workload (all files)
14
- - **`--max-semantic-files`**: Controls TypeScript symbol table memory (subset)
15
- - **Both needed**: Different purposes, complementary not redundant
16
-
17
- #### **2. Documentation Created**
18
- - **[FILE_LIMITS_EXPLANATION.md](./FILE_LIMITS_EXPLANATION.md)**: Comprehensive 5K+ word guide
19
- - **[QUICK_FILE_LIMITS.md](./QUICK_FILE_LIMITS.md)**: TL;DR quick reference
20
- - **README.md**: Updated with link to performance docs
21
-
22
- #### **3. CLI Help Enhanced**
23
- ```bash
24
- # Clear descriptions added
25
- --max-files <number> Analysis file limit (controls total files processed)
26
- --max-semantic-files <number> Symbol table file limit for TypeScript analysis
27
-
28
- # Usage examples provided
29
- sunlint --all --input=src --max-files=500 # Limit total files analyzed
30
- sunlint --all --input=src --max-semantic-files=200 # Limit TypeScript symbol table
31
- ```
32
-
33
- ---
34
-
35
- ## 🧠 **Key Insights Documented**
36
-
37
- ### **Memory Impact Analysis**
38
- | **Component** | **Memory per File** | **When to Limit** |
39
- |---------------|-------------------|-------------------|
40
- | File Analysis | ~50KB | Large projects (1000+ files) |
41
- | Symbol Table | ~2MB+ | TypeScript projects (200+ .ts files) |
42
-
43
- ### **Use Case Matrix**
44
- | **Project Type** | **Analysis Limit** | **Symbol Limit** | **Reason** |
45
- |------------------|-------------------|------------------|------------|
46
- | JavaScript | High (1500+) | Low (50) | Less type analysis |
47
- | TypeScript | Medium (800) | Medium (300) | Balanced approach |
48
- | Enterprise | Conservative (500) | Conservative (200) | Safe defaults |
49
-
50
- ### **90/10 Rule Applied**
51
- - **90% users**: Auto-detection handles both limits perfectly
52
- - **10% users**: Manual tuning for specific performance needs
53
-
54
- ---
55
-
56
- ## 📊 **Testing & Validation**
57
-
58
- ### **CLI Help Output Verified** ✅
59
- ```bash
60
- $ sunlint --help | grep -E "(max-files|max-semantic)"
61
- --max-files <number> Analysis file limit (controls total files processed)
62
- --max-semantic-files <number> Symbol table file limit for TypeScript analysis
63
- ```
64
-
65
- ### **Documentation Structure** ✅
66
- ```
67
- docs/
68
- ├── FILE_LIMITS_EXPLANATION.md # Comprehensive guide (5.7KB)
69
- ├── QUICK_FILE_LIMITS.md # Quick reference (1.8KB)
70
- └── [other docs...]
71
- ```
72
-
73
- ### **README Integration** ✅
74
- ```markdown
75
- ## 📚 Documentation
76
- - **[Performance & File Limits](./docs/FILE_LIMITS_EXPLANATION.md)** - Understanding --max-files vs --max-semantic-files
77
- ```
78
-
79
- ---
80
-
81
- ## 🎯 **Benefits Achieved**
82
-
83
- ### **✅ User Experience**
84
- - **Clear distinction**: No more confusion between options
85
- - **Self-service docs**: Users can understand without asking
86
- - **Progressive disclosure**: Quick ref → detailed guide
87
-
88
- ### **✅ Developer Experience**
89
- - **Maintainable code**: Logic stays in heuristic engine
90
- - **Clear documentation**: Contributors understand the purpose
91
- - **Consistent CLI**: Help text matches implementation
92
-
93
- ### **✅ Performance**
94
- - **Smart defaults**: Auto-detection works for 90% of cases
95
- - **Fine control**: Advanced users can tune both limits independently
96
- - **Memory safety**: Symbol table limit prevents memory explosion
97
-
98
- ---
99
-
100
- ## 🔄 **Integration Status**
101
-
102
- ### **Engine Architecture** ✅
103
- - Performance logic integrated into `heuristic-engine.js` v4.0
104
- - Auto-performance-manager handles limit calculations
105
- - No separate optimized engine file (simplified)
106
-
107
- ### **CLI Implementation** ✅
108
- - Both options available and documented
109
- - Clear help text with usage examples
110
- - Auto-detection as default behavior
111
-
112
- ### **Documentation Ecosystem** ✅
113
- - Comprehensive explanation for deep understanding
114
- - Quick reference for immediate help
115
- - README integration for discoverability
116
-
117
- ---
118
-
119
- ## 🚀 **Next Steps for Users**
120
-
121
- ### **Immediate Use**
122
- ```bash
123
- # ✅ Most users - just use auto-detection
124
- sunlint --all --input=src
125
-
126
- # ✅ Performance tuning when needed
127
- sunlint --all --input=src --max-files=1000 --max-semantic-files=300
128
- ```
129
-
130
- ### **Learning Path**
131
- 1. **Start**: Use auto-detection
132
- 2. **If slow**: Read [QUICK_FILE_LIMITS.md](./QUICK_FILE_LIMITS.md)
133
- 3. **If issues**: Read [FILE_LIMITS_EXPLANATION.md](./FILE_LIMITS_EXPLANATION.md)
134
- 4. **Fine-tune**: Use both options as needed
135
-
136
- ---
137
-
138
- ## 💡 **Key Takeaway**
139
-
140
- **Both `--max-files` and `--max-semantic-files` are essential and serve different purposes:**
141
-
142
- - **Analysis Limit**: Controls how many files get processed (performance)
143
- - **Symbol Table Limit**: Controls TypeScript memory usage (memory safety)
144
- - **Smart defaults**: Auto-detection chooses appropriate values
145
- - **Manual override**: When projects have specific constraints
146
-
147
- **The confusion is now resolved with clear documentation and examples. ✅**
148
-
149
- ---
150
-
151
- *📊 Performance Optimized • 🧠 Memory Safe • 📚 Well Documented • 🎯 User Friendly*
@@ -1,59 +0,0 @@
1
- # Sunlint Folder Structure
2
-
3
- ## Rules Directory Naming Convention
4
-
5
- All rule folders follow the consistent pattern: `C{ID}_{descriptive_name}`
6
-
7
- ### Current Rules Structure
8
-
9
- ```
10
- rules/
11
- ├── C006_function_naming/ # Function naming conventions
12
- │ ├── analyzer.js # Rule implementation
13
- │ └── config.json # Rule configuration
14
- ├── C019_log_level_usage/ # Log level usage validation
15
- │ ├── analyzer.js
16
- │ └── config.json
17
- ├── C029_catch_block_logging/ # Catch block error logging
18
- │ ├── analyzer.js
19
- │ └── config.json
20
- └── C031_validation_separation/ # Validation logic separation (planned)
21
- ├── analyzer.js
22
- └── config.json
23
- ```
24
-
25
- ### Benefits of This Naming Convention
26
-
27
- 1. **Consistency** - All folders follow the same pattern
28
- 2. **Resilience** - If rule IDs change, descriptive names provide context
29
- 3. **Readability** - Easy to understand rule purpose from folder name
30
- 4. **Maintainability** - Clear organization for developers
31
-
32
- ### Adding New Rules
33
-
34
- When adding a new rule, follow this pattern:
35
-
36
- 1. Create folder: `C{ID}_{snake_case_description}/`
37
- 2. Add `analyzer.js` with rule implementation
38
- 3. Add `config.json` with rule configuration
39
- 4. Update `rules-registry.json` with correct paths
40
- 5. Add tests in `test/fixtures/`
41
-
42
- ### Example
43
-
44
- For a new rule C040 about "API Response Format":
45
- ```
46
- rules/C040_api_response_format/
47
- ├── analyzer.js
48
- └── config.json
49
- ```
50
-
51
- Registry entry:
52
- ```json
53
- "C040": {
54
- "name": "API Response Format",
55
- "description": "Hàm xử lý API nên return response object chuẩn",
56
- "analyzer": "./rules/C040_api_response_format/analyzer.js",
57
- "config": "./rules/C040_api_response_format/config.json"
58
- }
59
- ```