@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
package/README.md CHANGED
@@ -33,7 +33,7 @@ SunLint uses a unified adapter pattern ensuring consistency between CLI and VSCo
33
33
  │ • Origin Rules (markdown) │
34
34
  │ • Heuristic Engine (244 rules) │
35
35
  │ • ESLint Engine (17 rules) │
36
- │ • AI Engine (256 rules)
36
+ │ • OpenAI Engine (256 rules)
37
37
  └───────────────────────────────────┘
38
38
  ```
39
39
 
@@ -166,13 +166,13 @@ sunlint --show-engines --rules=C010,R001,S005
166
166
  # Use specific engine
167
167
  sunlint --engine=heuristic --rules=C010,C020 --input=src
168
168
  sunlint --engine=eslint --rules=R001,R006 --input=src
169
- sunlint --engine=ai --rules=C010,S001 --input=src
169
+ sunlint --engine=openai --rules=C010,S001 --input=src
170
170
  ```
171
171
 
172
172
  **Engine Stats:**
173
173
  - **Heuristic Engine**: 244/256 rules (95.3%) - Fast, universal
174
174
  - **ESLint Engine**: 17/256 rules (6.6%) - JavaScript/TypeScript focused
175
- - **AI Engine**: 256/256 rules (100%) - Context-aware analysis
175
+ - **OpenAI Engine**: 256/256 rules (100%) - Context-aware analysis
176
176
 
177
177
  ### **ESLint Integration**
178
178
  Seamlessly integrate with existing ESLint configurations:
@@ -261,7 +261,6 @@ sunlint --all --only-source --input=src
261
261
  | **C043** | No Console or Print | ✅ Stable |
262
262
  | **C047** | No Duplicate Retry Logic | ✅ Stable |
263
263
  | **C075** | Explicit Function Return Types | ✅ Stable |
264
- | **C076** | Single Test Behavior | ✅ Stable |
265
264
  | **T002-T021** | TypeScript-specific rules | ✅ Stable |
266
265
 
