@sun-asterisk/sunlint 1.0.7 → 1.1.4

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 (219) hide show
  1. package/.sunlint.json +35 -0
  2. package/CHANGELOG.md +30 -3
  3. package/CONTRIBUTING.md +235 -0
  4. package/PROJECT_STRUCTURE.md +60 -0
  5. package/README.md +146 -58
  6. package/cli.js +1 -0
  7. package/config/README.md +88 -0
  8. package/config/defaults/ai-rules-context.json +231 -0
  9. package/config/engines/engines.json +49 -0
  10. package/config/engines/eslint-rule-mapping.json +74 -0
  11. package/config/eslint-rule-mapping.json +126 -0
  12. package/config/integrations/eslint/base.config.js +125 -0
  13. package/config/integrations/eslint/simple.config.js +24 -0
  14. package/config/presets/strict.json +0 -1
  15. package/config/rule-analysis-strategies.js +74 -0
  16. package/config/{rules-registry.json → rules/rules-registry.json} +30 -7
  17. package/core/analysis-orchestrator.js +383 -591
  18. package/core/ast-modules/README.md +103 -0
  19. package/core/ast-modules/base-parser.js +90 -0
  20. package/core/ast-modules/index.js +97 -0
  21. package/core/ast-modules/package.json +37 -0
  22. package/core/ast-modules/parsers/eslint-js-parser.js +153 -0
  23. package/core/ast-modules/parsers/eslint-ts-parser.js +98 -0
  24. package/core/ast-modules/parsers/javascript-parser.js +187 -0
  25. package/core/ast-modules/parsers/typescript-parser.js +187 -0
  26. package/core/cli-action-handler.js +271 -255
  27. package/core/cli-program.js +18 -4
  28. package/core/config-manager.js +9 -3
  29. package/core/config-merger.js +40 -1
  30. package/core/config-validator.js +2 -2
  31. package/core/dependency-checker.js +125 -0
  32. package/core/enhanced-rules-registry.js +331 -0
  33. package/core/file-targeting-service.js +92 -23
  34. package/core/interfaces/analysis-engine.interface.js +100 -0
  35. package/core/multi-rule-runner.js +0 -221
  36. package/core/output-service.js +1 -1
  37. package/core/rule-mapping-service.js +1 -1
  38. package/core/rule-selection-service.js +10 -2
  39. package/core/smart-installer.js +164 -0
  40. package/docs/AI.md +163 -0
  41. package/docs/ARCHITECTURE.md +78 -0
  42. package/docs/CI-CD-GUIDE.md +315 -0
  43. package/docs/COMMAND-EXAMPLES.md +256 -0
  44. package/docs/CONFIGURATION.md +414 -0
  45. package/docs/DEBUG.md +86 -0
  46. package/docs/DEPENDENCIES.md +90 -0
  47. package/docs/DEPLOYMENT-STRATEGIES.md +270 -0
  48. package/docs/DISTRIBUTION.md +153 -0
  49. package/docs/ESLINT-INTEGRATION-STRATEGY.md +392 -0
  50. package/docs/ESLINT_INTEGRATION.md +238 -0
  51. package/docs/FOLDER_STRUCTURE.md +59 -0
  52. package/docs/FUTURE_PACKAGES.md +83 -0
  53. package/docs/HEURISTIC_VS_AI.md +113 -0
  54. package/docs/PRODUCTION_DEPLOYMENT_ANALYSIS.md +112 -0
  55. package/docs/PRODUCTION_SIZE_IMPACT.md +183 -0
  56. package/docs/README.md +32 -0
  57. package/docs/RELEASE_GUIDE.md +230 -0
  58. package/engines/eslint-engine.js +610 -0
  59. package/engines/heuristic-engine.js +864 -0
  60. package/engines/openai-engine.js +374 -0
  61. package/engines/tree-sitter-parser.js +0 -0
  62. package/engines/universal-ast-engine.js +0 -0
  63. package/integrations/eslint/README.md +99 -0
  64. package/integrations/eslint/configs/.eslintrc.js +98 -0
  65. package/integrations/eslint/configs/eslint.config.js +133 -0
  66. package/integrations/eslint/configs/eslint.config.simple.js +24 -0
  67. package/integrations/eslint/package.json +23 -0
  68. package/integrations/eslint/plugin/index.js +164 -0
  69. package/integrations/eslint/plugin/package.json +13 -0
  70. package/integrations/eslint/plugin/rules/common/c002-no-duplicate-code.js +204 -0
  71. package/integrations/eslint/plugin/rules/common/c003-no-vague-abbreviations.js +246 -0
  72. package/integrations/eslint/plugin/rules/common/c006-function-name-verb-noun.js +216 -0
  73. package/integrations/eslint/plugin/rules/common/c010-limit-block-nesting.js +90 -0
  74. package/integrations/eslint/plugin/rules/common/c013-no-dead-code.js +78 -0
  75. package/integrations/eslint/plugin/rules/common/c014-abstract-dependency-preferred.js +38 -0
  76. package/integrations/eslint/plugin/rules/common/c017-limit-constructor-logic.js +146 -0
  77. package/integrations/eslint/plugin/rules/common/c018-no-generic-throw.js +335 -0
  78. package/integrations/eslint/plugin/rules/common/c023-no-duplicate-variable-name-in-scope.js +142 -0
  79. package/integrations/eslint/plugin/rules/common/c029-catch-block-logging.js +115 -0
  80. package/integrations/eslint/plugin/rules/common/c030-use-custom-error-classes.js +294 -0
  81. package/integrations/eslint/plugin/rules/common/c035-no-empty-catch.js +162 -0
  82. package/integrations/eslint/plugin/rules/common/c041-no-config-inline.js +122 -0
  83. package/integrations/eslint/plugin/rules/common/c042-boolean-name-prefix.js +406 -0
  84. package/integrations/eslint/plugin/rules/common/c043-no-console-or-print.js +300 -0
  85. package/integrations/eslint/plugin/rules/common/c047-no-duplicate-retry-logic.js +239 -0
  86. package/integrations/eslint/plugin/rules/common/c072-one-assert-per-test.js +184 -0
  87. package/integrations/eslint/plugin/rules/common/c075-explicit-function-return-types.js +168 -0
  88. package/integrations/eslint/plugin/rules/common/c076-single-behavior-per-test.js +254 -0
  89. package/integrations/eslint/plugin/rules/security/s001-fail-securely.js +381 -0
  90. package/integrations/eslint/plugin/rules/security/s002-idor-check.js +945 -0
  91. package/integrations/eslint/plugin/rules/security/s003-no-unvalidated-redirect.js +86 -0
  92. package/integrations/eslint/plugin/rules/security/s007-no-plaintext-otp.js +74 -0
  93. package/integrations/eslint/plugin/rules/security/s013-verify-tls-connection.js +47 -0
  94. package/integrations/eslint/plugin/rules/security/s047-secure-random-passwords.js +108 -0
  95. package/integrations/eslint/plugin/rules/security/s055-verification-rest-check-the-incoming-content-type.js +143 -0
  96. package/integrations/eslint/plugin/rules/typescript/t002-interface-prefix-i.js +42 -0
  97. package/integrations/eslint/plugin/rules/typescript/t003-ts-ignore-reason.js +48 -0
  98. package/integrations/eslint/plugin/rules/typescript/t004-no-empty-type.js +95 -0
  99. package/integrations/eslint/plugin/rules/typescript/t007-no-fn-in-constructor.js +52 -0
  100. package/integrations/eslint/plugin/rules/typescript/t010-no-nested-union-tuple.js +48 -0
  101. package/integrations/eslint/plugin/rules/typescript/t019-no-this-assign.js +81 -0
  102. package/integrations/eslint/plugin/rules/typescript/t020-no-default-multi-export.js +127 -0
  103. package/integrations/eslint/plugin/rules/typescript/t021-limit-nested-generics.js +150 -0
  104. package/integrations/eslint/tsconfig.json +27 -0
  105. package/package.json +61 -21
  106. package/rules/README.md +252 -0
  107. package/rules/common/C002_no_duplicate_code/analyzer.js +65 -0
  108. package/rules/common/C002_no_duplicate_code/config.json +23 -0
  109. package/rules/common/C003_no_vague_abbreviations/analyzer.js +418 -0
  110. package/rules/common/C003_no_vague_abbreviations/config.json +35 -0
  111. package/rules/{C006_function_naming → common/C006_function_naming}/analyzer.js +13 -2
  112. package/rules/common/C010_limit_block_nesting/analyzer.js +389 -0
  113. package/rules/common/C013_no_dead_code/analyzer.js +206 -0
  114. package/rules/common/C014_dependency_injection/analyzer.js +338 -0
  115. package/rules/common/C017_constructor_logic/analyzer.js +314 -0
  116. package/rules/{C019_log_level_usage → common/C019_log_level_usage}/analyzer.js +5 -2
  117. package/rules/{C029_catch_block_logging → common/C029_catch_block_logging}/analyzer.js +49 -15
  118. package/rules/common/C041_no_sensitive_hardcode/analyzer.js +292 -0
  119. package/rules/common/C042_boolean_name_prefix/analyzer.js +300 -0
  120. package/rules/common/C043_no_console_or_print/analyzer.js +304 -0
  121. package/rules/common/C047_no_duplicate_retry_logic/analyzer.js +351 -0
  122. package/rules/common/C075_explicit_return_types/analyzer.js +103 -0
  123. package/rules/common/C076_single_test_behavior/analyzer.js +121 -0
  124. package/rules/docs/C002_no_duplicate_code.md +57 -0
  125. package/rules/index.js +149 -0
  126. package/rules/migration/converter.js +385 -0
  127. package/rules/migration/mapping.json +164 -0
  128. package/rules/security/S026_json_schema_validation/analyzer.js +251 -0
  129. package/rules/security/S026_json_schema_validation/config.json +27 -0
  130. package/rules/security/S027_no_hardcoded_secrets/analyzer.js +263 -0
  131. package/rules/security/S027_no_hardcoded_secrets/config.json +29 -0
  132. package/rules/security/S029_csrf_protection/analyzer.js +264 -0
  133. package/rules/tests/C002_no_duplicate_code.test.js +50 -0
  134. package/rules/universal/C010/generic.js +0 -0
  135. package/rules/universal/C010/tree-sitter-analyzer.js +0 -0
  136. package/rules/utils/ast-utils.js +191 -0
  137. package/rules/utils/base-analyzer.js +98 -0
  138. package/rules/utils/pattern-matchers.js +239 -0
  139. package/rules/utils/rule-helpers.js +264 -0
  140. package/rules/utils/severity-constants.js +93 -0
  141. package/scripts/build-release.sh +117 -0
  142. package/scripts/ci-report.js +179 -0
  143. package/scripts/install.sh +196 -0
  144. package/scripts/manual-release.sh +338 -0
  145. package/scripts/merge-reports.js +424 -0
  146. package/scripts/pre-release-test.sh +175 -0
  147. package/scripts/prepare-release.sh +202 -0
  148. package/scripts/setup-github-registry.sh +42 -0
  149. package/scripts/test-scripts/README.md +22 -0
  150. package/scripts/test-scripts/test-c041-comparison.js +114 -0
  151. package/scripts/test-scripts/test-c041-eslint.js +67 -0
  152. package/scripts/test-scripts/test-eslint-rules.js +146 -0
  153. package/scripts/test-scripts/test-real-world.js +44 -0
  154. package/scripts/test-scripts/test-rules-on-real-projects.js +86 -0
  155. package/scripts/trigger-release.sh +285 -0
  156. package/scripts/validate-rule-structure.js +148 -0
  157. package/scripts/verify-install.sh +82 -0
  158. package/config/sunlint-schema.json +0 -159
  159. package/config/typescript/custom-rules.js +0 -9
  160. package/config/typescript/package-lock.json +0 -1585
  161. package/config/typescript/package.json +0 -13
  162. package/config/typescript/security-rules/index.js +0 -90
  163. package/config/typescript/tsconfig.json +0 -29
  164. package/core/ai-analyzer.js +0 -169
  165. package/core/eslint-engine-service.js +0 -312
  166. package/core/eslint-instance-manager.js +0 -104
  167. package/core/eslint-integration-service.js +0 -363
  168. package/core/sunlint-engine-service.js +0 -23
  169. package/core/typescript-analyzer.js +0 -262
  170. package/core/typescript-engine.js +0 -313
  171. /package/config/{default.json → defaults/default.json} +0 -0
  172. /package/config/{typescript/eslint.config.js → integrations/eslint/typescript.config.js} +0 -0
  173. /package/config/{typescript/custom-rules-new.js → schemas/sunlint-schema.json} +0 -0
  174. /package/config/{typescript → testing}/test-s005-working.ts +0 -0
  175. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s005-no-origin-auth.js +0 -0
  176. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s006-activation-recovery-secret-not-plaintext.js +0 -0
  177. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s008-crypto-agility.js +0 -0
  178. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s009-no-insecure-crypto.js +0 -0
  179. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s010-no-insecure-random-in-sensitive-context.js +0 -0
  180. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s011-no-insecure-uuid.js +0 -0
  181. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s012-hardcode-secret.js +0 -0
  182. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s014-insecure-tls-version.js +0 -0
  183. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s015-insecure-tls-certificate.js +0 -0
  184. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s016-sensitive-query-parameter.js +0 -0
  185. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s017-no-sql-injection.js +0 -0
  186. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s018-positive-input-validation.js +0 -0
  187. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s019-no-raw-user-input-in-email.js +0 -0
  188. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s020-no-eval-dynamic-execution.js +0 -0
  189. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s022-output-encoding.js +0 -0
  190. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s023-no-json-injection.js +0 -0
  191. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s025-server-side-input-validation.js +0 -0
  192. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s026-json-schema-validation.js +0 -0
  193. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s027-no-hardcoded-secrets.js +0 -0
  194. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s029-require-csrf-protection.js +0 -0
  195. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s030-no-directory-browsing.js +0 -0
  196. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s033-require-samesite-cookie.js +0 -0
  197. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s034-require-host-cookie-prefix.js +0 -0
  198. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s035-cookie-specific-path.js +0 -0
  199. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s036-no-unsafe-file-include.js +0 -0
  200. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s037-require-anti-cache-headers.js +0 -0
  201. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s038-no-version-disclosure.js +0 -0
  202. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s039-no-session-token-in-url.js +0 -0
  203. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s041-require-session-invalidate-on-logout.js +0 -0
  204. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s042-require-periodic-reauthentication.js +0 -0
  205. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s043-terminate-sessions-on-password-change.js +0 -0
  206. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s044-require-full-session-for-sensitive-operations.js +0 -0
  207. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s045-anti-automation-controls.js +0 -0
  208. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s046-secure-notification-on-auth-change.js +0 -0
  209. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s048-password-credential-recovery.js +0 -0
  210. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s050-session-token-weak-hash.js +0 -0
  211. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s052-secure-random-authentication-code.js +0 -0
  212. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s054-verification-default-account.js +0 -0
  213. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s057-utc-logging.js +0 -0
  214. /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s058-no-ssrf.js +0 -0
  215. /package/rules/{C006_function_naming → common/C006_function_naming}/config.json +0 -0
  216. /package/rules/{C019_log_level_usage → common/C019_log_level_usage}/config.json +0 -0
  217. /package/rules/{C029_catch_block_logging → common/C029_catch_block_logging}/config.json +0 -0
  218. /package/rules/{C031_validation_separation → common/C031_validation_separation}/analyzer.js +0 -0
  219. /package/rules/{C031_validation_separation/README.md → docs/C031_validation_separation.md} +0 -0
