@sun-asterisk/sunlint 1.3.0 → 1.3.2

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 +115 -1
  2. package/CONTRIBUTING.md +249 -605
  3. package/README.md +3 -4
  4. package/config/ci-cd.json +54 -0
  5. package/config/development.json +56 -0
  6. package/config/large-project.json +143 -0
  7. package/config/presets/all.json +0 -1
  8. package/config/release.json +70 -0
  9. package/config/rule-analysis-strategies.js +38 -3
  10. package/config/rules/enhanced-rules-registry.json +474 -1179
  11. package/config/rules/rules-registry-generated.json +3 -3
  12. package/core/cli-action-handler.js +24 -30
  13. package/core/cli-program.js +11 -3
  14. package/core/config-merger.js +29 -2
  15. package/core/enhanced-rules-registry.js +3 -2
  16. package/core/semantic-engine.js +129 -19
  17. package/core/semantic-rule-base.js +4 -2
  18. package/core/unified-rule-registry.js +1 -1
  19. package/docs/COMMAND-EXAMPLES.md +134 -0
  20. package/docs/LARGE-PROJECT-GUIDE.md +324 -0
  21. package/engines/heuristic-engine.js +135 -16
  22. package/integrations/eslint/plugin/index.js +0 -2
  23. package/integrations/eslint/plugin/rules/common/c003-no-vague-abbreviations.js +59 -1
  24. package/integrations/eslint/plugin/rules/common/c006-function-name-verb-noun.js +26 -1
  25. package/integrations/eslint/plugin/rules/common/c030-use-custom-error-classes.js +54 -19
  26. package/origin-rules/common-en.md +19 -15
  27. package/package.json +1 -1
  28. package/rules/common/C002_no_duplicate_code/analyzer.js +334 -36
  29. package/rules/common/C003_no_vague_abbreviations/analyzer.js +220 -35
  30. package/rules/common/C006_function_naming/analyzer.js +29 -3
  31. package/rules/common/C010_limit_block_nesting/analyzer.js +181 -337
  32. package/rules/common/C010_limit_block_nesting/config.json +64 -0
  33. package/rules/common/C010_limit_block_nesting/regex-based-analyzer.js +379 -0
  34. package/rules/common/C010_limit_block_nesting/symbol-based-analyzer.js +231 -0
  35. package/rules/common/C013_no_dead_code/analyzer.js +75 -177
  36. package/rules/common/C013_no_dead_code/config.json +61 -0
  37. package/rules/common/C013_no_dead_code/regex-based-analyzer.js +345 -0
  38. package/rules/common/C013_no_dead_code/symbol-based-analyzer.js +640 -0
  39. package/rules/common/C014_dependency_injection/analyzer.js +48 -313
  40. package/rules/common/C014_dependency_injection/config.json +26 -0
  41. package/rules/common/C014_dependency_injection/symbol-based-analyzer.js +751 -0
  42. package/rules/common/C017_constructor_logic/analyzer.js +254 -17
  43. package/rules/common/C017_constructor_logic/semantic-analyzer.js +340 -0
  44. package/rules/common/C018_no_throw_generic_error/analyzer.js +232 -0
  45. package/rules/common/C018_no_throw_generic_error/config.json +50 -0
  46. package/rules/common/C018_no_throw_generic_error/regex-based-analyzer.js +387 -0
  47. package/rules/common/C018_no_throw_generic_error/symbol-based-analyzer.js +314 -0
  48. package/rules/common/C019_log_level_usage/analyzer.js +110 -317
  49. package/rules/common/C019_log_level_usage/pattern-analyzer.js +88 -0
  50. package/rules/common/C019_log_level_usage/system-log-analyzer.js +1267 -0
  51. package/rules/common/C023_no_duplicate_variable/analyzer.js +180 -0
  52. package/rules/common/C023_no_duplicate_variable/config.json +50 -0
  53. package/rules/common/C023_no_duplicate_variable/symbol-based-analyzer.js +158 -0
  54. package/rules/common/C024_no_scatter_hardcoded_constants/analyzer.js +180 -0
  55. package/rules/common/C024_no_scatter_hardcoded_constants/config.json +50 -0
  56. package/rules/common/C024_no_scatter_hardcoded_constants/symbol-based-analyzer.js +181 -0
  57. package/rules/common/C030_use_custom_error_classes/analyzer.js +200 -0
  58. package/rules/common/C033_separate_service_repository/README.md +78 -0
  59. package/rules/common/C033_separate_service_repository/analyzer.js +160 -0
  60. package/rules/common/C033_separate_service_repository/config.json +50 -0
  61. package/rules/common/C033_separate_service_repository/regex-based-analyzer.js +585 -0
  62. package/rules/common/C033_separate_service_repository/symbol-based-analyzer.js +368 -0
  63. package/rules/common/C035_error_logging_context/STRATEGY.md +99 -0
  64. package/rules/common/C035_error_logging_context/analyzer.js +232 -0
  65. package/rules/common/C035_error_logging_context/config.json +54 -0
  66. package/rules/common/C035_error_logging_context/regex-based-analyzer.js +299 -0
  67. package/rules/common/C035_error_logging_context/symbol-based-analyzer.js +454 -0
  68. package/rules/common/C040_centralized_validation/analyzer.js +165 -0
  69. package/rules/common/C040_centralized_validation/config.json +46 -0
  70. package/rules/common/C040_centralized_validation/regex-based-analyzer.js +243 -0
  71. package/rules/common/C040_centralized_validation/symbol-based-analyzer.js +416 -0
  72. package/rules/common/{C076_single_test_behavior → C072_single_test_behavior}/analyzer.js +6 -6
  73. package/rules/common/C076_explicit_function_types/README.md +30 -0
  74. package/rules/common/C076_explicit_function_types/analyzer.js +172 -0
  75. package/rules/common/C076_explicit_function_types/config.json +15 -0
  76. package/rules/common/C076_explicit_function_types/semantic-analyzer.js +341 -0
  77. package/rules/index.js +6 -1
  78. package/rules/parser/rule-parser.js +13 -2
  79. package/rules/security/S005_no_origin_auth/README.md +226 -0
  80. package/rules/security/S005_no_origin_auth/analyzer.js +184 -0
  81. package/rules/security/S005_no_origin_auth/ast-analyzer.js +406 -0
  82. package/rules/security/S005_no_origin_auth/config.json +85 -0
  83. package/rules/security/S006_no_plaintext_recovery_codes/README.md +139 -0
  84. package/rules/security/S006_no_plaintext_recovery_codes/analyzer.js +306 -0
  85. package/rules/security/S006_no_plaintext_recovery_codes/config.json +48 -0
  86. package/rules/security/S007_no_plaintext_otp/README.md +198 -0
  87. package/rules/security/S007_no_plaintext_otp/analyzer.js +406 -0
  88. package/rules/security/S007_no_plaintext_otp/config.json +79 -0
  89. package/rules/security/S007_no_plaintext_otp/semantic-analyzer.js +609 -0
  90. package/rules/security/S007_no_plaintext_otp/semantic-config.json +195 -0
  91. package/rules/security/S007_no_plaintext_otp/semantic-wrapper.js +280 -0
  92. package/rules/security/S009_no_insecure_encryption/README.md +158 -0
  93. package/rules/security/S009_no_insecure_encryption/analyzer.js +319 -0
  94. package/rules/security/S009_no_insecure_encryption/config.json +55 -0
  95. package/rules/security/S010_no_insecure_encryption/README.md +224 -0
  96. package/rules/security/S010_no_insecure_encryption/analyzer.js +493 -0
  97. package/rules/security/S010_no_insecure_encryption/config.json +48 -0
  98. package/rules/security/S016_no_sensitive_querystring/STRATEGY.md +149 -0
  99. package/rules/security/S016_no_sensitive_querystring/analyzer.js +276 -0
  100. package/rules/security/S016_no_sensitive_querystring/config.json +127 -0
  101. package/rules/security/S016_no_sensitive_querystring/regex-based-analyzer.js +258 -0
  102. package/rules/security/S016_no_sensitive_querystring/symbol-based-analyzer.js +495 -0
  103. package/rules/security/S027_no_hardcoded_secrets/analyzer.js +180 -366
  104. package/rules/security/S027_no_hardcoded_secrets/categories.json +153 -0
  105. package/rules/security/S027_no_hardcoded_secrets/categorized-analyzer.js +250 -0
  106. package/rules/security/S048_no_current_password_in_reset/README.md +222 -0
  107. package/rules/security/S048_no_current_password_in_reset/analyzer.js +366 -0
  108. package/rules/security/S048_no_current_password_in_reset/config.json +48 -0
  109. package/rules/security/S055_content_type_validation/README.md +176 -0
  110. package/rules/security/S055_content_type_validation/analyzer.js +312 -0
  111. package/rules/security/S055_content_type_validation/config.json +48 -0
  112. package/rules/utils/rule-helpers.js +140 -1
  113. package/scripts/consolidate-config.js +116 -0
  114. package/scripts/prepare-release.sh +1 -1
  115. package/config/rules/rules-registry.json +0 -765
  116. package/docs/ESLINT-INTEGRATION-STRATEGY.md +0 -392
  117. package/docs/FUTURE_PACKAGES.md +0 -83
  118. package/docs/HEURISTIC_VS_AI.md +0 -113
  119. package/docs/PRODUCTION_DEPLOYMENT_ANALYSIS.md +0 -112
  120. package/docs/PRODUCTION_SIZE_IMPACT.md +0 -183
  121. package/docs/RELEASE_GUIDE.md +0 -230
  122. package/docs/STANDARDIZED-CATEGORY-FILTERING.md +0 -156
  123. package/integrations/eslint/plugin/rules/common/c076-single-behavior-per-test.js +0 -254
  124. package/rules/common/C006_function_naming/smart-analyzer.js +0 -503