267
266
  ### **Security Rules** 🔒 (47 rules)
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "CI/CD Optimized Configuration",
3
+ "description": "Fast analysis for CI/CD pipelines",
4
+
5
+ "performance": {
6
+ "maxSemanticFiles": 300,
7
+ "maxConcurrentRules": 3,
8
+ "timeoutMs": 30000
9
+ },
10
+
11
+ "input": ["."],
12
+
13
+ "include": [
14
+ "src/**/*.ts",
15
+ "src/**/*.js"
16
+ ],
17
+
18
+ "exclude": [
19
+ "**/*.test.*",
20
+ "**/*.d.ts",
21
+ "node_modules/**",
22
+ "dist/**",
23
+ "build/**"
24
+ ],
25
+
26
+ "rules": {
27
+ "categories": {
28
+ "security": true,
29
+ "quality": true,
30
+ "logging": false
31
+ }
32
+ },
33
+
34
+ "output": {
35
+ "format": "github",
36
+ "console": true,
37
+ "summary": false
38
+ },
39
+
40
+ "engines": {
41
+ "semantic": {
42
+ "enabled": true,
43
+ "fileLimit": 300
44
+ },
45
+ "ai": {
46
+ "enabled": false
47
+ }
48
+ },
49
+
50
+ "reporting": {
51
+ "exitOnError": true,
52
+ "showProgress": false
53
+ }
54
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "Development Configuration",
3
+ "description": "Fast feedback for daily development",
4
+
5
+ "performance": {
6
+ "maxSemanticFiles": 500,
7
+ "maxConcurrentRules": 4,
8
+ "timeoutMs": 15000
9
+ },
10
+
11
+ "input": ["."],
12
+
13
+ "include": [
14
+ "src/**/*.ts",
15
+ "src/**/*.js",
16
+ "lib/**/*.ts"
17
+ ],
18
+
19
+ "exclude": [
20
+ "**/*.test.*",
21
+ "**/*.spec.*",
22
+ "**/*.d.ts",
23
+ "node_modules/**",
24
+ "dist/**"
25
+ ],
26
+
27
+ "rules": {
28
+ "C006": "error",
29
+ "C019": "error",
30
+ "C029": "error",
31
+ "S001": "error",
32
+ "S005": "error"
33
+ },
34
+
35
+ "output": {
36
+ "format": "summary",
37
+ "console": true,
38
+ "summary": true,
39
+ "verbose": false
40
+ },
41
+
42
+ "engines": {
43
+ "semantic": {
44
+ "enabled": true,
45
+ "fileLimit": 500
46
+ },
47
+ "ai": {
48
+ "enabled": false
49
+ }
50
+ },
51
+
52
+ "git": {
53
+ "changedFiles": true,
54
+ "diffBase": "origin/main"
55
+ }
56
+ }
@@ -0,0 +1,143 @@
1
+ {
2
+ "$schema": "./sunlint-schema.json",
3
+ "name": "Large Project Configuration",
4
+ "description": "Optimized configuration for projects with 1000+ files",
5
+
6
+ "performance": {
7
+ "maxSemanticFiles": 1000,
8
+ "maxConcurrentRules": 5,
9
+ "timeoutMs": 60000,
10
+ "cacheEnabled": true,
11
+ "cacheLocation": ".sunlint-cache/"
12
+ },
13
+
14
+ "input": [
15
+ "src",
16
+ "lib",
17
+ "app",
18
+ "packages"
19
+ ],
20
+
21
+ "include": [
22
+ "src/**/*.ts",
23
+ "src/**/*.js",
24
+ "lib/**/*.ts",
25
+ "app/**/*.ts",
26
+ "packages/*/src/**/*.ts"
27
+ ],
28
+
29
+ "exclude": [
30
+ "node_modules/**",
31
+ "dist/**",
32
+ "build/**",
33
+ "coverage/**",
34
+ "**/*.test.*",
35
+ "**/*.spec.*",
36
+ "**/*.d.ts",
37
+ "**/*.generated.*",
38
+ "**/generated/**",
39
+ "**/*.min.*",
40
+ "**/*.bundle.*"
41
+ ],
42
+
43
+ "rules": {
44
+ "enabled": [
45
+ "C006", "C019", "C029", "C047",
46
+ "S001", "S005", "S010"
47
+ ],
48
+ "categories": {
49
+ "quality": true,
50
+ "security": true,
51
+ "performance": false,
52
+ "logging": true
53
+ }
54
+ },
55
+
56
+ "output": {
57
+ "format": "summary",
58
+ "console": true,
59
+ "summary": true,
60
+ "includeContext": true,
61
+ "showFixSuggestions": true,
62
+ "groupByFile": true,
63
+ "sortBy": "severity"
64
+ },
65
+
66
+ "engines": {
67
+ "semantic": {
68
+ "enabled": true,
69
+ "fileLimit": 1000,
70
+ "enableCaching": true,
71
+ "crossFileAnalysis": true
72
+ },
73
+ "heuristic": {
74
+ "enabled": true,
75
+ "fastMode": false
76
+ },
77
+ "ai": {
78
+ "enabled": false,
79
+ "fallbackToPattern": true
80
+ }
81
+ },
82
+
83
+ "ci": {
84
+ "changedFiles": {
85
+ "maxSemanticFiles": 300,
86
+ "format": "github",
87
+ "failOnError": true
88
+ },
89
+ "fullScan": {
90
+ "maxSemanticFiles": 1000,
91
+ "format": "json",
92
+ "output": "sunlint-report.json"
93
+ },
94
+ "nightly": {
95
+ "maxSemanticFiles": 2000,
96
+ "format": "detailed",
97
+ "output": "nightly-report.json"
98
+ }
99
+ },
100
+
101
+ "overrides": [
102
+ {
103
+ "files": ["src/critical/**/*.ts"],
104
+ "performance": {
105
+ "maxSemanticFiles": 2000
106
+ },
107
+ "rules": {
108
+ "enabled": "all"
109
+ }
110
+ },
111
+ {
112
+ "files": ["**/*.test.*", "**/*.spec.*"],
113
+ "performance": {
114
+ "maxSemanticFiles": 500
115
+ },
116
+ "rules": {
117
+ "categories": {
118
+ "testing": true,
119
+ "security": false
120
+ }
121
+ }
122
+ },
123
+ {
124
+ "files": ["packages/*/src/**"],
125
+ "performance": {
126
+ "maxSemanticFiles": 1500
127
+ }
128
+ }
129
+ ],
130
+
131
+ "reporting": {
132
+ "baseline": {
133
+ "enabled": true,
134
+ "file": "baseline.json",
135
+ "updateOnClean": true
136
+ },
137
+ "trends": {
138
+ "enabled": true,
139
+ "historyFile": "trends.json",
140
+ "trackMetrics": ["violations", "files", "performance"]
141
+ }
142
+ }
143
+ }
@@ -32,7 +32,6 @@
32
32
  "C072": "warn",
33
33
  "C073": "warn",
34
34
  "C075": "warn",
35
- "C076": "warn",
36
35
  "S001": "error",
37
36
  "S002": "error",
