loadwise 0.5.1 → 0.6.0

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 (131) hide show
  1. package/README.md +542 -627
  2. package/bin/loadwise.js +4 -0
  3. package/lib/accessibility/frontend-detect.js +2 -1
  4. package/lib/accessibility/rule-ids.js +12 -9
  5. package/{editor/accessibility-examples.cjs → lib/editor/accessibility-examples.js} +20 -21
  6. package/lib/editor/actions.js +117 -0
  7. package/{editor/apply-fix.cjs → lib/editor/apply-fix.js} +1 -6
  8. package/{editor/control-flow-comparison.cjs → lib/editor/control-flow-comparison.js} +1 -3
  9. package/lib/editor/diagnostics.js +365 -0
  10. package/lib/editor/dismissals.js +111 -0
  11. package/lib/editor/editor-document.js +99 -0
  12. package/{editor/finding-comparison.cjs → lib/editor/finding-comparison.js} +4 -7
  13. package/lib/editor/fix-edits.js +200 -0
  14. package/lib/editor/language-server.js +437 -0
  15. package/{editor/maintainability-examples.cjs → lib/editor/maintainability-examples.js} +1 -3
  16. package/{editor/perf-site-comparison.cjs → lib/editor/perf-site-comparison.js} +1 -3
  17. package/lib/editor/perf-watch.js +78 -0
  18. package/{editor/performance-examples.cjs → lib/editor/performance-examples.js} +129 -128
  19. package/{editor/reliability-examples.cjs → lib/editor/reliability-examples.js} +100 -41
  20. package/lib/editor/scan-session.js +334 -0
  21. package/{editor/security-examples.cjs → lib/editor/security-examples.js} +28 -32
  22. package/lib/editor/server-commands.js +232 -0
  23. package/{editor/source-example.cjs → lib/editor/source-example.js} +3 -5
  24. package/{editor/standalone-performance-examples.cjs → lib/editor/standalone-performance-examples.js} +349 -333
  25. package/lib/editor/types/dismissal.js +1 -0
  26. package/lib/editor/types/fix-example.js +1 -0
  27. package/lib/editor/types/source-document.js +1 -0
  28. package/lib/editor/workspace-files.js +78 -0
  29. package/lib/editor/workspace-paths.js +22 -0
  30. package/lib/maintainability/analyze-source.js +2 -0
  31. package/lib/maintainability/apply-fix.js +1 -1
  32. package/lib/maintainability/cli.js +1 -1
  33. package/lib/maintainability/examples.js +58 -41
  34. package/lib/maintainability/rule-ids.js +29 -14
  35. package/lib/maintainability/scan-changed.js +3 -0
  36. package/lib/maintainability/scan.js +13 -9
  37. package/lib/maintainability/tsconfig-strict.js +69 -0
  38. package/lib/maintainability/type-safety-hygiene.js +204 -0
  39. package/lib/performance/analyze.js +2 -0
  40. package/lib/performance/cli-arguments.js +0 -2
  41. package/lib/performance/cli-policy.js +17 -9
  42. package/lib/performance/cli-scan.js +10 -8
  43. package/lib/performance/cli.js +4 -23
  44. package/lib/performance/editor-signal.js +1 -1
  45. package/lib/performance/finding-text.js +3 -3
  46. package/lib/performance/fix-cli.js +1 -1
  47. package/lib/performance/frontend-perf.js +7 -0
  48. package/lib/performance/frontend-render-perf.js +200 -0
  49. package/lib/performance/llm-max-tokens.js +56 -0
  50. package/lib/performance/native.js +46 -26
  51. package/lib/performance/polyglot.js +22 -1
  52. package/lib/performance/pooling.js +38 -23
  53. package/lib/performance/projects.js +42 -21
  54. package/lib/performance/rule-ids.js +236 -222
  55. package/lib/performance/site-fixes/database.js +3 -1
  56. package/lib/performance/site-fixes/integrity.js +15 -1
  57. package/lib/performance/source-inputs.js +18 -6
  58. package/lib/performance/unscanned-javascript.js +66 -19
  59. package/lib/reliability/analyze.js +12 -0
  60. package/lib/reliability/child-process.js +106 -0
  61. package/lib/reliability/error-values.js +177 -0
  62. package/lib/reliability/pool-timeout.js +79 -0
  63. package/lib/reliability/react-bugs.js +602 -0
  64. package/lib/reliability/resource-leaks.js +3 -6
  65. package/lib/reliability/rule-ids.js +169 -127
  66. package/lib/reliability/switch-exhaustive.js +284 -0
  67. package/lib/reliability/uncaught-exception.js +223 -0
  68. package/lib/security/auth-crypto/rule-ids.js +3 -2
  69. package/lib/security/cli.js +6 -5
  70. package/lib/security/deps/rule-ids.js +1 -0
  71. package/lib/security/examples/auth-crypto.cjs +5 -4
  72. package/lib/security/examples/deps.cjs +1 -0
  73. package/lib/security/examples/exposure.cjs +55 -42
  74. package/lib/security/examples/files.cjs +1 -0
  75. package/lib/security/examples/injection.cjs +1 -0
  76. package/lib/security/examples/moved.cjs +5 -4
  77. package/lib/security/examples/request-forgery.cjs +1 -0
  78. package/lib/security/exposure/client-env.js +113 -0
  79. package/lib/security/exposure/frontend-security.js +12 -10
  80. package/lib/security/exposure/index.js +14 -3
  81. package/lib/security/exposure/jsx-url.js +267 -0
  82. package/lib/security/exposure/next-image-config.js +34 -0
  83. package/lib/security/exposure/package-manifest.js +45 -0
  84. package/lib/security/exposure/react-version.js +45 -0
  85. package/lib/security/exposure/rule-ids.js +16 -12
  86. package/lib/security/files/index.js +1 -1
  87. package/lib/security/files/rule-ids.js +1 -0
  88. package/lib/security/injection/code.js +24 -10
  89. package/lib/security/injection/command.js +81 -28
  90. package/lib/security/injection/nosql.js +109 -22
  91. package/lib/security/injection/redos.js +152 -308
  92. package/lib/security/injection/regex-pattern.js +290 -0
  93. package/lib/security/injection/regex.js +30 -11
  94. package/lib/security/injection/rule-ids.js +2 -1
  95. package/lib/security/injection/shared.js +19 -1
  96. package/lib/security/injection/sql.js +83 -2
  97. package/lib/security/request-forgery/rule-ids.js +1 -0
  98. package/lib/security/rule-descriptions.js +36 -32
  99. package/lib/security/rule-ids.js +74 -67
  100. package/lib/security/taint/filename-guard.js +3 -1
  101. package/lib/security/taint/guards.js +84 -10
  102. package/lib/security/taint/index.js +124 -13
  103. package/lib/security/taint/propagate.js +10 -7
  104. package/lib/security/taint/sanitizers.js +7 -3
  105. package/lib/security/taint/sources.js +6 -3
  106. package/lib/security/taint/summaries.js +13 -1
  107. package/lib/security/taint/url-parts.js +14 -5
  108. package/lib/shared/agent-session.js +2 -2
  109. package/lib/shared/check.js +9 -6
  110. package/lib/shared/explain.js +5 -5
  111. package/lib/shared/fix-convergence.js +1 -1
  112. package/lib/shared/formats/finding-location.js +6 -2
  113. package/lib/shared/formats/sarif.js +3 -3
  114. package/lib/shared/heap-limit.js +6 -0
  115. package/lib/shared/pillars.js +7 -7
  116. package/lib/shared/rule-docs.js +12 -0
  117. package/lib/shared/scan-cache.js +0 -1
  118. package/lib/shared/workspaces.js +31 -9
  119. package/package.json +9 -16
  120. package/plugin/.claude-plugin/plugin.json +1 -1
  121. package/schema/loadwise.config.schema.json +44 -0
  122. package/editor/README.md +0 -47
  123. package/examples/redis-keys.otlp.json +0 -22
  124. package/lib/maintainability/notify-editor.js +0 -1
  125. package/lib/performance/editor-report.js +0 -191
  126. package/lib/performance/editor-setup.js +0 -189
  127. package/lib/performance/editor-watch-supervisor.js +0 -104
  128. package/lib/performance/editor-watch.js +0 -193
  129. package/lib/performance/notify-editor.js +0 -1
  130. package/lib/performance/recursive-watch.js +0 -181
  131. /package/lib/{performance/types/editor-report.js → editor/types/comparison.js} +0 -0