@@ -1,392 +0,0 @@
1
- # 🎯 SunLint vs ESLint Integration Strategy Analysis
2
-
3
- ## 📊 **Current Situation Assessment**
4
-
5
- ### **Team Assets:**
6
- - ✅ **29+ mature ESLint custom rules** đã được team phát triển
7
- - ✅ **Production-ready** codebase với nhiều contributors
8
- - ✅ **Comprehensive coverage** for TypeScript
9
- - ✅ **Established workflow** với ESLint integration
10
-
11
- ### **SunLint Unique Value:**
12
- - ✅ **Multi-language support** (TypeScript, Dart, Kotlin)
13
- - ✅ **AI-powered analysis** capabilities
14
- - ✅ **Specialized rules** (C019, C029, C031) không có trong ESLint
15
- - ✅ **CI/CD optimization** features
16
-
17
- ### **Overlap Analysis:**
18
- | Rule | ESLint Custom | SunLint | Status |
19
- |------|---------------|---------|--------|
20
- | **C003** | ✅ Mature | ❌ Không có | ESLint wins |
21
- | **C006** | ✅ Mature | ✅ Basic | ESLint better |
22
- | **C019** | ❌ Không có | ✅ Specialized | SunLint unique |
23
- | **C029** | ✅ c029, c035 | ✅ Specialized | Both have |
24
- | **C031** | ❌ Không có | ✅ Specialized | SunLint unique |
25
-
26
- ## 🎯 **SOLUTION ANALYSIS**
27
-
28
- ### **Solution 1: Makefile Integration**
29
- ```bash
30
- # Makefile approach
31
- .PHONY: lint
32
- lint: lint-eslint lint-sunlint
33
-
34
- lint-eslint:
35
- cd coding-quality/config/typescript && ./run.sh
36
-
37
- lint-sunlint:
38
- cd coding-quality/extensions/sunlint && node cli.js --all --input=src
39
-
40
- lint-report:
41
- $(MAKE) lint-eslint --json > eslint-report.json
42
- $(MAKE) lint-sunlint --format=json > sunlint-report.json
43
- node merge-reports.js eslint-report.json sunlint-report.json
44
- ```
45
-
46
- **✅ Pros:**
47
- - ✅ **Zero migration cost** - giữ nguyên existing work
48
- - ✅ **Fast implementation** - 1-2 days setup
49
- - ✅ **Parallel execution** - có thể chạy concurrent
50
- - ✅ **Tool independence** - mỗi tool độc lập
51
- - ✅ **Team harmony** - không ảnh hưởng existing work
52
-
53
- **❌ Cons:**
54
- - ❌ **Fragmented results** - cần merge reports
55
- - ❌ **Duplicated overhead** - chạy 2 tools
56
- - ❌ **Configuration drift** - 2 sets of configs
57
- - ❌ **Learning curve** - team cần biết cả 2 tools
58
-
59
- **🎯 Score: 7/10** - Good short-term solution
60
-
61
- ---
62
-
63
- ### **Solution 2: Keep Separate Tools**
64
- ```bash
65
- # Current approach - no changes
66
- npm run lint:eslint
67
- npm run lint:sunlint
68
- ```
69
-
70
- **✅ Pros:**
71
- - ✅ **No migration cost**
72
- - ✅ **Maximum flexibility**
73
- - ✅ **Tool specialization**
74
- - ✅ **Zero risk**
75
-
76
- **❌ Cons:**
77
- - ❌ **Manual coordination**
78
- - ❌ **Inconsistent adoption**
79
- - ❌ **Results fragmentation**
80
- - ❌ **CI/CD complexity**
81
-
82
- **🎯 Score: 5/10** - Status quo, but not scalable
83
-
84
- ---
85
-
86
- ### **Solution 3A: ESLint Plugin for SunLint**
87
- ```bash
88
- # Embed ESLint rules into SunLint
89
- node cli.js --all --include-eslint --input=src
90
- ```
91
-
92
- **✅ Pros:**
93
- - ✅ **Unified command** - single entry point
94
- - ✅ **Leverage existing rules** - 29+ rules preserved
95
- - ✅ **Fast to implement** - ESLint integration
96
- - ✅ **Consistent output** - single report format
97
-
98
- **❌ Cons:**
99
- - ❌ **TypeScript only** - hard to extend to Dart/Kotlin
100
- - ❌ **ESLint dependency** - adds complexity
101
- - ❌ **Performance overhead** - running ESLint inside SunLint
102
- - ❌ **Limited AI integration** - ESLint rules can't use AI
103
-
104
- **🎯 Score: 6/10** - Quick fix but not scalable
105
-
106
- ---
107
-
108
- ### **Solution 3B: Migrate ESLint Rules to SunLint**
109
- ```bash
110
- # Pure SunLint approach
111
- node cli.js --all --input=src # All rules in SunLint
112
- ```
113
-
114
- **✅ Pros:**
115
- - ✅ **Unified architecture** - single system
116
- - ✅ **Multi-language ready** - Dart, Kotlin support
117
- - ✅ **AI integration** - all rules can use AI
118
- - ✅ **Performance optimized** - single pass analysis
119
- - ✅ **Future-proof** - scalable architecture
120
-
121
- **❌ Cons:**
122
- - ❌ **High migration cost** - 3-6 months effort
123
- - ❌ **Team disruption** - major workflow change
124
- - ❌ **Risk of regression** - might miss edge cases
125
- - ❌ **Doesn't acknowledge team effort** - feels like "starting over"
126
-
127
- **🎯 Score: 8/10** - Best long-term but expensive
128
-
129
- ## 🏆 **RECOMMENDED SOLUTION: Hybrid Evolution Strategy**
130
-
131
- ### **Phase 1: Immediate Integration (1-2 weeks)**
132
- ```bash
133
- # Enhanced Makefile + Report Merger
134
- make lint-all # Runs both ESLint + SunLint
135
- make lint-report # Unified JSON report
136
- ```
137
-
138
- **Implementation:**
139
- ```makefile
140
- # Makefile
141
- .PHONY: lint-all lint-eslint lint-sunlint lint-report
142
-
143
- lint-all: lint-eslint lint-sunlint
144
-
145
- lint-eslint:
146
- @echo "🔍 Running ESLint analysis..."
147
- cd coding-quality/config/typescript && \
148
- ./run.sh --json --export-json --json-file ../../extensions/sunlint/eslint-results.json $(INPUT)
149
-
150
- lint-sunlint:
151
- @echo "☀️ Running SunLint analysis..."
152
- cd coding-quality/extensions/sunlint && \
153
- node cli.js --all --input=$(INPUT) --format=json --output=sunlint-results.json --no-ai
154
-
155
- lint-report: lint-all
156
- @echo "📊 Generating unified report..."
157
- cd coding-quality/extensions/sunlint && \
158
- node scripts/merge-reports.js eslint-results.json sunlint-results.json --output=unified-report.json
159
- @echo "✅ Unified report: unified-report.json"
160
-
161
- # Usage
162
- INPUT ?= src
163
- lint: lint-all
164
- ```
165
-
166
- ### **Phase 2: SunLint ESLint Adapter (1-2 months)**
167
- ```javascript
168
- // SunLint với ESLint integration
169
- node cli.js --all --include-eslint --eslint-config=../config/typescript/.eslintrc.cjs --input=src
170
- ```
171
-
172
- **Implementation Strategy:**
173
- 1. **ESLint Runner Integration** trong SunLint
174
- 2. **Report normalization** - convert ESLint output to SunLint format
175
- 3. **Unified configuration** - single config controls both
176
- 4. **Gradual migration** - opt-in per rule
177
-
178
- ### **Phase 3: Selective Migration (3-6 months)**
179
- ```javascript
180
- // Migrate high-value rules only
181
- const migrationPriority = {
182
- immediate: ['c003', 'c006'], // High overlap with SunLint
183
- later: ['c010', 'c013'], // Complex but valuable
184
- keep_eslint: ['t002', 't003'] // TypeScript-specific
185
- };
186
- ```
187
-
188
- **Migration Strategy:**
189
- 1. **Automated conversion tools** - convert ESLint AST → SunLint patterns
190
- 2. **A/B testing** - run both versions, compare results
191
- 3. **Gradual rollout** - migrate 2-3 rules per sprint
192
- 4. **Team validation** - original authors review migrations
193
-
194
- ## 🎯 **DETAILED IMPLEMENTATION PLAN**
195
-
196
- ### **Week 1-2: Quick Win (Makefile + Report Merger)**
197
-
198
- #### **Step 1: Enhanced Makefile**
199
- ```makefile
200
- # coding-quality/Makefile
201
- include config/typescript/eslint.mk
202
- include extensions/sunlint/sunlint.mk
203
-
204
- .PHONY: install lint lint-quick lint-full ci-lint
205
-
206
- install:
207
- cd config/typescript && npm install
208
- cd extensions/sunlint && npm install
209
-
210
- lint-quick: lint-sunlint-changed
211
- lint-full: lint-eslint lint-sunlint-all
212
- lint: lint-full
213
-
214
- ci-lint:
215
- $(MAKE) lint-full INPUT=src FORMAT=github
216
- node scripts/ci-report.js
217
-
218
- # Development shortcuts
219
- lint-staged:
220
- $(MAKE) lint-sunlint-staged
221
-
222
- lint-pr:
223
- $(MAKE) lint-sunlint-changed BASE=origin/main
224
- ```
225
-
226
- #### **Step 2: Report Merger Script**
227
- ```javascript
228
- // scripts/merge-reports.js
229
- const fs = require('fs');
230
- const path = require('path');
231
-
232
- class ReportMerger {
233
- mergeReports(eslintReport, sunlintReport) {
234
- return {
235
- tools: {
236
- eslint: this.normalizeESLintReport(eslintReport),
237
- sunlint: this.normalizeSunLintReport(sunlintReport)
238
- },
239
- summary: this.generateSummary(eslintReport, sunlintReport),
240
- violations: this.mergeViolations(eslintReport, sunlintReport),
241
- metadata: {
242
- timestamp: new Date().toISOString(),
243
- tools_version: {
244
- eslint: this.getESLintVersion(),
245
- sunlint: this.getSunLintVersion()
246
- }
247
- }
248
- };
249
- }
250
-
251
- generateSummary(eslint, sunlint) {
252
- return {
253
- total_files: this.getTotalFiles(eslint, sunlint),
254
- total_violations: this.getTotalViolations(eslint, sunlint),
255
- by_severity: this.mergeSeverities(eslint, sunlint),
256
- by_tool: {
257
- eslint: this.getToolSummary(eslint),
258
- sunlint: this.getToolSummary(sunlint)
259
- }
260
- };
261
- }
262
- }
263
- ```
264
-
265
- ### **Month 1-2: ESLint Integration**
266
-
267
- #### **Step 1: SunLint ESLint Adapter**
268
- ```javascript
269
- // core/eslint-adapter.js
270
- class ESLintAdapter {
271
- constructor(eslintConfigPath) {
272
- this.eslintConfigPath = eslintConfigPath;
273
- this.eslint = require('eslint');
274
- }
275
-
276
- async runESLintRules(files, options) {
277
- const engine = new this.eslint.ESLint({
278
- configFile: this.eslintConfigPath,
279
- useEslintrc: false
280
- });
281
-
282
- const results = await engine.lintFiles(files);
283
- return this.convertToSunLintFormat(results);
284
- }
285
-
286
- convertToSunLintFormat(eslintResults) {
287
- return eslintResults.map(result => ({
288
- file: result.filePath,
289
- violations: result.messages.map(msg => ({
290
- ruleId: `eslint/${msg.ruleId}`,
291
- line: msg.line,
292
- column: msg.column,
293
- message: msg.message,
294
- severity: this.mapSeverity(msg.severity),
295
- source: 'eslint'
296
- }))
297
- }));
298
- }
299
- }
300
- ```
301
-
302
- #### **Step 2: Enhanced CLI Options**
303
- ```javascript
304
- // cli.js enhancements
305
- program
306
- .option('--include-eslint', 'Include ESLint custom rules')
307
- .option('--eslint-config <path>', 'ESLint config file path')
308
- .option('--eslint-only', 'Run only ESLint rules')
309
- .option('--sunlint-only', 'Run only SunLint rules')
310
- .option('--tool-comparison', 'Run both tools and compare results');
311
- ```
312
-
313
- ### **Month 3-6: Selective Migration**
314
-
315
- #### **Migration Priority Matrix:**
316
- ```javascript
317
- const migrationPlan = {
318
- // High priority - good candidates for migration
319
- immediate: {
320
- 'c003': {
321
- reason: 'Variable naming - core feature',
322
- complexity: 'medium',
323
- ai_potential: 'high',
324
- estimated_effort: '1 week'
325
- },
326
- 'c006': {
327
- reason: 'Function naming - already exists in SunLint',
328
- complexity: 'low',
329
- ai_potential: 'medium',
330
- estimated_effort: '3 days'
331
- }
332
- },
333
-
334
- // Medium priority - valuable but complex
335
- later: {
336
- 'c010': {
337
- reason: 'Block nesting - architectural rule',
338
- complexity: 'high',
339
- ai_potential: 'high',
340
- estimated_effort: '2 weeks'
341
- },
342
- 'c013': {
343
- reason: 'Dead code - useful across languages',
344
- complexity: 'high',
345
- ai_potential: 'very_high',
346
- estimated_effort: '3 weeks'
347
- }
348
- },
349
-
350
- // Keep in ESLint - TypeScript specific
351
- keep_eslint: {
352
- 't002': { reason: 'Interface prefix - TS specific syntax' },
353
- 't003': { reason: 'TS ignore reason - TS compiler specific' },
354
- 't004': { reason: 'Interface public only - TS type system' }
355
- }
356
- };
357
- ```
358
-
359
- ## 📊 **COST-BENEFIT ANALYSIS**
360
-
361
- | Solution | Implementation Time | Maintenance Cost | Team Disruption | Long-term Value |
362
- |----------|-------------------|------------------|-----------------|-----------------|
363
- | **Makefile** | 1-2 weeks | Low | Minimal | Medium |
364
- | **ESLint Integration** | 1-2 months | Medium | Low | High |
365
- | **Full Migration** | 3-6 months | Low | High | Very High |
366
- | **Hybrid Evolution** | 3-4 months total | Medium | Gradual | Very High |
367
-
368
- ## 🎯 **FINAL RECOMMENDATION**
369
-
370
- ### **🏆 Choose: Hybrid Evolution Strategy**
371
-
372
- **Rationale:**
373
- 1. **Preserves team effort** - ESLint rules remain valuable
374
- 2. **Immediate benefits** - unified reporting in weeks
375
- 3. **Future flexibility** - gradual migration path
376
- 4. **Risk mitigation** - incremental changes
377
- 5. **Team buy-in** - respects existing work
378
-
379
- **Success Metrics:**
380
- - ✅ **Week 2**: Unified report generation
381
- - ✅ **Month 1**: Single command execution
382
- - ✅ **Month 2**: ESLint integration in SunLint
383
- - ✅ **Month 6**: 50% rules migrated to SunLint
384
- - ✅ **Year 1**: Multi-language support with migrated rules
385
-
386
- **Key Decision Factors:**
387
- - ✅ **Team productivity** > tool purity
388
- - ✅ **Incremental value** > big bang approach
389
- - ✅ **Respect existing work** > reinvent everything
390
- - ✅ **Multi-language future** > TypeScript-only optimization
391
-
392
- This strategy acknowledges your team's investment while building toward a unified, scalable future! 🚀
@@ -1,83 +0,0 @@
1
- # Future SunLint Package Strategy
2
-
3
- ## Core Packages
4
-
5
- ### @sun-asterisk/sunlint (Core)
6
- - Size: ~235KB
7
- - Features: Basic JS/TS heuristic analysis
8
- - Dependencies: @babel/parser, espree
9
- - Target: Minimal setup, basic quality checks
10
-
11
- ### @sun-asterisk/sunlint-typescript
12
- - Size: ~2MB
13
- - Features: Full TypeScript analysis with AST
14
- - Dependencies: Core + @typescript-eslint/parser, typescript
15
- - Target: TypeScript projects
16
-
17
- ### @sun-asterisk/sunlint-full
18
- - Size: ~10MB
19
- - Features: Complete ESLint integration, all parsers
20
- - Dependencies: Core + all ESLint ecosystem
21
- - Target: Full-featured analysis
22
-
23
- ## Language Extensions
24
-
25
- ### @sun-asterisk/sunlint-dart
26
- - Dart-specific rules and analysis
27
- - Dependencies: dart_analyzer, dart tools
28
-
29
- ### @sun-asterisk/sunlint-python
30
- - Python-specific rules
31
- - Dependencies: pylint, autopep8, mypy
32
-
33
- ### @sun-asterisk/sunlint-go
34
- - Go-specific analysis
35
- - Dependencies: staticcheck, golint
36
-
37
- ## Feature Extensions
38
-
39
- ### @sun-asterisk/sunlint-ai
40
- - AI-powered code analysis
41
- - Dependencies: OpenAI API, Claude API
42
-
43
- ### @sun-asterisk/sunlint-security
44
- - Advanced security scanning
45
- - Dependencies: semgrep, snyk, security plugins
46
-
47
- ## Installation Examples
48
-
49
- ```bash
50
- # Basic usage
51
- npm install @sun-asterisk/sunlint --save-dev
52
-
53
- # TypeScript project
54
- npm install @sun-asterisk/sunlint-typescript --save-dev
55
-
56
- # Multi-language project
57
- npm install @sun-asterisk/sunlint @sun-asterisk/sunlint-dart @sun-asterisk/sunlint-python --save-dev
58
-
59
- # Enterprise setup with all features
60
- npm install @sun-asterisk/sunlint-full @sun-asterisk/sunlint-ai @sun-asterisk/sunlint-security --save-dev
61
- ```
62
-
63
- ## Configuration
64
-
65
- ### Package-based auto-detection
66
- ```json
67
- // .sunlint.json
68
- {
69
- "extends": ["auto-detect-packages"], // Automatically use installed packages
70
- "rules": {
71
- "C010": "error"
72
- }
73
- }
74
- ```
75
-
76
- ### Smart recommendations
77
- ```bash
78
- # When SunLint detects TypeScript files but no TS package
79
- npx sunlint --all
80
- # Output:
81
- # 💡 TypeScript files detected. For better analysis:
82
- # npm install @sun-asterisk/sunlint-typescript --save-dev
83
- ```
@@ -1,113 +0,0 @@
1
- # 🎯 Heuristic vs AI Analysis Guide
2
-
3
- ## Quick Commands
4
-
5
- ### 🔍 **Heuristic Mode (Fast & Accurate)**
6
- ```bash
7
- # Force heuristic analysis (ignore config)
8
- node cli.js --rule=C019 --input=src --no-ai
9
-
10
- # Disable in config file
11
- # In .sunlint.json: "ai": { "enabled": false }
12
- ```
13
-
14
- ### 🤖 **AI Mode (Context-Aware)**
15
- ```bash
16
- # Force AI analysis (with API key)
17
- export OPENAI_API_KEY="your-key"
18
- node cli.js --rule=C019 --input=src --ai
19
-
20
- # Enable in config file
21
- # In .sunlint.json: "ai": { "enabled": true }
22
- ```
23
-
24
- ## Performance Comparison
25
-
26
- | Mode | Speed | Accuracy | Cost | Use Case |
27
- |------|-------|----------|------|----------|
28
- | **Heuristic** | ⚡ ~100ms | 95%+ | Free | Daily development |
29
- | **AI** | 🐌 ~20-30s | 98%+ | $0.001/file | Complex analysis |
30
-
31
- ## Configuration Priority
32
-
33
- 1. **CLI flags** (highest priority)
34
- - `--ai` → Force enable AI
35
- - `--no-ai` → Force disable AI
36
-
37
- 2. **Config file** (.sunlint.json)
38
- ```json
39
- {
40
- "ai": {
41
- "enabled": true/false,
42
- "provider": "openai",
43
- "model": "gpt-4o-mini"
44
- }
45
- }
46
- ```
47
-
48
- 3. **Default** → Heuristic mode
49
-
50
- ## Use Cases
51
-
52
- ### ✅ **Use Heuristic When:**
53
- - Daily code reviews
54
- - CI/CD pipelines
55
- - Quick local checks
56
- - Large codebases
57
- - Limited internet/API quotas
58
-
59
- ### ✅ **Use AI When:**
60
- - Complex rule violations
61
- - Need context understanding
62
- - Training new developers
63
- - Quality audits
64
- - Unusual code patterns
65
-
66
- ## Debug Commands
67
-
68
- ```bash
69
- # Check which mode is active
70
- node cli.js --rule=C019 --input=src --debug
71
-
72
- # Look for these outputs:
73
- # Heuristic: "🔍 Running pattern analysis"
74
- # AI: "🤖 AI analysis enabled" + "🎯 AI found X violations"
75
- ```
76
-
77
- ## Troubleshooting
78
-
79
- ### AI Not Working?
80
- 1. Check API key: `echo $OPENAI_API_KEY`
81
- 2. Use `--ai --debug` to see errors
82
- 3. Verify config: `"ai": { "enabled": true }`
83
-
84
- ### Heuristic Not Working?
85
- 1. Use `--no-ai --debug`
86
- 2. Check output for "🔍 Running pattern analysis"
87
-
88
- ## Best Practices
89
-
90
- 1. **Development**: Use `--no-ai` for speed
91
- 2. **CI/CD**: Use heuristic mode by default
92
- 3. **Code Review**: Use AI for complex cases
93
- 4. **Training**: Use AI mode to understand violations better
94
-
95
- ## Example Workflows
96
-
97
- ### Daily Development
98
- ```bash
99
- # Quick check before commit
100
- node cli.js --quality --input=src --no-ai
101
- ```
102
-
103
- ### Code Review
104
- ```bash
105
- # Deep analysis with AI
106
- node cli.js --quality --input=src --ai --format=summary
107
- ```
108
-
109
- ### CI Pipeline
110
- ```bash
111
- # Fast, reliable heuristic
112
- node cli.js --all --input=src --no-ai --format=json
113
- ```
@@ -1,112 +0,0 @@
1
- # Production Deployment Analysis - SunLint Size Impact
2
-
3
- ## 🔍 **Câu hỏi từ Developer:**
4
- *"Công việc trên có phải là phổ biến không, tức là khi deploy thông thường có làm các công việc đó không?"*
5
-
6
- ## 📊 **Thực tế Deployment Phổ Biến**
7
-
8
- ### ✅ **THỰC TẾ 1: DevDependencies tự động bị loại trừ**
9
-
10
- **Hầu hết deployment platforms tự động loại trừ devDependencies:**
11
-
12
- | Platform | Auto-exclude devDependencies | Command |
13
- |----------|------------------------------|---------|
14
- | **Heroku** | ✅ | `npm install --production` |
15
- | **Vercel** | ✅ | `npm ci --production` |
16
- | **Netlify** | ✅ | `npm install --production` |
17
- | **Docker** | ✅ | `RUN npm ci --only=production` |
18
- | **AWS Lambda** | ✅ | `npm install --production` |
19
- | **Google Cloud** | ✅ | `npm ci --production` |
20
-
21
- ### ✅ **THỰC TẾ 2: Build process tự nhiên**
22
-
23
- **Typical CI/CD pipeline:**
24
- ```bash
25
- # Development
26
- npm install # Cài tất cả (bao gồm SunLint)
27
- npm run lint # SunLint chạy để check code
28
- npm run test # Tests chạy
29
- npm run build # Build production bundle
30
-
31
- # Production deployment
32
- npm ci --production # CHỈ cài runtime dependencies
33
- # SunLint tự động bị loại trừ!
34
- ```
35
-
36
- ### ✅ **THỰC TẾ 3: Docker multistage builds**
37
-
38
- **Phổ biến nhất - Docker multistage:**
39
- ```dockerfile
40
- # Build stage
41
- FROM node:18 AS builder
42
- COPY package*.json ./
43
- RUN npm install # Cài tất cả, kể cả SunLint
44
- COPY . .
45
- RUN npm run build # SunLint chạy trong quá trình build
46
-
47
- # Production stage
48
- FROM node:18-alpine AS production
49
- COPY package*.json ./
50
- RUN npm ci --production --silent # CHỈ runtime deps
51
- COPY --from=builder /app/dist ./dist
52
- # SunLint không có trong production image!
53
- ```
54
-
55
- ## 🎯 **Kết luận về SunLint**
56
-
57
- ### **TẠI SAO SUNLINT AN TOÀN 100%:**
58
-
59
- 1. **DevDependency by design** - SunLint được thiết kế như linting tool
60
- 2. **Industry standard** - Tất cả linting tools đều hoạt động như vậy
61
- 3. **Automatic exclusion** - Deployment platforms tự động loại trừ
62
- 4. **Zero production footprint** - Không code SunLint nào trong runtime
63
-
64
- ### **SO SÁNH VỚI CÔNG CỤ KHÁC:**
65
-
66
- | Tool | Size | Production Impact | Usage Pattern |
67
- |------|------|-------------------|---------------|
68
- | **ESLint** | ~500KB | ❌ (nếu sai cách) | DevDependency ✅ |
69
- | **SunLint** | **241KB** | ✅ **KHÔNG** | DevDependency ✅ |
70
- | **Prettier** | ~300KB | ❌ (nếu sai cách) | DevDependency ✅ |
71
- | **TypeScript** | ~60MB | ❌ (nếu sai cách) | DevDependency ✅ |
72
-
73
- ## 📈 **Best Practices Verification**
74
-
75
- ### **✅ ĐÚNG CÁCH (99% cases):**
76
- ```json
77
- {
78
- "devDependencies": {
79
- "@sun-asterisk/sunlint": "^1.1.4",
80
- "eslint": "^8.57.1",
81
- "prettier": "^3.0.0"
82
- },
83
- "dependencies": {
84
- "express": "^4.18.0" // Chỉ runtime deps
85
- }
86
- }
87
- ```
88
-
89
- ### **❌ SAI CÁCH (hiếm, chỉ newbie):**
90
- ```json
91
- {
92
- "dependencies": {
93
- "@sun-asterisk/sunlint": "^1.1.4", // ❌ Sai!
94
- "express": "^4.18.0"
95
- }
96
- }
97
- ```
98
-
99
- ## 🚀 **Tóm tắt**
100
-
101
- **CÂU TRẢ LỜI:** Các công việc này **HOÀN TOÀN PHỔ BIẾN** và **TỰ ĐỘNG** trong production deployment:
102
-
103
- 1. ✅ **DevDependencies tự động bị loại trừ** - Industry standard
104
- 2. ✅ **Build tools chỉ chạy development time** - Normal practice
105
- 3. ✅ **Production chỉ có runtime code** - Security best practice
106
- 4. ✅ **SunLint = 0KB trong production** - Guaranteed
107
-
108
- **Developer không cần lo lắng về size impact của SunLint!**
109
-
110
- ---
111
- *Generated on: 2025-07-24*
112
- *SunLint Version: 1.1.4*