@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
package/.sunlint.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "extends": ["@sun/sunlint/recommended"],
3
+ "rules": {
4
+ "C019": "warn",
5
+ "C006": "warn",
6
+ "C029": "error",
7
+ "C031": "warn",
8
+ "S001": "warn",
9
+ "S002": "warn",
10
+ "S007": "warn",
11
+ "S013": "warn",
12
+ "T019": "error",
13
+ "T020": "warn",
14
+ "T021": "error"
15
+ },
16
+ "include": ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
17
+ "exclude": [
18
+ "node_modules/**",
19
+ "coverage/**",
20
+ "**/*.min.*",
21
+ ".git/**",
22
+ "dist/**",
23
+ "build/**"
24
+ ],
25
+ "engine": "eslint",
26
+ "languages": ["typescript", "javascript"],
27
+ "output": {
28
+ "format": "summary",
29
+ "console": true
30
+ },
31
+ "fileTargeting": {
32
+ "followSymlinks": false,
33
+ "maxDepth": 10
34
+ }
35
+ }
package/CHANGELOG.md CHANGED
@@ -1,7 +1,34 @@
1
- # 🎉 SunLint v1.0.7 Release Notes
1
+ # 🎉 SunLint v1.1.0 Release Notes
2
2
 
3
- **Release Date**: July 20, 2025
4
- **Type**: Minor Release (Bug Fixes & Configuration Improvements)
3
+ **Release Date**: July 23, 2025
4
+ **Type**: Minor Release (AST Enhancement & CLI Options Fix)
5
+
6
+ ---
7
+
8
+ ## 🚀 **Key Improvements**
9
+
10
+ ### 🧠 **AST-Enhanced Analysis**
11
+ - **Enhanced**: Heuristic engine now supports AST-based analysis using ESLint's parser infrastructure
12
+ - **Improved**: Rule C010 (block nesting) now uses AST for accurate detection
13
+ - **Modular**: AST modules integrated with silent fallback to regex when parsing fails
14
+ - **Performance**: ESLint-based parsers (@babel/parser, @typescript-eslint/parser) for JS/TS analysis
15
+
16
+ ### 🎯 **CLI Options Fix**
17
+ - **Fixed**: `--quality` option now correctly selects quality rules (30 rules)
18
+ - **Fixed**: `--security` option now correctly selects security rules (41 rules)
19
+ - **Enhanced**: Rule selection service properly filters by category
20
+ - **Validated**: Both options tested and working correctly
21
+
22
+ ### 📦 **Package Optimization**
23
+ - **Reduced**: Package size from 8MB to 243KB by excluding nested node_modules
24
+ - **Clean**: Updated .npmignore to exclude development files
25
+ - **Dependencies**: Moved AST parser dependencies to root package.json
26
+
27
+ ---
28
+
29
+ ## 📋 **Previous Changes (v1.0.7)**
30
+
31
+ ### 🔧 **Configuration Cleanup**
5
32
 
6
33
  ---
7
34
 