@@ -1,80 +1,96 @@
1
1
  // Rules about code that crashes, loses data or silently misbehaves at runtime: unhandled async failures, error
2
2
  // handling, races and integrity, external-call resilience, migration lock and outage risks, and breaking API changes.
3
3
  // The source rules are reported by the shared TypeScript pass; migrations and contracts by their own subcommands.
4
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
4
5
  const sourceRules = [
5
- 'pg-transaction-on-pool',
6
- 'prisma-transaction-client-escape',
7
- 'prisma-read-modify-write',
8
- 'prisma-dependent-writes',
6
+ 'assignment-in-condition',
7
+ 'async-callback-unhandled-rejection',
8
+ 'async-route-unhandled-rejection',
9
+ 'browser-not-closed',
10
+ 'check-then-update-race',
11
+ 'child-process-without-error-listener',
12
+ 'discarded-error-result',
9
13
  'drizzle-unfiltered-write',
14
+ 'drizzle-write-preflight',
15
+ 'error-logged-without-stack',
16
+ 'error-rethrown-without-cause',
17
+ 'file-handle-not-closed',
18
+ 'find-then-create-race',
19
+ 'floating-promise',
10
20
  'http-call-without-timeout',
11
- 'upload-without-size-limit',
21
+ 'interval-not-cleared',
22
+ 'invalid-typeof-comparison',
23
+ 'json-parse-unguarded',
24
+ 'loop-index-past-length',
12
25
  'mongoose-aggregate-uncast-id',
13
- 'typeorm-transaction-client-escape',
14
- 'redis-incr-then-expire',
15
- 'floating-promise',
16
- 'discarded-error-result',
26
+ 'nan-comparison',
27
+ 'next-server-env-in-client',
28
+ 'payment-missing-idempotency-key',
29
+ 'pg-transaction-on-pool',
30
+ 'pool-without-connection-timeout',
31
+ 'prisma-dependent-writes',
32
+ 'prisma-read-modify-write',
33
+ 'prisma-transaction-client-escape',
17
34
  'promise-return-escapes-catch',
35
+ 'query-runner-not-released',
36
+ 'react-async-effect-callback',
37
+ 'react-effect-sets-state-every-render',
38
+ 'react-list-missing-key',
39
+ 'react-state-mutated-in-place',
40
+ 'redis-incr-then-expire',
41
+ 'request-number-unvalidated',
42
+ 'retry-without-backoff',
18
43
  'return-in-finally',
19
44
  'return-newline',
20
- 'drizzle-write-preflight',
21
- 'find-then-create-race',
22
- 'retry-without-backoff',
23
- 'async-route-unhandled-rejection',
24
- 'async-callback-unhandled-rejection',
45
+ 'sql-insert-truncated-at-semicolon',
25
46
  'stream-pipe-unhandled-error',
26
- 'json-parse-unguarded',
27
- 'request-number-unvalidated',
28
- 'check-then-update-race',
29
- 'payment-missing-idempotency-key',
30
- 'webhook-missing-idempotency-check',
31
- 'unbounded-promise-all',
32
47
  'swallowed-error',
33
- 'sql-insert-truncated-at-semicolon',
48
+ 'switch-not-exhaustive',
49
+ 'throw-non-error',
50
+ 'typeorm-transaction-client-escape',
51
+ 'unbounded-promise-all',
52
+ 'uncaught-exception-continues',
34
53
  'unguarded-boundary-access',
35
- 'assignment-in-condition',
36
- 'nan-comparison',
37
- 'invalid-typeof-comparison',
38
54
  'unreachable-code',
39
- 'loop-index-past-length',
40
- 'file-handle-not-closed',
41
- 'query-runner-not-released',
42
- 'browser-not-closed',
43
- 'interval-not-cleared',
55
+ 'upload-without-size-limit',
56
+ 'webhook-missing-idempotency-check',
44
57
  ];