38
37
  "S003": "warn",
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "Release Validation Configuration",
3
+ "description": "Comprehensive analysis for release validation",
4
+
5
+ "performance": {
6
+ "maxSemanticFiles": -1,
7
+ "maxConcurrentRules": 8,
8
+ "timeoutMs": 300000
9
+ },
10
+
11
+ "input": ["."],
12
+
13
+ "include": [
14
+ "src/**/*.ts",
15
+ "src/**/*.js",
16
+ "lib/**/*.ts",
17
+ "app/**/*.ts",
18
+ "packages/*/src/**/*.ts"
19
+ ],
20
+
21
+ "exclude": [
22
+ "node_modules/**",
23
+ "dist/**",
24
+ "build/**",
25
+ "coverage/**",
26
+ "**/*.min.*",
27
+ "**/*.bundle.*"
28
+ ],
29
+
30
+ "rules": {
31
+ "enabled": "all"
32
+ },
33
+
34
+ "output": {
35
+ "format": "detailed",
36
+ "console": true,
37
+ "summary": true,
38
+ "includeContext": true,
39
+ "showFixSuggestions": true,
40
+ "output": "release-validation-report.json"
41
+ },
42
+
43
+ "engines": {
44
+ "semantic": {
45
+ "enabled": true,
46
+ "fileLimit": -1,
47
+ "enableCaching": true,
48
+ "crossFileAnalysis": true
49
+ },
50
+ "ai": {
51
+ "enabled": true,
52
+ "provider": "openai",
53
+ "model": "gpt-4o-mini"
54
+ }
55
+ },
56
+
57
+ "reporting": {
58
+ "baseline": {
59
+ "enabled": true,
60
+ "file": "release-baseline.json",
61
+ "compareWithPrevious": true
62
+ },
63
+ "trends": {
64
+ "enabled": true,
65
+ "historyFile": "release-trends.json"
66
+ },
67
+ "failOnNewViolations": true,
68
+ "exitOnError": true
69
+ }
70
+ }
@@ -6,6 +6,11 @@
6
6
  module.exports = {
7
7
  // Rules that benefit significantly from AST analysis
8
8
  astPreferred: {
9
+ 'C003': {
10
+ reason: 'Variable naming requires context awareness (types, scopes, conventions)',
11
+ methods: ['ast', 'regex'],
12
+ accuracy: { ast: 95, regex: 75 }
13
+ },
9
14
  'C010': {
10
15
  reason: 'Block nesting requires precise scope tracking',
11
16
  methods: ['ast', 'regex'],
@@ -22,9 +27,10 @@ module.exports = {
22
27
  accuracy: { ast: 95, regex: 85 }
23
28
  },
24
29
  'C017': {
25
- reason: 'Constructor logic analysis needs AST context',
26
- methods: ['ast', 'regex'],
27
- accuracy: { ast: 90, regex: 70 }
30
+ reason: 'Constructor logic analysis needs semantic context - Phase 2 with symbol-based analysis',
31
+ methods: ['semantic', 'ast', 'regex'],
32
+ accuracy: { semantic: 95, ast: 85, regex: 70 },
33
+ strategy: 'semantic-primary'
28
34
  },
29
35
  'S015': {
30
36
  reason: 'TLS certificate validation requires AST context analysis',
@@ -45,6 +51,11 @@ module.exports = {
45
51
  methods: ['regex'],
46
52
  accuracy: { regex: 95 }
47
53
  },
54
+ 'C002': {
55
+ reason: 'Duplicate code detection requires cross-file analysis',
56
+ methods: ['regex'],
57
+ accuracy: { regex: 85 }
58
+ },
48
59
  'C043': {
49
60
  reason: 'Console/print detection via simple patterns',
50
61
  methods: ['regex'],
@@ -59,12 +70,36 @@ module.exports = {
59
70
 
60
71
  // Rules that require hybrid approach
61
72
  hybridOptimal: {
73
+ 'C018': {
74
+ reason: 'Do not throw generic errors',
75
+ methods: ['semantic', 'regex'],
76
+ strategy: 'semantic-primary-regex-fallback',
77
+ accuracy: { semantic: 90, regex: 70, combined: 95 }
78
+ },
62
79
  'C029': {
63
80
  reason: 'Catch block analysis needs context + patterns',
64
81
  methods: ['ast', 'regex', 'semantic'],
65
82
  strategy: 'ast-primary-regex-fallback',
66
83
  accuracy: { ast: 90, regex: 75, combined: 95 }
67
84
  },
85
+ 'C035': {
86
+ reason: 'Error logging context requires symbol-based + regex analysis',
87
+ methods: ['semantic', 'regex'],
88
+ strategy: 'semantic-primary-regex-fallback',
89
+ accuracy: { semantic: 90, regex: 70, combined: 95 }
90
+ },
91
+ 'C040': {
92
+ reason: 'Validation centralization requires project-wide symbol analysis + data flow tracking',
93
+ methods: ['semantic', 'regex'],
94
+ strategy: 'semantic-primary-regex-fallback',
95
+ accuracy: { semantic: 95, regex: 75, combined: 97 }
96
+ },
97
+ 'C076': {
98
+ reason: 'Public API type enforcement requires symbol-based analysis for export boundaries',
99
+ methods: ['semantic'],
100
+ strategy: 'semantic-primary',
101
+ accuracy: { semantic: 95 }
102
+ },
68
103
  'C041': {
69
104
  reason: 'Hardcoded secrets need AST literal analysis like ESLint',
70
105
  methods: ['ast', 'regex'],