@@ -0,0 +1,235 @@
1
+ # Contributing to Sun Lint
2
+
3
+ Thank you for your interest in contributing to Sun Lint! 🌟
4
+
5
+ ## 🚀 **Getting Started**
6
+
7
+ ### **Prerequisites**
8
+ - Node.js 16+
9
+ - npm 8+
10
+ - Git
11
+
12
+ ### **Setup Development Environment**
13
+
14
+ ```bash
15
+ # Clone the repository
16
+ git clone https://github.com/sun-engineering/sunlint.git
17
+ cd sunlint
18
+
19
+ # Install dependencies
20
+ npm install
21
+
22
+ # Run tests
23
+ npm test
24
+
25
+ # Try the CLI locally
26
+ node cli.js --help
27
+ ```
28
+
29
+ ## 📋 **Coding Standards**
30
+
31
+ When contributing to Sun Lint, please follow these coding rules:
32
+
33
+ ### **Code Quality Rules**
34
+ - **Rule C005** – Each function should do one thing only
35
+ - **Rule C006** – Function names must be verb/verb-noun
36
+ - **Rule C007** – Avoid comments that just describe the code
37
+ - **Rule C012** – Separate Command and Query operations (CQS principle)
38
+ - **Rule C014** – Use Dependency Injection instead of direct instantiation
39
+ - **Rule C015** – Use domain language in class/function names
40
+ - **Rule C019** – Don't use `error` log level for non-critical errors
41
+ - **Rule C031** – Keep validation logic separate
42
+ - **Rule C032** – Don't call external APIs in constructors or static blocks
43
+ - **Rule C033** – Separate processing logic and data queries in service layer
44
+ - **Rule C034** – Limit direct access to global state in domain logic
45
+ - **Rule C035** – When handling errors, log complete relevant information
46
+ - **Rule C037** – API handlers should return standard response objects (not raw strings)
47
+ - **Rule C038** – Avoid logic depending on file/module loading order
48
+ - **Rule C040** – Don't scatter validation logic across multiple classes
49
+
50
+ ## 🔧 **Development Workflow**
51
+
52
+ ### **Adding a New Quality Rule**
53
+
54
+ 1. **Create Rule Implementation**
55
+ ```bash
56
+ # Create the rule directory
57
+ mkdir -p rules/quality/c042-new-rule
58
+ cd rules/quality/c042-new-rule
59
+ ```
60
+
61
+ 2. **Implement the Rule**
62
+ ```javascript
63
+ // rules/quality/c042-new-rule/analyzer.js
64
+ class C042NewRuleAnalyzer {
65
+ analyze(code, filePath) {
66
+ // Implementation following Rule C005 (single responsibility)
67
+ return this.findViolations(code, filePath);
68
+ }
69
+
70
+ findViolations(code, filePath) {
71
+ // Rule C031: Keep validation logic separate
72
+ const violations = [];
73
+ // Analysis logic here
74
+ return violations;
75
+ }
76
+ }
77
+
78
+ module.exports = C042NewRuleAnalyzer;
79
+ ```
80
+
81
+ 3. **Add Configuration**
82
+ ```json
83
+ // rules/quality/c042-new-rule/config.json
84
+ {
85
+ "id": "C042",
86
+ "name": "New Rule Name",
87
+ "category": "quality",
88
+ "severity": "error",
89
+ "description": "Description following Rule C015 (domain language)",
90
+ "languages": ["typescript", "dart", "kotlin"],
91
+ "tags": ["maintainability", "readability"]
92
+ }
93
+ ```
94
+
95
+ 4. **Update Registry**
96
+ ```javascript
97
+ // Add to config/rules/rules-registry.json
98
+ {
99
+ "C042": {
100
+ "id": "C042",
101
+ "name": "New Rule Name",
102
+ "category": "quality",
103
+ "path": "./rules/quality/c042-new-rule",
104
+ "analyzer": "analyzer.js",
105
+ "config": "config.json"
106
+ }
107
+ }
108
+ ```
109
+
110
+ 5. **Add Tests**
111
+ ```javascript
112
+ // test/fixtures/c042/valid.ts
113
+ // test/fixtures/c042/invalid.ts
114
+ // test/unit/rules/c042.test.js
115
+ ```
116
+
117
+ ### **Adding a New Security Rule**
118
+
119
+ Same process but in `rules/security/` directory with `security` category.
120
+
121
+ ## 🧪 **Testing**
122
+
123
+ ### **Run All Tests**
124
+ ```bash
125
+ npm test
126
+ ```
127
+
128
+ ### **Run Specific Tests**
129
+ ```bash
130
+ # Test specific rule
131
+ npm run test:c019
132
+
133
+ # Test multiple rules
134
+ npm run test:multi
135
+
136
+ # Test all quality rules
137
+ npm run test:quality
138
+
139
+ # Test all security rules
140
+ npm run test:security
141
+ ```
142
+
143
+ ### **Test Your Changes**
144
+ ```bash
145
+ # Test your new rule
146
+ node cli.js --rule=C042 --input=test/fixtures --format=eslint
147
+ ```
148
+
149
+ ## 📊 **Code Review Process**
150
+
151
+ 1. **Self-Review Checklist**
152
+ - [ ] Follows all Sun Lint coding rules (C005, C006, etc.)
153
+ - [ ] Rule C035: Error handling includes complete logging
154
+ - [ ] Rule C037: API responses use standard format
155
+ - [ ] Rule C040: Validation logic is centralized
156
+ - [ ] Tests pass and cover edge cases
157
+ - [ ] Documentation updated
158
+
159
+ 2. **Submit Pull Request**
160
+ - Clear title and description
161
+ - Reference related issues
162
+ - Include test results
163
+ - Follow template
164
+
165
+ 3. **Review Criteria**
166
+ - Code quality (follows our own rules!)
167
+ - Test coverage
168
+ - Documentation completeness
169
+ - Performance impact
170
+ - Backward compatibility
171
+
172
+ ## 📝 **Documentation**
173
+
174
+ ### **Update Documentation**
175
+ When adding features:
176
+ - Update `README.md`
177
+ - Add rule documentation
178
+ - Update configuration examples
179
+ - Add usage examples
180
+
181
+ ### **Rule Documentation Template**
182
+ ```markdown
183
+ ## Rule C042: New Rule Name
184
+
185
+ **Category**: Quality
186
+ **Severity**: Error
187
+ **Languages**: TypeScript, Dart, Kotlin
188
+
189
+ ### Description
190
+ Following Rule C015 (domain language), use clear business terms...
191
+
192
+ ### Examples
193
+
194
+ **❌ Bad:**
195
+ ```typescript
196
+ // Code that violates the rule
197
+ ```
198
+
199
+ **✅ Good:**
200
+ ```typescript
201
+ // Code that follows the rule
202
+ ```
203
+ ```
204
+
205
+ ## 🐛 **Bug Reports**
206
+
207
+ When reporting bugs:
208
+ 1. Use clear, descriptive title
209
+ 2. Include reproduction steps
210
+ 3. Provide sample code
211
+ 4. Include environment details
212
+ 5. Include sunlint output
213
+
214
+ ## 💡 **Feature Requests**
215
+
216
+ For new features:
217
+ 1. Check existing issues first
218
+ 2. Describe the use case
219
+ 3. Provide examples
220
+ 4. Consider implementation complexity
221
+ 5. Think about backward compatibility
222
+
223
+ ## 🤝 **Community**
224
+
225
+ - **Discord**: [Sun Engineering Discord](https://discord.gg/sun-engineering)
226
+ - **Issues**: [GitHub Issues](https://github.com/sun-engineering/sunlint/issues)
227
+ - **Discussions**: [GitHub Discussions](https://github.com/sun-engineering/sunlint/discussions)
228
+
229
+ ## 📄 **License**
230
+
231
+ By contributing, you agree that your contributions will be licensed under the MIT License.
232
+
233
+ ---
234
+
235
+ **Thank you for making Sun Lint better! ☀️**
@@ -0,0 +1,60 @@
1
+ # SunLint Project Structure
2
+
3
+ ## 📁 **Organized Directory Structure**
4
+
5
+ ```
6
+ sunlint/
7
+ ├── 📄 README.md # Main documentation (490 lines, focused)
8
+ ├── 📄 CHANGELOG.md # Version history (concise)
9
+ ├── 🚀 cli.js # Main CLI entry point
10
+ ├── ⚙️ config/ # Configuration presets & schemas
11
+ ├── 🔧 core/ # Core services & engines
12
+ ├── 📖 docs/ # Detailed documentation
13
+ ├── 🔗 integrations/ # External tool integrations
14
+ │ └── eslint/ # ESLint plugin & configurations
15
+ ├── 📋 examples/ # Configuration examples & workflows
16
+ ├── 🧪 test/ # Test projects & fixtures
17
+ ├── 📦 release/ # Release artifacts
18
+ ├── 🎯 rules/ # SunLint rule implementations
19
+ └── 🛠️ scripts/ # Build & deployment scripts
20
+ ```
21
+
22
+ ## 🎯 **Key Changes Made**
23
+
24
+ ### ✅ **Files Removed**
25
+ - `CLI_STRUCTURE.md` - Temporary documentation (unnecessary)
26
+
27
+ ### ✅ **Structure Reorganized**
28
+ - **examples/** - Now pure configuration examples & CI/CD workflows
29
+ - **test/** - All test projects consolidated here
30
+ - `sunlint-test-project/` - ESLint v9 integration test
31
+ - `conflict-test-project/` - ESLint v8 legacy test
32
+ - `examples/integration-project/` - Integration example
33
+ - `fixtures/` - Unit test files
34
+ - **project-test/** - Real projects (gitignored, separate from test suite)
35
+
36
+ ### ✅ **Documentation Updated**
37
+ - **README.md** - Streamlined from 650 → 490 lines (25% reduction)
38
+ - **CHANGELOG.md** - Security rules section condensed
39
+ - **test/README.md** - Test project documentation
40
+ - **examples/README.md** - Configuration examples guide
41
+
42
+ ## 🎉 **Benefits**
43
+
44
+ 1. **Clear Separation**: Examples vs Tests vs Real Projects
45
+ 2. **Reduced Duplication**: Single source of truth for each purpose
46
+ 3. **Better Documentation**: Focused README + detailed CHANGELOG
47
+ 4. **Cleaner Repository**: No redundant files, proper gitignore
48
+ 5. **Developer Friendly**: Clear structure for contributors
49
+
50
+ ## 🔍 **Quick Navigation**
51
+
52
+ - **Getting Started**: `README.md`
53
+ - **Version History**: `CHANGELOG.md`
54
+ - **Configuration Help**: `examples/`
55
+ - **Testing**: `test/`
56
+ - **Development**: `docs/ARCHITECTURE.md`
57
+
58
+ ---
59
+
60
+ **Structure optimized for both users and contributors! 🚀**
package/README.md CHANGED
@@ -7,25 +7,32 @@
7
7
  Sun Lint is a universal coding standards checker providing comprehensive code quality and security analysis. Built by Sun* Engineering Team with integrated security rules from OWASP and industry best practices.
8
8
 
9
9
  ### **✨ Key Features**
10
- - ✅ **93+ Coding Rules**: Quality, security, and best practices
11
- - ✅ **ESLint Integration**: Merge with existing ESLint configurations
10
+ - ✅ **97+ Coding Rules**: Quality (30), Security (47), TypeScript-specific
11
+ - ✅ **Built-in AST Analysis**: JavaScript/TypeScript parsing out of the box
12
+ - ✅ **Multi-Engine Architecture**: Heuristic + ESLint + OpenAI integration
12
13
  - ✅ **Git Integration**: `--changed-files`, `--staged-files`, `--pr-mode`
13
- - ✅ **TypeScript Support**: Native TypeScript analysis engine
14
+ - ✅ **TypeScript Support**: Native TypeScript 5.8+ analysis
15
+ - ✅ **Zero Config**: Works immediately after `npm install`
14
16
  - ✅ **CI/CD Ready**: Baseline comparison, fail-on-new-violations
15
17
  - ✅ **Advanced File Targeting**: Include/exclude patterns, language filtering
16
18
 
17
19
  ### **🚀 Quick Start**
18
20
  ```bash
19
- # Install globally
21
+ # Install
20
22
  npm install -g @sun-asterisk/sunlint
21
23
 
22
- # Basic usage
24
+ # Basic usage - works immediately!
25
+ sunlint --all
26
+ sunlint --rules=C019,C006
27
+
28
+ # With input specification
23
29
  sunlint --all --input=src
24
30
  sunlint --rules=C019,C006 --input=src
25
31
  sunlint --quality --input=src
32
+ sunlint --security --input=src
26
33
 
27
- # ESLint integration
28
- sunlint --all --eslint-integration --input=src
34
+ # ESLint integration (requires eslint dependency)
35
+ sunlint --rules=C010,C006 --eslint-integration --input=src
29
36
 
30
37
  # Git integration
31
38
  sunlint --all --changed-files
@@ -42,12 +49,66 @@ sunlint --version
42
49
  ### **Project Installation**
43
50
  ```bash
44
51
  npm install --save-dev @sun-asterisk/sunlint
52
+ ```
53
+
54
+ **✅ Works immediately** with JavaScript analysis using built-in AST parsers (`@babel/parser`, `espree`)
55
+
56
+ ### **Enhanced TypeScript Support**
57
+ For advanced TypeScript analysis with ESLint integration:
58
+
59
+ ```bash
60
+ npm install --save-dev @sun-asterisk/sunlint eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript
61
+ ```
62
+
63
+ ### **What's Included by Default**
64
+ - ✅ **JavaScript Analysis**: High-accuracy AST analysis out of the box
65
+ - ✅ **Basic TypeScript**: Works with built-in Babel parser
66
+ - ✅ **97+ Rules**: All quality and security rules available
67
+ - ✅ **Heuristic Engine**: Pattern-based analysis for all languages
68
+
69
+ ### **Optional Dependencies (Install as needed)**
70
+ ```bash
71
+ # For ESLint engine integration
72
+ npm install eslint --save-dev
73
+
74
+ # For enhanced TypeScript analysis
75
+ npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev
76
+
77
+ # For TypeScript compiler integration
78
+ npm install typescript --save-dev
79
+ ```
80
+
81
+ **Quick setup for TypeScript projects:**
82
+ ```bash
83
+ npm install --save-dev @sun-asterisk/sunlint eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript
84
+ ```
85
+
86
+ > 💡 **Note**: SunLint gracefully handles missing dependencies. Install only what your project needs. See [docs/DEPENDENCIES.md](docs/DEPENDENCIES.md) for detailed guidance.
45
87
 
46
88
  # Package.json scripts
89
+ ```json
47
90
  {
48
91
  "scripts": {
49
92
  "lint": "sunlint --all --input=src",
50
- "lint:changed": "sunlint --all --changed-files"
93
+ "lint:changed": "sunlint --all --changed-files",
94
+ "lint:typescript": "sunlint --all --input=src",
95
+ "lint:eslint-integration": "sunlint --all --eslint-integration --input=src"
96
+ },
97
+ "devDependencies": {
98
+ "@sun-asterisk/sunlint": "^1.2.0"
99
+ }
100
+ }
101
+ ```
102
+
103
+ **For TypeScript projects, add:**
104
+ ```json
105
+ {
106
+ "devDependencies": {
107
+ "@sun-asterisk/sunlint": "^1.2.0",
108
+ "eslint": "^8.50.0",
109
+ "@typescript-eslint/parser": "^7.2.0",
110
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
111
+ "typescript": "^5.0.0"
51
112
  }
52
113
  }
53
114
  ```
@@ -57,14 +118,25 @@ npm install --save-dev @sun-asterisk/sunlint
57
118
  Seamlessly integrate with existing ESLint configurations:
58
119
 
59
120
  ```bash
60
- # Analyze with both SunLint + existing ESLint rules
121
+ # Analyze with both SunLint + existing ESLint rules
61
122
  sunlint --all --eslint-integration --input=src
123
+
124
+ # Mix ESLint and heuristic engines based on rule compatibility
125
+ sunlint --rules=C010,C006 --eslint-integration --input=src
62
126
  ```
63
127
 
64
- Benefits:
128
+ **✅ Current Status:**
129
+ - ✅ **Multi-engine orchestration**: Rules automatically routed to optimal engine
130
+ - ✅ **ESLint v8/v9 compatibility**: Production-ready with both major versions
131
+ - ✅ **TypeScript support**: Full TS/TSX parsing with custom rule implementation
132
+ - ✅ **Custom rule integration**: 27+ SunLint custom rules via ESLint engine
133
+ - ✅ **Smart fallback**: Automatic engine fallback for maximum rule coverage
134
+ - ✅ **Production tested**: Successfully processes real projects with mixed violations
135
+
136
+ **Benefits:**
65
137
  - ✅ **No workflow disruption**: Existing ESLint continues working
66
- - ✅ **Single command**: Execute 93 SunLint + your existing ESLint rules
67
- - ✅ **Combined reporting**: Unified violation tracking
138
+ - ✅ **Engine flexibility**: Automatic best-engine selection per rule
139
+ - ✅ **Combined reporting**: Unified violation tracking from multiple engines
68
140
 
69
141
  ## 🔀 **Git Integration**
70
142
 
@@ -107,69 +179,59 @@ sunlint --all --only-source --input=src
107
179
 
108
180
  ## 📋 **Available Rules**
109
181
 
110
- ### **Quality Rules** ✨ (9 rules)
182
+ ### **Quality Rules** ✨ (30 rules)
111
183
  | Rule ID | Name | Status |
112
184
  |---------|------|--------|
113
- | **C005** | Single Responsibility | ✅ Stable |
114
- | **C006** | Function Naming | ✅ Stable |
115
- | **C007** | Comment Quality | ✅ Stable |
116
- | **C012** | Command Query Separation | ✅ Stable |
185
+ | **C002** | No Duplicate Code | ✅ Stable |
186
+ | **C003** | No Vague Abbreviations | ✅ Stable |
187
+ | **C006** | Function Naming Convention | ✅ Stable |
188
+ | **C010** | Limit Block Nesting | ✅ Stable |
189
+ | **C013** | No Dead Code | ✅ Stable |
117
190
  | **C014** | Dependency Injection | ✅ Stable |
118
- | **C015** | Domain Language | ✅ Stable |
191
+ | **C017** | Limit Constructor Logic | ✅ Stable |
192
+ | **C018** | No Generic Throw | ✅ Stable |
119
193
  | **C019** | Log Level Usage | ✅ Stable |
194
+ | **C023** | No Duplicate Variable Names | ✅ Stable |
195
+ | **C029** | Catch Block Logging | ✅ Stable |
196
+ | **C030** | Use Custom Error Classes | ✅ Stable |
120
197
  | **C031** | Validation Separation | ✅ Stable |
121
- | **C037** | API Response Format | ✅ Stable |
122
-
123
- ### **Security Rules** 🔒 (43 rules)
198
+ | **C041** | No Hardcoded Config | ✅ Stable |
199
+ | **C042** | Boolean Name Prefix | ✅ Stable |
200
+ | **C043** | No Console or Print | ✅ Stable |
201
+ | **C047** | No Duplicate Retry Logic | ✅ Stable |
202
+ | **C075** | Explicit Function Return Types | ✅ Stable |
203
+ | **C076** | Single Test Behavior | ✅ Stable |
204
+ | **T002-T021** | TypeScript-specific rules | ✅ Stable |
205
+
206
+ ### **Security Rules** 🔒 (47 rules)
124
207
  | Rule ID | Name | Status |
125
208
  |---------|------|--------|
126
209
  | **S001** | Fail Securely Access Control | ✅ Stable |
127
210
  | **S002** | Prevent IDOR Vulnerabilities | ✅ Stable |
211
+ | **S003** | URL Redirect Validation | ✅ Stable |
128
212
  | **S005** | No Origin Header Authentication | ✅ Stable |
213
+ | **S006** | Activation Recovery Not Plaintext | ✅ Stable |
129
214
  | **S007** | Secure OTP Storage | ✅ Stable |
130
215
  | **S008** | Crypto Agility | ✅ Stable |
216
+ | **S009** | No Insecure Crypto | ✅ Stable |
217
+ | **S010** | Secure Random Generation | ✅ Stable |
218
+ | **S011** | Secure UUID Generation | ✅ Stable |
131
219
  | **S012** | No Hardcoded Secrets | ✅ Stable |
132
220
  | **S013** | Always Use TLS | ✅ Stable |
133
- | **S014-S058** | *...36 additional security rules* | ✅ Stable |
221
+ | **S014** | Secure TLS Version | ✅ Stable |
222
+ | **S015** | Valid TLS Certificate | ✅ Stable |
223
+ | **S016-S058** | *...Additional security rules* | ✅ Stable |
134
224
 
135
225
  ## ⚙️ **Configuration**
136
226
 
137
227
  Create `.sunlint.json` in your project root:
138
228
 
139
- > **🚨 BREAKING CHANGE**: `ignorePatterns` has been deprecated. Please use `exclude` instead for better consistency.
140
-
141
- ### **Basic Configuration**
142
- ```json
143
- {
144
- "extends": "@sun/sunlint/recommended",
145
- "rules": {
146
- "C019": "error",
147
- "C006": "warn",
148
- "S005": "error"
149
- }
150
- }
151
- ```
152
-
153
- ### **Advanced Configuration**
229
+ ### **Quick Start Configuration**
154
230
  ```json
155
231
  {
156
232
  "extends": "@sun/sunlint/recommended",
157
-
158
- "include": ["src/**", "lib/**"],
233
+ "input": ["src"],
159
234
  "exclude": ["**/*.test.*", "**/*.generated.*"],
160
-
161
- "languages": {
162
- "typescript": {
163
- "include": ["**/*.ts", "**/*.tsx"],
164
- "exclude": ["**/*.d.ts"]
165
- }
166
- },
167
-
168
- "testPatterns": {
169
- "include": ["**/*.test.*", "**/*.spec.*"],
170
- "rules": { "C006": "off" }
171
- },
172
-
173
235
  "rules": {
174
236
  "C019": "error",
175
237
  "C006": "warn",
@@ -178,27 +240,52 @@ Create `.sunlint.json` in your project root:
178
240
  }
179
241
  ```
180
242
 
181
- ### **Preset Configurations**
243
+ ### **Available Presets**
182
244
  - `@sun/sunlint/recommended` - Balanced rules for all projects
183
- - `@sun/sunlint/security` - Security-focused rules only
245
+ - `@sun/sunlint/security` - Security-focused rules only
184
246
  - `@sun/sunlint/quality` - Quality-focused rules only
185
247
  - `@sun/sunlint/beginner` - Gentle introduction for new teams
186
248
  - `@sun/sunlint/ci` - Optimized for CI/CD environments
187
249
 
250
+ ### **Full Configuration Reference**
251
+ 📖 **[View Complete Configuration Guide](./docs/CONFIGURATION.md)**
252
+
253
+ Complete reference with all available options:
254
+ - File targeting (`include`, `exclude`, `languages`)
255
+ - Rule configurations with detailed descriptions
256
+ - Git integration settings (`changedFiles`, `baseline`)
257
+ - ESLint integration options
258
+ - Performance and caching settings
259
+ - CI/CD optimizations
260
+
261
+ > **🚨 MIGRATION NOTE**: `ignorePatterns` is deprecated. Use `exclude` instead. Run `npx sunlint migrate-config` to auto-migrate.
262
+
188
263
  ## 🎮 **Usage Examples**
189
264
 
190
265
  ### **Development**
191
266
  ```bash
192
- # Run all rules
193
- sunlint --all --input=src
267
+ # Quick start - works immediately
268
+ npm install --save-dev @sun-asterisk/sunlint
269
+ npx sunlint --all --input=src
194
270
 
195
271
  # Check specific rules
196
272
  sunlint --rules=C019,S005 --input=src
197
273
 
198
- # ESLint + Git integration
274
+ # ESLint integration (requires eslint dependency)
275
+ npm install --save-dev eslint
199
276
  sunlint --all --eslint-integration --changed-files
200
277
  ```
201
278
 
279
+ ### **TypeScript Projects**
280
+ ```bash
281
+ # Enhanced TypeScript setup
282
+ npm install --save-dev @sun-asterisk/sunlint eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript
283
+
284
+ # Full TypeScript analysis
285
+ sunlint --all --input=src
286
+ sunlint --all --eslint-integration --input=src
287
+ ```
288
+
202
289
  ### **CI/CD**
203
290
  ```bash
204
291
  # Full project scan
@@ -207,12 +294,13 @@ sunlint --all --input=. --format=json --output=report.json
207
294
  # PR validation
208
295
  sunlint --all --changed-files --fail-on-new-violations
209
296
 
210
- # Pre-commit hook
297
+ # Pre-commit hook
211
298
  sunlint --all --staged-files --format=summary
212
299
  ```
213
300
 
214
301
  ## 📚 **Documentation**
215
302
 
303
+ - **[Configuration Guide](./docs/CONFIGURATION.md)** - Complete config options with examples
216
304
  - [ESLint Integration Guide](./docs/ESLINT_INTEGRATION.md)
217
305
  - [CI/CD Guide](./docs/CI-CD-GUIDE.md)
218
306
  - [Architecture](./docs/ARCHITECTURE.md)
package/cli.js CHANGED
@@ -16,6 +16,7 @@ const program = createCliProgram();
16
16
 
17
17
  // Set up main action handler
18
18
  program.action(async (options) => {
19
+ // Always use modern architecture (legacy removed)
19
20
  const actionHandler = new CliActionHandler(options);
20
21
  await actionHandler.execute();
21
22
  });