58
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
45
59
  const migrationRules = [
46
- 'migration-index-not-concurrent',
47
- 'migration-concurrent-in-transaction',
48
- 'migration-not-null-without-default',
49
- 'migration-volatile-default',
60
+ 'migration-breaking-drop',
61
+ 'migration-breaking-rename',
50
62
  'migration-column-type-rewrite',
51
- 'migration-set-not-null-scan',
63
+ 'migration-concurrent-in-transaction',
52
64
  'migration-constraint-not-valid',
53
65
  'migration-constraint-without-index',
54
- 'migration-breaking-drop',
55
- 'migration-breaking-rename',
66
+ 'migration-index-not-concurrent',
56
67
  'migration-missing-lock-timeout',
68
+ 'migration-mysql-lock-unspecified',
69
+ 'migration-mysql-table-copy',
70
+ 'migration-not-null-without-default',
71
+ 'migration-set-not-null-scan',
57
72
  'migration-table-rewrite-command',
58
73
  'migration-unparsed',
59
- 'migration-mysql-table-copy',
60
- 'migration-mysql-lock-unspecified',
74
+ 'migration-volatile-default',
61
75
  ];
76
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
62
77
  const contractRules = [
63
- 'api-removed-operation',
78
+ 'api-enum-value-removed',
64
79
  'api-removed-field',
80
+ 'api-removed-operation',
65
81
  'api-required-input',
66
82
  'api-type-changed',
67
- 'api-enum-value-removed',
68
83
  ];