@@ -0,0 +1,83 @@
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
+ ```
@@ -0,0 +1,113 @@
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
+ ```
@@ -0,0 +1,112 @@
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*
@@ -0,0 +1,183 @@
1
+ # 📦 SunLint Production Size Impact Analysis
2
+
3
+ ## Tóm tắt cho Leadership
4
+
5
+ **KẾT LUẬN: SunLint KHÔNG làm tăng size production khi sử dụng đúng cách.**
6
+
7
+ ## Chi tiết phân tích
8
+
9
+ ### 1. Package Size của SunLint
10
+
11
+ ```bash
12
+ SunLint package size: 241.6 kB
13
+ SunLint unpacked size: 1.1 MB
14
+ Total files: 214
15
+ ```
16
+
17
+ ### 2. Test Production Impact
18
+
19
+ Chúng tôi đã tạo một project test để kiểm tra impact thực tế:
20
+
21
+ | Giai đoạn | Size | Ghi chú |
22
+ |-----------|------|---------|
23
+ | Project ban đầu | 8.0K | Chỉ có package.json và .gitignore |
24
+ | Sau khi cài SunLint (devDependency) | 88M | Bao gồm tất cả devDependencies |
25
+ | Production bundle (dist/) | 4.0K | Code production thực tế |
26
+ | Sau npm prune --production | 156K | Đã xóa tất cả devDependencies |
27
+
28
+ ### 3. Khuyến nghị sử dụng trong Production
29
+
30
+ #### ✅ ĐÚNG CÁCH (Production-friendly):
31
+
32
+ ```json
33
+ {
34
+ "devDependencies": {
35
+ "@sun-asterisk/sunlint": "^1.1.4"
36
+ }
37
+ }
38
+ ```
39
+
40
+ **Lợi ích:**
41
+ - ✅ Không ảnh hưởng size production bundle
42
+ - ✅ Chỉ cài khi development (`npm install`)
43
+ - ✅ Tự động loại trừ khỏi production (`npm prune --production`)
44
+ - ✅ CI/CD có thể dùng để check code quality
45
+
46
+ #### ❌ SAI CÁCH (Không khuyến nghị):
47
+
48
+ ```json
49
+ {
50
+ "dependencies": {
51
+ "@sun-asterisk/sunlint": "^1.1.4"
52
+ }
53
+ }
54
+ ```
55
+
56
+ **Vấn đề:**
57
+ - ❌ Tăng 1.1MB cho production bundle
58
+ - ❌ Không cần thiết cho runtime
59
+ - ❌ Làm chậm deployment
60
+
61
+ ### 4. Deployment Strategies
62
+
63
+ #### Option 1: Development Only (Khuyến nghị)
64
+ ```bash
65
+ # Development
66
+ npm install
67
+
68
+ # Production build
69
+ npm run build
70
+ npm prune --production
71
+ # → SunLint sẽ bị xóa hoàn toàn
72
+ ```
73
+
74
+ #### Option 2: CI/CD Pipeline
75
+ ```yaml
76
+ # .github/workflows/ci.yml
77
+ - name: Install deps
78
+ run: npm ci
79
+ - name: Run SunLint
80
+ run: npx sunlint --quality --input=src
81
+ - name: Build production
82
+ run: npm run build
83
+ - name: Remove dev deps
84
+ run: npm prune --production
85
+ ```
86
+
87
+ #### Option 3: Docker Multi-stage
88
+ ```dockerfile
89
+ # Development stage với SunLint
90
+ FROM node:18 as dev
91
+ COPY package*.json ./
92
+ RUN npm ci
93
+ COPY . .
94
+ RUN npx sunlint --all --input=src
95
+
96
+ # Production stage KHÔNG có SunLint
97
+ FROM node:18-alpine as prod
98
+ COPY package*.json ./
99
+ RUN npm ci --only=production
100
+ COPY dist/ ./dist/
101
+ ```
102
+
103
+ ### 5. So sánh với các tools khác
104
+
105
+ | Tool | Package Size | Production Impact | Use Case |
106
+ |------|-------------|-------------------|-----------|
107
+ | ESLint | ~500KB | ❌ Nếu để dependencies | Development only |
108
+ | Prettier | ~200KB | ❌ Nếu để dependencies | Development only |
109
+ | **SunLint** | **241KB** | **✅ KHÔNG (devDep)** | **Development + CI/CD** |
110
+ | TypeScript | ~60MB | ❌ Nếu để dependencies | Development only |
111
+
112
+ ### 6. Best Practices cho Teams
113
+
114
+ #### Developers:
115
+ ```bash
116
+ # Local development
117
+ npm install # Cài tất cả deps (bao gồm SunLint)
118
+ npx sunlint --quality --input=src
119
+
120
+ # Pre-commit hook
121
+ npx sunlint --changed-files
122
+ ```
123
+
124
+ #### CI/CD:
125
+ ```bash
126
+ # Build pipeline
127
+ npm ci # Cài tất cả deps
128
+ npx sunlint --all --input=src # Quality check
129
+ npm run build # Build production
130
+ npm prune --production # Xóa devDeps
131
+ ```
132
+
133
+ #### Production:
134
+ ```bash
135
+ # Server deployment
136
+ npm ci --only=production # Chỉ cài production deps
137
+ # → SunLint sẽ KHÔNG được cài
138
+ ```
139
+
140
+ ### 7. Monitoring & Verification
141
+
142
+ #### Verify production size:
143
+ ```bash
144
+ # Trước deploy
145
+ du -sh node_modules
146
+ du -sh dist/
147
+
148
+ # Kiểm tra không có SunLint
149
+ ls node_modules | grep sunlint # Không có kết quả = OK
150
+ ```
151
+
152
+ #### Bundle size monitoring:
153
+ ```bash
154
+ # Add to package.json
155
+ {
156
+ "scripts": {
157
+ "analyze-bundle": "du -sh dist/ && echo 'Production bundle size'",
158
+ "verify-prod": "npm ls --production --depth=0"
159
+ }
160
+ }
161
+ ```
162
+
163
+ ## Kết luận
164
+
165
+ ### ✅ AN TOÀN cho Production:
166
+ - SunLint được thiết kế như devDependency
167
+ - Không ảnh hưởng size production bundle khi sử dụng đúng
168
+ - Có thể tích hợp vào CI/CD mà không ảnh hưởng deployment
169
+
170
+ ### 📊 Số liệu cụ thể:
171
+ - **Development**: +88MB (chỉ khi dev)
172
+ - **Production**: +0KB (khi dùng đúng cách)
173
+ - **CI/CD**: Impact chỉ ở build time, không ở runtime
174
+
175
+ ### 🚀 Khuyến nghị:
176
+ 1. **Luôn cài như devDependency**
177
+ 2. **Sử dụng trong CI/CD pipeline**
178
+ 3. **npm prune --production trước deploy**
179
+ 4. **Monitor bundle size định kỳ**
180
+
181
+ ---
182
+
183
+ *Tài liệu này được cập nhật cho SunLint v1.1.4 - July 2025*
package/docs/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # 📚 Sunlint Documentation
2
+
3
+ ## Quick Links
4
+
5
+ - **[AI Features](AI.md)** - AI-powered analysis guide
6
+ - **[Debug Guide](DEBUG.md)** - How to debug rules and CLI
7
+ - **[Architecture](ARCHITECTURE.md)** - System architecture and modular design
8
+ - **[Distribution](DISTRIBUTION.md)** - Installation and deployment methods
9
+
10
+ ## Development Guides
11
+
12
+ - **[Folder Structure](FOLDER_STRUCTURE.md)** - Project organization
13
+ - **[ESLint Integration Strategy](ESLINT-INTEGRATION-STRATEGY.md)** - ESLint vs SunLint strategy
14
+ - **[CI/CD Guide](CI-CD-GUIDE.md)** - Continuous integration setup
15
+ - **[Command Examples](COMMAND-EXAMPLES.md)** - CLI usage examples
16
+
17
+ ## Performance & Analysis
18
+
19
+ - **[Heuristic vs AI](HEURISTIC_VS_AI.md)** - Performance comparison guide
20
+ - **[Rule Responsibility Matrix](RULE-RESPONSIBILITY-MATRIX.md)** - Rules mapping and coverage
21
+
22
+ ## Main Documentation
23
+
24
+ - **[README.md](../README.md)** - Main project documentation
25
+ - **[CONTRIBUTING.md](../CONTRIBUTING.md)** - Contribution guidelines
26
+ - **[CHANGELOG.md](../CHANGELOG.md)** - Version history
27
+ - **[LICENSE](../LICENSE)** - License information
28
+
29
+ ## Configuration
30
+
31
+ - **[.sunlint-simple.json](../.sunlint-simple.json)** - Simple configuration example
32
+ - **[sunlint.config.json](../sunlint.config.json)** - Full configuration with all features