69
84
  // Rules the ast-grep polyglot scan reports from polyglot/reliability.
85
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
70
86
  const polyglotRules = [
71
87
  'csharp-async-void',
72
88
  'csharp-disposable-without-using',
73
- 'python-bare-except',
74
- 'python-swallowed-exception',
75
- 'go-error-discarded',
76
89
  'go-defer-before-error-check',
90
+ 'go-error-discarded',
77
91
  'java-resource-without-try',
92
+ 'python-bare-except',
93
+ 'python-swallowed-exception',
78
94
  'rust-unwrap-in-production',
79
95
  ];
80
96
  // One --ignore list is shared by every command, so a CI script can pass the same flags to each of them.
@@ -82,92 +98,121 @@ const knownRules = new Set([...sourceRules, ...migrationRules, ...contractRules]
82
98
  // Impact levels (see lib/shared/impact-levels.ts) for every rule id a reliability finding can carry. README criteria:
83
99
  // critical is data loss, an outage or a lock risk in production; high a crash, lost failure or race that a normal
84
100
  // request can hit; medium a failure that needs an unusual input or condition; low a hygiene issue.
101
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
85
102
  const impactByRule = {
86
- 'pg-transaction-on-pool': 'critical',
87
- 'prisma-transaction-client-escape': 'critical',
88
- 'typeorm-transaction-client-escape': 'critical',
89
- 'prisma-read-modify-write': 'critical',
90
- 'drizzle-unfiltered-write': 'critical',
91
- 'migration-index-not-concurrent': 'critical',
92
- 'migration-breaking-drop': 'critical',
93
- 'migration-column-type-rewrite': 'critical',
94
- 'migration-table-rewrite-command': 'critical',
95
- 'migration-mysql-table-copy': 'critical',
103
+ 'api-enum-value-removed': 'high',
104
+ 'api-removed-field': 'high',
96
105
  'api-removed-operation': 'critical',
97
- 'prisma-dependent-writes': 'high',
98
- 'find-then-create-race': 'high',
99
- 'floating-promise': 'high',
106
+ 'api-required-input': 'high',
107
+ 'api-type-changed': 'high',
108
+ 'assignment-in-condition': 'high',
109
+ 'async-callback-unhandled-rejection': 'high',
110
+ 'async-route-unhandled-rejection': 'high',
111
+ 'browser-not-closed': 'high',
112
+ 'check-then-update-race': 'high',
113
+ 'child-process-without-error-listener': 'high',
114
+ 'csharp-async-void': 'high',
115
+ 'csharp-disposable-without-using': 'medium',
100
116
  'discarded-error-result': 'high',
101
- 'promise-return-escapes-catch': 'high',
102
- 'return-in-finally': 'high',
103
- 'return-newline': 'high',
117
+ 'drizzle-unfiltered-write': 'critical',
104
118
  'drizzle-write-preflight': 'medium',
119
+ 'error-logged-without-stack': 'low',
120
+ 'error-rethrown-without-cause': 'low',
121
+ 'file-handle-not-closed': 'high',
122
+ 'find-then-create-race': 'high',
123
+ 'floating-promise': 'high',
124
+ 'go-defer-before-error-check': 'high',
125
+ 'go-error-discarded': 'high',
105
126
  'http-call-without-timeout': 'high',
106
- 'upload-without-size-limit': 'high',
107
- 'mongoose-aggregate-uncast-id': 'high',
108
- 'check-then-update-race': 'high',
109
- 'payment-missing-idempotency-key': 'high',
110
- 'webhook-missing-idempotency-check': 'medium',
111
- 'redis-incr-then-expire': 'medium',
112
- 'retry-without-backoff': 'medium',
113
- 'async-route-unhandled-rejection': 'high',
114
- 'async-callback-unhandled-rejection': 'high',
115
- 'stream-pipe-unhandled-error': 'high',
127
+ 'interval-not-cleared': 'medium',
128
+ 'invalid-typeof-comparison': 'high',
129
+ 'java-resource-without-try': 'high',
116
130
  'json-parse-unguarded': 'medium',
117
- 'request-number-unvalidated': 'medium',
131
+ 'loop-index-past-length': 'high',
132
+ 'migration-breaking-drop': 'critical',
133
+ 'migration-breaking-rename': 'high',
134
+ 'migration-column-type-rewrite': 'critical',
118
135
  'migration-concurrent-in-transaction': 'high',
119
- 'migration-not-null-without-default': 'high',
120
- 'migration-volatile-default': 'high',
121
- 'migration-set-not-null-scan': 'high',
122
136
  'migration-constraint-not-valid': 'high',
123
137
  'migration-constraint-without-index': 'high',
124
- 'migration-breaking-rename': 'high',
138
+ 'migration-index-not-concurrent': 'critical',
125
139
  'migration-missing-lock-timeout': 'high',
126
140
  'migration-mysql-lock-unspecified': 'high',
127
- 'api-removed-field': 'high',
128
- 'api-required-input': 'high',
129
- 'api-type-changed': 'high',
130
- 'api-enum-value-removed': 'high',
141
+ 'migration-mysql-table-copy': 'critical',
142
+ 'migration-not-null-without-default': 'high',
143
+ 'migration-set-not-null-scan': 'high',
144
+ 'migration-table-rewrite-command': 'critical',
131
145
  'migration-unparsed': 'low',
132
- 'unbounded-promise-all': 'high',
133
- 'csharp-async-void': 'high',
134
- 'sql-insert-truncated-at-semicolon': 'high',
135
- 'swallowed-error': 'medium',
136
- 'unguarded-boundary-access': 'medium',
137
- 'assignment-in-condition': 'high',
146
+ 'migration-volatile-default': 'high',
147
+ 'mongoose-aggregate-uncast-id': 'high',
138
148
  'nan-comparison': 'high',
139
- 'invalid-typeof-comparison': 'high',
140
- 'unreachable-code': 'medium',
141
- 'loop-index-past-length': 'high',
142
- 'file-handle-not-closed': 'high',
143
- 'query-runner-not-released': 'critical',
144
- 'browser-not-closed': 'high',
145
- 'interval-not-cleared': 'medium',
146
- 'csharp-disposable-without-using': 'medium',
149
+ 'next-server-env-in-client': 'high',
150
+ 'payment-missing-idempotency-key': 'high',
151
+ 'pg-transaction-on-pool': 'critical',
152
+ 'pool-without-connection-timeout': 'medium',
153
+ 'prisma-dependent-writes': 'high',
154
+ 'prisma-read-modify-write': 'critical',
155
+ 'prisma-transaction-client-escape': 'critical',
156
+ 'promise-return-escapes-catch': 'high',
147
157
  'python-bare-except': 'medium',
148
158
  'python-swallowed-exception': 'medium',
149
- 'go-error-discarded': 'high',
150
- 'go-defer-before-error-check': 'high',
151
- 'java-resource-without-try': 'high',
159
+ 'query-runner-not-released': 'critical',
160
+ 'react-async-effect-callback': 'medium',
161
+ 'react-effect-sets-state-every-render': 'high',
162
+ 'react-list-missing-key': 'medium',
163
+ 'react-state-mutated-in-place': 'high',
164
+ 'redis-incr-then-expire': 'medium',
165
+ 'request-number-unvalidated': 'medium',
166
+ 'retry-without-backoff': 'medium',
167
+ 'return-in-finally': 'high',
168
+ 'return-newline': 'high',
152
169
  'rust-unwrap-in-production': 'medium',
170
+ 'sql-insert-truncated-at-semicolon': 'high',
171
+ 'stream-pipe-unhandled-error': 'high',
172
+ 'swallowed-error': 'medium',
173
+ 'switch-not-exhaustive': 'medium',
174
+ 'throw-non-error': 'medium',
175
+ 'typeorm-transaction-client-escape': 'critical',
176
+ 'unbounded-promise-all': 'high',
177
+ 'uncaught-exception-continues': 'high',
178
+ 'unguarded-boundary-access': 'medium',
179
+ 'unreachable-code': 'medium',
180
+ 'upload-without-size-limit': 'high',
181
+ 'webhook-missing-idempotency-check': 'medium',
153
182
  };
154
183
  // One-line summaries of every rule above, used where a rule needs a fixed name (SARIF shortDescription) rather than
155
184
  // the per-site finding message. The README row for each rule has the full evidence.
185
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
156
186
  const descriptionByRule = {
157
187
  'api-enum-value-removed': 'An enum value or string-literal option that clients could send was removed.',
158
188
  'api-removed-field': 'A response field, GraphQL type, field, argument or union member, or returned DTO property was removed.',
159
189
  'api-removed-operation': 'An OpenAPI operation or a GraphQL Query, Mutation or Subscription field was removed.',
160
190
  'api-required-input': 'A request field, parameter or GraphQL argument is new and required, or became required.',
161
191
  'api-type-changed': 'A field or parameter changed type, or a GraphQL type changed nullability in a breaking direction.',
192
+ 'assignment-in-condition': 'A condition assigns with = where a comparison was probably meant.',
193
+ 'async-callback-unhandled-rejection': 'An async callback given to an event emitter, timer or scheduler has no error handling, so a rejection is unhandled.',
194
+ 'async-route-unhandled-rejection': 'An Express 4 async route handler has no error handling, so a rejection never reaches the error middleware.',
195
+ 'browser-not-closed': 'A Playwright or Puppeteer browser is not closed in a finally block, so an error leaves the process running.',
196
+ 'check-then-update-race': "A Mongoose or Sequelize document's numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates.",
197
+ 'child-process-without-error-listener': "A spawned child process has no 'error' listener, so a failed spawn crashes the parent process.",
198
+ 'csharp-async-void': 'An async void method cannot be awaited and can crash the process on unhandled exceptions.',
199
+ 'csharp-disposable-without-using': 'A C# stream, connection or other IDisposable is created without using, so an exception leaks it.',
200
+ 'discarded-error-result': 'A call discards a typed Either or Result that can carry a failure as a value.',
162
201
  'drizzle-unfiltered-write': 'A Drizzle update or delete executes without an effective where clause.',
202
+ 'drizzle-write-preflight': 'A separate existence check before a Drizzle write can race with another request.',
203
+ 'error-logged-without-stack': 'A catch block logs only error.message and carries on, so the stack trace is lost.',
204
+ 'error-rethrown-without-cause': 'A catch block throws a new error without the caught one, so the original message and stack are lost.',
205
+ 'file-handle-not-closed': 'A FileHandle from fs/promises open() is not closed on every path, leaking a file descriptor.',
163
206
  'find-then-create-race': 'A lookup by key is followed by an insert with that key, with no unique constraint to stop duplicates.',
164
207
  'floating-promise': 'A promise-returning call is neither awaited, returned nor handled, so its failure goes unseen.',
165
- 'discarded-error-result': 'A call discards a typed Either or Result that can carry a failure as a value.',
166
- 'promise-return-escapes-catch': 'Returning a promise directly from a protected try block can bypass its catch on rejection.',
167
- 'return-in-finally': 'Returning from finally can replace a pending return value or suppress a thrown error.',
168
- 'return-newline': 'A line break after return ends the statement before the apparent return value.',
169
- 'drizzle-write-preflight': 'A separate existence check before a Drizzle write can race with another request.',
208
+ 'go-defer-before-error-check': 'A Go defer closes a resource before its error is checked, so a failed open dereferences nil.',
209
+ 'go-error-discarded': 'A Go error result is assigned to the blank identifier and never checked.',
170
210
  'http-call-without-timeout': 'A fetch or axios call has no timeout or abort signal.',
211
+ 'interval-not-cleared': 'A setInterval handle is discarded or never cleared, so the timer outlives its owner.',
212
+ 'invalid-typeof-comparison': 'A typeof result is compared to a string typeof never returns, so the check never matches.',
213
+ 'java-resource-without-try': 'A Java stream, reader or connection is opened outside try-with-resources, so an exception leaks it.',
214
+ 'json-parse-unguarded': 'JSON.parse runs on outside input with no try/catch, so malformed input throws where it is not handled.',
215
+ 'loop-index-past-length': 'A loop runs its index up to and including length, so the last pass reads past the end.',
171
216
  'migration-breaking-drop': 'A migration drops a column or table that running code may still use.',
172
217
  'migration-breaking-rename': 'A migration renames a column or table that running code may still use.',
173
218
  'migration-column-type-rewrite': 'A migration changes a column type in a way that rewrites the table.',
@@ -183,43 +228,40 @@ const descriptionByRule = {
183
228
  'migration-table-rewrite-command': 'A migration runs VACUUM FULL, CLUSTER or REINDEX, which rewrites or locks the table.',
184
229
  'migration-unparsed': 'A migration statement could not be parsed and needs a manual review.',
185
230
  'migration-volatile-default': 'A column is added with a volatile default, which rewrites the table.',
231
+ 'mongoose-aggregate-uncast-id': 'A Mongoose aggregate $match compares _id to an uncast string instead of an ObjectId.',
232
+ 'nan-comparison': 'A value is compared to NaN with an equality operator, which is never true.',
233
+ 'next-server-env-in-client': "A 'use client' file reads a process.env variable without the NEXT_PUBLIC_ prefix, so it is unavailable in the browser by default.",
234
+ 'payment-missing-idempotency-key': 'A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice.',
186
235
  'pg-transaction-on-pool': 'A transaction statement is sent to a pool, so its statements can run on different connections.',
236
+ 'pool-without-connection-timeout': 'A pg Pool or Client sets no connectionTimeoutMillis, so its default of 0 waits for a connection forever.',
187
237
  'prisma-dependent-writes': 'Adjacent Prisma creates pass a value from the first record into the next write.',
188
238
  'prisma-read-modify-write': 'A Prisma read feeds a numeric update of the same row, losing concurrent updates.',
189
239
  'prisma-transaction-client-escape': 'A Prisma call inside an interactive transaction uses the outer client instead of the transaction client.',
240
+ 'promise-return-escapes-catch': 'Returning a promise directly from a protected try block can bypass its catch on rejection.',
241
+ 'python-bare-except': 'A bare except also catches SystemExit and KeyboardInterrupt, hiding shutdowns and bugs.',
242
+ 'python-swallowed-exception': 'A Python except block only passes, so the failure is dropped silently.',
243
+ 'query-runner-not-released': 'A TypeORM QueryRunner is not released in a finally block, so an error leaks its pooled connection.',
244
+ 'react-async-effect-callback': 'An async function is passed to useEffect, so its promise is treated as the cleanup function and its errors go unhandled.',
245
+ 'react-effect-sets-state-every-render': 'An effect with no dependency array sets state to a new value on every run, so the component re-renders forever.',
246
+ 'react-list-missing-key': 'An element or fragment returned from .map() has no key prop, so React cannot track items when the list changes.',
247
+ 'react-state-mutated-in-place': 'A useState value is mutated in place and passed to its own setter, so React sees the same reference and skips the re-render.',
190
248
  'redis-incr-then-expire': 'A Redis counter increment and its expire on the same key are two round trips and not atomic.',
249
+ 'request-number-unvalidated': 'A number parsed from request input reaches a query or calculation with no NaN or range check.',
191
250
  'retry-without-backoff': 'A retry loop calls the network again with no delay between attempts.',
192
- 'async-route-unhandled-rejection': 'An Express 4 async route handler has no error handling, so a rejection never reaches the error middleware.',
193
- 'async-callback-unhandled-rejection': 'An async callback given to an event emitter, timer or scheduler has no error handling, so a rejection is unhandled.',
251
+ 'return-in-finally': 'Returning from finally can replace a pending return value or suppress a thrown error.',
252
+ 'return-newline': 'A line break after return ends the statement before the apparent return value.',
253
+ 'rust-unwrap-in-production': 'Rust code outside tests calls unwrap(), turning an Err or None into a panic.',
254
+ 'sql-insert-truncated-at-semicolon': 'A SQL dump parser ends INSERT values at a semicolon inside quoted text.',
194
255
  'stream-pipe-unhandled-error': 'A stream is piped with .pipe() and no error handling, so a stream error can crash the process or leak the file.',
195
- 'json-parse-unguarded': 'JSON.parse runs on outside input with no try/catch, so malformed input throws where it is not handled.',
196
- 'request-number-unvalidated': 'A number parsed from request input reaches a query or calculation with no NaN or range check.',
256
+ 'swallowed-error': 'A catch block drops the error and the code after the try carries on as if it succeeded.',
257
+ 'switch-not-exhaustive': 'A switch over a union or enum has no default and misses members, so the missing value leaves the result undefined.',
258
+ 'throw-non-error': 'A string, number or object literal is thrown instead of an Error, so there is no stack trace.',
197
259
  'typeorm-transaction-client-escape': 'A write inside a TypeORM transaction goes through a repository not bound to it.',
198
- 'upload-without-size-limit': 'A multer or Nest upload interceptor has no file size limit.',
199
- 'mongoose-aggregate-uncast-id': 'A Mongoose aggregate $match compares _id to an uncast string instead of an ObjectId.',
200
- 'check-then-update-race': "A Mongoose or Sequelize document's numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates.",
201
- 'payment-missing-idempotency-key': 'A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice.',
202
- 'webhook-missing-idempotency-check': 'A webhook route inserts rows without first checking whether the event was already processed.',
203
260
  'unbounded-promise-all': 'Promise.all runs over an unbounded collection without a concurrency limit, risking memory spikes or downstream saturation.',
204
- 'csharp-async-void': 'An async void method cannot be awaited and can crash the process on unhandled exceptions.',
205
- 'sql-insert-truncated-at-semicolon': 'A SQL dump parser ends INSERT values at a semicolon inside quoted text.',
206
- 'swallowed-error': 'A catch block drops the error and the code after the try carries on as if it succeeded.',
261
+ 'uncaught-exception-continues': 'An uncaughtException handler neither exits nor rethrows, so the process keeps running in an undefined state.',
207
262
  'unguarded-boundary-access': 'A nested property is read from outside input or a lookup that can be missing, so absent data throws a TypeError.',
208
- 'assignment-in-condition': 'A condition assigns with = where a comparison was probably meant.',
209
- 'nan-comparison': 'A value is compared to NaN with an equality operator, which is never true.',
210
- 'invalid-typeof-comparison': 'A typeof result is compared to a string typeof never returns, so the check never matches.',
211
263
  'unreachable-code': 'Statements follow a return, throw, break or continue in the same block and never run.',
212
- 'loop-index-past-length': 'A loop runs its index up to and including length, so the last pass reads past the end.',
213
- 'file-handle-not-closed': 'A FileHandle from fs/promises open() is not closed on every path, leaking a file descriptor.',
214
- 'query-runner-not-released': 'A TypeORM QueryRunner is not released in a finally block, so an error leaks its pooled connection.',
215
- 'browser-not-closed': 'A Playwright or Puppeteer browser is not closed in a finally block, so an error leaves the process running.',
216
- 'interval-not-cleared': 'A setInterval handle is discarded or never cleared, so the timer outlives its owner.',
217
- 'csharp-disposable-without-using': 'A C# stream, connection or other IDisposable is created without using, so an exception leaks it.',
218
- 'python-bare-except': 'A bare except also catches SystemExit and KeyboardInterrupt, hiding shutdowns and bugs.',
219
- 'python-swallowed-exception': 'A Python except block only passes, so the failure is dropped silently.',
220
- 'go-error-discarded': 'A Go error result is assigned to the blank identifier and never checked.',
221
- 'go-defer-before-error-check': 'A Go defer closes a resource before its error is checked, so a failed open dereferences nil.',
222
- 'java-resource-without-try': 'A Java stream, reader or connection is opened outside try-with-resources, so an exception leaks it.',
223
- 'rust-unwrap-in-production': 'Rust code outside tests calls unwrap(), turning an Err or None into a panic.',
264
+ 'upload-without-size-limit': 'A multer or Nest upload interceptor has no file size limit.',
265
+ 'webhook-missing-idempotency-check': 'A webhook route inserts rows without first checking whether the event was already processed.',
224
266
  };
225
267
  export { sourceRules, migrationRules, contractRules, polyglotRules, knownRules, impactByRule, descriptionByRule };