loadwise 0.6.0 → 0.6.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 (1122) hide show
  1. package/PERFORMANCE.md +31 -6
  2. package/README.md +489 -839
  3. package/dist/bin/loadwise.js +104 -0
  4. package/dist/lib/accessibility/analyze.js +26 -0
  5. package/dist/lib/accessibility/angular-inline.js +43 -0
  6. package/dist/lib/accessibility/cli.js +11 -0
  7. package/dist/lib/accessibility/frontend-detect.js +99 -0
  8. package/dist/lib/accessibility/jsx-elements.js +196 -0
  9. package/dist/lib/accessibility/markup-files.js +41 -0
  10. package/dist/lib/accessibility/markup.js +34 -0
  11. package/dist/lib/accessibility/rule-ids.js +51 -0
  12. package/dist/lib/accessibility/rules.js +492 -0
  13. package/dist/lib/accessibility/template-attributes.js +148 -0
  14. package/dist/lib/accessibility/template-elements.js +451 -0
  15. package/dist/lib/accessibility/template-file.js +183 -0
  16. package/dist/lib/editor/accessibility-examples.js +112 -0
  17. package/dist/lib/editor/diagnostics.js +365 -0
  18. package/dist/lib/editor/dismissals.js +111 -0
  19. package/dist/lib/editor/language-server.js +437 -0
  20. package/dist/lib/editor/reliability-examples.js +151 -0
  21. package/dist/lib/editor/scan-session.js +334 -0
  22. package/dist/lib/editor/server-commands.js +232 -0
  23. package/dist/lib/editor/workspace-paths.js +22 -0
  24. package/dist/lib/maintainability/analysis/analyze-source.js +92 -0
  25. package/dist/lib/maintainability/analysis/snapshot-context.js +64 -0
  26. package/dist/lib/maintainability/analysis/source-facts.js +39 -0
  27. package/dist/lib/maintainability/analysis/walk.js +17 -0
  28. package/dist/lib/maintainability/architecture/architecture-nest.js +103 -0
  29. package/dist/lib/maintainability/architecture/architecture.js +482 -0
  30. package/dist/lib/maintainability/cli/apply-fix.js +85 -0
  31. package/dist/lib/maintainability/cli/changed-lines.js +135 -0
  32. package/dist/lib/maintainability/cli/changed-output.js +22 -0
  33. package/dist/lib/maintainability/cli/finding-ids.js +39 -0
  34. package/dist/lib/maintainability/cli/fix-cli.js +209 -0
  35. package/dist/lib/maintainability/cli/fix-text.js +11 -0
  36. package/dist/lib/maintainability/cli/git-inventory.js +116 -0
  37. package/dist/lib/maintainability/cli/inputs.js +234 -0
  38. package/dist/lib/maintainability/cli/review-directive.js +91 -0
  39. package/dist/lib/maintainability/cli/site-fix.js +221 -0
  40. package/dist/lib/maintainability/cli.js +411 -0
  41. package/dist/lib/maintainability/entry-points/config-entry-points.js +86 -0
  42. package/dist/lib/maintainability/entry-points/entry-points.js +603 -0
  43. package/dist/lib/maintainability/polyglot.js +174 -0
  44. package/dist/lib/maintainability/project.js +116 -0
  45. package/dist/lib/maintainability/quality/deprecated-apis.js +170 -0
  46. package/dist/lib/maintainability/quality/duplicates.js +326 -0
  47. package/dist/lib/maintainability/quality/functions.js +315 -0
  48. package/dist/lib/maintainability/quality/size-limits.js +95 -0
  49. package/dist/lib/maintainability/quality/stray-console.js +354 -0
  50. package/dist/lib/maintainability/quality/tsconfig-strict.js +74 -0
  51. package/dist/lib/maintainability/quality/type-safety-hygiene.js +562 -0
  52. package/dist/lib/maintainability/rule-ids.js +82 -0
  53. package/dist/lib/maintainability/scan-changed.js +72 -0
  54. package/dist/lib/maintainability/scan-worker.js +38 -0
  55. package/dist/lib/maintainability/scan.js +246 -0
  56. package/dist/lib/maintainability/site-fixes/branches.js +425 -0
  57. package/dist/lib/maintainability/site-fixes/control-flow.js +67 -0
  58. package/dist/lib/maintainability/site-fixes/deprecated-apis.js +230 -0
  59. package/dist/lib/maintainability/site-fixes/duplicate-arrows.js +345 -0
  60. package/dist/lib/maintainability/site-fixes/duplicate-edits.js +393 -0
  61. package/dist/lib/maintainability/site-fixes/duplicate-methods.js +414 -0
  62. package/dist/lib/maintainability/site-fixes/duplicate-module-style.js +90 -0
  63. package/dist/lib/maintainability/site-fixes/duplicates.js +126 -0
  64. package/dist/lib/maintainability/site-fixes/extract-block-measure.js +131 -0
  65. package/dist/lib/maintainability/site-fixes/extract-block.js +38 -0
  66. package/dist/lib/maintainability/site-fixes/parameters.js +460 -0
  67. package/dist/lib/maintainability/site-fixes/stray-console.js +21 -0
  68. package/dist/lib/maintainability/site-fixes/unused-bindings.js +180 -0
  69. package/dist/lib/maintainability/unused/ancestor-aliases.js +35 -0
  70. package/dist/lib/maintainability/unused/module-usage-dynamic.js +175 -0
  71. package/dist/lib/maintainability/unused/module-usage.js +574 -0
  72. package/dist/lib/maintainability/unused/unused-bindings.js +182 -0
  73. package/dist/lib/performance/analysis/call-syntax.js +27 -0
  74. package/dist/lib/performance/analysis/function-kinds.js +9 -0
  75. package/dist/lib/performance/analysis/missing-packages.js +116 -0
  76. package/dist/lib/performance/analysis/package-types.js +57 -0
  77. package/dist/lib/performance/analysis/review-context.js +422 -0
  78. package/dist/lib/performance/analysis/schema-tooling.js +191 -0
  79. package/dist/lib/performance/analysis/scope-evidence.js +137 -0
  80. package/dist/lib/performance/analysis/source-inputs.js +83 -0
  81. package/dist/lib/performance/analysis/source-options.js +103 -0
  82. package/dist/lib/performance/analysis/source-pillars.js +23 -0
  83. package/dist/lib/performance/analysis/source-text.js +59 -0
  84. package/dist/lib/performance/analysis/unscanned-javascript.js +76 -0
  85. package/dist/lib/performance/analyze.js +257 -0
  86. package/dist/lib/performance/async/async-errors.js +190 -0
  87. package/dist/lib/performance/async/await-before-early-exit.js +176 -0
  88. package/dist/lib/performance/async/awaits.js +70 -0
  89. package/dist/lib/performance/async/discarded-error-result.js +46 -0
  90. package/dist/lib/performance/async/floating-promises.js +261 -0
  91. package/dist/lib/performance/async/json-input-origin.js +250 -0
  92. package/dist/lib/performance/async/literal-awaits.js +190 -0
  93. package/dist/lib/performance/async/promise-return-escapes-catch.js +96 -0
  94. package/dist/lib/performance/async/retry-backoff.js +132 -0
  95. package/dist/lib/performance/async/return-in-finally.js +12 -0
  96. package/dist/lib/performance/async/return-newline.js +54 -0
  97. package/dist/lib/performance/async/stream-errors.js +493 -0
  98. package/dist/lib/performance/cli/changed-lines.js +141 -0
  99. package/dist/lib/performance/cli/cli-output.js +176 -0
  100. package/dist/lib/performance/cli/cli-policy.js +110 -0
  101. package/dist/lib/performance/cli/cli-scan.js +444 -0
  102. package/dist/lib/performance/cli/editor-signal.js +57 -0
  103. package/dist/lib/performance/cli/finding-ids.js +102 -0
  104. package/dist/lib/performance/cli/finding-text.js +117 -0
  105. package/dist/lib/performance/cli/fix-cli.js +216 -0
  106. package/dist/lib/performance/cli/scan-outcome.js +29 -0
  107. package/dist/lib/performance/cli/watch.js +99 -0
  108. package/dist/lib/performance/cli.js +101 -0
  109. package/dist/lib/performance/collections/collection-bindings.js +283 -0
  110. package/dist/lib/performance/collections/collection-bounds.js +247 -0
  111. package/dist/lib/performance/collections/collection-copy.js +169 -0
  112. package/dist/lib/performance/collections/collection-lookups.js +432 -0
  113. package/dist/lib/performance/collections/collection-reduce.js +340 -0
  114. package/dist/lib/performance/collections/collections.js +25 -0
  115. package/dist/lib/performance/collections/json-clone.js +92 -0
  116. package/dist/lib/performance/collections/json-parse-context.js +99 -0
  117. package/dist/lib/performance/collections/list-counts.js +321 -0
  118. package/dist/lib/performance/collections/list-overfetch.js +214 -0
  119. package/dist/lib/performance/collections/memory-growth.js +514 -0
  120. package/dist/lib/performance/collections/repeated.js +200 -0
  121. package/dist/lib/performance/collections/sort-extreme.js +142 -0
  122. package/dist/lib/performance/collections/workbook-decodes.js +147 -0
  123. package/dist/lib/performance/contracts/cli.js +231 -0
  124. package/dist/lib/performance/contracts/dto.js +244 -0
  125. package/dist/lib/performance/contracts/openapi.js +363 -0
  126. package/dist/lib/performance/datastores/pg-fragments.js +300 -0
  127. package/dist/lib/performance/datastores/pg-integrity.js +115 -0
  128. package/dist/lib/performance/datastores/pooling.js +193 -0
  129. package/dist/lib/performance/datastores/postgres.js +200 -0
  130. package/dist/lib/performance/datastores/redis-client.js +19 -0
  131. package/dist/lib/performance/datastores/redis-keys.js +78 -0
  132. package/dist/lib/performance/datastores/redis.js +188 -0
  133. package/dist/lib/performance/datastores/session-store.js +86 -0
  134. package/dist/lib/performance/db/cli.js +470 -0
  135. package/dist/lib/performance/db/redact.js +126 -0
  136. package/dist/lib/performance/engine/native-checker.js +319 -0
  137. package/dist/lib/performance/engine/native-runtime.js +25 -0
  138. package/dist/lib/performance/engine/native-syntax.js +136 -0
  139. package/dist/lib/performance/engine/native-workspaces.js +31 -0
  140. package/dist/lib/performance/engine/native.js +382 -0
  141. package/dist/lib/performance/frontend/frontend-dom-perf.js +310 -0
  142. package/dist/lib/performance/frontend/frontend-helpers.js +93 -0
  143. package/dist/lib/performance/frontend/frontend-perf.js +479 -0
  144. package/dist/lib/performance/frontend/frontend-render-perf.js +375 -0
  145. package/dist/lib/performance/index-rules/index-rules-foreign-keys.js +81 -0
  146. package/dist/lib/performance/index-rules/index-rules-order.js +152 -0
  147. package/dist/lib/performance/index-rules/index-rules-pattern.js +137 -0
  148. package/dist/lib/performance/index-rules/index-rules-table.js +286 -0
  149. package/dist/lib/performance/index-rules/index-rules.js +107 -0
  150. package/dist/lib/performance/index-rules/redundant-indexes.js +403 -0
  151. package/dist/lib/performance/migrations/cli.js +204 -0
  152. package/dist/lib/performance/models/index.js +284 -0
  153. package/dist/lib/performance/orm/cartesian-includes.js +364 -0
  154. package/dist/lib/performance/orm/drizzle-write-preflight.js +195 -0
  155. package/dist/lib/performance/orm/drizzle.js +288 -0
  156. package/dist/lib/performance/orm/filter-existence.js +149 -0
  157. package/dist/lib/performance/orm/find-then-create.js +281 -0
  158. package/dist/lib/performance/orm/last-insert-id.js +120 -0
  159. package/dist/lib/performance/orm/mongoose-patterns.js +245 -0
  160. package/dist/lib/performance/orm/offset-pagination.js +166 -0
  161. package/dist/lib/performance/orm/orm-owners.js +145 -0
  162. package/dist/lib/performance/orm/orm-queries.js +496 -0
  163. package/dist/lib/performance/orm/page-counts.js +262 -0
  164. package/dist/lib/performance/orm/prisma-aggregates.js +125 -0
  165. package/dist/lib/performance/orm/prisma-integrity.js +239 -0
  166. package/dist/lib/performance/orm/prisma.js +307 -0
  167. package/dist/lib/performance/orm/typeorm-projection.js +261 -0
  168. package/dist/lib/performance/orm/typeorm-transaction-loops.js +143 -0
  169. package/dist/lib/performance/orm/typeorm-unused-count.js +36 -0
  170. package/dist/lib/performance/orm/typeorm-updates.js +268 -0
  171. package/dist/lib/performance/orm/unbounded-list-queries.js +598 -0
  172. package/dist/lib/performance/polyglot.js +215 -0
  173. package/dist/lib/performance/projects.js +483 -0
  174. package/dist/lib/performance/query-loops/dependent-writes.js +228 -0
  175. package/dist/lib/performance/query-loops/guard-queries.js +356 -0
  176. package/dist/lib/performance/query-loops/notification-loops.js +176 -0
  177. package/dist/lib/performance/query-loops/parallel-reads.js +139 -0
  178. package/dist/lib/performance/query-loops/query-loop-batch.js +188 -0
  179. package/dist/lib/performance/query-loops/query-loop-bounds.js +219 -0
  180. package/dist/lib/performance/query-loops/query-loop-exits.js +180 -0
  181. package/dist/lib/performance/query-loops/query-loop-helpers.js +42 -0
  182. package/dist/lib/performance/query-loops/query-loop-memo.js +81 -0
  183. package/dist/lib/performance/query-loops/query-loop-pagination.js +130 -0
  184. package/dist/lib/performance/query-loops/query-loops.js +29 -0
  185. package/dist/lib/performance/query-loops/query-results.js +179 -0
  186. package/dist/lib/performance/query-loops/queue-loops.js +87 -0
  187. package/dist/lib/performance/query-loops/sequential-loops.js +557 -0
  188. package/dist/lib/performance/query-loops/service-call-resolution.js +54 -0
  189. package/dist/lib/performance/query-loops/service-loop-collections.js +263 -0
  190. package/dist/lib/performance/query-loops/service-loops.js +416 -0
  191. package/dist/lib/performance/query-loops/transaction-io.js +428 -0
  192. package/dist/lib/performance/request/axios-timeout-defaults.js +538 -0
  193. package/dist/lib/performance/request/backend-mastery.js +444 -0
  194. package/dist/lib/performance/request/http-options-writes.js +204 -0
  195. package/dist/lib/performance/request/http-timeouts.js +499 -0
  196. package/dist/lib/performance/request/llm-max-tokens.js +53 -0
  197. package/dist/lib/performance/request/mongoose-lean.js +149 -0
  198. package/dist/lib/performance/request/node-event-listener-leak.js +160 -0
  199. package/dist/lib/performance/request/node-fs-context.js +397 -0
  200. package/dist/lib/performance/request/node-fs.js +452 -0
  201. package/dist/lib/performance/request/password-hashing.js +218 -0
  202. package/dist/lib/performance/request/phase5-ast.js +144 -0
  203. package/dist/lib/performance/request/phase5-rules.js +317 -0
  204. package/dist/lib/performance/request/pure-js-hashing.js +97 -0
  205. package/dist/lib/performance/request/request-handlers.js +429 -0
  206. package/dist/lib/performance/request/request-heavy-work.js +135 -0
  207. package/dist/lib/performance/request/request-inputs.js +303 -0
  208. package/dist/lib/performance/request/unbounded-promise-all.js +426 -0
  209. package/dist/lib/performance/request/upload-limits.js +145 -0
  210. package/dist/lib/performance/rule-ids.js +371 -0
  211. package/dist/lib/performance/schema/drizzle-schema.js +278 -0
  212. package/dist/lib/performance/schema/mongoose-schema.js +189 -0
  213. package/dist/lib/performance/schema/prisma-owners.js +118 -0
  214. package/dist/lib/performance/schema/prisma-schema.js +472 -0
  215. package/dist/lib/performance/schema/query-site-support.js +60 -0
  216. package/dist/lib/performance/schema/query-sites-drizzle.js +220 -0
  217. package/dist/lib/performance/schema/query-sites-mongoose.js +140 -0
  218. package/dist/lib/performance/schema/query-sites-prisma.js +173 -0
  219. package/dist/lib/performance/schema/query-sites-sequelize.js +133 -0
  220. package/dist/lib/performance/schema/query-sites-typeorm.js +180 -0
  221. package/dist/lib/performance/schema/raw-sql-sites.js +284 -0
  222. package/dist/lib/performance/schema/sequelize-schema.js +322 -0
  223. package/dist/lib/performance/schema/ts-helpers.js +130 -0
  224. package/dist/lib/performance/schema/typeorm-schema.js +262 -0
  225. package/dist/lib/performance/site-fix.js +271 -0
  226. package/dist/lib/performance/site-fixes/await-before-early-exit.js +121 -0
  227. package/dist/lib/performance/site-fixes/delete-preflight.js +99 -0
  228. package/dist/lib/performance/site-fixes/error-handling.js +115 -0
  229. package/dist/lib/performance/site-fixes/helpers.js +200 -0
  230. package/dist/lib/performance/site-fixes/http-timeouts.js +96 -0
  231. package/dist/lib/performance/site-fixes/json-parse.js +114 -0
  232. package/dist/lib/performance/site-fixes/last-insert-id.js +230 -0
  233. package/dist/lib/performance/site-fixes/list-queries.js +164 -0
  234. package/dist/lib/performance/site-fixes/literal-awaits.js +430 -0
  235. package/dist/lib/performance/site-fixes/page-counts.js +88 -0
  236. package/dist/lib/performance/site-fixes/prisma-aggregates.js +455 -0
  237. package/dist/lib/performance/site-fixes/promise-catch.js +174 -0
  238. package/dist/lib/performance/site-fixes/query-shapes.js +573 -0
  239. package/dist/lib/performance/site-fixes/scope-names.js +30 -0
  240. package/dist/lib/performance/site-fixes/service-loop-ast.js +84 -0
  241. package/dist/lib/performance/site-fixes/service-loop-callee.js +57 -0
  242. package/dist/lib/performance/site-fixes/small-rewrites.js +210 -0
  243. package/dist/lib/performance/site-fixes/typeorm-updates.js +277 -0
  244. package/dist/lib/performance/site-fixes/typeorm.js +239 -0
  245. package/dist/lib/performance/site-fixes/upload-limits.js +91 -0
  246. package/dist/lib/performance/site-fixes/workbook-decodes.js +254 -0
  247. package/dist/lib/reliability/analyze.js +47 -0
  248. package/dist/lib/reliability/boundary-access.js +521 -0
  249. package/dist/lib/reliability/callback-completion.js +649 -0
  250. package/dist/lib/reliability/callback-loop-overrides.js +63 -0
  251. package/dist/lib/reliability/child-process.js +528 -0
  252. package/dist/lib/reliability/cli.js +20 -0
  253. package/dist/lib/reliability/crlf-line-split.js +593 -0
  254. package/dist/lib/reliability/error-values.js +242 -0
  255. package/dist/lib/reliability/parse-failure-files.js +292 -0
  256. package/dist/lib/reliability/parse-failure-flow.js +196 -0
  257. package/dist/lib/reliability/parse-failure-paths.js +405 -0
  258. package/dist/lib/reliability/parse-failure-reset.js +482 -0
  259. package/dist/lib/reliability/pool-timeout.js +54 -0
  260. package/dist/lib/reliability/react-bugs.js +401 -0
  261. package/dist/lib/reliability/react-effect-bindings.js +107 -0
  262. package/dist/lib/reliability/react-state-aliases.js +313 -0
  263. package/dist/lib/reliability/react-state-initial.js +201 -0
  264. package/dist/lib/reliability/react-state-order.js +176 -0
  265. package/dist/lib/reliability/react-state-paths.js +86 -0
  266. package/dist/lib/reliability/react-state-setter.js +398 -0
  267. package/dist/lib/reliability/react-state-walker.js +654 -0
  268. package/dist/lib/reliability/react-state.js +49 -0
  269. package/dist/lib/reliability/resource-leaks.js +523 -0
  270. package/dist/lib/reliability/rule-ids.js +276 -0
  271. package/dist/lib/reliability/site-fixes/boundary-access.js +140 -0
  272. package/dist/lib/reliability/site-fixes/suspicious-logic.js +116 -0
  273. package/dist/lib/reliability/source-helpers.js +38 -0
  274. package/dist/lib/reliability/sql-insert-terminator.js +106 -0
  275. package/dist/lib/reliability/standalone-sources.js +93 -0
  276. package/dist/lib/reliability/suspicious-logic.js +423 -0
  277. package/dist/lib/reliability/swallowed-errors.js +371 -0
  278. package/dist/lib/reliability/switch-exhaustive.js +425 -0
  279. package/dist/lib/reliability/switch-fallthrough.js +152 -0
  280. package/dist/lib/reliability/test-cleanup-after-await.js +326 -0
  281. package/dist/lib/reliability/uncaught-exception.js +402 -0
  282. package/dist/lib/reliability/walk.js +16 -0
  283. package/dist/lib/security/analyze.js +129 -0
  284. package/dist/lib/security/auth-crypto/comparison.js +97 -0
  285. package/dist/lib/security/auth-crypto/hashing.js +302 -0
  286. package/dist/lib/security/auth-crypto/index.js +33 -0
  287. package/dist/lib/security/auth-crypto/jwt.js +522 -0
  288. package/dist/lib/security/auth-crypto/plaintext-password.js +171 -0
  289. package/dist/lib/security/auth-crypto/random.js +151 -0
  290. package/dist/lib/security/auth-crypto/rate-limits.js +328 -0
  291. package/dist/lib/security/auth-crypto/secrets.js +331 -0
  292. package/dist/lib/security/auth-crypto/shared.js +105 -0
  293. package/dist/lib/security/auth-crypto/transport-and-ciphers.js +386 -0
  294. package/dist/lib/security/bindings.js +286 -0
  295. package/dist/lib/security/cli.js +304 -0
  296. package/dist/lib/security/declarations.js +25 -0
  297. package/dist/lib/security/deps/cli.js +75 -0
  298. package/dist/lib/security/deps/lockfiles.js +310 -0
  299. package/dist/lib/security/deps/osv.js +217 -0
  300. package/dist/lib/security/deps/scan.js +69 -0
  301. package/dist/lib/security/examples/injection.cjs +58 -0
  302. package/dist/lib/security/exposure/backend-security-mastery.js +84 -0
  303. package/dist/lib/security/exposure/client-env.js +121 -0
  304. package/dist/lib/security/exposure/cookies.js +173 -0
  305. package/dist/lib/security/exposure/cors-origin-regex.js +177 -0
  306. package/dist/lib/security/exposure/cors.js +217 -0
  307. package/dist/lib/security/exposure/error-responses.js +453 -0
  308. package/dist/lib/security/exposure/frontend-security.js +583 -0
  309. package/dist/lib/security/exposure/graphql.js +131 -0
  310. package/dist/lib/security/exposure/jsx-url.js +336 -0
  311. package/dist/lib/security/exposure/literals.js +186 -0
  312. package/dist/lib/security/exposure/logging.js +168 -0
  313. package/dist/lib/security/exposure/mass-assignment.js +165 -0
  314. package/dist/lib/security/exposure/next-image-config.js +34 -0
  315. package/dist/lib/security/exposure/package-manifest.js +72 -0
  316. package/dist/lib/security/exposure/password-response.js +315 -0
  317. package/dist/lib/security/exposure/prototype-pollution.js +291 -0
  318. package/dist/lib/security/exposure/reflected-xss.js +57 -0
  319. package/dist/lib/security/exposure/storage-acl.js +87 -0
  320. package/dist/lib/security/exposure/template-autoescape.js +39 -0
  321. package/dist/lib/security/exposure/url-secrets.js +164 -0
  322. package/dist/lib/security/exposure/validation-pipe.js +36 -0
  323. package/dist/lib/security/exposure/xml.js +28 -0
  324. package/dist/lib/security/file-context.js +94 -0
  325. package/dist/lib/security/files/project-files.js +103 -0
  326. package/dist/lib/security/files/review-directive.js +30 -0
  327. package/dist/lib/security/files/secrets.js +123 -0
  328. package/dist/lib/security/injection/code.js +145 -0
  329. package/dist/lib/security/injection/command.js +180 -0
  330. package/dist/lib/security/injection/escape-replace.js +330 -0
  331. package/dist/lib/security/injection/index.js +23 -0
  332. package/dist/lib/security/injection/nosql.js +353 -0
  333. package/dist/lib/security/injection/redos.js +453 -0
  334. package/dist/lib/security/injection/regex.js +67 -0
  335. package/dist/lib/security/injection/rule-ids.js +18 -0
  336. package/dist/lib/security/injection/shared.js +137 -0
  337. package/dist/lib/security/injection/sql.js +513 -0
  338. package/dist/lib/security/pg-dynamic-query.js +30 -0
  339. package/dist/lib/security/pg-identifier-guards.js +155 -0
  340. package/dist/lib/security/phase5-rules.js +539 -0
  341. package/dist/lib/security/polyglot.js +8 -0
  342. package/dist/lib/security/request-forgery/open-redirect-query.js +338 -0
  343. package/dist/lib/security/request-forgery/open-redirect.js +371 -0
  344. package/dist/lib/security/request-forgery/path-traversal.js +103 -0
  345. package/dist/lib/security/request-forgery/shared.js +359 -0
  346. package/dist/lib/security/request-forgery/ssrf.js +133 -0
  347. package/dist/lib/security/request-forgery/upload-filename.js +75 -0
  348. package/dist/lib/security/request-forgery/zip-slip.js +42 -0
  349. package/dist/lib/security/rule-descriptions.js +89 -0
  350. package/dist/lib/security/rule-ids.js +150 -0
  351. package/dist/lib/security/scope/drizzle-policy.js +197 -0
  352. package/dist/lib/security/scope/query-policy.js +156 -0
  353. package/dist/lib/security/site-fixes/auth-crypto.js +224 -0
  354. package/dist/lib/security/site-fixes/injection.js +119 -0
  355. package/dist/lib/security/site-fixes/jwt.js +89 -0
  356. package/dist/lib/security/taint/archive-sources.js +127 -0
  357. package/dist/lib/security/taint/filename-guard.js +112 -0
  358. package/dist/lib/security/taint/guards.js +346 -0
  359. package/dist/lib/security/taint/index.js +615 -0
  360. package/dist/lib/security/taint/propagate.js +120 -0
  361. package/dist/lib/security/taint/resolution-cache.js +105 -0
  362. package/dist/lib/security/taint/sanitizers.js +71 -0
  363. package/dist/lib/security/taint/sources.js +360 -0
  364. package/dist/lib/security/taint/summaries.js +219 -0
  365. package/dist/lib/security/taint/url-parts.js +273 -0
  366. package/dist/lib/security/taint/validators.js +420 -0
  367. package/dist/lib/security/vm-module-members.js +52 -0
  368. package/dist/lib/shared/agent/agent-init.js +236 -0
  369. package/dist/lib/shared/agent/agent-verify.js +239 -0
  370. package/dist/lib/shared/agent/git-hook.js +153 -0
  371. package/dist/lib/shared/agent/pending-review.js +119 -0
  372. package/dist/lib/shared/agent/review-mcp.js +262 -0
  373. package/dist/lib/shared/analysis/ast-semantics.js +453 -0
  374. package/dist/lib/shared/analysis/caller-name-inventory.js +21 -0
  375. package/dist/lib/shared/analysis/declaration-path.js +87 -0
  376. package/dist/lib/shared/analysis/execution-context.js +397 -0
  377. package/dist/lib/shared/analysis/function-summaries.js +571 -0
  378. package/dist/lib/shared/analysis/function-syntax.js +86 -0
  379. package/dist/lib/shared/analysis/hot-path-graph.js +268 -0
  380. package/dist/lib/shared/analysis/scan-cache.js +351 -0
  381. package/dist/lib/shared/check.js +272 -0
  382. package/dist/lib/shared/config-root-files.js +28 -0
  383. package/dist/lib/shared/config.js +286 -0
  384. package/dist/lib/shared/fix/fix-command.js +23 -0
  385. package/dist/lib/shared/fix/fix-convergence.js +545 -0
  386. package/dist/lib/shared/fix/fix-handoff.js +57 -0
  387. package/dist/lib/shared/fix/fix-history.js +305 -0
  388. package/dist/lib/shared/fix/fix-hunks.js +117 -0
  389. package/dist/lib/shared/fix/fix-presentation-comments.js +254 -0
  390. package/dist/lib/shared/fix/fix-presentation-style.js +230 -0
  391. package/dist/lib/shared/fix/fix-presentation.js +177 -0
  392. package/dist/lib/shared/fix/fix-rationales.js +152 -0
  393. package/dist/lib/shared/fix/fix-recipes.js +101 -0
  394. package/dist/lib/shared/fix/fix-typecheck.js +222 -0
  395. package/dist/lib/shared/fix/project-file-access.js +172 -0
  396. package/dist/lib/shared/fix.js +258 -0
  397. package/dist/lib/shared/formats/finding-location.js +35 -0
  398. package/dist/lib/shared/formats/sarif.js +91 -0
  399. package/dist/lib/shared/package-root.js +18 -0
  400. package/dist/lib/shared/reporting/baseline-lines.js +127 -0
  401. package/dist/lib/shared/reporting/baseline.js +239 -0
  402. package/dist/lib/shared/reporting/coverage-notes.js +35 -0
  403. package/dist/lib/shared/reporting/flow-skips.js +87 -0
  404. package/dist/lib/shared/reporting/impact-levels.js +49 -0
  405. package/dist/lib/shared/reporting/pillar-rules.js +6 -0
  406. package/dist/lib/shared/reporting/pillars.js +377 -0
  407. package/dist/lib/shared/reporting/rule-docs.js +21 -0
  408. package/dist/lib/shared/reporting/source-report.js +157 -0
  409. package/dist/lib/shared/system/atomic-write.js +77 -0
  410. package/dist/lib/shared/system/terminal-safe.js +16 -0
  411. package/dist/lib/shared/types/typescript-outer-expression.js +1 -0
  412. package/dist/lib/shared/workspaces.js +434 -0
  413. package/dist/polyglot/maintainability/rules.js +159 -0
  414. package/package.json +53 -30
  415. package/plugin/.claude-plugin/plugin.json +2 -2
  416. package/plugin/hooks/check-edited-file.mjs +151 -0
  417. package/plugin/hooks/hooks.json +1 -1
  418. package/schema/loadwise.config.schema.json +16 -0
  419. package/bin/loadwise.js +0 -102
  420. package/lib/accessibility/analyze.js +0 -26
  421. package/lib/accessibility/angular-inline.js +0 -43
  422. package/lib/accessibility/cli.js +0 -11
  423. package/lib/accessibility/frontend-detect.js +0 -99
  424. package/lib/accessibility/jsx-elements.js +0 -110
  425. package/lib/accessibility/markup-files.js +0 -41
  426. package/lib/accessibility/markup.js +0 -24
  427. package/lib/accessibility/rule-ids.js +0 -39
  428. package/lib/accessibility/rules.js +0 -293
  429. package/lib/accessibility/template-attributes.js +0 -137
  430. package/lib/accessibility/template-elements.js +0 -434
  431. package/lib/accessibility/template-file.js +0 -183
  432. package/lib/editor/accessibility-examples.js +0 -89
  433. package/lib/editor/diagnostics.js +0 -365
  434. package/lib/editor/dismissals.js +0 -111
  435. package/lib/editor/language-server.js +0 -437
  436. package/lib/editor/reliability-examples.js +0 -136
  437. package/lib/editor/scan-session.js +0 -334
  438. package/lib/editor/server-commands.js +0 -232
  439. package/lib/editor/workspace-paths.js +0 -22
  440. package/lib/maintainability/analyze-source.js +0 -95
  441. package/lib/maintainability/ancestor-aliases.js +0 -35
  442. package/lib/maintainability/apply-fix.js +0 -85
  443. package/lib/maintainability/architecture-nest.js +0 -103
  444. package/lib/maintainability/architecture.js +0 -482
  445. package/lib/maintainability/changed-lines.js +0 -135
  446. package/lib/maintainability/changed-output.js +0 -21
  447. package/lib/maintainability/cli.js +0 -410
  448. package/lib/maintainability/config-entry-points.js +0 -86
  449. package/lib/maintainability/deprecated-apis.js +0 -170
  450. package/lib/maintainability/duplicates.js +0 -326
  451. package/lib/maintainability/entry-points.js +0 -603
  452. package/lib/maintainability/finding-ids.js +0 -46
  453. package/lib/maintainability/fix-cli.js +0 -235
  454. package/lib/maintainability/fix-text.js +0 -11
  455. package/lib/maintainability/functions.js +0 -315
  456. package/lib/maintainability/inputs.js +0 -231
  457. package/lib/maintainability/module-usage-dynamic.js +0 -175
  458. package/lib/maintainability/module-usage.js +0 -574
  459. package/lib/maintainability/polyglot.js +0 -173
  460. package/lib/maintainability/project.js +0 -116
  461. package/lib/maintainability/review-directive.js +0 -91
  462. package/lib/maintainability/rule-ids.js +0 -82
  463. package/lib/maintainability/scan-changed.js +0 -70
  464. package/lib/maintainability/scan-worker.js +0 -38
  465. package/lib/maintainability/scan.js +0 -242
  466. package/lib/maintainability/site-fix.js +0 -221
  467. package/lib/maintainability/site-fixes/branches.js +0 -418
  468. package/lib/maintainability/site-fixes/control-flow.js +0 -67
  469. package/lib/maintainability/site-fixes/deprecated-apis.js +0 -67
  470. package/lib/maintainability/site-fixes/duplicate-arrows.js +0 -343
  471. package/lib/maintainability/site-fixes/duplicate-edits.js +0 -396
  472. package/lib/maintainability/site-fixes/duplicate-methods.js +0 -407
  473. package/lib/maintainability/site-fixes/duplicates.js +0 -125
  474. package/lib/maintainability/site-fixes/extract-block-measure.js +0 -131
  475. package/lib/maintainability/site-fixes/extract-block.js +0 -38
  476. package/lib/maintainability/site-fixes/parameters.js +0 -460
  477. package/lib/maintainability/site-fixes/stray-console.js +0 -21
  478. package/lib/maintainability/site-fixes/unused-bindings.js +0 -158
  479. package/lib/maintainability/size-limits.js +0 -94
  480. package/lib/maintainability/snapshot-context.js +0 -63
  481. package/lib/maintainability/source-facts.js +0 -39
  482. package/lib/maintainability/stray-console.js +0 -352
  483. package/lib/maintainability/tsconfig-strict.js +0 -69
  484. package/lib/maintainability/type-safety-hygiene.js +0 -204
  485. package/lib/maintainability/unused-bindings.js +0 -182
  486. package/lib/maintainability/walk.js +0 -17
  487. package/lib/performance/analyze.js +0 -253
  488. package/lib/performance/async-errors.js +0 -190
  489. package/lib/performance/await-before-early-exit.js +0 -176
  490. package/lib/performance/awaits.js +0 -70
  491. package/lib/performance/backend-mastery.js +0 -444
  492. package/lib/performance/call-syntax.js +0 -27
  493. package/lib/performance/cartesian-includes.js +0 -364
  494. package/lib/performance/changed-lines.js +0 -141
  495. package/lib/performance/cli-output.js +0 -175
  496. package/lib/performance/cli-policy.js +0 -87
  497. package/lib/performance/cli-scan.js +0 -421
  498. package/lib/performance/cli.js +0 -101
  499. package/lib/performance/collection-bindings.js +0 -283
  500. package/lib/performance/collection-bounds.js +0 -247
  501. package/lib/performance/collection-copy.js +0 -169
  502. package/lib/performance/collection-lookups.js +0 -432
  503. package/lib/performance/collection-reduce.js +0 -340
  504. package/lib/performance/collections.js +0 -25
  505. package/lib/performance/contracts/cli.js +0 -230
  506. package/lib/performance/contracts/dto.js +0 -244
  507. package/lib/performance/contracts/openapi.js +0 -363
  508. package/lib/performance/db/cli.js +0 -469
  509. package/lib/performance/db/redact.js +0 -126
  510. package/lib/performance/dependent-writes.js +0 -228
  511. package/lib/performance/discarded-error-result.js +0 -46
  512. package/lib/performance/drizzle-write-preflight.js +0 -195
  513. package/lib/performance/drizzle.js +0 -288
  514. package/lib/performance/editor-signal.js +0 -57
  515. package/lib/performance/filter-existence.js +0 -149
  516. package/lib/performance/find-then-create.js +0 -281
  517. package/lib/performance/finding-ids.js +0 -48
  518. package/lib/performance/finding-text.js +0 -117
  519. package/lib/performance/fix-cli.js +0 -200
  520. package/lib/performance/floating-promises.js +0 -248
  521. package/lib/performance/frontend-dom-perf.js +0 -310
  522. package/lib/performance/frontend-helpers.js +0 -93
  523. package/lib/performance/frontend-perf.js +0 -479
  524. package/lib/performance/frontend-render-perf.js +0 -200
  525. package/lib/performance/function-kinds.js +0 -9
  526. package/lib/performance/guard-queries.js +0 -356
  527. package/lib/performance/http-timeouts.js +0 -492
  528. package/lib/performance/index-rules-foreign-keys.js +0 -81
  529. package/lib/performance/index-rules-order.js +0 -152
  530. package/lib/performance/index-rules-pattern.js +0 -137
  531. package/lib/performance/index-rules-table.js +0 -288
  532. package/lib/performance/index-rules.js +0 -107
  533. package/lib/performance/json-clone.js +0 -28
  534. package/lib/performance/json-parse-context.js +0 -99
  535. package/lib/performance/last-insert-id.js +0 -120
  536. package/lib/performance/list-counts.js +0 -321
  537. package/lib/performance/list-overfetch.js +0 -216
  538. package/lib/performance/literal-awaits.js +0 -190
  539. package/lib/performance/llm-max-tokens.js +0 -56
  540. package/lib/performance/memory-growth.js +0 -516
  541. package/lib/performance/migrations/cli.js +0 -203
  542. package/lib/performance/missing-packages.js +0 -116
  543. package/lib/performance/models/index.js +0 -284
  544. package/lib/performance/mongoose-patterns.js +0 -245
  545. package/lib/performance/native-checker.js +0 -312
  546. package/lib/performance/native-runtime.js +0 -24
  547. package/lib/performance/native-syntax.js +0 -132
  548. package/lib/performance/native-workspaces.js +0 -31
  549. package/lib/performance/native.js +0 -362
  550. package/lib/performance/node-fs-context.js +0 -390
  551. package/lib/performance/node-fs.js +0 -452
  552. package/lib/performance/notification-loops.js +0 -176
  553. package/lib/performance/offset-pagination.js +0 -166
  554. package/lib/performance/orm-owners.js +0 -145
  555. package/lib/performance/orm-queries.js +0 -496
  556. package/lib/performance/package-types.js +0 -57
  557. package/lib/performance/page-counts.js +0 -262
  558. package/lib/performance/parallel-reads.js +0 -139
  559. package/lib/performance/password-hashing.js +0 -218
  560. package/lib/performance/pg-fragments.js +0 -300
  561. package/lib/performance/pg-integrity.js +0 -115
  562. package/lib/performance/phase5-rules.js +0 -539
  563. package/lib/performance/polyglot.js +0 -214
  564. package/lib/performance/pooling.js +0 -215
  565. package/lib/performance/postgres.js +0 -182
  566. package/lib/performance/prisma-aggregates.js +0 -125
  567. package/lib/performance/prisma-integrity.js +0 -239
  568. package/lib/performance/prisma.js +0 -399
  569. package/lib/performance/projects.js +0 -452
  570. package/lib/performance/promise-return-escapes-catch.js +0 -96
  571. package/lib/performance/pure-js-hashing.js +0 -96
  572. package/lib/performance/query-loop-batch.js +0 -188
  573. package/lib/performance/query-loop-bounds.js +0 -219
  574. package/lib/performance/query-loop-exits.js +0 -171
  575. package/lib/performance/query-loop-helpers.js +0 -42
  576. package/lib/performance/query-loop-memo.js +0 -81
  577. package/lib/performance/query-loop-pagination.js +0 -130
  578. package/lib/performance/query-loops.js +0 -29
  579. package/lib/performance/query-results.js +0 -179
  580. package/lib/performance/queue-loops.js +0 -87
  581. package/lib/performance/redis-client.js +0 -19
  582. package/lib/performance/redis-keys.js +0 -78
  583. package/lib/performance/redis.js +0 -188
  584. package/lib/performance/redundant-indexes.js +0 -403
  585. package/lib/performance/repeated.js +0 -200
  586. package/lib/performance/request-handlers.js +0 -429
  587. package/lib/performance/request-heavy-work.js +0 -135
  588. package/lib/performance/request-inputs.js +0 -303
  589. package/lib/performance/retry-backoff.js +0 -132
  590. package/lib/performance/return-in-finally.js +0 -12
  591. package/lib/performance/return-newline.js +0 -54
  592. package/lib/performance/review-context.js +0 -434
  593. package/lib/performance/rule-ids.js +0 -371
  594. package/lib/performance/scan-outcome.js +0 -37
  595. package/lib/performance/schema/drizzle-schema.js +0 -278
  596. package/lib/performance/schema/mongoose-schema.js +0 -189
  597. package/lib/performance/schema/prisma-schema.js +0 -472
  598. package/lib/performance/schema/query-site-support.js +0 -61
  599. package/lib/performance/schema/query-sites-drizzle.js +0 -220
  600. package/lib/performance/schema/query-sites-mongoose.js +0 -140
  601. package/lib/performance/schema/query-sites-prisma.js +0 -201
  602. package/lib/performance/schema/query-sites-sequelize.js +0 -133
  603. package/lib/performance/schema/query-sites-typeorm.js +0 -180
  604. package/lib/performance/schema/raw-sql-sites.js +0 -284
  605. package/lib/performance/schema/sequelize-schema.js +0 -322
  606. package/lib/performance/schema/ts-helpers.js +0 -130
  607. package/lib/performance/schema/typeorm-schema.js +0 -262
  608. package/lib/performance/schema-tooling.js +0 -193
  609. package/lib/performance/scope-evidence.js +0 -137
  610. package/lib/performance/sequential-loops.js +0 -557
  611. package/lib/performance/service-call-resolution.js +0 -54
  612. package/lib/performance/service-loop-collections.js +0 -263
  613. package/lib/performance/service-loops.js +0 -416
  614. package/lib/performance/session-store.js +0 -86
  615. package/lib/performance/site-fix.js +0 -271
  616. package/lib/performance/site-fixes/await-before-early-exit.js +0 -121
  617. package/lib/performance/site-fixes/delete-preflight.js +0 -99
  618. package/lib/performance/site-fixes/error-handling.js +0 -99
  619. package/lib/performance/site-fixes/helpers.js +0 -200
  620. package/lib/performance/site-fixes/http-timeouts.js +0 -56
  621. package/lib/performance/site-fixes/json-parse.js +0 -114
  622. package/lib/performance/site-fixes/last-insert-id.js +0 -230
  623. package/lib/performance/site-fixes/list-queries.js +0 -164
  624. package/lib/performance/site-fixes/literal-awaits.js +0 -431
  625. package/lib/performance/site-fixes/page-counts.js +0 -88
  626. package/lib/performance/site-fixes/prisma-aggregates.js +0 -455
  627. package/lib/performance/site-fixes/promise-catch.js +0 -147
  628. package/lib/performance/site-fixes/query-shapes.js +0 -573
  629. package/lib/performance/site-fixes/scope-names.js +0 -30
  630. package/lib/performance/site-fixes/service-loop-ast.js +0 -85
  631. package/lib/performance/site-fixes/service-loop-callee.js +0 -57
  632. package/lib/performance/site-fixes/small-rewrites.js +0 -210
  633. package/lib/performance/site-fixes/typeorm-updates.js +0 -277
  634. package/lib/performance/site-fixes/typeorm.js +0 -239
  635. package/lib/performance/site-fixes/upload-limits.js +0 -74
  636. package/lib/performance/site-fixes/workbook-decodes.js +0 -254
  637. package/lib/performance/sort-extreme.js +0 -142
  638. package/lib/performance/source-inputs.js +0 -83
  639. package/lib/performance/source-options.js +0 -103
  640. package/lib/performance/source-pillars.js +0 -23
  641. package/lib/performance/source-text.js +0 -59
  642. package/lib/performance/stream-errors.js +0 -650
  643. package/lib/performance/transaction-io.js +0 -427
  644. package/lib/performance/typeorm-projection.js +0 -261
  645. package/lib/performance/typeorm-transaction-loops.js +0 -143
  646. package/lib/performance/typeorm-unused-count.js +0 -36
  647. package/lib/performance/typeorm-updates.js +0 -268
  648. package/lib/performance/unbounded-list-queries.js +0 -600
  649. package/lib/performance/unscanned-javascript.js +0 -76
  650. package/lib/performance/upload-limits.js +0 -68
  651. package/lib/performance/watch.js +0 -99
  652. package/lib/performance/workbook-decodes.js +0 -147
  653. package/lib/reliability/analyze.js +0 -41
  654. package/lib/reliability/boundary-access.js +0 -521
  655. package/lib/reliability/child-process.js +0 -106
  656. package/lib/reliability/cli.js +0 -20
  657. package/lib/reliability/error-values.js +0 -177
  658. package/lib/reliability/pool-timeout.js +0 -79
  659. package/lib/reliability/react-bugs.js +0 -602
  660. package/lib/reliability/resource-leaks.js +0 -523
  661. package/lib/reliability/rule-ids.js +0 -267
  662. package/lib/reliability/site-fixes/boundary-access.js +0 -80
  663. package/lib/reliability/site-fixes/suspicious-logic.js +0 -115
  664. package/lib/reliability/source-helpers.js +0 -32
  665. package/lib/reliability/sql-insert-terminator.js +0 -106
  666. package/lib/reliability/standalone-sources.js +0 -54
  667. package/lib/reliability/suspicious-logic.js +0 -364
  668. package/lib/reliability/swallowed-errors.js +0 -321
  669. package/lib/reliability/switch-exhaustive.js +0 -284
  670. package/lib/reliability/uncaught-exception.js +0 -223
  671. package/lib/reliability/walk.js +0 -16
  672. package/lib/security/analyze.js +0 -129
  673. package/lib/security/auth-crypto/comparison.js +0 -97
  674. package/lib/security/auth-crypto/hashing.js +0 -302
  675. package/lib/security/auth-crypto/index.js +0 -32
  676. package/lib/security/auth-crypto/jwt.js +0 -468
  677. package/lib/security/auth-crypto/plaintext-password.js +0 -171
  678. package/lib/security/auth-crypto/random.js +0 -124
  679. package/lib/security/auth-crypto/rate-limits.js +0 -326
  680. package/lib/security/auth-crypto/secrets.js +0 -331
  681. package/lib/security/auth-crypto/shared.js +0 -105
  682. package/lib/security/auth-crypto/transport-and-ciphers.js +0 -217
  683. package/lib/security/bindings.js +0 -286
  684. package/lib/security/cli.js +0 -294
  685. package/lib/security/declarations.js +0 -25
  686. package/lib/security/deps/cli.js +0 -75
  687. package/lib/security/deps/lockfiles.js +0 -310
  688. package/lib/security/deps/osv.js +0 -217
  689. package/lib/security/deps/scan.js +0 -69
  690. package/lib/security/examples/injection.cjs +0 -54
  691. package/lib/security/exposure/backend-security-mastery.js +0 -80
  692. package/lib/security/exposure/client-env.js +0 -113
  693. package/lib/security/exposure/cookies.js +0 -173
  694. package/lib/security/exposure/cors-origin-regex.js +0 -177
  695. package/lib/security/exposure/cors.js +0 -217
  696. package/lib/security/exposure/error-responses.js +0 -437
  697. package/lib/security/exposure/frontend-security.js +0 -549
  698. package/lib/security/exposure/graphql.js +0 -131
  699. package/lib/security/exposure/jsx-url.js +0 -267
  700. package/lib/security/exposure/literals.js +0 -133
  701. package/lib/security/exposure/logging.js +0 -168
  702. package/lib/security/exposure/mass-assignment.js +0 -165
  703. package/lib/security/exposure/next-image-config.js +0 -34
  704. package/lib/security/exposure/package-manifest.js +0 -45
  705. package/lib/security/exposure/password-response.js +0 -315
  706. package/lib/security/exposure/prototype-pollution.js +0 -291
  707. package/lib/security/exposure/reflected-xss.js +0 -57
  708. package/lib/security/exposure/storage-acl.js +0 -87
  709. package/lib/security/exposure/template-autoescape.js +0 -39
  710. package/lib/security/exposure/url-secrets.js +0 -164
  711. package/lib/security/exposure/validation-pipe.js +0 -36
  712. package/lib/security/exposure/xml.js +0 -28
  713. package/lib/security/file-context.js +0 -82
  714. package/lib/security/files/project-files.js +0 -103
  715. package/lib/security/files/review-directive.js +0 -30
  716. package/lib/security/files/secrets.js +0 -121
  717. package/lib/security/injection/code.js +0 -122
  718. package/lib/security/injection/command.js +0 -180
  719. package/lib/security/injection/index.js +0 -13
  720. package/lib/security/injection/nosql.js +0 -353
  721. package/lib/security/injection/redos.js +0 -453
  722. package/lib/security/injection/regex.js +0 -67
  723. package/lib/security/injection/rule-ids.js +0 -17
  724. package/lib/security/injection/shared.js +0 -137
  725. package/lib/security/injection/sql.js +0 -513
  726. package/lib/security/pg-dynamic-query.js +0 -30
  727. package/lib/security/pg-identifier-guards.js +0 -155
  728. package/lib/security/phase5-rules.js +0 -515
  729. package/lib/security/polyglot.js +0 -8
  730. package/lib/security/request-forgery/open-redirect.js +0 -336
  731. package/lib/security/request-forgery/path-traversal.js +0 -103
  732. package/lib/security/request-forgery/shared.js +0 -355
  733. package/lib/security/request-forgery/ssrf.js +0 -133
  734. package/lib/security/request-forgery/upload-filename.js +0 -75
  735. package/lib/security/request-forgery/zip-slip.js +0 -42
  736. package/lib/security/rule-descriptions.js +0 -88
  737. package/lib/security/rule-ids.js +0 -149
  738. package/lib/security/scope/drizzle-policy.js +0 -197
  739. package/lib/security/scope/query-policy.js +0 -156
  740. package/lib/security/site-fixes/auth-crypto.js +0 -223
  741. package/lib/security/site-fixes/injection.js +0 -119
  742. package/lib/security/site-fixes/jwt.js +0 -89
  743. package/lib/security/taint/archive-sources.js +0 -127
  744. package/lib/security/taint/filename-guard.js +0 -112
  745. package/lib/security/taint/guards.js +0 -348
  746. package/lib/security/taint/index.js +0 -670
  747. package/lib/security/taint/propagate.js +0 -120
  748. package/lib/security/taint/sanitizers.js +0 -71
  749. package/lib/security/taint/sources.js +0 -360
  750. package/lib/security/taint/summaries.js +0 -219
  751. package/lib/security/taint/url-parts.js +0 -273
  752. package/lib/security/taint/validators.js +0 -420
  753. package/lib/shared/agent-init.js +0 -235
  754. package/lib/shared/agent-verify.js +0 -239
  755. package/lib/shared/atomic-write.js +0 -52
  756. package/lib/shared/baseline.js +0 -237
  757. package/lib/shared/check.js +0 -257
  758. package/lib/shared/config.js +0 -286
  759. package/lib/shared/coverage-notes.js +0 -27
  760. package/lib/shared/execution-context.js +0 -278
  761. package/lib/shared/fix-command.js +0 -23
  762. package/lib/shared/fix-convergence.js +0 -389
  763. package/lib/shared/fix-handoff.js +0 -57
  764. package/lib/shared/fix-history.js +0 -303
  765. package/lib/shared/fix-hunks.js +0 -108
  766. package/lib/shared/fix-presentation-comments.js +0 -253
  767. package/lib/shared/fix-presentation-style.js +0 -230
  768. package/lib/shared/fix-presentation.js +0 -177
  769. package/lib/shared/fix-rationales.js +0 -151
  770. package/lib/shared/fix-recipes.js +0 -101
  771. package/lib/shared/fix-typecheck.js +0 -188
  772. package/lib/shared/fix.js +0 -257
  773. package/lib/shared/formats/finding-location.js +0 -35
  774. package/lib/shared/formats/sarif.js +0 -91
  775. package/lib/shared/function-summaries.js +0 -571
  776. package/lib/shared/function-syntax.js +0 -86
  777. package/lib/shared/git-hook.js +0 -153
  778. package/lib/shared/hot-path-graph.js +0 -268
  779. package/lib/shared/impact-levels.js +0 -49
  780. package/lib/shared/pending-review.js +0 -117
  781. package/lib/shared/pillar-rules.js +0 -6
  782. package/lib/shared/pillars.js +0 -384
  783. package/lib/shared/review-mcp.js +0 -262
  784. package/lib/shared/rule-docs.js +0 -12
  785. package/lib/shared/scan-cache.js +0 -233
  786. package/lib/shared/source-report.js +0 -156
  787. package/lib/shared/workspaces.js +0 -321
  788. package/plugin/hooks/check-edited-file.js +0 -142
  789. package/polyglot/maintainability/rules.js +0 -159
  790. /package/{bin → dist/bin}/github-action.js +0 -0
  791. /package/{lib → dist/lib}/accessibility/aria-tables.js +0 -0
  792. /package/{lib → dist/lib}/accessibility/site-fixes/buttons.js +0 -0
  793. /package/{lib → dist/lib}/accessibility/usage.js +0 -0
  794. /package/{lib → dist/lib}/editor/actions.js +0 -0
  795. /package/{lib → dist/lib}/editor/apply-fix.js +0 -0
  796. /package/{lib → dist/lib}/editor/control-flow-comparison.js +0 -0
  797. /package/{lib → dist/lib}/editor/editor-document.js +0 -0
  798. /package/{lib → dist/lib}/editor/finding-comparison.js +0 -0
  799. /package/{lib → dist/lib}/editor/fix-edits.js +0 -0
  800. /package/{lib → dist/lib}/editor/maintainability-examples.js +0 -0
  801. /package/{lib → dist/lib}/editor/perf-site-comparison.js +0 -0
  802. /package/{lib → dist/lib}/editor/perf-watch.js +0 -0
  803. /package/{lib → dist/lib}/editor/performance-examples.js +0 -0
  804. /package/{lib → dist/lib}/editor/security-examples.js +0 -0
  805. /package/{lib → dist/lib}/editor/source-example.js +0 -0
  806. /package/{lib → dist/lib}/editor/standalone-performance-examples.js +0 -0
  807. /package/{lib → dist/lib}/editor/types/comparison.js +0 -0
  808. /package/{lib → dist/lib}/editor/types/dismissal.js +0 -0
  809. /package/{lib → dist/lib}/editor/types/fix-example.js +0 -0
  810. /package/{lib → dist/lib}/editor/types/source-document.js +0 -0
  811. /package/{lib → dist/lib}/editor/workspace-files.js +0 -0
  812. /package/{lib/maintainability → dist/lib/maintainability/analysis}/advisory-context.js +0 -0
  813. /package/{lib/maintainability → dist/lib/maintainability/analysis}/checklist-context.js +0 -0
  814. /package/{lib/maintainability → dist/lib/maintainability/analysis}/source-exclusions.js +0 -0
  815. /package/{lib/maintainability → dist/lib/maintainability/analysis}/traversal-context.js +0 -0
  816. /package/{lib/maintainability → dist/lib/maintainability/architecture}/data-access.js +0 -0
  817. /package/{lib/maintainability → dist/lib/maintainability/architecture}/graph.js +0 -0
  818. /package/{lib/maintainability → dist/lib/maintainability/architecture}/layout.js +0 -0
  819. /package/{lib/maintainability → dist/lib/maintainability/cli}/branch-advice.js +0 -0
  820. /package/{lib/maintainability → dist/lib/maintainability/entry-points}/docker-entry-points.js +0 -0
  821. /package/{lib/maintainability → dist/lib/maintainability/entry-points}/html-entry-points.js +0 -0
  822. /package/{lib/maintainability → dist/lib/maintainability/entry-points}/mocha-entry-points.js +0 -0
  823. /package/{lib/maintainability → dist/lib/maintainability/entry-points}/runtime-directories.js +0 -0
  824. /package/{lib/maintainability → dist/lib/maintainability/entry-points}/workflow-entry-points.js +0 -0
  825. /package/{lib → dist/lib}/maintainability/examples.js +0 -0
  826. /package/{lib → dist/lib}/maintainability/polyglot-duplicates.js +0 -0
  827. /package/{lib/maintainability → dist/lib/maintainability/quality}/child-buffer.js +0 -0
  828. /package/{lib/maintainability → dist/lib/maintainability/quality}/limits.js +0 -0
  829. /package/{lib/maintainability → dist/lib/maintainability/quality}/modifiers.js +0 -0
  830. /package/{lib → dist/lib}/maintainability/site-fixes/boolean-returns.js +0 -0
  831. /package/{lib → dist/lib}/maintainability/site-fixes/cycles.js +0 -0
  832. /package/{lib → dist/lib}/maintainability/site-fixes/duplicate-bindings.js +0 -0
  833. /package/{lib → dist/lib}/maintainability/site-fixes/exports.js +0 -0
  834. /package/{lib → dist/lib}/maintainability/site-fixes/extract-block-ast.js +0 -0
  835. /package/{lib → dist/lib}/maintainability/site-fixes/extract-block-edits.js +0 -0
  836. /package/{lib → dist/lib}/maintainability/site-fixes/extract-block-flow.js +0 -0
  837. /package/{lib → dist/lib}/maintainability/site-fixes/extract-block-naming.js +0 -0
  838. /package/{lib → dist/lib}/maintainability/site-fixes/extract-block-narrowing.js +0 -0
  839. /package/{lib → dist/lib}/maintainability/site-fixes/helpers.js +0 -0
  840. /package/{lib → dist/lib}/maintainability/site-fixes/if-rewrites.js +0 -0
  841. /package/{lib → dist/lib}/maintainability/site-fixes/isolated-program.js +0 -0
  842. /package/{lib → dist/lib}/maintainability/site-fixes/large-module.js +0 -0
  843. /package/{lib → dist/lib}/maintainability/types/changed-lines.js +0 -0
  844. /package/{lib → dist/lib}/maintainability/types/created-module.js +0 -0
  845. /package/{lib → dist/lib}/maintainability/types/duplicate-sites.js +0 -0
  846. /package/{lib → dist/lib}/maintainability/types/duplicates.js +0 -0
  847. /package/{lib → dist/lib}/maintainability/types/entry-points.js +0 -0
  848. /package/{lib → dist/lib}/maintainability/types/extract-block.js +0 -0
  849. /package/{lib → dist/lib}/maintainability/types/extraction-drafts.js +0 -0
  850. /package/{lib → dist/lib}/maintainability/types/finding-comparison.js +0 -0
  851. /package/{lib → dist/lib}/maintainability/types/fix-files.js +0 -0
  852. /package/{lib/maintainability/types/module-graph.js → dist/lib/maintainability/types/git-entry-source.js} +0 -0
  853. /package/{lib/maintainability/types/module-resolver.js → dist/lib/maintainability/types/module-graph.js} +0 -0
  854. /package/{lib/maintainability/types/module-usage.js → dist/lib/maintainability/types/module-resolver.js} +0 -0
  855. /package/{lib/maintainability/types/policy.js → dist/lib/maintainability/types/module-usage.js} +0 -0
  856. /package/{lib/maintainability/types/polyglot-scan.js → dist/lib/maintainability/types/policy.js} +0 -0
  857. /package/{lib/maintainability/types/scan-report.js → dist/lib/maintainability/types/polyglot-scan.js} +0 -0
  858. /package/{lib/maintainability/types/scan-worker.js → dist/lib/maintainability/types/scan-report.js} +0 -0
  859. /package/{lib/maintainability/types/site-fix-edits.js → dist/lib/maintainability/types/scan-worker.js} +0 -0
  860. /package/{lib/maintainability/types/site-fix-loader.js → dist/lib/maintainability/types/site-fix-edits.js} +0 -0
  861. /package/{lib/maintainability/types/site-fix-nodes.js → dist/lib/maintainability/types/site-fix-loader.js} +0 -0
  862. /package/{lib/maintainability/types/source-analysis.js → dist/lib/maintainability/types/site-fix-nodes.js} +0 -0
  863. /package/{lib/maintainability/types/source-facts.js → dist/lib/maintainability/types/source-analysis.js} +0 -0
  864. /package/{lib/maintainability/types/typescript-jsdoc-internals.js → dist/lib/maintainability/types/source-facts.js} +0 -0
  865. /package/{lib/maintainability/types/typescript-site-fix-internals.js → dist/lib/maintainability/types/typescript-jsdoc-internals.js} +0 -0
  866. /package/{lib/performance/cli-types.js → dist/lib/maintainability/types/typescript-site-fix-internals.js} +0 -0
  867. /package/{lib/maintainability → dist/lib/maintainability/unused}/operator-references.js +0 -0
  868. /package/{lib/maintainability → dist/lib/maintainability/unused}/unused-modules.js +0 -0
  869. /package/{lib/maintainability → dist/lib/maintainability/unused}/verified-private-types.js +0 -0
  870. /package/{lib/performance → dist/lib/performance/cli}/cli-arguments.js +0 -0
  871. /package/{lib/performance/migrations/extract-code-types.js → dist/lib/performance/cli/cli-types.js} +0 -0
  872. /package/{lib/performance → dist/lib/performance/cli}/emit-options.js +0 -0
  873. /package/{lib/performance → dist/lib/performance/cli}/impact.js +0 -0
  874. /package/{lib → dist/lib}/performance/contracts/git-files.js +0 -0
  875. /package/{lib → dist/lib}/performance/contracts/graphql.js +0 -0
  876. /package/{lib → dist/lib}/performance/db/checks.js +0 -0
  877. /package/{lib → dist/lib}/performance/db/cli-format.js +0 -0
  878. /package/{lib → dist/lib}/performance/db/cli-mysql.js +0 -0
  879. /package/{lib → dist/lib}/performance/db/drivers.js +0 -0
  880. /package/{lib → dist/lib}/performance/db/gateway.js +0 -0
  881. /package/{lib → dist/lib}/performance/db/hypopg.js +0 -0
  882. /package/{lib → dist/lib}/performance/db/measure.js +0 -0
  883. /package/{lib → dist/lib}/performance/db/mongo.js +0 -0
  884. /package/{lib → dist/lib}/performance/db/mysql-catalog.js +0 -0
  885. /package/{lib → dist/lib}/performance/db/pg-catalog.js +0 -0
  886. /package/{lib → dist/lib}/performance/db/plan-estimates.js +0 -0
  887. /package/{lib → dist/lib}/performance/db/snapshot.js +0 -0
  888. /package/{lib/performance → dist/lib/performance/engine}/compiler.js +0 -0
  889. /package/{lib/performance → dist/lib/performance/engine}/reference-checks.js +0 -0
  890. /package/{lib/performance → dist/lib/performance/evidence}/cache-reads.js +0 -0
  891. /package/{lib/performance → dist/lib/performance/evidence}/plans.js +0 -0
  892. /package/{lib/performance → dist/lib/performance/evidence}/span-timing.js +0 -0
  893. /package/{lib/performance → dist/lib/performance/evidence}/traces.js +0 -0
  894. /package/{lib → dist/lib}/performance/migrations/discover.js +0 -0
  895. /package/{lib → dist/lib}/performance/migrations/enforce.js +0 -0
  896. /package/{lib → dist/lib}/performance/migrations/extract-code-builders.js +0 -0
  897. /package/{lib → dist/lib}/performance/migrations/extract-code-discovery.js +0 -0
  898. /package/{lib → dist/lib}/performance/migrations/extract-code-sql.js +0 -0
  899. /package/{lib/performance/site-fixes/types/module-binding.js → dist/lib/performance/migrations/extract-code-types.js} +0 -0
  900. /package/{lib → dist/lib}/performance/migrations/extract-code.js +0 -0
  901. /package/{lib → dist/lib}/performance/migrations/extract-sql.js +0 -0
  902. /package/{lib → dist/lib}/performance/migrations/operations.js +0 -0
  903. /package/{lib → dist/lib}/performance/migrations/postgres-registry.js +0 -0
  904. /package/{lib → dist/lib}/performance/migrations/rules-mysql.js +0 -0
  905. /package/{lib → dist/lib}/performance/migrations/rules-postgres-add-column.js +0 -0
  906. /package/{lib → dist/lib}/performance/migrations/rules-postgres-shared.js +0 -0
  907. /package/{lib → dist/lib}/performance/migrations/rules-postgres.js +0 -0
  908. /package/{lib/performance → dist/lib/performance/query-loops}/parallel-reads-policy.js +0 -0
  909. /package/{lib/performance → dist/lib/performance/query-loops}/query-policy.js +0 -0
  910. /package/{lib/performance → dist/lib/performance/query-loops}/service-loop-operations.js +0 -0
  911. /package/{lib → dist/lib}/performance/schema/context.js +0 -0
  912. /package/{lib → dist/lib}/performance/schema/model.js +0 -0
  913. /package/{lib → dist/lib}/performance/schema/project-indexes-events.js +0 -0
  914. /package/{lib → dist/lib}/performance/schema/project-indexes.js +0 -0
  915. /package/{lib → dist/lib}/performance/schema/query-sites.js +0 -0
  916. /package/{lib → dist/lib}/performance/site-fixes/backend-mastery-fixes.js +0 -0
  917. /package/{lib → dist/lib}/performance/site-fixes/batch-loops.js +0 -0
  918. /package/{lib → dist/lib}/performance/site-fixes/collection-copy.js +0 -0
  919. /package/{lib → dist/lib}/performance/site-fixes/collection-existence.js +0 -0
  920. /package/{lib → dist/lib}/performance/site-fixes/collection-find.js +0 -0
  921. /package/{lib → dist/lib}/performance/site-fixes/collection-helpers.js +0 -0
  922. /package/{lib → dist/lib}/performance/site-fixes/collection-lookup-declarations.js +0 -0
  923. /package/{lib → dist/lib}/performance/site-fixes/collection-lookups.js +0 -0
  924. /package/{lib → dist/lib}/performance/site-fixes/collection-membership.js +0 -0
  925. /package/{lib → dist/lib}/performance/site-fixes/collections.js +0 -0
  926. /package/{lib → dist/lib}/performance/site-fixes/database.js +0 -0
  927. /package/{lib → dist/lib}/performance/site-fixes/drizzle-index.js +0 -0
  928. /package/{lib → dist/lib}/performance/site-fixes/frontend-fixes.js +0 -0
  929. /package/{lib → dist/lib}/performance/site-fixes/guard-queries.js +0 -0
  930. /package/{lib → dist/lib}/performance/site-fixes/hoisting.js +0 -0
  931. /package/{lib → dist/lib}/performance/site-fixes/indexes.js +0 -0
  932. /package/{lib → dist/lib}/performance/site-fixes/integrity-drizzle.js +0 -0
  933. /package/{lib → dist/lib}/performance/site-fixes/integrity-wrap.js +0 -0
  934. /package/{lib → dist/lib}/performance/site-fixes/integrity.js +0 -0
  935. /package/{lib → dist/lib}/performance/site-fixes/method-calls.js +0 -0
  936. /package/{lib → dist/lib}/performance/site-fixes/migration-column-rules.js +0 -0
  937. /package/{lib → dist/lib}/performance/site-fixes/migration-context.js +0 -0
  938. /package/{lib → dist/lib}/performance/site-fixes/migration-lock-rules.js +0 -0
  939. /package/{lib → dist/lib}/performance/site-fixes/migration-placement.js +0 -0
  940. /package/{lib → dist/lib}/performance/site-fixes/migrations.js +0 -0
  941. /package/{lib → dist/lib}/performance/site-fixes/pure-js-hashing.js +0 -0
  942. /package/{lib → dist/lib}/performance/site-fixes/query-loop-collections.js +0 -0
  943. /package/{lib → dist/lib}/performance/site-fixes/query-loop-lookups.js +0 -0
  944. /package/{lib → dist/lib}/performance/site-fixes/query-loop-materialization.js +0 -0
  945. /package/{lib → dist/lib}/performance/site-fixes/query-loop-names.js +0 -0
  946. /package/{lib → dist/lib}/performance/site-fixes/query-loop-nodes.js +0 -0
  947. /package/{lib → dist/lib}/performance/site-fixes/query-loop-pg-redis.js +0 -0
  948. /package/{lib → dist/lib}/performance/site-fixes/query-loop-prisma.js +0 -0
  949. /package/{lib → dist/lib}/performance/site-fixes/query-loop-sites.js +0 -0
  950. /package/{lib → dist/lib}/performance/site-fixes/query-loop-typeorm.js +0 -0
  951. /package/{lib → dist/lib}/performance/site-fixes/query-loops.js +0 -0
  952. /package/{lib → dist/lib}/performance/site-fixes/queue-loops.js +0 -0
  953. /package/{lib → dist/lib}/performance/site-fixes/redis-keys.js +0 -0
  954. /package/{lib → dist/lib}/performance/site-fixes/service-loop-concurrent.js +0 -0
  955. /package/{lib → dist/lib}/performance/site-fixes/service-loop-imports.js +0 -0
  956. /package/{lib → dist/lib}/performance/site-fixes/service-loop-read-batch.js +0 -0
  957. /package/{lib → dist/lib}/performance/site-fixes/service-loop-siblings.js +0 -0
  958. /package/{lib → dist/lib}/performance/site-fixes/service-loop-signature.js +0 -0
  959. /package/{lib → dist/lib}/performance/site-fixes/service-loop-sites.js +0 -0
  960. /package/{lib → dist/lib}/performance/site-fixes/service-loop-write-batch.js +0 -0
  961. /package/{lib → dist/lib}/performance/site-fixes/service-loops.js +0 -0
  962. /package/{lib → dist/lib}/performance/site-fixes/streams.js +0 -0
  963. /package/{lib → dist/lib}/performance/site-fixes/sync-calls.js +0 -0
  964. /package/{lib → dist/lib}/performance/site-fixes/sync-imports.js +0 -0
  965. /package/{lib → dist/lib}/performance/site-fixes/transaction-escape.js +0 -0
  966. /package/{lib → dist/lib}/performance/site-fixes/transaction-io.js +0 -0
  967. /package/{lib/performance/types/batch-plan.js → dist/lib/performance/site-fixes/types/module-binding.js} +0 -0
  968. /package/{lib → dist/lib}/performance/site-fixes/writes.js +0 -0
  969. /package/{lib → dist/lib}/performance/sql/locations.js +0 -0
  970. /package/{lib → dist/lib}/performance/sql/mysql-tokens.js +0 -0
  971. /package/{lib → dist/lib}/performance/sql/pg-parser.js +0 -0
  972. /package/{lib → dist/lib}/performance/types/ast-grep-match.js +0 -0
  973. /package/{lib/performance/types/batched-fix-input.js → dist/lib/performance/types/batch-plan.js} +0 -0
  974. /package/{lib/performance/types/call-site.js → dist/lib/performance/types/batched-fix-input.js} +0 -0
  975. /package/{lib/performance/types/callee-helper.js → dist/lib/performance/types/call-site.js} +0 -0
  976. /package/{lib/performance/types/client-family.js → dist/lib/performance/types/callee-helper.js} +0 -0
  977. /package/{lib/performance/types/collections.js → dist/lib/performance/types/client-family.js} +0 -0
  978. /package/{lib/performance/types/db-cli.js → dist/lib/performance/types/collections.js} +0 -0
  979. /package/{lib → dist/lib}/performance/types/contract-findings.js +0 -0
  980. /package/{lib/performance/types/db-connection.js → dist/lib/performance/types/db-cli.js} +0 -0
  981. /package/{lib/performance/types/db-plan-findings.js → dist/lib/performance/types/db-connection.js} +0 -0
  982. /package/{lib → dist/lib}/performance/types/db-model.js +0 -0
  983. /package/{lib/performance/types/db-snapshot.js → dist/lib/performance/types/db-plan-findings.js} +0 -0
  984. /package/{lib → dist/lib}/performance/types/db-plan.js +0 -0
  985. /package/{lib/performance/types/decorator-call.js → dist/lib/performance/types/db-snapshot.js} +0 -0
  986. /package/{lib → dist/lib}/performance/types/declaration-link.js +0 -0
  987. /package/{lib/performance/types/drizzle-query.js → dist/lib/performance/types/decorator-call.js} +0 -0
  988. /package/{lib/performance/types/helper-function.js → dist/lib/performance/types/drizzle-query.js} +0 -0
  989. /package/{lib → dist/lib}/performance/types/find-lookup-facts.js +0 -0
  990. /package/{lib/performance/types/hoist-anchor.js → dist/lib/performance/types/helper-function.js} +0 -0
  991. /package/{lib/performance/types/http-call.js → dist/lib/performance/types/hoist-anchor.js} +0 -0
  992. /package/{lib/performance/types/lookup-construction.js → dist/lib/performance/types/http-call.js} +0 -0
  993. /package/{lib/performance/types/lookup-placement.js → dist/lib/performance/types/lookup-construction.js} +0 -0
  994. /package/{lib/performance/types/loop-key-site.js → dist/lib/performance/types/lookup-placement.js} +0 -0
  995. /package/{lib/performance/types/loop-lookup.js → dist/lib/performance/types/loop-key-site.js} +0 -0
  996. /package/{lib/performance/types/method-call.js → dist/lib/performance/types/loop-lookup.js} +0 -0
  997. /package/{lib/performance/types/migration-extraction.js → dist/lib/performance/types/method-call.js} +0 -0
  998. /package/{lib/performance/types/migration-files.js → dist/lib/performance/types/migration-extraction.js} +0 -0
  999. /package/{lib/performance/types/migration-operations.js → dist/lib/performance/types/migration-files.js} +0 -0
  1000. /package/{lib/performance/types/migrations.js → dist/lib/performance/types/migration-operations.js} +0 -0
  1001. /package/{lib/performance/types/native-modules.js → dist/lib/performance/types/migrations.js} +0 -0
  1002. /package/{lib → dist/lib}/performance/types/model-fallback.js +0 -0
  1003. /package/{lib → dist/lib}/performance/types/mysql-statements.js +0 -0
  1004. /package/{lib/performance/types/native-typescript.js → dist/lib/performance/types/native-modules.js} +0 -0
  1005. /package/{lib/performance/types/otlp-attributes.js → dist/lib/performance/types/native-typescript.js} +0 -0
  1006. /package/{lib/performance/types/otlp-trace.js → dist/lib/performance/types/otlp-attributes.js} +0 -0
  1007. /package/{lib/performance/types/page-count-pair.js → dist/lib/performance/types/otlp-trace.js} +0 -0
  1008. /package/{lib/performance/types/parallel-reads.js → dist/lib/performance/types/page-count-pair.js} +0 -0
  1009. /package/{lib/performance/types/performance-policy.js → dist/lib/performance/types/parallel-reads.js} +0 -0
  1010. /package/{lib/performance/types/pg-statements.js → dist/lib/performance/types/performance-policy.js} +0 -0
  1011. /package/{lib/performance/types/plain-property.js → dist/lib/performance/types/pg-statements.js} +0 -0
  1012. /package/{lib/performance/types/postgres-registry.js → dist/lib/performance/types/plain-property.js} +0 -0
  1013. /package/{lib/performance/types/prisma-schema.js → dist/lib/performance/types/postgres-registry.js} +0 -0
  1014. /package/{lib/performance/types/program-scan.js → dist/lib/performance/types/prisma-schema.js} +0 -0
  1015. /package/{lib/performance/types/project-indexes.js → dist/lib/performance/types/program-scan.js} +0 -0
  1016. /package/{lib/performance/types/query-loops.js → dist/lib/performance/types/project-indexes.js} +0 -0
  1017. /package/{lib/performance/types/query-site.js → dist/lib/performance/types/query-loops.js} +0 -0
  1018. /package/{lib/performance/types/repeat-owner.js → dist/lib/performance/types/query-site.js} +0 -0
  1019. /package/{lib → dist/lib}/performance/types/related-location.js +0 -0
  1020. /package/{lib/performance/types/request-handler.js → dist/lib/performance/types/repeat-owner.js} +0 -0
  1021. /package/{lib/performance/types/request-input.js → dist/lib/performance/types/request-handler.js} +0 -0
  1022. /package/{lib/performance/types/sibling-declaration.js → dist/lib/performance/types/request-input.js} +0 -0
  1023. /package/{lib → dist/lib}/performance/types/schema-model.js +0 -0
  1024. /package/{lib/performance/types/source-analyzer.js → dist/lib/performance/types/sibling-declaration.js} +0 -0
  1025. /package/{lib/performance/types/source-check-values.js → dist/lib/performance/types/source-analyzer.js} +0 -0
  1026. /package/{lib/performance/types/source-command.js → dist/lib/performance/types/source-check-values.js} +0 -0
  1027. /package/{lib/performance/types/source-scan-values.js → dist/lib/performance/types/source-command.js} +0 -0
  1028. /package/{lib → dist/lib}/performance/types/source-position.js +0 -0
  1029. /package/{lib/performance/types/typeorm-save-shape.js → dist/lib/performance/types/source-scan-values.js} +0 -0
  1030. /package/{lib → dist/lib}/performance/types/statement-range.js +0 -0
  1031. /package/{lib/performance/types/typescript-binder.js → dist/lib/performance/types/typeorm-save-shape.js} +0 -0
  1032. /package/{lib/performance/types/typescript-token-lookup.js → dist/lib/performance/types/typescript-binder.js} +0 -0
  1033. /package/{lib/performance/types/typescript-token-position.js → dist/lib/performance/types/typescript-token-lookup.js} +0 -0
  1034. /package/{lib/security/types/condition-guards.js → dist/lib/performance/types/typescript-token-position.js} +0 -0
  1035. /package/{lib → dist/lib}/reliability/site-fixes/resource-leaks.js +0 -0
  1036. /package/{lib/security/types/file-finding.js → dist/lib/reliability/types/parse-failure.js} +0 -0
  1037. /package/{lib → dist/lib}/reliability/usage.js +0 -0
  1038. /package/{lib → dist/lib}/security/auth-crypto/rule-ids.js +0 -0
  1039. /package/{lib → dist/lib}/security/deps/advisory.js +0 -0
  1040. /package/{lib → dist/lib}/security/deps/rule-ids.js +0 -0
  1041. /package/{lib → dist/lib}/security/examples/auth-crypto.cjs +0 -0
  1042. /package/{lib → dist/lib}/security/examples/deps.cjs +0 -0
  1043. /package/{lib → dist/lib}/security/examples/exposure.cjs +0 -0
  1044. /package/{lib → dist/lib}/security/examples/files.cjs +0 -0
  1045. /package/{lib → dist/lib}/security/examples/moved.cjs +0 -0
  1046. /package/{lib → dist/lib}/security/examples/request-forgery.cjs +0 -0
  1047. /package/{lib → dist/lib}/security/exposure/index.js +0 -0
  1048. /package/{lib → dist/lib}/security/exposure/react-version.js +0 -0
  1049. /package/{lib → dist/lib}/security/exposure/report.js +0 -0
  1050. /package/{lib → dist/lib}/security/exposure/rule-ids.js +0 -0
  1051. /package/{lib → dist/lib}/security/files/compose.js +0 -0
  1052. /package/{lib → dist/lib}/security/files/dockerfile.js +0 -0
  1053. /package/{lib → dist/lib}/security/files/index.js +0 -0
  1054. /package/{lib → dist/lib}/security/files/rule-ids.js +0 -0
  1055. /package/{lib → dist/lib}/security/files/secret-values.js +0 -0
  1056. /package/{lib → dist/lib}/security/injection/regex-pattern.js +0 -0
  1057. /package/{lib → dist/lib}/security/request-forgery/index.js +0 -0
  1058. /package/{lib → dist/lib}/security/request-forgery/rule-ids.js +0 -0
  1059. /package/{lib → dist/lib}/security/site-fixes/backend-security-fixes.js +0 -0
  1060. /package/{lib → dist/lib}/security/site-fixes/error-responses.js +0 -0
  1061. /package/{lib → dist/lib}/security/site-fixes/exposure.js +0 -0
  1062. /package/{lib → dist/lib}/security/site-fixes/files.js +0 -0
  1063. /package/{lib → dist/lib}/security/site-fixes/frontend-security-fixes.js +0 -0
  1064. /package/{lib → dist/lib}/security/site-fixes/list-edits.js +0 -0
  1065. /package/{lib → dist/lib}/security/site-fixes/request-forgery.js +0 -0
  1066. /package/{lib → dist/lib}/security/site-fixes/secret-comparison.js +0 -0
  1067. /package/{lib → dist/lib}/security/site-fixes/template-autoescape.js +0 -0
  1068. /package/{lib/security/types/inspectable-type.js → dist/lib/security/types/condition-guards.js} +0 -0
  1069. /package/{lib/security/types/lockfile.js → dist/lib/security/types/file-finding.js} +0 -0
  1070. /package/{lib/security/types/osv-vulnerability.js → dist/lib/security/types/inspectable-type.js} +0 -0
  1071. /package/{lib/security/types/project-files.js → dist/lib/security/types/lockfile.js} +0 -0
  1072. /package/{lib/security/types/propagation.js → dist/lib/security/types/osv-vulnerability.js} +0 -0
  1073. /package/{lib/security/types/rule-example.js → dist/lib/security/types/project-files.js} +0 -0
  1074. /package/{lib/security/types/schema-call.js → dist/lib/security/types/propagation.js} +0 -0
  1075. /package/{lib/security/types/security-check.js → dist/lib/security/types/rule-example.js} +0 -0
  1076. /package/{lib/shared/types.js → dist/lib/security/types/schema-call.js} +0 -0
  1077. /package/{lib/shared/types/baseline.js → dist/lib/security/types/security-check.js} +0 -0
  1078. /package/{lib/shared → dist/lib/shared/agent}/agent-session.js +0 -0
  1079. /package/{lib/shared → dist/lib/shared/agent}/managed-blocks.js +0 -0
  1080. /package/{lib/shared → dist/lib/shared/agent}/notify-editor.js +0 -0
  1081. /package/{lib/shared → dist/lib/shared/agent}/review-delivery.js +0 -0
  1082. /package/{lib/shared → dist/lib/shared/agent}/review-request.js +0 -0
  1083. /package/{lib/shared → dist/lib/shared/analysis}/hot-path.js +0 -0
  1084. /package/{lib/shared → dist/lib/shared/analysis}/polyglot-compatibility.js +0 -0
  1085. /package/{lib → dist/lib}/shared/explain.js +0 -0
  1086. /package/{lib/shared → dist/lib/shared/fix}/fix-imports.js +0 -0
  1087. /package/{lib/shared → dist/lib/shared/fix}/fix-presentation-prettier.js +0 -0
  1088. /package/{lib/shared → dist/lib/shared/fix}/fix-presentation-rows.js +0 -0
  1089. /package/{lib/shared → dist/lib/shared/fix}/fix-safety.js +0 -0
  1090. /package/{lib/shared → dist/lib/shared/fix}/fix-terminal.js +0 -0
  1091. /package/{lib → dist/lib}/shared/formats/contract-rules.js +0 -0
  1092. /package/{lib → dist/lib}/shared/formats/github.js +0 -0
  1093. /package/{lib → dist/lib}/shared/formats/index.js +0 -0
  1094. /package/{lib → dist/lib}/shared/project-root.js +0 -0
  1095. /package/{lib/shared → dist/lib/shared/reporting}/baseline-flags.js +0 -0
  1096. /package/{lib/shared → dist/lib/shared/reporting}/reason-groups.js +0 -0
  1097. /package/{lib → dist/lib}/shared/rule-registry.js +0 -0
  1098. /package/{lib/shared → dist/lib/shared/system}/build-output.js +0 -0
  1099. /package/{lib/shared → dist/lib/shared/system}/error-code.js +0 -0
  1100. /package/{lib/shared → dist/lib/shared/system}/git-paths.js +0 -0
  1101. /package/{lib/shared → dist/lib/shared/system}/glob.js +0 -0
  1102. /package/{lib/shared → dist/lib/shared/system}/heap-limit.js +0 -0
  1103. /package/{lib/shared → dist/lib/shared/system}/is-record.js +0 -0
  1104. /package/{lib/shared → dist/lib/shared/system}/real-target.js +0 -0
  1105. /package/{lib/shared → dist/lib/shared/system}/shell-argument.js +0 -0
  1106. /package/{lib/shared/types/cli-finding.js → dist/lib/shared/types/baseline.js} +0 -0
  1107. /package/{lib/shared/types/fix-hunks.js → dist/lib/shared/types/checker-run.js} +0 -0
  1108. /package/{lib/shared/types/fix-presentation.js → dist/lib/shared/types/fix-hunks.js} +0 -0
  1109. /package/{lib/shared/types/fix-run.js → dist/lib/shared/types/fix-presentation.js} +0 -0
  1110. /package/{lib/shared/types/function-summaries.js → dist/lib/shared/types/fix-run.js} +0 -0
  1111. /package/{lib/shared/types/managed-blocks.js → dist/lib/shared/types/function-summaries.js} +0 -0
  1112. /package/{lib/shared/types/pillar-name.js → dist/lib/shared/types/managed-blocks.js} +0 -0
  1113. /package/{lib/shared/types/report-formats.js → dist/lib/shared/types/pillar-name.js} +0 -0
  1114. /package/{lib/shared/types/review-event.js → dist/lib/shared/types/report-formats.js} +0 -0
  1115. /package/{lib/shared/types/review-history.js → dist/lib/shared/types/review-event.js} +0 -0
  1116. /package/{lib/shared/types/settings.js → dist/lib/shared/types/review-history.js} +0 -0
  1117. /package/{lib/shared/types/source-report.js → dist/lib/shared/types/settings.js} +0 -0
  1118. /package/{lib/shared/types/typescript-assignment-target.js → dist/lib/shared/types/source-report.js} +0 -0
  1119. /package/{lib/shared/types/typescript-internals.js → dist/lib/shared/types/typescript-assignment-target.js} +0 -0
  1120. /package/{lib/shared/types/typescript-module-resolution.js → dist/lib/shared/types/typescript-internals.js} +0 -0
  1121. /package/{lib/shared/types/typescript-outer-expression.js → dist/lib/shared/types/typescript-module-resolution.js} +0 -0
  1122. /package/{lib/shared/types/checker-run.js → dist/lib/shared/types.js} +0 -0
package/README.md CHANGED
@@ -2,31 +2,32 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/loadwise)](https://www.npmjs.com/package/loadwise) [![check](https://github.com/IbrahimHafez1/loadwise/actions/workflows/check.yml/badge.svg)](https://github.com/IbrahimHafez1/loadwise/actions/workflows/check.yml) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/IbrahimHafez1/loadwise/badge)](https://scorecard.dev/viewer/?uri=github.com/IbrahimHafez1/loadwise) [![license](https://img.shields.io/npm/l/loadwise?cacheSeconds=3600)](LICENSE)
4
4
 
5
- Loadwise checks a backend project before it ships. One CLI runs five checkers:
5
+ **[npm package](https://www.npmjs.com/package/loadwise)** · **[Documentation](https://loadwise.mintlify.app/)** · **[Sponsor](https://github.com/sponsors/IbrahimHafez1)**
6
6
 
7
- - **Performance** (`loadwise perf`): repeated database work, ORM and query integrity, blocking calls, collection complexity, schema-aware indexes, OpenTelemetry traces, executed query plans and an optional read-only database inspection.
8
- - **Reliability** (`loadwise rel`): unhandled rejections and swallowed errors, races and transaction-client escapes, missing timeouts and idempotency keys, migration safety and breaking API changes.
7
+ Loadwise checks a TypeScript or JavaScript project before it ships. Its deepest coverage is backend and database code, and it also checks React, Next.js, Vue and Angular frontends. One CLI runs five checkers:
8
+
9
+ - **Performance** (`loadwise perf`): repeated database work, ORM and query integrity, blocking calls, collection complexity, React, Vue and Angular rendering and cleanup work, schema-aware indexes, OpenTelemetry traces, executed query plans and an optional read-only database inspection.
10
+ - **Reliability** (`loadwise rel`): unhandled rejections and swallowed errors, races and transaction-client escapes, missing timeouts and idempotency keys, React effect and state bugs, migration safety and breaking API changes.
9
11
  - **Maintainability** (`loadwise maint`): deep nesting, branch complexity, duplicate implementations, dependency cycles and the folder, placement and data-access rules a team declares.
10
- - **Security** (`loadwise sec`): request data reaching sensitive operations, authentication and cryptography, exposed credentials, Docker and Compose configuration, declared row scopes, and optionally dependency advisories.
12
+ - **Security** (`loadwise sec`): request data reaching sensitive operations, authentication and cryptography, exposed credentials including secrets bundled into client code, unsafe HTML in JSX, Vue and Angular, `javascript:` URLs in JSX, Docker and Compose configuration, declared row scopes, and optionally dependency advisories.
11
13
  - **Accessibility** (`loadwise a11y`): images without alt text, unlabelled form controls, click handlers on non-interactive elements, invalid ARIA and missing page language in JSX, HTML, Vue, Svelte and Angular templates. Skipped on projects without frontend sources.
12
14
 
13
- Each finding has a stable `#id` for review. Where a checker can generate an edit, it shows the diff and any assumptions to verify. Supported source rules accept a `loadwise-reviewed` comment with a reason for intentional code.
15
+ Each finding has a stable `#id` for review. Where a checker can generate an edit, it shows the diff and any assumptions to verify. Supported source rules accept a `loadwise-reviewed` comment with a reason for intentional code. Every rule has its own page under [docs/rules](docs/rules/), linked from the rule tables below.
14
16
 
15
17
  > **Pre-1.0.** Loadwise is under active development. Until 1.0, rule ids, CLI flags, the JSON report and the config schema can change in a minor release. Every such change is listed in the [changelog](CHANGELOG.md), and a moved or renamed rule keeps accepting its old id where possible. False-positive reports are the most useful feedback: [open one](https://github.com/IbrahimHafez1/loadwise/issues/new?template=false-positive.yml).
16
18
 
17
19
  ## Install
18
20
 
19
- Use Node.js 22 or later. Run directly with `npx` or install as a devDependency:
21
+ Use Node.js 22 or later. From the project root, install Loadwise from npm and run a check.
20
22
 
21
23
  ```sh
22
- npx loadwise check
23
-
24
- # or install in your project:
25
24
  npm install --save-dev loadwise
26
- npx loadwise --version
25
+ npx loadwise check
27
26
  ```
28
27
 
29
- By default `loadwise check` reports actionable findings across Performance, Reliability, Maintainability, Security, and Accessibility; see the [corpus rule scorecard](bench/corpus/scorecard.md) for measured precision and recall across real-world open-source backends.
28
+ For a one-off scan, run `npx loadwise check` without adding a project dependency. Run `npx loadwise --version` to check the installed version. [Editor integration](docs/editor.mdx#set-up-a-custom-stdio-lsp-client) is optional.
29
+
30
+ By default `loadwise check` runs all five checkers; see the [corpus rule scorecard](bench/corpus/scorecard.md) for measured precision and recall across real-world open-source backends.
30
31
 
31
32
  **Autofix example:** `npx loadwise fix --yes` rewrites eligible issues in place and verifies TypeScript projects with a post-edit typecheck:
32
33
 
@@ -38,11 +39,9 @@ By default `loadwise check` reports actionable findings across Performance, Reli
38
39
 
39
40
  **With an AI coding agent**, say **“Run Loadwise”** in your project chat. The agent can run the installed CLI directly. It should check the findings against the code, explain what it would fix or leave alone and why, and let you choose before making edits. [Active-agent workflow and optional MCP setup](#using-loadwise-with-an-active-coding-agent)
40
41
 
41
- **Working manually**, run `npx loadwise check` to see recommendations or `npx loadwise fix --yes` to apply eligible fixes. In any editor with a language server client, `loadwise lsp` shows findings as diagnostics with hovers and fixes. [Editor setup](#editor-language-server)
42
-
43
42
  ### Try a finding and a fix
44
43
 
45
- From the directory where you installed Loadwise, copy the bundled example to a disposable file and scan it. The copy command refuses to overwrite an existing file.
44
+ From a project where you ran `npm install --save-dev loadwise`, copy the bundled example to a disposable file and scan it. The copy command refuses to overwrite an existing file.
46
45
 
47
46
  ```sh
48
47
  node -e "require('node:fs').copyFileSync('node_modules/loadwise/examples/slow.ts', 'loadwise-demo.ts', require('node:fs').constants.COPYFILE_EXCL)"
@@ -75,48 +74,47 @@ The second scan should report two findings. Remove the disposable copy when fini
75
74
  | `loadwise fix --yes` | Scans the current project once and applies eligible edits across the configured checkers. |
76
75
  | `loadwise agent init [--mode ask\|auto] [--hook [block\|warn\|off]]` | Writes project instructions for coding agents. Use `--hook` to configure a pre-commit hook. |
77
76
 
78
- `loadwise check` reuses the previous result for an unchanged Git project from the `loadwise` folder of the OS cache directory. Any edit to a tracked or untracked (not ignored) file, a package install that rewrites `node_modules`, a different flag or a new Loadwise version runs a fresh scan; `LOADWISE_NO_CACHE=1` always scans afresh. Fixes, `--staged`, `--changed-since`, `--online` and `--write-baseline` runs are never cached.
79
-
80
- Choose the checkers by name, separated by spaces. With no names, Loadwise uses the project's configured checkers.
81
-
82
- ```bash
83
- npx loadwise fix --all # all generated edits, including review suggestions
84
- npx loadwise fix --all performance # performance only
85
- npx loadwise fix --all performance security # performance and security
86
- npx loadwise fix --all reliability # reliability only
87
- npx loadwise fix --all accessibility # accessibility only
88
- npx loadwise fix --yes maintainability # automatic maintainability edits only
89
- ```
77
+ `check` accepts these flags and passes them to every selected checker:
90
78
 
91
- Manual findings have no generated edit. With `--all`, inspect the resulting diff and run the project's tests, especially for schema changes and edits that alter application behavior.
79
+ - `--json` prints one object with a key per selected checker, `{ "performance": report, "reliability": report, "maintainability": report, "security": report, "accessibility": report }`. A checker that was skipped or could not run has `null`.
80
+ - `--format text|json|sarif|github` picks the output; `--json` is `--format json`. `sarif` prints SARIF 2.1.0 with one run per checker for GitHub code scanning, and `github` prints `::warning`/`::error`/`::notice` workflow annotations. The checker commands accept it too. Exit codes do not depend on the format.
81
+ - `--include-contextual` also shows lower-priority findings (one-off blocking calls in CLI startup, test and seed sources and similar), each with its reason. JSON counts the hidden ones in `contextualFindingCount`; in the expanded view they appear in `findings` with a `contextualReason`.
82
+ - `--staged` or `--changed-since <git-ref>` reports only findings on changed lines (see [Changed lines](#changed-lines)).
83
+ - `--fail-on contract|all` sets the exit threshold. By default, performance, reliability, security and accessibility fail on displayed findings, and a full maintainability scan fails on contract violations. Changed-line maintainability scans fail on any displayed finding. Configured rule levels can change these defaults.
84
+ - `--min-impact <low|medium|high|critical>` reports only findings at that level or above (see [Impact levels](#impact-levels)).
85
+ - `--config <file>`, `--ignore <rule-id>` and `--workspace <name|path>` are described under [Configuration](#configuration); `--online` adds the [dependency checks](#dependency-checks).
86
+ - `--write-baseline [file]` records the current findings and `--baseline [file]` reports only findings not recorded. The default file is `loadwise-baseline.json` in the checked directory, with one section per checker; the checker commands take the same flags and read or write only their own section. Entries match on rule, file and flagged code, with a count per entry so N recorded copies allow N findings. Refreshed JavaScript and TypeScript baselines also match after spacing changes and removal of optional statement-ending semicolons. Text output ends with `N baseline findings hidden.` and `--json` adds `baselineHidden`. A full comparison reports unmatched entries in `baselineStale`; a partial one, such as a changed-line or single-file scan, reports `null`. Refresh the baseline using its original scope and settings. Not combinable with `--fix`, and `--write-baseline` not with `--staged` or `--changed-since`. `loadwise rel migrations` keeps its own baseline.
92
87
 
93
- Each applied fix in a JavaScript or TypeScript file gets a `// Loadwise <rule-id>: <why>` comment above the fixed statement, and the changed lines are formatted with the project's own Prettier, honouring its config and `.prettierignore`; the rest of the file stays byte-identical. Without Prettier in the project the edits are written as generated, with a note. `--no-comments` and `--no-format` turn these off; the per-checker `--fix` takes the same flags. `loadwise fix` also supports `--dry-run` (preview unified diffs without writing), repeatable `--rule <rule-id>` filtering, and `--no-verify-types` (skip Layer-2 semantic type checking on TypeScript projects).
88
+ **Exit codes:** **0** passed, **1** a checker met its exit threshold, **2** invalid input or configuration in any checker, a checker that produced no result, or a scan that skipped a file. A JavaScript or TypeScript file that does not parse, or whose analysis fails, is skipped while every other file is still reported; it is named on stderr and in a `skippedFiles` array of `{ file, reason }` in `--json` output (also with `--fix` and `--write-baseline`). `check` keeps that checker's findings, marks its SARIF run as not successful and emits a GitHub warning for each skipped file. A file that exists but cannot be read (the schema snapshot, `package.json`, a review directive) prints a note on stderr; an absent file stays silent.
94
89
 
95
- ### Project-specific fixes
90
+ **Projects and workspaces.** The source checkers use the directory's `tsconfig.json` or `jsconfig.json`. Without one, `check` looks for workspace packages (`package.json` `workspaces`, `pnpm-workspace.yaml` or `lerna.json`) and checks each one's config in one report, grouped per package. A package with a `package.json` and no config has its JavaScript and TypeScript sources inferred from the project inventory and checked with ES2022 and NodeNext defaults; a package whose TypeScript sits under a sub-folder's own `tsconfig.json` still needs a config at its root. When performance and reliability are selected together, they share a type-check unless a baseline is being written. Source scans are read-only; when fixes are available, text reports include a `Fix all:` command such as `npx loadwise perf -p tsconfig.json --fix --only <ids>`.
96
91
 
97
- The default `fix --yes` can simplify nested conditions that choose the same status string. It preserves evaluation order and short-circuiting. Two other transformations need individual review: making a locally used constant private can affect consumers outside the scan, and sharing a private helper between sibling TypeScript modules changes the files included in the build. Inspect those diffs before applying them by finding ID.
92
+ **Cache.** `loadwise check` reuses the previous result for an unchanged Git project from the `loadwise` folder of the OS cache directory. Any edit to a tracked or untracked (not ignored) file, a package install that rewrites `node_modules`, a different flag or a new Loadwise version runs a fresh scan; `LOADWISE_NO_CACHE=1` always scans afresh. Fixes, `--staged`, `--changed-since`, `--online` and `--write-baseline` runs are never cached.
98
93
 
99
- The unused-module check considers literal Node commands in operator documentation and corroborated container entry points. Running a script establishes that the file is used; its unused exports can still be reported. The performance checker also recognizes supported Drizzle helpers that already receive a batch of keys.
94
+ **Memory.** On large projects the checkers run with a larger Node memory limit, 60% of the machine's memory, at least 4096 MB and at most 16384 MB (never below Node's own default). A `--max-old-space-size` you set in `NODE_OPTIONS` is never overridden. Direct `loadwise perf`, `loadwise sec` and `loadwise maint` runs re-launch once to apply the limit. If a checker still runs out of memory, `check` names it and the limit it had, tells you to raise it with `NODE_OPTIONS=--max-old-space-size=<megabytes>`, and exits 2. The native engine (`--engine native`) uses much less memory on most projects.
100
95
 
101
- For private TypeScript applications that control their consumers, Loadwise includes a compiler-backed recipe for unused type exports:
96
+ ### Fixes
102
97
 
103
98
  ```bash
104
- npx loadwise fix --all --recipe verified-private-types
99
+ npx loadwise fix --yes # automatic edits for the configured checkers
100
+ npx loadwise fix --all # all generated edits, including review suggestions
101
+ npx loadwise fix --all performance security # only the named checkers
102
+ npx loadwise fix --yes maintainability --dry-run # preview unified diffs without writing
105
103
  ```
106
104
 
107
- This applies the usual generated fixes and also considers making locally used type declarations private. It checks the proposed type edits against the application with the bundled TypeScript compiler before offering them. The extra compilation takes time, and can verify only consumers included in the project. Omit this recipe when other repositories import your types.
105
+ Checker names (`performance`, `reliability`, `maintainability`, `security`, `accessibility`) are separated by spaces; with none, Loadwise uses the project's configured checkers. `fix` lists manual changes and findings that need individual review by location and ID; a fix that touches lines reserved for review also needs individual review. Loadwise checks the remaining edits together before writing, and performance and security share a type-check when both are selected. It exits 2 if a selected checker fails or is skipped, source lines have changed, or automatic fixes conflict, and 0 on success even when manual findings remain. Manual findings have no generated edit; with `--all`, inspect the diff and run your tests, especially for schema changes and edits that alter behavior. `--json` with `--yes` or `--all` records the applied hunks and outstanding findings.
108
106
 
109
- If your project has a policy for a manual finding, you can encode it once in a local CommonJS recipe and share the file with your team. Run it alongside the built-in fixes for the selected checkers:
107
+ Each applied fix in a JavaScript or TypeScript file gets a `// Loadwise <rule-id>: <why>` comment above the fixed statement, and the changed lines are formatted with the project's own Prettier, honouring its config and `.prettierignore`; the rest of the file stays byte-identical. Without Prettier the edits are written as generated, with a note. `--no-comments` and `--no-format` turn these off, also on the per-checker `--fix`. `fix` also takes repeatable `--rule <rule-id>` filtering and `--no-verify-types` (skip the post-edit TypeScript check).
110
108
 
111
- ```bash
112
- npx loadwise fix --all maintainability --recipe ./loadwise-fixes.cjs
113
- ```
109
+ Maintainability `--fix` limits edits to the checked project. Performance, reliability, security, and accessibility `--fix` use the containing Git repositories of the checked projects or explicitly named source files, so fixes can include shared files such as a schema at a monorepo root. Outside a Git repository, they use the project root. Per-checker fixes refuse hard-linked files and symbolic links that are dangling or resolve outside those limits. Existing files keep their permissions when replaced.
114
110
 
115
- For example, suppose a failed cache refresh in one maintenance script must fail the job. This recipe handles an empty catch at that specific site:
111
+ Some transformations always need individual review: making a locally used constant private can affect consumers outside the scan; sharing a private helper between sibling TypeScript modules changes the files included in the build; narrowing a whole-table Drizzle update to rows with differing values can affect locking, triggers and affected-row counts; an upload size limit (the 10 MiB example can reject valid uploads, so check existing gateway or Multer limits); and the Mongoose `.lean()` rewrite, because a lean result skips schema defaults, getters and virtuals. For private TypeScript applications that control their consumers, `npx loadwise fix --all --recipe verified-private-types` also makes locally used type declarations private, after checking the edits with the bundled TypeScript compiler; omit it when other repositories import your types.
112
+
113
+ A local CommonJS recipe encodes your own policy for a manual finding, run alongside the built-in fixes with `npx loadwise fix --all reliability --recipe ./loadwise-fixes.cjs`:
116
114
 
117
115
  ```js
118
116
  module.exports = {
119
- 'maint/swallowed-error'({ finding, source }) {
117
+ 'rel/swallowed-error'({ finding, source }) {
120
118
  if (finding.file !== 'scripts/refresh-cache.ts') return null;
121
119
  const before = source.split(/\r?\n/)[finding.line - 1];
122
120
  if (before?.trim() !== '} catch {}') return null;
@@ -129,26 +127,30 @@ module.exports = {
129
127
  };
130
128
  ```
131
129
 
132
- Keys use `perf`, `rel`, `maint`, `sec`, or `a11y` followed by the rule ID from the report. A handler receives the finding and the source file text. Return exact, whole-line replacements in that file or return `null` to leave the site manual. Loadwise tries recipes only where it has no built-in fix. It validates the proposed edits together before writing. Recipe files execute as local JavaScript, so run only recipes you trust and keep handlers free of side effects.
130
+ Keys are `perf`, `rel`, `maint`, `sec` or `a11y` followed by `/` and the rule ID. A handler receives the finding and the source file text and returns exact, whole-line replacements in that file, or `null` to leave the site manual. Recipes run only where there is no built-in fix, and their edits are validated together before writing. Recipe files execute as local JavaScript, so run only recipes you trust and keep handlers free of side effects.
133
131
 
134
- To apply automatic fixes across your project, run `npx loadwise fix --yes` from its root. Performance and security share a type-check when both are selected. The command lists manual changes and findings that need individual review by location and ID. A fix that touches lines reserved for review also requires individual review. Loadwise checks the remaining edits together before writing and exits 2 if a selected checker fails or is skipped, source lines have changed, or automatic fixes conflict. A successful application exits 0 even when manual findings remain. Review the diff, run your tests, and use `npx loadwise check` to see what remains.
132
+ ### Per-checker fixes and dismissals
135
133
 
136
- `check` accepts these flags and passes them to every selected checker:
134
+ The source-check commands (`perf`, `rel`, `maint`, `sec` and `a11y` on a project or files, not subcommands such as `perf traces`, `rel migrations` or `sec deps`) take `--fix` (asks **y**es, **n**o, **a**ll remaining or **q**uit for each fix; needs a terminal), `--fix --yes` (applies eligible fixes without asking) and `--fix --only <id>[,<id>...]` (applies exactly those fixes, no prompt or terminal needed). With `--json`, `--only` prints `{ applied, alreadyApplied, failed }`: an id whose change an earlier id already made, such as a shared `Set`, is in `alreadyApplied`; an unknown id, a finding without a fix or a stale fix is in `failed` and the exit code is 2. `--fix` cannot be combined with `--watch` or `--graph`, or with `--json` except with `--only`, and `--yes` is valid only with `--fix`. A fix applies only where the original lines still exist and never overwrites an existing file. With `--json`, a fix is `fix = { changes: [{ file, line, before, after, create? }], note? }`, where `create` holds a whole new file such as a migration; findings also carry `fixable`. The id hashes the rule, the file and the flagged line's text, so it survives edits above the finding. If identical findings occur in differently named JavaScript or TypeScript declarations, the ids also hash those names. Remaining collisions receive numbered suffixes.
137
135
 
138
- - `--json` prints one object with a key per selected checker, `{ "performance": report, "reliability": report, "maintainability": report, "security": report, "accessibility": report }`. A checker that was skipped or could not run has `null`.
139
- - `--format text|json|sarif|github` picks the output; `--json` is `--format json`. `sarif` prints SARIF 2.1.0 with one run per checker for GitHub code scanning, and `github` prints `::warning`/`::error`/`::notice` workflow annotations. `loadwise perf`, `loadwise rel`, `loadwise maint`, `loadwise sec` and `loadwise a11y` accept it too. Exit codes do not depend on the format.
140
- - `--include-contextual` also shows lower-priority findings, each with its reason.
141
- - `--staged` or `--changed-since <git-ref>` reports only findings on changed lines.
142
- - `--fail-on contract|all` sets the exit threshold. By default, performance, reliability, security and accessibility fail on displayed findings, and a full maintainability scan fails on contract violations. Changed-line maintainability scans fail on any displayed finding. Configured rule levels can change these defaults.
143
- - `--write-baseline [file]` records the current findings and `--baseline [file]` reports only findings not recorded. The default file is `loadwise-baseline.json` in the checked directory, with one section per checker; `loadwise perf`, `loadwise rel`, `loadwise maint`, `loadwise sec` and `loadwise a11y` take the same flags and read or write only their own section. Entries match on rule, file and flagged code (the finding id), never the line number, with a count per entry so N recorded copies allow N findings. Text output ends with `N baseline findings hidden.` and `--json` adds `baselineHidden`. A full comparison reports the number of unmatched entries in `baselineStale`. A partial comparison, such as a changed-line or single-file scan, reports `null` because unscanned findings may still exist. Refresh the baseline using its original scope and settings. Not combinable with `--fix`, and `--write-baseline` not with `--staged` or `--changed-since`. `loadwise rel migrations` keeps its own per-file baseline.
136
+ To keep an intentional site, put a comment on its own line immediately before the diagnostic line (line 1 for a whole-file finding such as `large-module`), naming one exact rule and a reason. The comment makes every eligible finding of that rule on the diagnostic line contextual, including findings introduced by later edits to that line. Use `--include-contextual` to see those findings. Declared contracts (CI contract rules, `file-placement`, `folder-boundary`, `data-access-boundary`, `query-mutates-state`, configured row scopes) and Prisma transaction-client escapes and read-modify-write findings cannot be lowered this way.
144
137
 
145
- The performance, reliability, security and accessibility checkers use the directory's `tsconfig.json` or `jsconfig.json`; without one, `check` looks for workspace packages (`package.json` `workspaces`, `pnpm-workspace.yaml` or `lerna.json`) and checks each one's config in one report, grouped per package (a package without a config is checked with the standalone defaults below); `--workspace <name|path>` (repeatable) limits every checker to some packages. For a package with a `package.json` and no config, `check` and `fix` infer its JavaScript and TypeScript source files from the project inventory without writing a config, and check them with ES2022 and NodeNext defaults. A package whose TypeScript sits under a sub-folder's own `tsconfig.json` still needs a config at its root, since those defaults would miss that config's settings. For a JavaScript file without a project config, use `npx loadwise perf path/to/file.js` and `npx loadwise sec path/to/file.js`. For Python, Go, Java, C# or Rust performance checks, run `npx loadwise perf polyglot src` explicitly, and `npx loadwise rel polyglot src` for the reliability patterns. The security checker can still scan Dockerfiles, Compose files and tracked environment files. When performance and reliability are selected together, they share a type-check unless a baseline is being written. Source scans are read-only. When fixes are available, text reports include a `Fix all:` command, such as `npx loadwise perf -p tsconfig.json --fix --only <ids>`, that applies its fixes.
138
+ ```ts
139
+ // loadwise-reviewed pg-query-in-loop -- Each iteration measures a separate query-plan sample.
140
+ await client.query(statement);
141
+ ```
146
142
 
147
- Exit codes: **0** passed, **1** a checker met its exit threshold, **2** invalid input or configuration in any checker, or a scan that skipped a file (see below).
143
+ ### Changed lines
144
+
145
+ ```sh
146
+ npx loadwise perf --staged # lines added or modified in the git index
147
+ npx loadwise perf --changed-since origin/main # lines changed in the working tree since a ref
148
+ npx loadwise maint --staged .
149
+ ```
148
150
 
149
- A scan skips a JavaScript or TypeScript file that does not parse, or whose analysis fails, and still reports the findings of every other file. Each skipped file is named in a note on stderr and in a `skippedFiles` array of `{ file, reason }` in `--json` output, and the run exits 2, also with `--fix` and `--write-baseline`. A file that exists but cannot be read (the schema snapshot, `package.json`, a review directive) prints a note on stderr; an absent file stays silent.
151
+ These report only findings on changed lines, each with its id, the exact `--fix --only <id>` command when an automatic fix exists, and the `loadwise-reviewed` comment that dismisses it. `--json` keeps the usual shape, filtered, and the exit code is 1 when findings remain. With no changed supported source files the command exits 0 before TypeScript loads. Only the changed files are analysed as roots while imports still resolve through the project; untracked files count as fully changed with `--changed-since`, and a file with unstaged edits can report lines that differ from the staged version. `schema.prisma` findings are not part of this mode. The flags cannot be combined with explicit files, `--watch` or `--fix`.
150
152
 
151
- On large projects the checkers run with a larger Node memory limit, 60% of the machine's memory, at least 4096 MB and at most 16384 MB (never below Node's own default). A `--max-old-space-size` you set in `NODE_OPTIONS` is never overridden. Direct `loadwise perf`, `loadwise sec` and `loadwise maint` runs re-launch once to apply the limit. If a checker still runs out of memory, `check` prints one line naming it and the limit it had, tells you to raise it with `NODE_OPTIONS=--max-old-space-size=<megabytes>`, and exits 2. When a checker exits 2 because it skipped files, `check` keeps its findings and `skippedFiles` in `--json` output, marks its SARIF run as not successful and emits a GitHub warning for each skipped file. A checker that produced no result is named on stderr and `check` exits 2. The native engine (`--engine native`) uses much less memory on most projects; [PERFORMANCE.md](PERFORMANCE.md) has the measurements.
153
+ For maintainability, a JS/TS function-level finding (`high-branch-complexity`, `deep-control-flow`) is kept when a changed line falls anywhere inside its function, and `--fail-on` defaults to `all`. When at least 600 files changed, the full scan runs and is filtered to the changed lines; otherwise `duplicate-implementation` is skipped and `dependency-cycle` only sees cycles made of the changed files' imports.
152
154
 
153
155
  ## Configuration
154
156
 
@@ -177,12 +179,22 @@ One optional file, `loadwise.config.json`, sets the defaults for every checker.
177
179
 
178
180
  - `checkers` is the default selection for `loadwise check`; `--only` and `--skip` override it.
179
181
  - `ignore` lists globs, relative to the config file, that no checker scans or reports on; they leave the scan itself, so they cost no time and never count toward duplicates, cycles or architecture. `*` matches within a folder, `**` any depth, `?` one character and `{a,b}` alternatives; naming a folder covers everything below it.
180
- - `rules` sets each rule to `"off"` (its findings are dropped), `"warn"` (reported, but never changes the exit code) or `"error"` (reported findings always count, even under `--fail-on contract`). A hidden contextual finding is not reported, so it never counts. The object form `{ "level": "warn" }` is accepted for future rule options; no rule has options yet.
182
+ - `rules` sets each rule to `"off"` (its findings are dropped), `"warn"` (reported, but never changes the exit code) or `"error"` (reported findings always count, even under `--fail-on contract`). A hidden contextual finding is not reported, so it never counts. The object form `{ "level": "warn", "options": { ... } }` sets thresholds for rules that take them, such as `maxDepth` or `maxComplexity`; the [config schema](schema/loadwise.config.schema.json) lists each rule's options, and an unknown option exits with code 2.
181
183
  - `overrides` apply `rules` to the files matching `files`; a later override wins over an earlier one and over `rules`.
182
184
  - `performance` holds the query policy (see [Project-defined access policy](#project-defined-access-policy)), and `maintainability` holds the maintainability policy (see [Project rules](#project-rules)). `--policy file.json` and `--config file.json` name a policy file for one run and beat the config sections.
183
- - `--ignore <rule-id>` (repeatable, on `check`, `perf`, `rel` and `maint`) adds a rule to `"off"` for one run and beats the config.
185
+ - `--ignore <rule-id>` (repeatable, on `check` and every checker) adds a rule to `"off"` for one run and beats the config.
186
+ - `--workspace <name|path>` (repeatable) limits every checker to some workspace packages.
187
+
188
+ An unknown key or rule id, a wrong level or a malformed section exits with code 2 and lists each problem. Rule ids come from the registered checkers, so a rule id that no checker has yet is rejected. The config applies to source checks and the `polyglot` commands. `rel contracts` reads `loadwise.config.json` in the current directory, or the file named by `--loadwise-config <file>`, and applies `ignore` and the rule levels in `rules` and `overrides`. An ignored file can still supply inherited properties when an included NestJS DTO extends a class from that file. In that case, any finding points to the included DTO. `rel migrations`, `perf db`, `perf traces` and `perf plan` do not read the config.
189
+
190
+ ## Impact levels
184
191
 
185
- An unknown key or rule id, a wrong level or a malformed section exits with code 2 and lists each problem. Rule ids come from the registered checkers, so a rule id that no checker has yet is rejected. The config applies to source checks and the `polyglot` commands; `rel migrations`, `rel contracts`, `perf db`, `perf traces` and `perf plan` do not read it.
192
+ Every finding carries an impact level, shown after the rule in text output, where the most severe finding comes first within each file. JSON findings carry it as `impactLevel` (`impact` is the before/after estimate). `--min-impact <low|medium|high|critical>` reports only findings at that level or above, and the filtered ones do not count toward the exit code; an unknown level exits 2. The rule tables list each rule's default level, and dependency findings use the advisory severity.
193
+
194
+ - `critical`: data loss or corruption, an outage or a lock risk in production.
195
+ - `high`: a per-request scaling problem such as an N+1 or query in a loop, a deep offset, a missing foreign-key or filter index, an HTTP call without a timeout, or a dependency cycle with load-time effects.
196
+ - `medium`: a measurable but local cost, or significant maintainability debt.
197
+ - `low`: a micro-optimization or a readability issue.
186
198
 
187
199
  ## GitHub Action
188
200
 
@@ -220,52 +232,32 @@ The action installs its locked runtime dependencies in a runner temporary direct
220
232
 
221
233
  ## Use with AI coding agents
222
234
 
223
- Ask your coding agent to run Loadwise. On its first check or fix, the CLI gives a recognized agent the review workflow on stderr. A check lets the agent inspect every scoped finding, earlier edit, caller and test. A fix request also lets it apply or adapt justified changes. The agent can read the full workflow with `loadwise agent instructions`. The first run works in a fresh checkout and leaves project instruction files and Git hooks alone.
235
+ Ask your coding agent to run Loadwise. On its first check or fix, the CLI gives a recognized agent the review workflow on stderr: a check lets the agent inspect every scoped finding, earlier edit, caller and test, and a fix request also lets it apply or adapt justified changes. The agent can read the full workflow with `loadwise agent instructions`. The first run works in a fresh checkout and leaves project instruction files and Git hooks alone.
224
236
 
225
237
  Loadwise recognizes agent shell markers from Codex, Claude Code, Cursor, Gemini CLI and GitHub Copilot, as well as tools that identify themselves with `AI_AGENT`. An integration that supplies no marker can set `LOADWISE_AGENT=1` in its tool subprocess. Set `LOADWISE_AGENT=0` on a command to disable detection. Commands typed in plain Git Bash or an ordinary IDE terminal run normally. A shell opened inside an agent can inherit its markers.
226
238
 
227
- Agent-run CLI fixes save their actual edited hunks locally from the first fix. For earlier fixes and saved review decisions, run `loadwise agent history` from the checked project, optionally with a checker name such as `maintainability` or `reliability`. History stays under the user's local state directory and can include excerpts of project source. For unrecorded edits, including edits made on another machine, use an earlier report or a known diff.
228
-
229
- For persistent project instructions, or to have a future agent review fixes you run manually in a terminal, use the optional setup command. It updates the managed section of `AGENTS.md`, imports it from `CLAUDE.md` and enables history for manual CLI fixes too.
239
+ For persistent project instructions, or to have a future agent review fixes you run manually in a terminal, run `npx loadwise agent init`. It updates the managed section of `AGENTS.md`, imports it from `CLAUDE.md` and enables history for manual CLI fixes too.
230
240
 
231
- ```sh
232
- npx loadwise agent init
233
- ```
241
+ Agent-run CLI fixes save their actual edited hunks locally from the first fix. For earlier fixes and saved review decisions, run `loadwise agent history` from the checked project, optionally with a checker name such as `maintainability`. History stays under the user's local state directory and can include excerpts of project source. For unrecorded edits, including edits made on another machine, use an earlier report or a known diff.
234
242
 
235
- Agents use the original scan, the relevant history and the rescan to check that every finding has a disposition. The outcomes file is an object with an `outcomes` array. Each entry supplies `checker`, `id`, `status` and specific `evidence`. Supported statuses are `fixed`, `verified`, `intentional`, `false-positive` and `deferred`. For a narrower request, provide only the authorized findings in those reports. With a local Loadwise installation, the commands below run from the project root; put report files in a local scratch directory.
243
+ Agents check that every finding has a disposition with the original scan, the relevant history and the rescan. The outcomes file is an object with an `outcomes` array whose entries supply `checker`, `id`, `status` (`fixed`, `verified`, `intentional`, `false-positive` or `deferred`) and specific `evidence`. For a narrower request, provide only the authorized findings in those reports; put report files in a local scratch directory.
236
244
 
237
245
  ```sh
238
246
  npx loadwise agent verify --outcomes outcomes.json before.json history.json after.json
239
247
  npx loadwise agent verify --save --outcomes outcomes.json before.json history.json after.json
240
248
  ```
241
249
 
242
- The first command checks coverage. The second also retains successful review decisions for the next session in a recognized agent session or an explicitly initialized checkout. A missing decision or skipped checker is reported as incomplete. A reasoned deferral counts as reviewed and stays visible as deferred. Code review and relevant tests establish whether a change works.
250
+ The first command checks coverage. `--save` also retains successful review decisions for the next session in a recognized agent session or an explicitly initialized checkout. A missing decision or skipped checker is reported as incomplete; a reasoned deferral counts as reviewed and stays visible as deferred. Code review and relevant tests establish whether a change works. For a standalone JSON scan, pass its checker, for example `--checker maint`: `perf` for performance and database reports, `rel` for reliability, migration and contract reports, `maint`, `sec` or `a11y`, one checker per invocation. Combined scans and history keep their original checker selection.
243
251
 
244
- For a standalone JSON scan, pass its checker name, for example `npx loadwise agent verify --checker maint --outcomes outcomes.json maint-scan.json`. Use `perf` for performance and database reports, `rel` for reliability, migration and contract reports, `maint` for maintainability, `sec` for security, and `a11y` for accessibility. Use one checker per invocation for unlabelled standalone reports. Combined scans and history keep their original checker selection.
245
-
246
- To read or save the same brief yourself, use the same checker names as the fix request:
247
-
248
- ```sh
249
- npx loadwise fix --handoff maintainability > loadwise-manual.md
250
- ```
252
+ To read or save the same brief yourself, use the checker names of the fix request: `npx loadwise fix --handoff maintainability > loadwise-manual.md`.
251
253
 
252
254
  ### Using Loadwise with an active coding agent
253
255
 
254
256
  Ask the agent you are already working with to check the project with Loadwise. A shell-capable agent can run `npx loadwise check --json` and review the findings directly in the conversation. Ask it to verify findings against your code, suggest improvements, or implement the changes you choose. A check is read-only. A request to apply fixes can use `npx loadwise fix --yes --json` and review the actual edits and remaining findings in the same chat.
255
257
 
256
- For an agent that uses Model Context Protocol (MCP), install Loadwise in the project, then run:
257
-
258
- ```bash
259
- npx loadwise agent mcp --print-config
260
- ```
261
-
262
- Register the printed command and arguments as a local stdio server named `loadwise` in the agent. The agent can call `loadwise_check` to run a fresh offline scan and review the findings during the current turn. It can read larger reports in pages with `loadwise_read_report`. Loadwise does not start a chat or send findings to another session.
263
-
264
- If you ran a terminal command yourself and want to share it later, use `npx loadwise check --review` or `npx loadwise fix --yes --review`. Paste the printed handoff into the chat you choose, or attach the report. The optional `loadwise agent pending` command and MCP tool `loadwise_list_reports` list saved reports for that project.
258
+ For an agent that uses Model Context Protocol (MCP), install Loadwise in the project, run `npx loadwise agent mcp --print-config`, and register the printed command and arguments as a local stdio server named `loadwise`. The agent can call `loadwise_check` to run a fresh offline scan and read larger reports in pages with `loadwise_read_report`. Loadwise does not start a chat or send findings to another session.
265
259
 
266
- ### Using Loadwise without AI
267
-
268
- Run `npx loadwise check` to see findings or `npx loadwise fix --yes` to scan and apply automatic fixes. With the language server running in your editor, hover over a finding to see its recommendation. Findings that require judgment remain available for manual review. [Editor setup](#editor-language-server)
260
+ If you ran a terminal command yourself and want to share it later, use `npx loadwise check --review` or `npx loadwise fix --yes --review`. Paste the printed handoff into the chat you choose, or attach the report. `loadwise agent pending` and the MCP tool `loadwise_list_reports` list saved reports for that project.
269
261
 
270
262
  ### Claude Code plugin
271
263
 
@@ -276,9 +268,7 @@ Run `npx loadwise check` to see findings or `npx loadwise fix --yes` to scan and
276
268
  /plugin install loadwise@loadwise
277
269
  ```
278
270
 
279
- After every `Edit`, `Write` or `MultiEdit` on a `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, `.cjs`, `.mts` or `.cts` file, or a `.html`, `.htm`, `.vue` or `.svelte` file, a hook runs the project's locally installed `loadwise` on that file (`perf`, `rel` and `sec` on the file, `maint` on the uncommitted changes, keeping that file's findings, and `a11y` on `.tsx`, `.jsx`, `.html`, `.htm`, `.vue` and `.svelte` files) with a 20 second limit. Findings go back to Claude with their ids and `--fix --only <id>` commands for the corresponding checker; a clean file prints nothing. The hook never downloads anything: without a local install, outside a project, on other file types, on a timeout or on any error it exits silently. The plugin also adds a `/loadwise [args]` command for read-only checks and a `/loadwise fix [checker names]` workflow for agent-reviewed remediation.
280
-
281
- To turn the hook off, run `/plugin disable loadwise` (or `/plugin uninstall loadwise`).
271
+ After every `Edit`, `Write` or `MultiEdit` on a `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, `.cjs`, `.mts` or `.cts` file, or a `.html`, `.htm`, `.vue` or `.svelte` file, a hook runs the project's locally installed `loadwise` on that file (`perf`, `rel` and `sec` on the file, `maint` on the uncommitted changes, keeping that file's findings, and `a11y` on `.tsx`, `.jsx`, `.html`, `.htm`, `.vue` and `.svelte` files) with a 20 second limit. Findings go back to Claude with their ids and `--fix --only <id>` commands; a clean file prints nothing. The hook never downloads anything: without a local install, outside a project, on other file types, on a timeout or on any error it exits silently. The plugin also adds a `/loadwise [args]` command for read-only checks and a `/loadwise fix [checker names]` workflow for agent-reviewed remediation. To turn the hook off, run `/plugin disable loadwise` (or `/plugin uninstall loadwise`).
282
272
 
283
273
  ### Git pre-commit hook
284
274
 
@@ -292,19 +282,13 @@ The hook runs `loadwise check --staged` from the project folder, so every tool t
292
282
 
293
283
  ## Editor (language server)
294
284
 
295
- `loadwise lsp` is a language server for any editor with a Language Server Protocol client. It shows findings from all five checkers (performance, reliability, maintainability, security and accessibility) as diagnostics, with hovers, fixes, dismissals and code lenses. It needs Node.js 22+ and this package in the project (`npm install --save-dev loadwise`) or on the PATH. Every editor starts it the same way:
285
+ `loadwise lsp` shows findings as editor diagnostics, with hovers, fixes, dismissals and code lenses. For any editor with a custom stdio LSP client, see the [Node.js launch settings and editor examples](docs/editor.mdx#set-up-a-custom-stdio-lsp-client). Use the installed CLI path in place of `/absolute/path/to/loadwise.js` in the examples below.
296
286
 
297
- ```sh
298
- npx loadwise lsp --stdio
299
- ```
300
-
301
- On Windows, use `npx.cmd` where the editor does not resolve `npx` itself. Choose the file types each editor attaches it to; the snippets below cover JavaScript, TypeScript and Python, and the checkers also read Go, Java, C#, Rust, HTML, Vue and Svelte.
302
-
303
- **Neovim 0.11+** (`init.lua`):
287
+ **Neovim 0.11+** (`init.lua`); with an older Neovim, register the same `cmd`, `filetypes` and root markers as a custom nvim-lspconfig server:
304
288
 
305
289
  ```lua
306
290
  vim.lsp.config('loadwise', {
307
- cmd = { 'npx', 'loadwise', 'lsp', '--stdio' },
291
+ cmd = { 'node', '/absolute/path/to/loadwise.js', 'lsp', '--stdio' },
308
292
  filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'python' },
309
293
  root_markers = { 'loadwise.config.json', 'tsconfig.json', 'jsconfig.json', 'package.json', '.git' },
310
294
  init_options = { loadwise = { severity = 'default' } },
@@ -312,51 +296,19 @@ vim.lsp.config('loadwise', {
312
296
  vim.lsp.enable('loadwise')
313
297
  ```
314
298
 
315
- With an older Neovim and nvim-lspconfig, register the same settings as a custom server:
316
-
317
- ```lua
318
- require('lspconfig.configs').loadwise = {
319
- default_config = {
320
- cmd = { 'npx', 'loadwise', 'lsp', '--stdio' },
321
- filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'python' },
322
- root_dir = require('lspconfig.util').root_pattern('loadwise.config.json', 'tsconfig.json', 'package.json', '.git'),
323
- },
324
- }
325
- require('lspconfig').loadwise.setup({})
326
- ```
327
-
328
299
  **Helix** (`languages.toml`), added beside each language's own server:
329
300
 
330
301
  ```toml
331
302
  [language-server.loadwise]
332
- command = "npx"
333
- args = ["loadwise", "lsp", "--stdio"]
303
+ command = "node"
304
+ args = ["/absolute/path/to/loadwise.js", "lsp", "--stdio"]
334
305
 
335
306
  [[language]]
336
307
  name = "typescript"
337
308
  language-servers = ["typescript-language-server", "loadwise"]
338
-
339
- [[language]]
340
- name = "python"
341
- language-servers = ["pylsp", "loadwise"]
342
309
  ```
343
310
 
344
- **Zed** (`settings.json`). Zed starts only language servers that an extension registers; with one that registers `loadwise`, these settings choose the command and the languages it runs for:
345
-
346
- ```json
347
- {
348
- "lsp": {
349
- "loadwise": {
350
- "binary": { "path": "npx", "arguments": ["loadwise", "lsp", "--stdio"] },
351
- "initialization_options": { "loadwise": { "severity": "default" } }
352
- }
353
- },
354
- "languages": {
355
- "TypeScript": { "language_servers": ["...", "loadwise"] },
356
- "Python": { "language_servers": ["...", "loadwise"] }
357
- }
358
- }
359
- ```
311
+ **Zed**: follow the [extension-based setup](docs/editor.mdx#zed) if your installed extension registers Loadwise.
360
312
 
361
313
  **Sublime Text** with the LSP package (**Preferences > Package Settings > LSP > Settings**):
362
314
 
@@ -365,38 +317,27 @@ language-servers = ["pylsp", "loadwise"]
365
317
  "clients": {
366
318
  "loadwise": {
367
319
  "enabled": true,
368
- "command": ["npx", "loadwise", "lsp", "--stdio"],
369
- "selector": "source.js | source.jsx | source.ts | source.tsx | source.python",
370
- "initializationOptions": { "loadwise": { "severity": "default" } }
320
+ "command": ["node", "/absolute/path/to/loadwise.js", "lsp", "--stdio"],
321
+ "selector": "source.js | source.jsx | source.ts | source.tsx | source.python"
371
322
  }
372
323
  }
373
324
  }
374
325
  ```
375
326
 
376
- **Emacs** with eglot. Eglot runs one server per buffer, so for these modes Loadwise takes the place of another server:
327
+ **Emacs** with eglot, which runs one server per buffer, so Loadwise takes the place of another server for these modes:
377
328
 
378
329
  ```elisp
379
330
  (with-eval-after-load 'eglot
380
331
  (add-to-list 'eglot-server-programs
381
332
  '((js-mode js-ts-mode typescript-ts-mode tsx-ts-mode python-mode python-ts-mode)
382
- . ("npx" "loadwise" "lsp" "--stdio"))))
333
+ . ("node" "/absolute/path/to/loadwise.js" "lsp" "--stdio"))))
383
334
  ```
384
335
 
385
- **VS Code and VSCodium**: install a generic Language Server Protocol client extension from Open VSX and set its server command to `npx loadwise lsp --stdio`. To apply eligible fixes on save, add `"editor.codeActionsOnSave": { "source.fixAll.loadwise": "explicit" }` to your settings.
386
-
387
- ### What you see
336
+ **VS Code and VSCodium**: follow the [Simple LSP Client workspace setup](docs/editor.mdx#vs-code-and-vscodium). For IntelliJ IDEA, see the [stdio server configuration](docs/editor.mdx#intellij-idea).
388
337
 
389
- - Each finding is a diagnostic with its checker as the source (`loadwise perf`, `loadwise maint`, `loadwise sec`) and its rule as the code, linked to the rule's documentation. Related locations, such as the other imports of a dependency cycle, are listed with it. Rule levels from `loadwise.config.json` decide the severity: by default declared contract violations are errors and other findings warnings. Live-database findings, which name a table rather than a file, appear on the first line of `package.json`.
390
- - Hover over a finding to read the recommendation on the first line (a source-based rewrite, an illustrative example or a review action), then the original finding and the before and after code, highlighted for the file's language.
391
- - The code actions on a flagged line are **Apply fix: <rule>** when the checker has a rewrite, **Dismiss this finding** and **Dismiss <rule> in this file**, and **Apply all Loadwise fixes in this file** when there are several. Fixes that span several files, or create a migration file, apply all-or-nothing. A fix never overwrites an existing file, and it refuses code that changed since the scan, comparing against the editor's unsaved text. The `source.fixAll.loadwise` action applies every eligible fix in the file as one undoable edit and leaves fixes that need individual review for **Apply fix**.
392
- - Code lenses put **Apply fix** and **Dismiss** above each fixable line, and **Apply all** on the first line of a file with several fixes.
393
- - A dismissed finding stays hidden until its flagged line changes; a rule dismissed for a file stays hidden in that file. Dismissals are saved in `.loadwise/dismissed.json` at the workspace folder root, never in your code, and you can commit the file to share them.
338
+ **What you see.** Each finding is a diagnostic with its checker as the source (`loadwise perf`, `loadwise maint`, `loadwise sec`) and its rule as the code, linked to the rule's page, with related locations such as the other imports of a dependency cycle. Rule levels from `loadwise.config.json` decide the severity: by default declared contract violations are errors and other findings warnings. Live-database findings appear on the first line of `package.json`. Hovers show the recommendation, the finding and the before and after code. Code actions are **Apply fix: <rule>**, **Dismiss this finding**, **Dismiss <rule> in this file** and **Apply all Loadwise fixes in this file**, and code lenses put **Apply fix**, **Dismiss** and **Apply all** above fixable lines. Multi-file fixes apply all-or-nothing, never overwrite an existing file and refuse code that changed since the scan, including unsaved editor text. `source.fixAll.loadwise` applies every eligible fix in the file as one undoable edit and leaves fixes that need individual review for **Apply fix**. A dismissed finding stays hidden until its flagged line changes; dismissals are saved in `.loadwise/dismissed.json` at the workspace folder root, which you can commit to share them.
394
339
 
395
- ### What gets scanned
396
-
397
- Each workspace folder is scanned when the server starts and again after every change: a save in the editor, or a change by git, another editor or a code generator to a source file, `schema.prisma`, a SQL migration, `package.json`, `tsconfig*.json`, `jsconfig*.json`, `loadwise.config.json` or `.loadwise/dismissed.json`. Rapid changes are grouped, and a completed source scan in the project terminal refreshes the editor too. Performance, reliability and accessibility come from the incremental `loadwise perf --watch` process, which re-analyzes only changed files, restarts when a config file or package changes, and falls back to full rescans if it stops. Maintainability and security rerun on each change, and the polyglot rules run when the folder has Python, Go, Java, C# or Rust files. The default project is a root `tsconfig.json` or `jsconfig.json`; in a monorepo, open individual packages as workspace folders or set `project`. Progress appears while a scan runs, and scan counts and errors go to the editor's language server log.
398
-
399
- ### Commands and settings
340
+ **What gets scanned.** Each workspace folder is scanned on start and after every change to a source file, `schema.prisma`, a SQL migration, `package.json`, `tsconfig*.json`, `jsconfig*.json`, `loadwise.config.json` or `.loadwise/dismissed.json`, whether from the editor, git or another tool; a completed source scan in the project terminal refreshes it too. Performance, reliability and accessibility come from an incremental `loadwise perf --watch` process; maintainability and security rerun on each change, and the polyglot rules run when the folder has Python, Go, Java, C# or Rust files. The default project is a root `tsconfig.json` or `jsconfig.json`; in a monorepo, open packages as workspace folders or set `project`. Scan counts and errors go to the editor's language server log.
400
341
 
401
342
  | Command | Action |
402
343
  | --------------------------- | ---------------------------------------------------------- |
@@ -413,26 +354,15 @@ Settings go in the client's `initializationOptions` or its `loadwise` configurat
413
354
  | ---------- | ----------- | ----------------------------------------------------------------------------- |
414
355
  | `enabled` | `true` | Show diagnostics for the folder |
415
356
  | `project` | `""` | TypeScript or JavaScript project config, relative to the folder |
416
- | `cli` | `""` | Absolute path to another `bin/loadwise.js`, such as a development build |
357
+ | `cli` | `""` | Absolute path to another `dist/bin/loadwise.js`, such as a development build |
417
358
  | `severity` | `"default"` | `error`, `warning`, `information` or `hint` shows every finding at that level |
418
359
  | `codeLens` | `true` | Show the Apply fix and Dismiss code lenses |
419
360
 
420
361
  # Performance checker
421
362
 
422
- `loadwise perf` finds repeated backend work before deployment or in a recorded request. It checks source code, OpenTelemetry traces and executed database plans. Findings include a location or trace identifier, a rule ID, and a suggested change to evaluate.
423
-
424
- ## What you get
425
-
426
- | Capability | Command | Needs a database |
427
- | ------------------------- | ---------------------------------------- | ---------------- |
428
- | Source and ORM checks | `loadwise perf -p tsconfig.json` | No |
429
- | Migration safety | `loadwise rel migrations` | No |
430
- | API contract safety | `loadwise rel contracts` | No |
431
- | Schema-aware index checks | `loadwise perf --schema snap.json` | No (snapshot) |
432
- | Live database inspection | `loadwise perf db` | Yes, read-only |
433
- | Traces and executed plans | `traces trace.json`, `plan explain.json` | No |
363
+ `loadwise perf` finds repeated backend work and avoidable React, Vue and Angular rendering work in source code, OpenTelemetry traces and executed database plans. Findings for loops and repeated spans carry an **Impact:** line that says which side is measured and which is estimated (`~`); a millisecond figure is never printed without a measurement behind it.
434
364
 
435
- Text findings carry a stable `#id`, a **Fix** diff where one applies and, for loops and repeated spans, an **Impact:** line. Impact always says which side is measured and which is estimated.
365
+ Sample text finding with its fix diff:
436
366
 
437
367
  ```text
438
368
  examples/slow.ts:7:48 [array-repeated-find #9ab891a8b8f7] medium: Each item can rescan the lookup array with find(), so cost grows with items times rows. Build `const byKey = new Map()` once (first match wins) and call `byKey.get(key)`; keep the original key-equality semantics.
@@ -442,317 +372,213 @@ examples/slow.ts:7:48 [array-repeated-find #9ab891a8b8f7] medium: Each item can
442
372
  + const names = visible.map(order => customersById.get(order.customerId)?.name ?? 'Unknown');
443
373
  ```
444
374
 
445
- ```text
446
- 00000000000000000000000000000001 parent 0000000000000010 [repeated-db-span] 5 sibling database calls share one operation signature, one round trip each. Batch them into one statement such as WHERE id = ANY($1), or reuse a shared result, if behavior allows it.
447
- Impact: 40 ms measured -> ~8 ms estimated; method: OTLP start/end times; after assumes one batched operation costs as much as the slowest span.
448
- ```
449
-
450
- The second sample is `examples/repeated-db.otlp.json` with span timings added. A `~` marks an estimate. Loop findings (`*-query-in-loop`) show a round-trip model, and a measured figure only when `--schema` supplies a snapshot with a measured round trip. An Impact line in milliseconds is never printed without a measurement behind it.
451
-
452
- ## Start here
453
-
454
- Try the two included implementations of the same order lookup. The first reports three findings. The second preserves the result order, the first matching customer and the fallback for a missing customer.
455
-
456
- ```sh
457
- npx loadwise perf node_modules/loadwise/examples/slow.ts
458
- npx loadwise perf node_modules/loadwise/examples/indexed.ts
459
- ```
460
-
461
- Use the same one-shot commands in CI. Exit **0** means no displayed finding met the fail threshold, **1** means at least one did and **2** means the check could not complete or skipped a file. Add `--json` for structured output.
462
-
463
- Source checks summarize contextual findings separately. They include certain one-off blocking calls in CLI startup or unit tests and write advisories in test sources. Use `--include-contextual` to display every candidate and its reason. JSON includes `contextualFindingCount` when any remain after explicit rule exclusions. In the default view this count is additional to the displayed findings. In the expanded view these entries appear in `findings` with a `contextualReason`.
464
-
465
- The default `--fail-on all` applies to the displayed findings. For a complete advisory report that only fails CI on a transaction-client or import contract violation, use `npx loadwise rel --include-contextual --fail-on contract`. Performance has no contract rules; `loadwise rel --fail-on contract` enforces `pg-transaction-on-pool`.
466
-
467
- | Input | Command after `npx loadwise perf` | Coverage |
468
- | --------------------------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------- |
469
- | JavaScript or TypeScript | `-p tsconfig.json`, `--watch -p tsconfig.json` or `src/handler.ts` | Typed database calls, collection algorithms, connections and synchronous Node APIs. |
470
- | Python, Go, Java, C#, Rust | `polyglot src` | Five narrowly scoped source patterns powered by a Rust binary. |
471
- | OTLP/JSON from any application language | `traces request.otlp.json --threshold 5` | Repeated SQL or NoSQL operations, duplicate lookups and Redis/Valkey commands. |
472
- | Executed PostgreSQL or MongoDB plan | `plan explain.json` | Inefficient scans, disk sorts and deep pagination at individual plan stages. |
375
+ | Input | Command after `npx loadwise perf` | Needs a database |
376
+ | --------------------------------------- | ------------------------------------------------------------------ | --------------------------------- |
377
+ | JavaScript or TypeScript | `-p tsconfig.json`, `--watch -p tsconfig.json` or `src/handler.ts` | No |
378
+ | Schema-aware index checks | `--schema snapshot.json` | No (snapshot) |
379
+ | Python, Go, Java, C#, Rust | `polyglot src` | No |
380
+ | OTLP/JSON from any application language | `traces request.otlp.json --threshold 5` | No |
381
+ | Executed PostgreSQL or MongoDB plan | `plan explain.json` | No |
382
+ | Live database inspection | `db` | Yes, read-only unless `--measure` |
473
383
 
474
384
  ## Source checks
475
385
 
476
- Run in the directory containing `tsconfig.json` or `jsconfig.json`, pass `-p path/to/config.json`, or give explicit JS/TS files. A project check scans the config's input files and follows project references. Declaration files supply types. A standalone file check uses ES2022 and NodeNext compiler defaults. Use a project config for aliases, custom libraries and JS projects with `allowJs`. When the config Loadwise finds leaves JavaScript files in its folder out because `allowJs` is off, Loadwise still checks them with those standalone defaults and a note names them; set `allowJs` or add a `jsconfig.json` to check them with the project's settings. A config passed with `-p` is checked exactly as it lists its files, and the note names the JavaScript it leaves out.
386
+ Run in the directory containing `tsconfig.json` or `jsconfig.json`, pass `-p path/to/config.json`, or give explicit JS/TS files (checked with ES2022 and NodeNext defaults). A project check follows project references. JavaScript files that the found config leaves out because `allowJs` is off are still checked with the standalone defaults and named in a note; a config passed with `-p` is checked exactly as it lists its files. Install the application's driver declarations and generate its Prisma client first: unresolved types, wrappers and deferred callbacks can hide findings. Test, seed and operator-tooling sources (`scripts`, `seeds`, `prisma/seed.ts`, `*.seed.ts`, deployment, migrations) make per-item query, index, serial-await, Redis `KEYS`, pure-JavaScript hashing, Prisma dependent-write and Drizzle whole-table-write findings contextual. `prisma-count-for-existence` findings may carry `idField`, the model's single primary-key field that the fix selects.
387
+
388
+ Engines: one-shot checks use Microsoft's Go-based [TypeScript 7](https://github.com/microsoft/typescript-go) compiler on Node.js 22.13+ with the optional native package for your platform (same findings; 1.7–2.2 times faster on the 3,200-file benchmark in [PERFORMANCE.md](PERFORMANCE.md), and the gain depends on the project) and fall back to TypeScript 6.0.3 with a stderr note when TypeScript 7 rejects the configuration (for example `baseUrl` or `moduleResolution: "node10"`). `--engine native` (alias `--native`) requires TypeScript 7 and reports incompatible configuration as exit 2; `--engine js` always uses TypeScript 6.0.3. `perf --json` names the engine in `engine` (`"js"` or `"native"`). `--watch` uses TypeScript 6.0.3 on a single project; with `--watch --json` each completed scan writes one JSON line.
477
389
 
478
390
  <!-- loadwise:rules:start checker=performance group=source-checks -->
479
391
 
480
- | Rule | Impact | What it flags |
481
- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
482
- | <a id="angular-default-change-detection"></a>[`angular-default-change-detection`](docs/rules/angular-default-change-detection.md) | low | An Angular component uses default change detection instead of OnPush, so its subtree is re-checked on every event. |
483
- | <a id="angular-ngfor-missing-trackby"></a>[`angular-ngfor-missing-trackby`](docs/rules/angular-ngfor-missing-trackby.md) | low | An *ngFor has no trackBy, so a list replaced with new objects recreates the DOM of every item. |
484
- | <a id="angular-subscribe-without-cleanup"></a>[`angular-subscribe-without-cleanup`](docs/rules/angular-subscribe-without-cleanup.md) | medium | An RxJS subscription in a component has no completing operator or ngOnDestroy unsubscribe and keeps running after destruction. |
485
- | <a id="array-repeated-find"></a>[`array-repeated-find`](docs/rules/array-repeated-find.md) | medium | An array is searched with find or findIndex repeatedly where a Map lookup would do. |
486
- | <a id="array-repeated-membership"></a>[`array-repeated-membership`](docs/rules/array-repeated-membership.md) | medium | An array is tested with includes or indexOf repeatedly where a Set would do. |
487
- | <a id="dom-layout-thrashing"></a>[`dom-layout-thrashing`](docs/rules/dom-layout-thrashing.md) | medium | A loop reads layout metrics and mutates DOM styles or classes, forcing a reflow on each iteration. |
488
- | <a id="dom-listener-without-cleanup"></a>[`dom-listener-without-cleanup`](docs/rules/dom-listener-without-cleanup.md) | low | A window or document listener uses an inline function with no AbortSignal or once, so it can never be removed. |
489
- | <a id="dom-unthrottled-scroll-resize"></a>[`dom-unthrottled-scroll-resize`](docs/rules/dom-unthrottled-scroll-resize.md) | low | A scroll, resize, mousemove, wheel or touch listener runs unthrottled work (or is non-passive) on the main thread. |
490
- | <a id="express-missing-compression"></a>[`express-missing-compression`](docs/rules/express-missing-compression.md) | low | An Express server registers no response compression middleware. |
491
- | <a id="external-call-in-transaction"></a>[`external-call-in-transaction`](docs/rules/external-call-in-transaction.md) | high | An external call is awaited inside a database transaction, holding its connection and locks. |
492
- | <a id="filter-for-existence"></a>[`filter-for-existence`](docs/rules/filter-for-existence.md) | low | filter(...).length is used only to test whether any element matches. |
493
- | <a id="frontend-barrel-heavy-import"></a>[`frontend-barrel-heavy-import`](docs/rules/frontend-barrel-heavy-import.md) | low | A client module imports the whole of lodash or moment instead of subpaths or a lighter library. |
494
- | <a id="graphql-n-plus-one-resolver"></a>[`graphql-n-plus-one-resolver`](docs/rules/graphql-n-plus-one-resolver.md) | high | A GraphQL field resolver executes a database or HTTP query per parent item without DataLoader batching. |
495
- | <a id="heavy-media-in-request-handler"></a>[`heavy-media-in-request-handler`](docs/rules/heavy-media-in-request-handler.md) | medium | Heavy image (sharp) or PDF rendering runs directly inside an HTTP request handler. |
496
- | <a id="json-roundtrip-clone"></a>[`json-roundtrip-clone`](docs/rules/json-roundtrip-clone.md) | low | A value is deep-cloned with JSON.parse(JSON.stringify(...)) on a request path. |
497
- | <a id="json-stringify-in-loop"></a>[`json-stringify-in-loop`](docs/rules/json-stringify-in-loop.md) | medium | JSON.stringify runs inside a loop instead of serializing once or streaming. |
498
- | <a id="list-count-per-request"></a>[`list-count-per-request`](docs/rules/list-count-per-request.md) | medium | A list endpoint runs a full count query on every request. |
499
- | <a id="list-query-overfetch"></a>[`list-query-overfetch`](docs/rules/list-query-overfetch.md) | medium | A list query loads large columns or nested relations without a narrow projection. |
500
- | <a id="llm-call-without-max-tokens"></a>[`llm-call-without-max-tokens`](docs/rules/llm-call-without-max-tokens.md) | medium | An OpenAI chat or responses call sets no output token limit. |
501
- | <a id="loop-copy-accumulator"></a>[`loop-copy-accumulator`](docs/rules/loop-copy-accumulator.md) | medium | A loop copies its growing result on every iteration. |
502
- | <a id="mongoose-hydrate-for-to-object"></a>[`mongoose-hydrate-for-to-object`](docs/rules/mongoose-hydrate-for-to-object.md) | medium | A Mongoose query hydrates full Documents only to convert them immediately via .toObject() or .toJSON(). |
503
- | <a id="mongoose-missing-lean"></a>[`mongoose-missing-lean`](docs/rules/mongoose-missing-lean.md) | medium | A Mongoose read query is returned or serialized without .lean(), paying full Document hydration overhead. |
504
- | <a id="node-event-listener-leak"></a>[`node-event-listener-leak`](docs/rules/node-event-listener-leak.md) | high | An event listener is registered inside a repeated or per-request context without matching cleanup. |
505
- | <a id="node-sync-compression-in-async"></a>[`node-sync-compression-in-async`](docs/rules/node-sync-compression-in-async.md) | medium | A synchronous zlib call blocks the event loop inside an async function. |
506
- | <a id="node-sync-crypto-in-async"></a>[`node-sync-crypto-in-async`](docs/rules/node-sync-crypto-in-async.md) | high | A synchronous crypto call blocks the event loop inside an async function. |
507
- | <a id="node-sync-fs-in-async"></a>[`node-sync-fs-in-async`](docs/rules/node-sync-fs-in-async.md) | medium | A synchronous fs call blocks the event loop inside an async function. |
508
- | <a id="node-sync-process-in-async"></a>[`node-sync-process-in-async`](docs/rules/node-sync-process-in-async.md) | high | A synchronous child_process call blocks the event loop inside an async function. |
509
- | <a id="notification-send-in-loop"></a>[`notification-send-in-loop`](docs/rules/notification-send-in-loop.md) | high | A push, email or Firebase message is sent once per loop iteration instead of in one batch. |
510
- | <a id="orm-cartesian-include"></a>[`orm-cartesian-include`](docs/rules/orm-cartesian-include.md) | high | One query joins two or more one-to-many relations, so the returned rows multiply. |
511
- | <a id="orm-deep-offset"></a>[`orm-deep-offset`](docs/rules/orm-deep-offset.md) | high | A list query pages with a large or unbounded offset, so the database reads and discards every skipped row. |
512
- | <a id="password-hash-pure-js"></a>[`password-hash-pure-js`](docs/rules/password-hash-pure-js.md) | medium | bcryptjs hashes passwords in pure JavaScript on the main thread. |
513
- | <a id="password-hash-sync-in-async"></a>[`password-hash-sync-in-async`](docs/rules/password-hash-sync-in-async.md) | high | A synchronous bcrypt call blocks the event loop inside an async function. |
514
- | <a id="pg-count-materialization"></a>[`pg-count-materialization`](docs/rules/pg-count-materialization.md) | medium | A pg query loads rows only to count them. |
515
- | <a id="pg-filter-materialization"></a>[`pg-filter-materialization`](docs/rules/pg-filter-materialization.md) | medium | A pg query loads an unbounded result that JavaScript then filters by equality. |
516
- | <a id="pg-first-materialization"></a>[`pg-first-materialization`](docs/rules/pg-first-materialization.md) | medium | A pg query loads an unbounded result to read only its first row. |
517
- | <a id="pg-query-in-loop"></a>[`pg-query-in-loop`](docs/rules/pg-query-in-loop.md) | high | A pg query runs once per loop iteration. |
518
- | <a id="pg-top-k-materialization"></a>[`pg-top-k-materialization`](docs/rules/pg-top-k-materialization.md) | medium | A pg query loads an unbounded result that JavaScript sorts to keep the top rows. |
519
- | <a id="pg-unreleased-checkout"></a>[`pg-unreleased-checkout`](docs/rules/pg-unreleased-checkout.md) | critical | A chained pool checkout loses the client, so it is never released. |
520
- | <a id="pool-created-per-request-or-item"></a>[`pool-created-per-request-or-item`](docs/rules/pool-created-per-request-or-item.md) | critical | A database, Redis, S3, OpenAI, Anthropic or Stripe client or pool is created on a per-request or per-item path. |
521
- | <a id="prisma-count-materialization"></a>[`prisma-count-materialization`](docs/rules/prisma-count-materialization.md) | medium | A Prisma query loads rows only to count them. |
522
- | <a id="prisma-filter-materialization"></a>[`prisma-filter-materialization`](docs/rules/prisma-filter-materialization.md) | medium | A Prisma query loads an unbounded result that JavaScript then filters by equality. |
523
- | <a id="prisma-first-materialization"></a>[`prisma-first-materialization`](docs/rules/prisma-first-materialization.md) | medium | A Prisma query loads an unbounded result to read only its first row. |
524
- | <a id="prisma-query-in-loop"></a>[`prisma-query-in-loop`](docs/rules/prisma-query-in-loop.md) | high | A Prisma query runs once per loop iteration. |
525
- | <a id="prisma-top-k-materialization"></a>[`prisma-top-k-materialization`](docs/rules/prisma-top-k-materialization.md) | medium | A Prisma query loads an unbounded result that JavaScript sorts to keep the top rows. |
526
- | <a id="queue-add-in-loop"></a>[`queue-add-in-loop`](docs/rules/queue-add-in-loop.md) | high | A job queue add runs once per item instead of one addBulk. |
527
- | <a id="react-component-defined-in-component"></a>[`react-component-defined-in-component`](docs/rules/react-component-defined-in-component.md) | medium | A component is declared inside another component and rendered as an element, so it remounts on every render and loses its state and DOM. |
528
- | <a id="react-context-value-recreated"></a>[`react-context-value-recreated`](docs/rules/react-context-value-recreated.md) | low | An inline object or array literal in Context.Provider value creates a new reference on every render. |
529
- | <a id="react-fetch-in-effect-no-abort"></a>[`react-fetch-in-effect-no-abort`](docs/rules/react-fetch-in-effect-no-abort.md) | low | A fetch in an effect has no AbortController or cleanup, so dependency changes can race and apply stale results. |
530
- | <a id="react-index-as-key"></a>[`react-index-as-key`](docs/rules/react-index-as-key.md) | low | A list item uses the map index as its React key, which breaks reconciliation when items are inserted or reordered. |
531
- | <a id="react-inline-object-in-jsx-prop"></a>[`react-inline-object-in-jsx-prop`](docs/rules/react-inline-object-in-jsx-prop.md) | low | An inline object literal is passed to a memo() component, creating a new reference each render and defeating the memo. |
532
- | <a id="react-missing-cleanup"></a>[`react-missing-cleanup`](docs/rules/react-missing-cleanup.md) | medium | An effect starts a global listener, interval, socket or endless subscription and returns no cleanup, so it leaks on every remount. |
533
- | <a id="rebuild-lookup-in-loop"></a>[`rebuild-lookup-in-loop`](docs/rules/rebuild-lookup-in-loop.md) | high | A Set or Map is rebuilt from the same data on every loop iteration. |
534
- | <a id="redis-command-in-loop"></a>[`redis-command-in-loop`](docs/rules/redis-command-in-loop.md) | high | A per-key Redis command runs once per loop iteration. |
535
- | <a id="redis-keys-command"></a>[`redis-keys-command`](docs/rules/redis-keys-command.md) | high | A Redis KEYS call blocks the server while it scans the keyspace. |
536
- | <a id="reduce-copy-accumulator"></a>[`reduce-copy-accumulator`](docs/rules/reduce-copy-accumulator.md) | medium | A reduce callback copies its growing accumulator on every step. |
537
- | <a id="sequential-http-in-loop"></a>[`sequential-http-in-loop`](docs/rules/sequential-http-in-loop.md) | high | Independent HTTP requests are awaited one at a time inside a loop. |
538
- | <a id="serial-awaits-in-literal"></a>[`serial-awaits-in-literal`](docs/rules/serial-awaits-in-literal.md) | medium | An array or object literal awaits two or more independent values one after another. |
539
- | <a id="service-query-in-loop"></a>[`service-query-in-loop`](docs/rules/service-query-in-loop.md) | high | A loop calls a project function that runs several database operations per item. |
540
- | <a id="session-memory-store"></a>[`session-memory-store`](docs/rules/session-memory-store.md) | high | An express-session middleware has no store, so sessions live in process memory. |
541
- | <a id="sql-select-star-in-query"></a>[`sql-select-star-in-query`](docs/rules/sql-select-star-in-query.md) | low | A raw SQL query selects every column with SELECT * instead of the columns it needs. |
542
- | <a id="unbounded-list-query"></a>[`unbounded-list-query`](docs/rules/unbounded-list-query.md) | high | A request handler returns query results without an apparent row limit. |
543
- | <a id="unbounded-module-cache"></a>[`unbounded-module-cache`](docs/rules/unbounded-module-cache.md) | medium | A long-lived cache accepts dynamic keys without an apparent bound or eviction. |
544
- | <a id="vue-v-for-missing-key"></a>[`vue-v-for-missing-key`](docs/rules/vue-v-for-missing-key.md) | low | A list rendered with h() has no key prop, forcing inefficient patching. |
545
- | <a id="vue-watch-missing-cleanup"></a>[`vue-watch-missing-cleanup`](docs/rules/vue-watch-missing-cleanup.md) | medium | onMounted registers a global listener, timer or observer with no unmount cleanup. |
546
- | <a id="whole-payload-in-memory"></a>[`whole-payload-in-memory`](docs/rules/whole-payload-in-memory.md) | medium | An operation loads an entire file, stream, or response into memory. |
392
+ | Rule | Impact | What it flags |
393
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
394
+ | <a id="angular-default-change-detection"></a>[`angular-default-change-detection`](docs/rules/performance/angular-default-change-detection.md) | low | An Angular component uses default change detection instead of OnPush, so its subtree is re-checked on every event. |
395
+ | <a id="angular-ngfor-missing-trackby"></a>[`angular-ngfor-missing-trackby`](docs/rules/performance/angular-ngfor-missing-trackby.md) | low | An *ngFor has no trackBy, so a list replaced with new objects recreates the DOM of every item. |
396
+ | <a id="angular-subscribe-without-cleanup"></a>[`angular-subscribe-without-cleanup`](docs/rules/performance/angular-subscribe-without-cleanup.md) | medium | An RxJS subscription in a component has no completing operator or ngOnDestroy unsubscribe and keeps running after destruction. |
397
+ | <a id="array-repeated-find"></a>[`array-repeated-find`](docs/rules/performance/array-repeated-find.md) | medium | An array is searched with find or findIndex repeatedly where a Map lookup would do. |
398
+ | <a id="array-repeated-membership"></a>[`array-repeated-membership`](docs/rules/performance/array-repeated-membership.md) | medium | An array is tested with includes or indexOf repeatedly where a Set would do. |
399
+ | <a id="dom-layout-thrashing"></a>[`dom-layout-thrashing`](docs/rules/performance/dom-layout-thrashing.md) | medium | A loop reads layout metrics and mutates DOM styles or classes, forcing a reflow on each iteration. |
400
+ | <a id="dom-listener-without-cleanup"></a>[`dom-listener-without-cleanup`](docs/rules/performance/dom-listener-without-cleanup.md) | low | A window or document listener uses an inline function with no AbortSignal or once, so it can never be removed. |
401
+ | <a id="dom-unthrottled-scroll-resize"></a>[`dom-unthrottled-scroll-resize`](docs/rules/performance/dom-unthrottled-scroll-resize.md) | low | A scroll, resize, mousemove, wheel or touch listener runs unthrottled work (or is non-passive) on the main thread. |
402
+ | <a id="express-missing-compression"></a>[`express-missing-compression`](docs/rules/performance/express-missing-compression.md) | low | An Express server registers no response compression middleware. |
403
+ | <a id="external-call-in-transaction"></a>[`external-call-in-transaction`](docs/rules/performance/external-call-in-transaction.md) | high | An external call is awaited inside a database transaction, holding its connection and locks. |
404
+ | <a id="filter-for-existence"></a>[`filter-for-existence`](docs/rules/performance/filter-for-existence.md) | low | filter(...).length is used only to test whether any element matches. |
405
+ | <a id="frontend-barrel-heavy-import"></a>[`frontend-barrel-heavy-import`](docs/rules/performance/frontend-barrel-heavy-import.md) | low | A client module imports the whole of lodash or moment instead of subpaths or a lighter library. |
406
+ | <a id="graphql-n-plus-one-resolver"></a>[`graphql-n-plus-one-resolver`](docs/rules/performance/graphql-n-plus-one-resolver.md) | high | A GraphQL field resolver executes a database or HTTP query per parent item without DataLoader batching. |
407
+ | <a id="heavy-media-in-request-handler"></a>[`heavy-media-in-request-handler`](docs/rules/performance/heavy-media-in-request-handler.md) | medium | Heavy image (sharp) or PDF rendering runs directly inside an HTTP request handler. |
408
+ | <a id="json-roundtrip-clone"></a>[`json-roundtrip-clone`](docs/rules/performance/json-roundtrip-clone.md) | low | A value is deep-cloned with JSON.parse(JSON.stringify(...)) on a request path. |
409
+ | <a id="json-stringify-in-loop"></a>[`json-stringify-in-loop`](docs/rules/performance/json-stringify-in-loop.md) | medium | JSON.stringify runs inside a loop instead of serializing once or streaming. |
410
+ | <a id="list-count-per-request"></a>[`list-count-per-request`](docs/rules/performance/list-count-per-request.md) | medium | A list endpoint runs a full count query on every request. |
411
+ | <a id="list-query-overfetch"></a>[`list-query-overfetch`](docs/rules/performance/list-query-overfetch.md) | medium | A list query loads large columns or nested relations without a narrow projection. |
412
+ | <a id="llm-call-without-max-tokens"></a>[`llm-call-without-max-tokens`](docs/rules/performance/llm-call-without-max-tokens.md) | medium | An OpenAI chat or responses call sets no output token limit. |
413
+ | <a id="loop-copy-accumulator"></a>[`loop-copy-accumulator`](docs/rules/performance/loop-copy-accumulator.md) | medium | A loop copies its growing result on every iteration. |
414
+ | <a id="mongoose-hydrate-for-to-object"></a>[`mongoose-hydrate-for-to-object`](docs/rules/performance/mongoose-hydrate-for-to-object.md) | medium | A Mongoose query hydrates full Documents only to convert them immediately via .toObject() or .toJSON(). |
415
+ | <a id="mongoose-missing-lean"></a>[`mongoose-missing-lean`](docs/rules/performance/mongoose-missing-lean.md) | medium | A Mongoose read query is returned or serialized without .lean(), paying full Document hydration overhead. |
416
+ | <a id="node-event-listener-leak"></a>[`node-event-listener-leak`](docs/rules/performance/node-event-listener-leak.md) | high | An event listener is registered inside a repeated or per-request context without matching cleanup. |
417
+ | <a id="node-sync-compression-in-async"></a>[`node-sync-compression-in-async`](docs/rules/performance/node-sync-compression-in-async.md) | medium | A synchronous zlib call blocks the event loop inside an async function. |
418
+ | <a id="node-sync-crypto-in-async"></a>[`node-sync-crypto-in-async`](docs/rules/performance/node-sync-crypto-in-async.md) | high | A synchronous crypto call blocks the event loop inside an async function. |
419
+ | <a id="node-sync-fs-in-async"></a>[`node-sync-fs-in-async`](docs/rules/performance/node-sync-fs-in-async.md) | medium | A synchronous fs call blocks the event loop inside an async function. |
420
+ | <a id="node-sync-process-in-async"></a>[`node-sync-process-in-async`](docs/rules/performance/node-sync-process-in-async.md) | high | A synchronous child_process call blocks the event loop inside an async function. |
421
+ | <a id="notification-send-in-loop"></a>[`notification-send-in-loop`](docs/rules/performance/notification-send-in-loop.md) | high | A push, email or Firebase message is sent once per loop iteration instead of in one batch. |
422
+ | <a id="orm-cartesian-include"></a>[`orm-cartesian-include`](docs/rules/performance/orm-cartesian-include.md) | high | One query joins two or more one-to-many relations, so the returned rows multiply. |
423
+ | <a id="orm-deep-offset"></a>[`orm-deep-offset`](docs/rules/performance/orm-deep-offset.md) | high | A list query pages with a large or unbounded offset, so the database reads and discards every skipped row. |
424
+ | <a id="password-hash-pure-js"></a>[`password-hash-pure-js`](docs/rules/performance/password-hash-pure-js.md) | medium | bcryptjs hashes passwords in pure JavaScript on the main thread. |
425
+ | <a id="password-hash-sync-in-async"></a>[`password-hash-sync-in-async`](docs/rules/performance/password-hash-sync-in-async.md) | high | A synchronous bcrypt call blocks the event loop inside an async function. |
426
+ | <a id="pg-count-materialization"></a>[`pg-count-materialization`](docs/rules/performance/pg-count-materialization.md) | medium | A pg query loads rows only to count them. |
427
+ | <a id="pg-filter-materialization"></a>[`pg-filter-materialization`](docs/rules/performance/pg-filter-materialization.md) | medium | A pg query loads an unbounded result that JavaScript then filters by equality. |
428
+ | <a id="pg-first-materialization"></a>[`pg-first-materialization`](docs/rules/performance/pg-first-materialization.md) | medium | A pg query loads an unbounded result to read only its first row. |
429
+ | <a id="pg-query-in-loop"></a>[`pg-query-in-loop`](docs/rules/performance/pg-query-in-loop.md) | high | A pg query runs once per loop iteration. |
430
+ | <a id="pg-top-k-materialization"></a>[`pg-top-k-materialization`](docs/rules/performance/pg-top-k-materialization.md) | medium | A pg query loads an unbounded result that JavaScript sorts to keep the top rows. |
431
+ | <a id="pg-unreleased-checkout"></a>[`pg-unreleased-checkout`](docs/rules/performance/pg-unreleased-checkout.md) | critical | A chained pool checkout loses the client, so it is never released. |
432
+ | <a id="pool-created-per-request-or-item"></a>[`pool-created-per-request-or-item`](docs/rules/performance/pool-created-per-request-or-item.md) | critical | A database, Redis, S3, OpenAI, Anthropic or Stripe client or pool is created on a per-request or per-item path. |
433
+ | <a id="prisma-count-materialization"></a>[`prisma-count-materialization`](docs/rules/performance/prisma-count-materialization.md) | medium | A Prisma query loads rows only to count them. |
434
+ | <a id="prisma-filter-materialization"></a>[`prisma-filter-materialization`](docs/rules/performance/prisma-filter-materialization.md) | medium | A Prisma query loads an unbounded result that JavaScript then filters by equality. |
435
+ | <a id="prisma-first-materialization"></a>[`prisma-first-materialization`](docs/rules/performance/prisma-first-materialization.md) | medium | A Prisma query loads an unbounded result to read only its first row. |
436
+ | <a id="prisma-query-in-loop"></a>[`prisma-query-in-loop`](docs/rules/performance/prisma-query-in-loop.md) | high | A Prisma query runs once per loop iteration. |
437
+ | <a id="prisma-top-k-materialization"></a>[`prisma-top-k-materialization`](docs/rules/performance/prisma-top-k-materialization.md) | medium | A Prisma query loads an unbounded result that JavaScript sorts to keep the top rows. |
438
+ | <a id="queue-add-in-loop"></a>[`queue-add-in-loop`](docs/rules/performance/queue-add-in-loop.md) | high | A job queue add runs once per item instead of one addBulk. |
439
+ | <a id="react-component-defined-in-component"></a>[`react-component-defined-in-component`](docs/rules/performance/react-component-defined-in-component.md) | medium | A component is declared inside another component and rendered as an element, so it remounts on every render and loses its state and DOM. |
440
+ | <a id="react-context-value-recreated"></a>[`react-context-value-recreated`](docs/rules/performance/react-context-value-recreated.md) | low | An inline object or array literal in Context.Provider value creates a new reference on every render. |
441
+ | <a id="react-fetch-in-effect-no-abort"></a>[`react-fetch-in-effect-no-abort`](docs/rules/performance/react-fetch-in-effect-no-abort.md) | low | A fetch in an effect has no AbortController or cleanup, so dependency changes can race and apply stale results. |
442
+ | <a id="react-index-as-key"></a>[`react-index-as-key`](docs/rules/performance/react-index-as-key.md) | low | A list item uses the map index as its React key, which breaks reconciliation when items are inserted or reordered. |
443
+ | <a id="react-inline-object-in-jsx-prop"></a>[`react-inline-object-in-jsx-prop`](docs/rules/performance/react-inline-object-in-jsx-prop.md) | low | An inline object literal is passed to a memo() component, creating a new reference each render and defeating the memo. |
444
+ | <a id="react-missing-cleanup"></a>[`react-missing-cleanup`](docs/rules/performance/react-missing-cleanup.md) | medium | An effect starts a global listener, interval, socket or endless subscription and returns no cleanup, so it leaks on every remount. |
445
+ | <a id="rebuild-lookup-in-loop"></a>[`rebuild-lookup-in-loop`](docs/rules/performance/rebuild-lookup-in-loop.md) | high | A Set or Map is rebuilt from the same data on every loop iteration. |
446
+ | <a id="redis-command-in-loop"></a>[`redis-command-in-loop`](docs/rules/performance/redis-command-in-loop.md) | high | A per-key Redis command runs once per loop iteration. |
447
+ | <a id="redis-keys-command"></a>[`redis-keys-command`](docs/rules/performance/redis-keys-command.md) | high | A Redis KEYS call blocks the server while it scans the keyspace. |
448
+ | <a id="reduce-copy-accumulator"></a>[`reduce-copy-accumulator`](docs/rules/performance/reduce-copy-accumulator.md) | medium | A reduce callback copies its growing accumulator on every step. |
449
+ | <a id="sequential-http-in-loop"></a>[`sequential-http-in-loop`](docs/rules/performance/sequential-http-in-loop.md) | high | Independent HTTP requests are awaited one at a time inside a loop. |
450
+ | <a id="serial-awaits-in-literal"></a>[`serial-awaits-in-literal`](docs/rules/performance/serial-awaits-in-literal.md) | medium | An array or object literal awaits two or more independent values one after another. |
451
+ | <a id="service-query-in-loop"></a>[`service-query-in-loop`](docs/rules/performance/service-query-in-loop.md) | high | A loop calls a project function that runs several database operations per item. |
452
+ | <a id="session-memory-store"></a>[`session-memory-store`](docs/rules/performance/session-memory-store.md) | high | An express-session middleware has no store, so sessions live in process memory. |
453
+ | <a id="sql-select-star-in-query"></a>[`sql-select-star-in-query`](docs/rules/performance/sql-select-star-in-query.md) | low | A raw SQL query selects every column with SELECT * instead of the columns it needs. |
454
+ | <a id="unbounded-list-query"></a>[`unbounded-list-query`](docs/rules/performance/unbounded-list-query.md) | high | A request handler returns query results without an apparent row limit. |
455
+ | <a id="unbounded-module-cache"></a>[`unbounded-module-cache`](docs/rules/performance/unbounded-module-cache.md) | medium | A long-lived cache accepts dynamic keys without an apparent bound or eviction. |
456
+ | <a id="vue-v-for-missing-key"></a>[`vue-v-for-missing-key`](docs/rules/performance/vue-v-for-missing-key.md) | low | A list rendered with h() has no key prop, forcing inefficient patching. |
457
+ | <a id="vue-watch-missing-cleanup"></a>[`vue-watch-missing-cleanup`](docs/rules/performance/vue-watch-missing-cleanup.md) | medium | onMounted registers a global listener, timer or observer with no unmount cleanup. |
458
+ | <a id="whole-payload-in-memory"></a>[`whole-payload-in-memory`](docs/rules/performance/whole-payload-in-memory.md) | medium | An operation loads an entire file, stream, or response into memory. |
547
459
 
548
460
  <!-- loadwise:rules:end -->
549
461
 
550
- Source diagnostics include a one-based line and column. Repeat `--ignore RULE` to omit specific JS/TS rules from a run. Keep your project's own type check in CI.
551
-
552
- For an intentionally repeated operation, attach the review to that specific site. The comment must be on its own line immediately before the diagnostic line, name one exact rule and include a reason.
553
-
554
- ```ts
555
- // loadwise-reviewed pg-query-in-loop -- Each iteration measures a separate query-plan sample.
556
- await client.query(statement);
557
- ```
558
-
559
- The site remains available with `--include-contextual`. Source comments cannot lower either CI contract, a configured row-scope check, a Prisma transaction-client escape or a Prisma read-modify-write finding. Test, seed and script context applies to Prisma dependent writes and Drizzle whole-table writes in test sources. It also applies to per-item query rules, index rules, serial awaits in literals, Redis `KEYS` and pure-JavaScript password hashing in test, seed and operator-tooling sources (`scripts`, `seeds`, `prisma/seed.ts`, `*.seed.ts`, deployment, migrations). Application code, tests and scripts still participate in source analysis.
560
-
561
- Watch mode uses TypeScript 6.0.3. Watch a single project while editing. With `--watch --json`, each completed scan writes one JSON line. Ctrl+C stops the watcher. One-shot runs support project references.
562
-
563
- One-shot checks pick the compiler automatically. On Node.js 22.13+ with the optional native package for your platform, they use Microsoft's Go-based TypeScript 7.1 beta compiler. It is 2-4 times faster on large projects and reports the same findings. If TypeScript 7 rejects the project configuration, for example `baseUrl` or `moduleResolution: "node10"`, the check uses TypeScript 6.0.3 and prints one note on stderr. `--engine native` (alias `--native`) requires TypeScript 7 and reports incompatible configuration as exit 2. `--engine js` always uses TypeScript 6.0.3. `perf --json` names the engine used in `engine` (`"js"` or `"native"`), and a silent fall-back from the native engine prints a note on stderr. [TypeScript native compiler](https://github.com/microsoft/typescript-go)
564
-
565
- Install the application's driver declarations and generate its Prisma client before checking. Result-shape checks target simple literal PostgreSQL reads and supported Prisma model delegates. Unresolved types, wrappers and deferred callbacks can hide findings. Repeated calls can be intentional, for example retries and ordered writes.
566
-
567
462
  ## ORM and query integrity checks
568
463
 
569
- The JS/TS checker resolves declarations from installed drivers and generated clients. Install the dependencies used by the project, including type declarations. When resolution is incomplete, some calls will be missed. The rules run locally against source and recorded evidence.
570
-
571
- | Library | Source patterns covered |
572
- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
573
- | Prisma | Executed per-item operations, fetching rows only to count, filter, sort or take the first, dependent creates, transaction client use and stale numeric overwrites. |
574
- | Drizzle ORM | Executed fluent queries on the PostgreSQL, MySQL and SQLite core APIs, per-item prepared executions, and direct mutations with an absent or demonstrably ineffective predicate. |
575
- | TypeORM | Repository reads inside repeated execution and simple `find` or `findBy` calls that load entities only for their count. |
576
- | Sequelize | Model reads inside repeated execution and immediate counts of simple `findAll` results. |
577
- | Mongoose | Consumed model queries including common `lean` and `exec` chains, plus immediate counts for simple equivalent filters. |
578
- | Knex and Kysely | Consumed Knex builders and Kysely SELECT execution methods inside repeated work. Simple single-table queries materialized only to read their length. |
579
- | node-postgres | Per-item queries, client-side result processing, pool handoff and transaction commands issued through a pool. |
464
+ Covered libraries: Prisma, Drizzle ORM (PostgreSQL, MySQL and SQLite core APIs), TypeORM, Sequelize, Mongoose, Knex, Kysely and node-postgres. Building an array of lazy Prisma queries alone is quiet, and same-tick `findUnique` calls that Prisma batches itself are left to runtime traces.
580
465
 
581
466
  <!-- loadwise:rules:start checker=performance group=orm-and-query-integrity-checks -->
582
467
 
583
- | Rule | Impact | What it flags |
584
- | ------------------------------------------------------------------------------------------------------------------------------------ | ------ | ---------------------------------------------------------------------------------------- |
585
- | <a id="drizzle-query-in-loop"></a>[`drizzle-query-in-loop`](docs/rules/drizzle-query-in-loop.md) | high | A Drizzle statement executes once per loop iteration. |
586
- | <a id="guard-query-per-request"></a>[`guard-query-per-request`](docs/rules/guard-query-per-request.md) | medium | A guard or per-request hook runs a database query before every handler. |
587
- | <a id="orm-count-materialization"></a>[`orm-count-materialization`](docs/rules/orm-count-materialization.md) | medium | A TypeORM, Sequelize, Mongoose, Knex or Kysely query loads rows only to count them. |
588
- | <a id="orm-query-in-loop"></a>[`orm-query-in-loop`](docs/rules/orm-query-in-loop.md) | high | A TypeORM, Sequelize, Mongoose, Knex or Kysely operation runs once per loop iteration. |
589
- | <a id="prisma-distinct-in-memory"></a>[`prisma-distinct-in-memory`](docs/rules/prisma-distinct-in-memory.md) | medium | Prisma findMany with distinct reads every matching row and de-duplicates in memory. |
590
- | <a id="prisma-relation-count-in-list"></a>[`prisma-relation-count-in-list`](docs/rules/prisma-relation-count-in-list.md) | medium | A paged Prisma findMany selects a relation _count computed over the whole related table. |
591
- | <a id="typeorm-existence-materialization"></a>[`typeorm-existence-materialization`](docs/rules/typeorm-existence-materialization.md) | medium | A TypeORM entity is loaded only to check whether it exists. |
592
- | <a id="typeorm-load-then-save"></a>[`typeorm-load-then-save`](docs/rules/typeorm-load-then-save.md) | high | A TypeORM entity is loaded only to change a few fields and save it back. |
593
- | <a id="typeorm-transaction-in-loop"></a>[`typeorm-transaction-in-loop`](docs/rules/typeorm-transaction-in-loop.md) | high | A loop calls a helper that starts one TypeORM transaction per item. |
594
- | <a id="typeorm-wide-projection"></a>[`typeorm-wide-projection`](docs/rules/typeorm-wide-projection.md) | low | A TypeORM DTO projection loads wide columns it never uses. |
468
+ | Rule | Impact | What it flags |
469
+ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | ---------------------------------------------------------------------------------------- |
470
+ | <a id="drizzle-query-in-loop"></a>[`drizzle-query-in-loop`](docs/rules/performance/drizzle-query-in-loop.md) | high | A Drizzle statement executes once per loop iteration. |
471
+ | <a id="guard-query-per-request"></a>[`guard-query-per-request`](docs/rules/performance/guard-query-per-request.md) | medium | A guard or per-request hook runs a database query before every handler. |
472
+ | <a id="orm-count-materialization"></a>[`orm-count-materialization`](docs/rules/performance/orm-count-materialization.md) | medium | A TypeORM, Sequelize, Mongoose, Knex or Kysely query loads rows only to count them. |
473
+ | <a id="orm-query-in-loop"></a>[`orm-query-in-loop`](docs/rules/performance/orm-query-in-loop.md) | high | A TypeORM, Sequelize, Mongoose, Knex or Kysely operation runs once per loop iteration. |
474
+ | <a id="prisma-distinct-in-memory"></a>[`prisma-distinct-in-memory`](docs/rules/performance/prisma-distinct-in-memory.md) | medium | Prisma findMany with distinct reads every matching row and de-duplicates in memory. |
475
+ | <a id="prisma-relation-count-in-list"></a>[`prisma-relation-count-in-list`](docs/rules/performance/prisma-relation-count-in-list.md) | medium | A paged Prisma findMany selects a relation _count computed over the whole related table. |
476
+ | <a id="typeorm-existence-materialization"></a>[`typeorm-existence-materialization`](docs/rules/performance/typeorm-existence-materialization.md) | medium | A TypeORM entity is loaded only to check whether it exists. |
477
+ | <a id="typeorm-load-then-save"></a>[`typeorm-load-then-save`](docs/rules/performance/typeorm-load-then-save.md) | high | A TypeORM entity is loaded only to change a few fields and save it back. |
478
+ | <a id="typeorm-transaction-in-loop"></a>[`typeorm-transaction-in-loop`](docs/rules/performance/typeorm-transaction-in-loop.md) | high | A loop calls a helper that starts one TypeORM transaction per item. |
479
+ | <a id="typeorm-wide-projection"></a>[`typeorm-wide-projection`](docs/rules/performance/typeorm-wide-projection.md) | low | A TypeORM DTO projection loads wide columns it never uses. |
595
480
 
596
481
  <!-- loadwise:rules:end -->
597
482
 
598
- For Prisma, building an array of lazy queries alone is quiet. A sequential `await` inside a loop can trigger the rule. Same-tick `findUnique` callbacks can use Prisma's own batching, so these are left to runtime traces. [Prisma Client reference](https://www.prisma.io/docs/orm/reference/prisma-client-reference#prismapromise-behavior) · [Prisma transactions](https://www.prisma.io/docs/orm/prisma-client/queries/transactions) · [node-postgres transactions](https://node-postgres.com/features/transactions) · [Drizzle conditional filters](https://orm.drizzle.team/docs/guides/conditional-filters-in-query)
599
-
600
483
  ### Project-defined access policy
601
484
 
602
- Put the policy in the `performance` section of `loadwise.config.json` beside the selected project config (in the working directory for explicit source files), or pass `--policy path/to/file.json`. A policy can use just the sections the project needs (`prismaScopes`, `drizzleScopes`, `parallelReads`, and `fireAndForget`, a list of helper names that `floating-promise` accepts without an await). Duplicate JSON keys within the same object produce a configuration error. [Example policy](examples/query-policy.json)
485
+ Put the policy in the `performance` section of `loadwise.config.json` beside the selected project config (in the working directory for explicit source files), or pass `--policy path/to/file.json`. A policy can use just the sections the project needs: `parallelReads` (groups of exports that may start together, used by `known-reads-awaited-serially`), `fireAndForget` (helper names that `floating-promise` accepts without an await), and `prismaScopes` and `drizzleScopes` (see [Project-defined row scopes](#project-defined-row-scopes)). Duplicate JSON keys within the same object produce a configuration error. [Example policy](examples/query-policy.json)
603
486
 
604
487
  ### Async work and sorting
605
488
 
606
489
  <!-- loadwise:rules:start checker=performance group=async-work-and-sorting -->
607
490
 
608
- | Rule | Impact | What it flags |
609
- | ------------------------------------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------------------------------- |
610
- | <a id="await-before-early-exit"></a>[`await-before-early-exit`](docs/rules/await-before-early-exit.md) | medium | An awaited read runs before a guard that returns or throws without using its result. |
611
- | <a id="count-then-page-serial"></a>[`count-then-page-serial`](docs/rules/count-then-page-serial.md) | low | A count and a page query with the same filter run one after the other. |
612
- | <a id="drizzle-last-insert-id"></a>[`drizzle-last-insert-id`](docs/rules/drizzle-last-insert-id.md) | medium | A MySQL insert is followed by an extra query for its generated ID. |
613
- | <a id="known-reads-awaited-serially"></a>[`known-reads-awaited-serially`](docs/rules/known-reads-awaited-serially.md) | medium | Two independent reads from a configured parallelReads group are awaited one after the other. |
614
- | <a id="numeric-sort-for-extreme"></a>[`numeric-sort-for-extreme`](docs/rules/numeric-sort-for-extreme.md) | low | A numeric sort is used only to read the smallest or largest value. |
615
- | <a id="prisma-count-for-existence"></a>[`prisma-count-for-existence`](docs/rules/prisma-count-for-existence.md) | medium | A Prisma query counts all matches only to check whether any row exists. |
616
- | <a id="promise-combinator-serial-await"></a>[`promise-combinator-serial-await`](docs/rules/promise-combinator-serial-await.md) | medium | Promise.all receives calls that were already awaited one by one. |
617
- | <a id="repeated-workbook-decode"></a>[`repeated-workbook-decode`](docs/rules/repeated-workbook-decode.md) | medium | A workflow decodes the same input with ExcelJS more than once. |
618
- | <a id="typeorm-unused-count"></a>[`typeorm-unused-count`](docs/rules/typeorm-unused-count.md) | medium | A TypeORM count-and-list query discards its total in immediate tuple destructuring. |
491
+ | Rule | Impact | What it flags |
492
+ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------------------------------- |
493
+ | <a id="await-before-early-exit"></a>[`await-before-early-exit`](docs/rules/performance/await-before-early-exit.md) | medium | An awaited read runs before a guard that returns or throws without using its result. |
494
+ | <a id="count-then-page-serial"></a>[`count-then-page-serial`](docs/rules/performance/count-then-page-serial.md) | low | A count and a page query with the same filter run one after the other. |
495
+ | <a id="drizzle-last-insert-id"></a>[`drizzle-last-insert-id`](docs/rules/performance/drizzle-last-insert-id.md) | medium | A MySQL insert is followed by an extra query for its generated ID. |
496
+ | <a id="known-reads-awaited-serially"></a>[`known-reads-awaited-serially`](docs/rules/performance/known-reads-awaited-serially.md) | medium | Two independent reads from a configured parallelReads group are awaited one after the other. |
497
+ | <a id="numeric-sort-for-extreme"></a>[`numeric-sort-for-extreme`](docs/rules/performance/numeric-sort-for-extreme.md) | low | A numeric sort is used only to read the smallest or largest value. |
498
+ | <a id="prisma-count-for-existence"></a>[`prisma-count-for-existence`](docs/rules/performance/prisma-count-for-existence.md) | medium | A Prisma query counts all matches only to check whether any row exists. |
499
+ | <a id="promise-combinator-serial-await"></a>[`promise-combinator-serial-await`](docs/rules/performance/promise-combinator-serial-await.md) | medium | Promise.all receives calls that were already awaited one by one. |
500
+ | <a id="repeated-workbook-decode"></a>[`repeated-workbook-decode`](docs/rules/performance/repeated-workbook-decode.md) | medium | A workflow decodes the same input with ExcelJS more than once. |
501
+ | <a id="typeorm-unused-count"></a>[`typeorm-unused-count`](docs/rules/performance/typeorm-unused-count.md) | medium | A TypeORM count-and-list query discards its total in immediate tuple destructuring. |
619
502
 
620
503
  <!-- loadwise:rules:end -->
621
504
 
622
- The example policy declares that `fetchUser` and `fetchPosts` from `@app/reads` may start together. Only group operations whose ordering, shared connections, rate limits and failure effects your project has reviewed. With that declaration, the checker can flag the pair below. Ordinary adjacent calls such as `saveSettings()` followed by `reloadSettings()` carry no such contract.
623
-
624
- ```ts
625
- import { fetchUser, fetchPosts } from '@app/reads';
626
-
627
- async function load() {
628
- const user = await fetchUser();
629
- const posts = await fetchPosts();
630
- return { user, posts };
631
- }
632
- ```
633
-
634
- The CLI reports review candidates and leaves source files untouched. The scheduling and sorting rules were implemented in this package. The lockfile test checks the full resolved graph for ESLint and the referenced plugins. Design references include the documented ordering limits of sequential-await analysis, ESLint's loop examples and Unicorn's numeric-sort and Promise rules. [Parallelize](https://github.com/braeden/eslint-plugin-parallelize) · [ESLint](https://eslint.org/docs/latest/rules/no-await-in-loop) · [Unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) · [Perf Fiscal](https://github.com/ruidosujeira/perf-fiscal)
635
-
636
- ## Inline fixes
637
-
638
- Where a rule has a safe rewrite for the flagged code, the finding carries a concrete change. With `--json`, it is `fix = { changes: [{ file, line, before, after, create? }], note? }`. Text output prints the change as a diff. A change with `create` holds a whole new file, for example a migration that adds an index. Rules with no safe rewrite fall back to a generic example.
639
-
640
- ```sh
641
- npx loadwise perf -p tsconfig.json --fix # asks y/n/a/q for each fix; needs a terminal
642
- npx loadwise perf -p tsconfig.json --fix --yes # applies eligible fixes without asking
643
- ```
644
-
645
- `--fix` answers are **y**es, **n**o, **a**ll remaining and **q**uit. Without a terminal it requires `--yes`. `--fix` cannot be combined with `--watch`, or with `--json` except with `--only`, and `--yes` is valid only with `--fix`. A fix applies only where the original lines still exist, so code that changed since the scan is refused and a change already in the file is reported as already applied. A fix never overwrites an existing file. Like `loadwise fix`, it adds a why-comment above each fixed statement and formats the changed lines with the project's Prettier; `--no-comments` and `--no-format` turn these off. Review the diff and run your tests afterwards. Rewrites that narrow a whole-table Drizzle update to rows with differing values require individual review because the change can affect locking, triggers and affected-row counts. Upload size limits also require individual review. So does the Mongoose `.lean()` rewrite, because a lean result skips schema defaults, getters and virtuals. The 10 MiB example can reject valid uploads, so check the endpoint's file requirements and any existing gateway or Multer limits before applying it.
646
-
647
- ## Apply fixes by id
648
-
649
- Every finding has a stable `id`, shown as `[rule-id #id]` in text output. It hashes the rule, the file and the flagged line's text, so it survives edits above the finding. JSON findings also carry `fixable` and, when available, `fix`. `prisma-count-for-existence` findings may carry `idField`, the model's single primary-key field, which the fix uses for its `select`. To apply chosen fixes without a prompt:
650
-
651
- ```sh
652
- npx loadwise perf --fix --only a1b2c3d4e5f6,0f9e8d7c6b5a --json # prints { applied, alreadyApplied, failed }
653
- ```
654
-
655
- An unknown id, a finding with no fix, or a fix whose code changed since the scan is listed in `failed`, and the exit code is 2. An id whose change an earlier id in the same run already made, such as a shared `Set`, is listed in `alreadyApplied` and is not a failure. To dismiss a false positive, add the `// loadwise-reviewed <rule-id> -- <reason>` comment described under Source checks.
656
-
657
- ## Check only the lines you changed
658
-
659
- ```sh
660
- npx loadwise perf --staged # lines added or modified in the git index
661
- npx loadwise perf --changed-since origin/main # lines changed in the working tree since a ref
662
- npx loadwise perf -p tsconfig.json --staged --json
663
- ```
664
-
665
- Both flags report only findings on changed lines, each with its id, the exact `--fix --only <id>` command when an automatic fix exists, and the `// loadwise-reviewed <rule-id> -- <reason>` comment that dismisses it. `--json` keeps the usual shape, filtered. The exit code is 1 when findings remain. With no changed JavaScript or TypeScript files the command exits 0 before TypeScript loads. Only the changed files are analyzed as roots, and their imports still resolve through the tsconfig; `schema.prisma` findings are not part of this mode. Files that are untracked count as fully changed with `--changed-since`. Analysis reads the working tree, so a file with unstaged edits can report lines that differ from the staged version. The flags cannot be combined with explicit files, `--watch` or `--fix`.
666
-
667
505
  ## Schema-aware index checks
668
506
 
669
- The source checker reads the project's ORM schema (Prisma, Drizzle, TypeORM, Sequelize, Mongoose) and compares declared indexes with the queries it finds.
507
+ The source checker reads the project's ORM schema (Prisma, Drizzle, TypeORM, Sequelize, Mongoose) and compares declared indexes with the queries it finds. Each suggested index carries one explicit name, used both in the ORM snippet and in the `CREATE INDEX CONCURRENTLY` statement, so building it by hand and then generating a migration does not create a duplicate. Pass `--schema snapshot.json` (written by `perf db --schema-snapshot`) to refine findings with real table sizes and the measured round trip, which also feeds the Impact line of `*-query-in-loop` findings.
670
508
 
671
509
  <!-- loadwise:rules:start checker=performance group=schema-aware-index-checks -->
672
510
 
673
- | Rule | Impact | What it flags |
674
- | ------------------------------------------------------------------------------------------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------- |
675
- | <a id="index-missing-filter"></a>[`index-missing-filter`](docs/rules/index-missing-filter.md) | high | A query filters on a column that no index leads with. |
676
- | <a id="index-missing-foreign-key"></a>[`index-missing-foreign-key`](docs/rules/index-missing-foreign-key.md) | high | A foreign key column in the schema has no index. |
677
- | <a id="index-missing-order"></a>[`index-missing-order`](docs/rules/index-missing-order.md) | medium | A query orders by columns that no index serves in that order. |
678
- | <a id="index-redundant-prefix"></a>[`index-redundant-prefix`](docs/rules/index-redundant-prefix.md) | low | An index repeats the leading columns of a longer index on the same table, adding write cost for no read benefit. |
679
- | <a id="index-unusable-expression"></a>[`index-unusable-expression`](docs/rules/index-unusable-expression.md) | high | A function or expression on an indexed column keeps the index from being used. |
680
- | <a id="index-unusable-pattern"></a>[`index-unusable-pattern`](docs/rules/index-unusable-pattern.md) | high | A predicate such as a leading-wildcard LIKE cannot use an ordinary index. |
511
+ | Rule | Impact | What it flags |
512
+ | ------------------------------------------------------------------------------------------------------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------- |
513
+ | <a id="index-missing-filter"></a>[`index-missing-filter`](docs/rules/performance/index-missing-filter.md) | high | A query filters on a column that no index leads with. |
514
+ | <a id="index-missing-foreign-key"></a>[`index-missing-foreign-key`](docs/rules/performance/index-missing-foreign-key.md) | high | A foreign key column in the schema has no index. |
515
+ | <a id="index-missing-order"></a>[`index-missing-order`](docs/rules/performance/index-missing-order.md) | medium | A query orders by columns that no index serves in that order. |
516
+ | <a id="index-redundant-prefix"></a>[`index-redundant-prefix`](docs/rules/performance/index-redundant-prefix.md) | low | An index repeats the leading columns of a longer index on the same table, adding write cost for no read benefit. |
517
+ | <a id="index-unusable-expression"></a>[`index-unusable-expression`](docs/rules/performance/index-unusable-expression.md) | high | A function or expression on an indexed column keeps the index from being used. |
518
+ | <a id="index-unusable-pattern"></a>[`index-unusable-pattern`](docs/rules/performance/index-unusable-pattern.md) | high | A predicate such as a leading-wildcard LIKE cannot use an ordinary index. |
681
519
 
682
520
  <!-- loadwise:rules:end -->
683
521
 
684
- Each suggested index carries one explicit name, used both in the ORM snippet (`@@index([a, b], map: "<name>")`, `@Index('<name>', ['a', 'b'])`, `{ name: '<name>', fields: [...] }`, `index('<name>')`, `schema.index({ a: 1 }, { name: '<name>' })`) and in the `CREATE INDEX CONCURRENTLY` statement for a live database, so building it by hand and then generating a migration does not create a duplicate. A fix that adds an index to a Prisma, TypeORM or Drizzle model says to generate a migration for it.
685
-
686
- Pass `--schema snapshot.json` (written by `db --schema-snapshot`) to refine them with real table sizes and the measured round trip, which also feeds the Impact line of `*-query-in-loop` findings. Without a snapshot, the checks run from the source schema alone.
687
-
688
522
  ## Polyglot source checks
689
523
 
690
- `npx loadwise perf polyglot src` accepts directories or individual `.py`, `.go`, `.java`, `.cs` and `.rs` files. It uses the optional ast-grep native binary and its syntax-tree patterns. `npx loadwise rel polyglot src` runs the reliability patterns, listed under [Reliability checker](#reliability-checker), on the same files. Language-specific aliases and wrappers can fall outside a pattern. [ast-grep](https://ast-grep.github.io/)
691
-
692
- Performance and maintainability scans retry files when the bundled parser rejects a Java marker annotation before varargs or a C# 14 conditional member assignment (`=`) in a simple identifier chain. The retry uses a position-preserving copy in memory and still fails if the parser reports a syntax error.
524
+ `npx loadwise perf polyglot src` accepts directories or individual `.py`, `.go`, `.java`, `.cs` and `.rs` files and needs the optional [ast-grep](https://ast-grep.github.io/) native binary. `npx loadwise rel polyglot src` runs the reliability patterns on the same files. Language-specific aliases and wrappers can fall outside a pattern.
693
525
 
694
526
  <!-- loadwise:rules:start checker=performance group=polyglot-source-checks -->
695
527
 
696
- | Rule | Impact | What it flags |
697
- | --------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------- |
698
- | <a id="csharp-fixed-regex-in-loop"></a>[`csharp-fixed-regex-in-loop`](docs/rules/csharp-fixed-regex-in-loop.md) | medium | A C# Regex with a fixed pattern is constructed inside a loop. |
699
- | <a id="csharp-string-concat-in-loop"></a>[`csharp-string-concat-in-loop`](docs/rules/csharp-string-concat-in-loop.md) | medium | String concatenation in a C# loop allocates repeatedly; use StringBuilder. |
700
- | <a id="go-fixed-regexp-in-loop"></a>[`go-fixed-regexp-in-loop`](docs/rules/go-fixed-regexp-in-loop.md) | medium | A Go regexp with a fixed pattern is compiled inside a loop. |
701
- | <a id="go-sql-query-in-loop"></a>[`go-sql-query-in-loop`](docs/rules/go-sql-query-in-loop.md) | high | A Go database query executes inside a loop instead of batching. |
702
- | <a id="go-string-concat-in-loop"></a>[`go-string-concat-in-loop`](docs/rules/go-string-concat-in-loop.md) | medium | String concatenation in a Go loop allocates repeatedly; use strings.Builder. |
703
- | <a id="java-fixed-regex-in-loop"></a>[`java-fixed-regex-in-loop`](docs/rules/java-fixed-regex-in-loop.md) | medium | A Java Pattern with a fixed pattern is compiled inside a loop. |
704
- | <a id="java-jdbc-query-in-loop"></a>[`java-jdbc-query-in-loop`](docs/rules/java-jdbc-query-in-loop.md) | high | A JDBC query executes inside a Java loop instead of batching. |
705
- | <a id="java-string-concat-in-loop"></a>[`java-string-concat-in-loop`](docs/rules/java-string-concat-in-loop.md) | medium | String concatenation in a Java loop allocates repeatedly; use StringBuilder. |
706
- | <a id="python-blocking-sleep-in-async"></a>[`python-blocking-sleep-in-async`](docs/rules/python-blocking-sleep-in-async.md) | high | A blocking time.sleep call runs inside a Python async def function. |
707
- | <a id="python-copy-growing-list"></a>[`python-copy-growing-list`](docs/rules/python-copy-growing-list.md) | medium | A Python loop rebuilds a growing list with items = items + [value]. |
708
- | <a id="python-fixed-regex-in-loop"></a>[`python-fixed-regex-in-loop`](docs/rules/python-fixed-regex-in-loop.md) | low | A Python loop compiles a fixed pattern with re.compile on every iteration. |
709
- | <a id="python-n-plus-one-orm-loop"></a>[`python-n-plus-one-orm-loop`](docs/rules/python-n-plus-one-orm-loop.md) | high | An ORM query executes inside a Python loop instead of using eager loading or batching. |
710
- | <a id="python-sync-requests-in-async"></a>[`python-sync-requests-in-async`](docs/rules/python-sync-requests-in-async.md) | high | A blocking requests HTTP call runs inside a Python async def function. |
711
- | <a id="python-unbounded-comprehension"></a>[`python-unbounded-comprehension`](docs/rules/python-unbounded-comprehension.md) | medium | A Python list comprehension materializes an unbounded collection in memory. |
712
- | <a id="rust-clone-in-loop"></a>[`rust-clone-in-loop`](docs/rules/rust-clone-in-loop.md) | low | Cloning values inside a Rust loop adds avoidable heap allocations. |
713
- | <a id="rust-fixed-regex-in-loop"></a>[`rust-fixed-regex-in-loop`](docs/rules/rust-fixed-regex-in-loop.md) | medium | A Rust Regex with a fixed pattern is compiled inside a loop. |
714
- | <a id="rust-format-in-loop"></a>[`rust-format-in-loop`](docs/rules/rust-format-in-loop.md) | low | Calling format! inside a Rust loop allocates a new String on every iteration. |
528
+ | Rule | Impact | What it flags |
529
+ | --------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------- |
530
+ | <a id="csharp-fixed-regex-in-loop"></a>[`csharp-fixed-regex-in-loop`](docs/rules/performance/csharp-fixed-regex-in-loop.md) | medium | A C# Regex with a fixed pattern is constructed inside a loop. |
531
+ | <a id="csharp-string-concat-in-loop"></a>[`csharp-string-concat-in-loop`](docs/rules/performance/csharp-string-concat-in-loop.md) | medium | String concatenation in a C# loop allocates repeatedly; use StringBuilder. |
532
+ | <a id="go-fixed-regexp-in-loop"></a>[`go-fixed-regexp-in-loop`](docs/rules/performance/go-fixed-regexp-in-loop.md) | medium | A Go regexp with a fixed pattern is compiled inside a loop. |
533
+ | <a id="go-sql-query-in-loop"></a>[`go-sql-query-in-loop`](docs/rules/performance/go-sql-query-in-loop.md) | high | A Go database query executes inside a loop instead of batching. |
534
+ | <a id="go-string-concat-in-loop"></a>[`go-string-concat-in-loop`](docs/rules/performance/go-string-concat-in-loop.md) | medium | String concatenation in a Go loop allocates repeatedly; use strings.Builder. |
535
+ | <a id="java-fixed-regex-in-loop"></a>[`java-fixed-regex-in-loop`](docs/rules/performance/java-fixed-regex-in-loop.md) | medium | A Java Pattern with a fixed pattern is compiled inside a loop. |
536
+ | <a id="java-jdbc-query-in-loop"></a>[`java-jdbc-query-in-loop`](docs/rules/performance/java-jdbc-query-in-loop.md) | high | A JDBC query executes inside a Java loop instead of batching. |
537
+ | <a id="java-string-concat-in-loop"></a>[`java-string-concat-in-loop`](docs/rules/performance/java-string-concat-in-loop.md) | medium | String concatenation in a Java loop allocates repeatedly; use StringBuilder. |
538
+ | <a id="python-blocking-sleep-in-async"></a>[`python-blocking-sleep-in-async`](docs/rules/performance/python-blocking-sleep-in-async.md) | high | A blocking time.sleep call runs inside a Python async def function. |
539
+ | <a id="python-copy-growing-list"></a>[`python-copy-growing-list`](docs/rules/performance/python-copy-growing-list.md) | medium | A Python loop rebuilds a growing list with items = items + [value]. |
540
+ | <a id="python-fixed-regex-in-loop"></a>[`python-fixed-regex-in-loop`](docs/rules/performance/python-fixed-regex-in-loop.md) | low | A Python loop compiles a fixed pattern with re.compile on every iteration. |
541
+ | <a id="python-n-plus-one-orm-loop"></a>[`python-n-plus-one-orm-loop`](docs/rules/performance/python-n-plus-one-orm-loop.md) | high | An ORM query executes inside a Python loop instead of using eager loading or batching. |
542
+ | <a id="python-sync-requests-in-async"></a>[`python-sync-requests-in-async`](docs/rules/performance/python-sync-requests-in-async.md) | high | A blocking requests HTTP call runs inside a Python async def function. |
543
+ | <a id="python-unbounded-comprehension"></a>[`python-unbounded-comprehension`](docs/rules/performance/python-unbounded-comprehension.md) | medium | A Python list comprehension materializes an unbounded collection in memory. |
544
+ | <a id="rust-clone-in-loop"></a>[`rust-clone-in-loop`](docs/rules/performance/rust-clone-in-loop.md) | low | Cloning values inside a Rust loop adds avoidable heap allocations. |
545
+ | <a id="rust-fixed-regex-in-loop"></a>[`rust-fixed-regex-in-loop`](docs/rules/performance/rust-fixed-regex-in-loop.md) | medium | A Rust Regex with a fixed pattern is compiled inside a loop. |
546
+ | <a id="rust-format-in-loop"></a>[`rust-format-in-loop`](docs/rules/performance/rust-format-in-loop.md) | low | Calling format! inside a Rust loop allocates a new String on every iteration. |
715
547
 
716
548
  <!-- loadwise:rules:end -->
717
549
 
718
550
  ## Trace checks in other languages and databases
719
551
 
720
- Supply a local **OTLP/JSON trace export** with `resourceSpans → scopeSpans → spans`. An OpenTelemetry Collector with a file export can produce this format. The CLI accepts one export object per invocation. For a collector output containing multiple JSON lines, pass the relevant export object for the request. Spans split across separate invocations count independently.
721
-
722
- Try `npx loadwise perf traces node_modules/loadwise/examples/repeated-db.otlp.json`. The example reports five similar MongoDB operations under one parent. The trace rules use current and legacy database attributes and deduplicate span IDs.
552
+ `npx loadwise perf traces <file>` reads one local OTLP/JSON trace export (`resourceSpans → scopeSpans → spans`), such as an OpenTelemetry Collector file export; for a collector output with multiple JSON lines, pass the export object for the request. `--threshold` sets how many similar sibling calls form a finding. Try `npx loadwise perf traces node_modules/loadwise/examples/repeated-db.otlp.json`. Reports contain span IDs and counts and omit raw SQL, parameters and keys; check `scannedSpans` and `eligibleDbSpans` when interpreting a clean result.
723
553
 
724
554
  <!-- loadwise:rules:start checker=performance group=trace-checks-in-other-languages-and-databases -->
725
555
 
726
- | Rule | Impact | What it flags |
727
- | ------------------------------------------------------------------------------------------ | ------ | ------------------------------------------------------------------- |
728
- | <a id="duplicate-key-read"></a>[`duplicate-key-read`](docs/rules/duplicate-key-read.md) | medium | A trace repeats the same key or row read under one parent span. |
729
- | <a id="redis-keys-scan"></a>[`redis-keys-scan`](docs/rules/redis-keys-scan.md) | high | A trace shows a Redis KEYS command scanning the keyspace. |
730
- | <a id="redis-repeated-read"></a>[`redis-repeated-read`](docs/rules/redis-repeated-read.md) | medium | A trace shows repeated sibling Redis GET or HGET calls. |
731
- | <a id="repeated-db-span"></a>[`repeated-db-span`](docs/rules/repeated-db-span.md) | high | A trace shows many similar sibling database calls under one parent. |
556
+ | Rule | Impact | What it flags |
557
+ | ------------------------------------------------------------------------------------------------------ | ------ | ------------------------------------------------------------------- |
558
+ | <a id="duplicate-key-read"></a>[`duplicate-key-read`](docs/rules/performance/duplicate-key-read.md) | medium | A trace repeats the same key or row read under one parent span. |
559
+ | <a id="redis-keys-scan"></a>[`redis-keys-scan`](docs/rules/performance/redis-keys-scan.md) | high | A trace shows a Redis KEYS command scanning the keyspace. |
560
+ | <a id="redis-repeated-read"></a>[`redis-repeated-read`](docs/rules/performance/redis-repeated-read.md) | medium | A trace shows repeated sibling Redis GET or HGET calls. |
561
+ | <a id="repeated-db-span"></a>[`repeated-db-span`](docs/rules/performance/repeated-db-span.md) | high | A trace shows many similar sibling database calls under one parent. |
732
562
 
733
563
  <!-- loadwise:rules:end -->
734
564
 
735
- Matching keys in two reads are a reason to consider **request-local** reuse when authorization, freshness and ordering allow it. Keep existing telemetry redaction. A redacted key can still support a batching finding. Reports contain span IDs and counts and omit raw SQL, parameters and keys. Check `scannedSpans` and `eligibleDbSpans` when interpreting a clean result. Sampling, missing parents, different literal values and coarse summaries affect grouping. [OpenTelemetry database spans](https://opentelemetry.io/docs/specs/semconv/db/database-spans/) · [OTLP JSON encoding](https://opentelemetry.io/docs/specs/otlp/#json-protobuf-encoding)
736
-
737
565
  ## Executed query plans
738
566
 
739
- Feed the CLI a JSON file from PostgreSQL `EXPLAIN (ANALYZE, FORMAT JSON)` or MongoDB `explain("executionStats")`. For example, run `npx loadwise perf plan node_modules/loadwise/examples/postgres-plan.json`. The checker reads the file locally. PostgreSQL's `ANALYZE` option executes the statement when you collect the plan. [PostgreSQL EXPLAIN](https://www.postgresql.org/docs/current/using-explain.html) · [MongoDB explain results](https://www.mongodb.com/docs/manual/reference/explain-results/)
567
+ `npx loadwise perf plan <file>` reads a JSON file from PostgreSQL `EXPLAIN (ANALYZE, FORMAT JSON)` or MongoDB `explain("executionStats")`, for example `node_modules/loadwise/examples/postgres-plan.json`, and reports the stage path and observed counts (MongoDB: classic stages and selected slot-based scan, filter and skip shapes). Planner estimates alone, and layouts where a scan cannot be attributed, exit 2. PostgreSQL's `ANALYZE` option executes the statement when you collect the plan.
740
568
 
741
569
  <!-- loadwise:rules:start checker=performance group=executed-query-plans -->
742
570
 
743
- | Rule | Impact | What it flags |
744
- | ------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------- |
745
- | <a id="mongo-collection-scan"></a>[`mongo-collection-scan`](docs/rules/mongo-collection-scan.md) | high | A MongoDB plan scans many documents for each one it returns. |
746
- | <a id="mongo-deep-skip"></a>[`mongo-deep-skip`](docs/rules/mongo-deep-skip.md) | high | A MongoDB query skips past many documents to return a page. |
747
- | <a id="mongo-disk-sort"></a>[`mongo-disk-sort`](docs/rules/mongo-disk-sort.md) | medium | A MongoDB sort spilled to disk. |
748
- | <a id="pg-deep-offset"></a>[`pg-deep-offset`](docs/rules/pg-deep-offset.md) | high | A PostgreSQL plan walks past many rows with OFFSET to return a page. |
749
- | <a id="pg-disk-sort"></a>[`pg-disk-sort`](docs/rules/pg-disk-sort.md) | medium | A PostgreSQL sort spilled to disk. |
750
- | <a id="pg-sequential-scan"></a>[`pg-sequential-scan`](docs/rules/pg-sequential-scan.md) | high | A PostgreSQL plan scans many rows for each one it returns. |
571
+ | Rule | Impact | What it flags |
572
+ | ------------------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------- |
573
+ | <a id="mongo-collection-scan"></a>[`mongo-collection-scan`](docs/rules/performance/mongo-collection-scan.md) | high | A MongoDB plan scans many documents for each one it returns. |
574
+ | <a id="mongo-deep-skip"></a>[`mongo-deep-skip`](docs/rules/performance/mongo-deep-skip.md) | high | A MongoDB query skips past many documents to return a page. |
575
+ | <a id="mongo-disk-sort"></a>[`mongo-disk-sort`](docs/rules/performance/mongo-disk-sort.md) | medium | A MongoDB sort spilled to disk. |
576
+ | <a id="pg-deep-offset"></a>[`pg-deep-offset`](docs/rules/performance/pg-deep-offset.md) | high | A PostgreSQL plan walks past many rows with OFFSET to return a page. |
577
+ | <a id="pg-disk-sort"></a>[`pg-disk-sort`](docs/rules/performance/pg-disk-sort.md) | medium | A PostgreSQL sort spilled to disk. |
578
+ | <a id="pg-sequential-scan"></a>[`pg-sequential-scan`](docs/rules/performance/pg-sequential-scan.md) | high | A PostgreSQL plan scans many rows for each one it returns. |
751
579
 
752
580
  <!-- loadwise:rules:end -->
753
581
 
754
- Results include the stage path and observed counts. PostgreSQL and MongoDB planner estimates alone return exit 2. MongoDB coverage includes classic executed query stages and selected slot-based scan/filter and skip shapes. Unsupported layouts return an input error where a scan cannot be attributed.
755
-
756
582
  ## Database inspection (optional)
757
583
 
758
584
  `npx loadwise perf db` is the only command that connects to a database. Point it at a staging or read replica database, never a primary you cannot afford to touch. It uses the project's own `pg`, `mysql2` or `mongodb` package.
@@ -774,163 +600,100 @@ npx loadwise perf --schema snapshot.json
774
600
  | `--measure --i-understand-this-locks-tables` | PostgreSQL staging only. Time each suggested index for `--queries` by building it in a rolled-back transaction. |
775
601
  | `--runs N` | `EXPLAIN ANALYZE` runs per side for `--measure` (default 5). |
776
602
 
777
- Rules: `db-unindexed-foreign-key`, `db-unused-index`, `db-duplicate-index`, `db-seq-scan-heavy-table`, `db-slow-query-plan`, `db-missing-index` and, for MongoDB, `mongo-collection-scan-observed`. `--include-contextual`, `--ignore RULE` and `--json` work as in the other commands.
603
+ `--include-contextual`, `--ignore RULE` and `--json` work as in the other commands.
778
604
 
779
605
  <!-- loadwise:rules:start checker=performance group=database-inspection-optional -->
780
606
 
781
- | Rule | Impact | What it flags |
782
- | --------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------- |
783
- | <a id="db-duplicate-index"></a>[`db-duplicate-index`](docs/rules/db-duplicate-index.md) | low | A database index is covered by another index on the same table. |
784
- | <a id="db-missing-index"></a>[`db-missing-index`](docs/rules/db-missing-index.md) | high | A query plan scans a table that a suggested index would let it seek. |
785
- | <a id="db-seq-scan-heavy-table"></a>[`db-seq-scan-heavy-table`](docs/rules/db-seq-scan-heavy-table.md) | high | A large table is read by many sequential scans on the live database. |
786
- | <a id="db-slow-query-plan"></a>[`db-slow-query-plan`](docs/rules/db-slow-query-plan.md) | high | One of the slowest statements reads a table with a full table scan. |
787
- | <a id="db-unindexed-foreign-key"></a>[`db-unindexed-foreign-key`](docs/rules/db-unindexed-foreign-key.md) | high | A foreign key on the live database has no index that leads with its columns. |
788
- | <a id="db-unused-index"></a>[`db-unused-index`](docs/rules/db-unused-index.md) | low | A database index has not been scanned since statistics were last reset. |
789
- | <a id="mongo-collection-scan-observed"></a>[`mongo-collection-scan-observed`](docs/rules/mongo-collection-scan-observed.md) | high | Profiled MongoDB operations scanned a whole collection. |
607
+ | Rule | Impact | What it flags |
608
+ | --------------------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------- |
609
+ | <a id="db-duplicate-index"></a>[`db-duplicate-index`](docs/rules/performance/db-duplicate-index.md) | low | A database index is covered by another index on the same table. |
610
+ | <a id="db-missing-index"></a>[`db-missing-index`](docs/rules/performance/db-missing-index.md) | high | A query plan scans a table that a suggested index would let it seek. |
611
+ | <a id="db-seq-scan-heavy-table"></a>[`db-seq-scan-heavy-table`](docs/rules/performance/db-seq-scan-heavy-table.md) | high | A large table is read by many sequential scans on the live database. |
612
+ | <a id="db-slow-query-plan"></a>[`db-slow-query-plan`](docs/rules/performance/db-slow-query-plan.md) | high | One of the slowest statements reads a table with a full table scan. |
613
+ | <a id="db-unindexed-foreign-key"></a>[`db-unindexed-foreign-key`](docs/rules/performance/db-unindexed-foreign-key.md) | high | A foreign key on the live database has no index that leads with its columns. |
614
+ | <a id="db-unused-index"></a>[`db-unused-index`](docs/rules/performance/db-unused-index.md) | low | A database index has not been scanned since statistics were last reset. |
615
+ | <a id="mongo-collection-scan-observed"></a>[`mongo-collection-scan-observed`](docs/rules/performance/mongo-collection-scan-observed.md) | high | Profiled MongoDB operations scanned a whole collection. |
790
616
 
791
617
  <!-- loadwise:rules:end -->
792
618
 
793
- **Safety guarantees.** Statements go through a read-only gateway: sessions and transactions are read-only, with a 5 s statement timeout on PostgreSQL, and only SELECT, INSERT, UPDATE and DELETE can be explained. `EXPLAIN ANALYZE` runs only for a plain SELECT (a `WITH` that modifies data is refused). MongoDB uses a command allowlist. Error text is redacted: the connection URL, host, user, password and resolved IP addresses are replaced with `[redacted]`. Usage counters come from the node that answered, so an index unused here may still be used on a replica.
794
-
795
- **`--measure` warning.** Building an index blocks writes to that table while it runs. Use it on staging only. It refuses a connection variable or database name matching `/prod/i`, a replica, an unknown table size and any table over 5,000,000 estimated rows, and it needs the long confirmation flag. When the HypoPG extension is installed, suggested indexes are also checked hypothetically without building anything.
796
-
797
- **Measured vs estimated.** Output labels every figure. A _measured_ number was timed on your database (a round-trip median, or an `EXPLAIN ANALYZE` before and after an index built by `--measure`). An _estimated_ number comes from planner statistics or a model, and a suggestion validated only by HypoPG still says it is an estimate. Treat estimates as a reason to test, not as a result.
798
-
799
- ## Interpreting findings
800
-
801
- Start with the endpoint's query count, latency and a representative input size. A reusable index or lookup table costs memory and build time. An extra database index also costs writes and storage. For a proposed batch or cache, compare results as well as time, including empty inputs, duplicates, tenant boundaries and concurrent writes.
802
-
803
- The rules cover query shape, caching candidates, pooling, selected blocking work and collection complexity. Response compression settings, CDN placement, load balancing, partitioning, service boundaries and capacity planning depend on traffic, topology and operational costs. Use workload measurements when making those deployment decisions. [10 Essential Tips for Backend Performance Optimization](https://medium.com/@rhgustmfrh/10-essential-tips-for-backend-performance-optimization-8b55fce0ca17) · [Backend Performance Best Practices roadmap](https://roadmap.sh/backend-performance-best-practices)
804
-
805
- ## Impact levels
806
-
807
- Every finding carries an impact level. `--min-impact <low|medium|high|critical>` reports only findings at that level or above, and the filtered ones do not count toward the exit code; an unknown level exits 2. JSON findings carry it as `impactLevel` (`impact` is the before/after estimate). Text output shows the level after the rule and lists the most severe finding first within each file, keeping the current order for equal levels.
808
-
809
- - `critical`: data loss or corruption, an outage or a lock risk in production.
810
- - `high`: a per-request scaling problem such as an N+1 or query in a loop, a deep offset, a missing foreign-key or filter index, an HTTP call without a timeout, or a dependency cycle with load-time effects.
811
- - `medium`: a measurable but local cost, or significant maintainability debt.
812
- - `low`: a micro-optimization or a readability issue.
813
-
814
- ## Verification and benchmarks
815
-
816
- Integration checks used PostgreSQL 18.0 and MongoDB 8.2.3. Each engine examined 20,000 records for one match before an index was added. The corresponding indexed read passed. In both databases a deep page walked 15,010 entries to return ten, and the equivalent keyset query passed. Both engines also produced a disk-sort finding. MongoDB's live test used classic execution stages.
817
-
818
- On Redis 7.2.16, the CLI flagged a real `KEYS` call and eight redacted `GET` calls. A test hook exposing only a synthetic key let it identify eight duplicate reads. A single request-local read returned the same eight values and passed. Python SQLite instrumentation separately verified nine statements versus one batched statement for the same eight result rows.
819
-
820
- Use Node.js 22.13+ for the full development workflow, including the in-memory SQLite benchmark.
821
-
822
- ### Source conventions
823
-
824
- The CLI and checkers are TypeScript (`.ts`) compiled in place to ES modules (`.js`, not committed) by `npm run build`, while the security example tables under `lib/security/examples/` are `.cts` compiled to CommonJS (`.cjs`); `npm test` builds first and `npm run typecheck` checks without emitting. Import with the runtime extension (`.js` or `.cjs`). The compiler runs in `strict` mode.
825
-
826
- - Write ES `import`/`export`, with imports at the top of the file. Oxlint rejects `require()`. Where load order or startup cost forbids a top-level import (the compiler must be chosen before the rules load, and `maint --staged` must not load TypeScript), load lazily in an async function with `await import()`.
827
- - No `any` and no `as` assertions (`as const` is fine) in new code. Narrow with type guards, give a function a precise type, or use overloads. A deliberate exception needs a lint-disable comment that says why.
828
- - Types shared by two or more files live in the `types/` folder of their area (`lib/performance/types/`, `lib/security/types/`, `lib/maintainability/types/`, `lib/shared/types/`, `test/types/`), one topic per file. Cross-pillar types are in `lib/shared/types.ts`. A type used by one file stays in that file.
829
- - Comments wrap at 100 columns, and Prettier formats everything. `.vscode/settings.json` formats on save, and the pre-commit hook in `hooks/` formats and lints staged files (`npm install` enables it).
830
-
831
- ```sh
832
- npm ci
833
- npm test
834
- node bin/loadwise.js perf -p examples
835
- npm run bench:patterns
836
- npm run bench:scan
837
- npm run bench:scan -- --large
838
- npm run bench:traces
839
- npm run bench:scorecard
840
- npm run bench:corpus
841
- npm run bench:recall
842
- ```
843
-
844
- The benchmark commands verify their expected results. The pattern benchmark compares equal application outputs. The scan benchmarks measure the checker itself. Real request latency depends on the workload, instrumentation and database. `bench:scorecard` writes `bench/corpus/scorecard.md`, and `bench:corpus` fails when a default-level rule with at least 10 labels is under 80% precision, unless `bench/corpus/precision-floor-exceptions.json` lists it. `bench:recall` scans the known-vulnerable and known-slow snippets in `bench/recall/cases`, prints the recall, and exits 1 while any case in `bench/recall/manifest.json` is missed.
845
-
846
- To repeat the optional six-package ORM declaration integration from the source checkout, run the commands below. The fixture typechecks the application, compares exact diagnostic locations and checks that clean controls stay quiet.
619
+ **Safety.** Sessions and transactions are read-only, with a 5 s statement timeout on PostgreSQL, and only SELECT, INSERT, UPDATE and DELETE can be explained. `EXPLAIN ANALYZE` runs only for a plain SELECT (a `WITH` that modifies data is refused). MongoDB uses a command allowlist. Error text replaces the connection URL, host, user, password and resolved IP addresses with `[redacted]`. Usage counters come from the node that answered, so an index unused here may still be used on a replica.
847
620
 
848
- ```sh
849
- npm --prefix test/performance/integration/orms install --ignore-scripts --omit=optional --no-audit --no-fund
850
- npm --prefix test/performance/integration/orms run verify -- --native
851
- ```
852
-
853
- The large benchmark checks 3,200 generated source files and verifies expected diagnostics. The performance report also covers a 1,180-file NestJS checkout. [Measurements and methodology](PERFORMANCE.md)
854
-
855
- ## References
856
-
857
- Prisma documents per-item queries and batching. Node documents the event-loop effects of synchronous file I/O. [Prisma query optimization](https://www.prisma.io/docs/orm/v6/prisma-client/queries/query-optimization-performance) · [Node event loop guidance](https://nodejs.org/learn/asynchronous-work/dont-block-the-event-loop)
858
-
859
- Repeated lookups can benefit from a reusable membership index. Repeated growing copies can become quadratic. Biome already includes a lint rule for accumulating spread. [JavaScript Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) · [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#when_to_not_use_reduce) · [Biome rule](https://biomejs.dev/linter/rules/no-accumulating-spread/javascript/)
860
-
861
- Sentry also has an N+1 detector that considers sequential spans and their total duration. This package's local trace check groups similar sibling calls, including concurrent calls. [Sentry N+1 detection](https://docs.sentry.io/product/issues/issue-details/performance-issues/n-one-queries/)
621
+ **`--measure` blocks writes** to the table while each index builds. It refuses a connection variable or database name matching `/prod/i`, a replica, an unknown table size and any table over 5,000,000 estimated rows, and it needs the long confirmation flag. With the HypoPG extension, suggested indexes are also checked hypothetically. Output labels every figure as _measured_ (timed on your database) or _estimated_ (planner statistics, a model or HypoPG).
862
622
 
863
623
  # Reliability checker
864
624
 
865
- `loadwise rel` finds code that fails at runtime or under concurrency: unhandled rejections, swallowed errors, races, missing timeouts and idempotency, transactions that escape their client, unsafe migrations and breaking API changes. It shares the source check of `loadwise perf`, so project discovery, policy, config, engines, baselines and fix flags are the same, and `loadwise check` type-checks the project once for both. Run it with `npx loadwise rel -p tsconfig.json`; `npx loadwise rel --help` lists every flag.
625
+ `loadwise rel` finds code that fails at runtime or under concurrency: unhandled rejections, swallowed errors, races, missing timeouts and idempotency, transactions that escape their client, unsafe migrations and breaking API changes. It shares the source check of `loadwise perf`, so project discovery, policy, config, engines, baselines and fix flags are the same, and `loadwise check` type-checks the project once for both. Run it with `npx loadwise rel -p tsconfig.json`; `npx loadwise rel --help` lists every flag. `loadwise rel --fail-on contract` enforces only `pg-transaction-on-pool`.
866
626
 
867
627
  ## Source rules
868
628
 
869
- The rules from `pg-transaction-on-pool` to `swallowed-error` moved from the performance and maintainability checkers with the same ids, so existing `// loadwise-reviewed` comments, `--ignore` flags and config `rules` entries keep working. Migration and API contract rules are described in [Migration safety](#migration-safety) and [API contract safety](#api-contract-safety). `csharp-async-void` and the `python-`, `go-`, `java-`, `csharp-` and `rust-` rules come from `loadwise rel polyglot`, which needs the optional ast-grep executable.
629
+ Some rules moved here from the performance and maintainability checkers and kept their ids, so existing `// loadwise-reviewed` comments, `--ignore` flags and config `rules` entries keep working. `csharp-async-void` and the `python-`, `go-`, `java-`, `csharp-` and `rust-` rules come from `loadwise rel polyglot`, which needs the optional ast-grep executable.
870
630
 
871
631
  <!-- loadwise:rules:start checker=reliability group=source-rules -->
872
632
 
873
- | Rule | Impact | What it flags |
874
- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
875
- | <a id="assignment-in-condition"></a>[`assignment-in-condition`](docs/rules/assignment-in-condition.md) | high | A condition assigns with = where a comparison was probably meant. |
876
- | <a id="async-callback-unhandled-rejection"></a>[`async-callback-unhandled-rejection`](docs/rules/async-callback-unhandled-rejection.md) | high | An async callback given to an event emitter, timer or scheduler has no error handling, so a rejection is unhandled. |
877
- | <a id="async-route-unhandled-rejection"></a>[`async-route-unhandled-rejection`](docs/rules/async-route-unhandled-rejection.md) | high | An Express 4 async route handler has no error handling, so a rejection never reaches the error middleware. |
878
- | <a id="browser-not-closed"></a>[`browser-not-closed`](docs/rules/browser-not-closed.md) | high | A Playwright or Puppeteer browser is not closed in a finally block, so an error leaves the process running. |
879
- | <a id="check-then-update-race"></a>[`check-then-update-race`](docs/rules/check-then-update-race.md) | high | A Mongoose or Sequelize document's numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates. |
880
- | <a id="child-process-without-error-listener"></a>[`child-process-without-error-listener`](docs/rules/child-process-without-error-listener.md) | high | A spawned child process has no 'error' listener, so a failed spawn crashes the parent process. |
881
- | <a id="csharp-async-void"></a>[`csharp-async-void`](docs/rules/csharp-async-void.md) | high | An async void method cannot be awaited and can crash the process on unhandled exceptions. |
882
- | <a id="csharp-disposable-without-using"></a>[`csharp-disposable-without-using`](docs/rules/csharp-disposable-without-using.md) | medium | A C# stream, connection or other IDisposable is created without using, so an exception leaks it. |
883
- | <a id="discarded-error-result"></a>[`discarded-error-result`](docs/rules/discarded-error-result.md) | high | A call discards a typed Either or Result that can carry a failure as a value. |
884
- | <a id="drizzle-unfiltered-write"></a>[`drizzle-unfiltered-write`](docs/rules/drizzle-unfiltered-write.md) | critical | A Drizzle update or delete executes without an effective where clause. |
885
- | <a id="drizzle-write-preflight"></a>[`drizzle-write-preflight`](docs/rules/drizzle-write-preflight.md) | medium | A separate existence check before a Drizzle write can race with another request. |
886
- | <a id="error-logged-without-stack"></a>[`error-logged-without-stack`](docs/rules/error-logged-without-stack.md) | low | A catch block logs only error.message and carries on, so the stack trace is lost. |
887
- | <a id="error-rethrown-without-cause"></a>[`error-rethrown-without-cause`](docs/rules/error-rethrown-without-cause.md) | low | A catch block throws a new error without the caught one, so the original message and stack are lost. |
888
- | <a id="file-handle-not-closed"></a>[`file-handle-not-closed`](docs/rules/file-handle-not-closed.md) | high | A FileHandle from fs/promises open() is not closed on every path, leaking a file descriptor. |
889
- | <a id="find-then-create-race"></a>[`find-then-create-race`](docs/rules/find-then-create-race.md) | high | A lookup by key is followed by an insert with that key, with no unique constraint to stop duplicates. |
890
- | <a id="floating-promise"></a>[`floating-promise`](docs/rules/floating-promise.md) | high | A promise-returning call is neither awaited, returned nor handled, so its failure goes unseen. |
891
- | <a id="go-defer-before-error-check"></a>[`go-defer-before-error-check`](docs/rules/go-defer-before-error-check.md) | high | A Go defer closes a resource before its error is checked, so a failed open dereferences nil. |
892
- | <a id="go-error-discarded"></a>[`go-error-discarded`](docs/rules/go-error-discarded.md) | high | A Go error result is assigned to the blank identifier and never checked. |
893
- | <a id="http-call-without-timeout"></a>[`http-call-without-timeout`](docs/rules/http-call-without-timeout.md) | high | A fetch or axios call has no timeout or abort signal. |
894
- | <a id="interval-not-cleared"></a>[`interval-not-cleared`](docs/rules/interval-not-cleared.md) | medium | A setInterval handle is discarded or never cleared, so the timer outlives its owner. |
895
- | <a id="invalid-typeof-comparison"></a>[`invalid-typeof-comparison`](docs/rules/invalid-typeof-comparison.md) | high | A typeof result is compared to a string typeof never returns, so the check never matches. |
896
- | <a id="java-resource-without-try"></a>[`java-resource-without-try`](docs/rules/java-resource-without-try.md) | high | A Java stream, reader or connection is opened outside try-with-resources, so an exception leaks it. |
897
- | <a id="json-parse-unguarded"></a>[`json-parse-unguarded`](docs/rules/json-parse-unguarded.md) | medium | JSON.parse runs on outside input with no try/catch, so malformed input throws where it is not handled. |
898
- | <a id="loop-index-past-length"></a>[`loop-index-past-length`](docs/rules/loop-index-past-length.md) | high | A loop runs its index up to and including length, so the last pass reads past the end. |
899
- | <a id="mongoose-aggregate-uncast-id"></a>[`mongoose-aggregate-uncast-id`](docs/rules/mongoose-aggregate-uncast-id.md) | high | A Mongoose aggregate $match compares _id to an uncast string instead of an ObjectId. |
900
- | <a id="nan-comparison"></a>[`nan-comparison`](docs/rules/nan-comparison.md) | high | A value is compared to NaN with an equality operator, which is never true. |
901
- | <a id="next-server-env-in-client"></a>[`next-server-env-in-client`](docs/rules/next-server-env-in-client.md) | high | A 'use client' file reads a process.env variable without the NEXT_PUBLIC_ prefix, so it is unavailable in the browser by default. |
902
- | <a id="payment-missing-idempotency-key"></a>[`payment-missing-idempotency-key`](docs/rules/payment-missing-idempotency-key.md) | high | A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice. |
903
- | <a id="pg-transaction-on-pool"></a>[`pg-transaction-on-pool`](docs/rules/pg-transaction-on-pool.md) | critical | A transaction statement is sent to a pool, so its statements can run on different connections. |
904
- | <a id="pool-without-connection-timeout"></a>[`pool-without-connection-timeout`](docs/rules/pool-without-connection-timeout.md) | medium | A pg Pool or Client sets no connectionTimeoutMillis, so its default of 0 waits for a connection forever. |
905
- | <a id="prisma-dependent-writes"></a>[`prisma-dependent-writes`](docs/rules/prisma-dependent-writes.md) | high | Adjacent Prisma creates pass a value from the first record into the next write. |
906
- | <a id="prisma-read-modify-write"></a>[`prisma-read-modify-write`](docs/rules/prisma-read-modify-write.md) | critical | A Prisma read feeds a numeric update of the same row, losing concurrent updates. |
907
- | <a id="prisma-transaction-client-escape"></a>[`prisma-transaction-client-escape`](docs/rules/prisma-transaction-client-escape.md) | critical | A Prisma call inside an interactive transaction uses the outer client instead of the transaction client. |
908
- | <a id="promise-return-escapes-catch"></a>[`promise-return-escapes-catch`](docs/rules/promise-return-escapes-catch.md) | high | Returning a promise directly from a protected try block can bypass its catch on rejection. |
909
- | <a id="python-bare-except"></a>[`python-bare-except`](docs/rules/python-bare-except.md) | medium | A bare except also catches SystemExit and KeyboardInterrupt, hiding shutdowns and bugs. |
910
- | <a id="python-swallowed-exception"></a>[`python-swallowed-exception`](docs/rules/python-swallowed-exception.md) | medium | A Python except block only passes, so the failure is dropped silently. |
911
- | <a id="query-runner-not-released"></a>[`query-runner-not-released`](docs/rules/query-runner-not-released.md) | critical | A TypeORM QueryRunner is not released in a finally block, so an error leaks its pooled connection. |
912
- | <a id="react-async-effect-callback"></a>[`react-async-effect-callback`](docs/rules/react-async-effect-callback.md) | medium | An async function is passed to useEffect, so its promise is treated as the cleanup function and its errors go unhandled. |
913
- | <a id="react-effect-sets-state-every-render"></a>[`react-effect-sets-state-every-render`](docs/rules/react-effect-sets-state-every-render.md) | high | An effect with no dependency array sets state to a new value on every run, so the component re-renders forever. |
914
- | <a id="react-list-missing-key"></a>[`react-list-missing-key`](docs/rules/react-list-missing-key.md) | medium | An element or fragment returned from .map() has no key prop, so React cannot track items when the list changes. |
915
- | <a id="react-state-mutated-in-place"></a>[`react-state-mutated-in-place`](docs/rules/react-state-mutated-in-place.md) | high | A useState value is mutated in place and passed to its own setter, so React sees the same reference and skips the re-render. |
916
- | <a id="redis-incr-then-expire"></a>[`redis-incr-then-expire`](docs/rules/redis-incr-then-expire.md) | medium | A Redis counter increment and its expire on the same key are two round trips and not atomic. |
917
- | <a id="request-number-unvalidated"></a>[`request-number-unvalidated`](docs/rules/request-number-unvalidated.md) | medium | A number parsed from request input reaches a query or calculation with no NaN or range check. |
918
- | <a id="retry-without-backoff"></a>[`retry-without-backoff`](docs/rules/retry-without-backoff.md) | medium | A retry loop calls the network again with no delay between attempts. |
919
- | <a id="return-in-finally"></a>[`return-in-finally`](docs/rules/return-in-finally.md) | high | Returning from finally can replace a pending return value or suppress a thrown error. |
920
- | <a id="return-newline"></a>[`return-newline`](docs/rules/return-newline.md) | high | A line break after return ends the statement before the apparent return value. |
921
- | <a id="rust-unwrap-in-production"></a>[`rust-unwrap-in-production`](docs/rules/rust-unwrap-in-production.md) | medium | Rust code outside tests calls unwrap(), turning an Err or None into a panic. |
922
- | <a id="sql-insert-truncated-at-semicolon"></a>[`sql-insert-truncated-at-semicolon`](docs/rules/sql-insert-truncated-at-semicolon.md) | high | A SQL dump parser ends INSERT values at a semicolon inside quoted text. |
923
- | <a id="stream-pipe-unhandled-error"></a>[`stream-pipe-unhandled-error`](docs/rules/stream-pipe-unhandled-error.md) | high | A stream is piped with .pipe() and no error handling, so a stream error can crash the process or leak the file. |
924
- | <a id="swallowed-error"></a>[`swallowed-error`](docs/rules/swallowed-error.md) | medium | A catch block drops the error and the code after the try carries on as if it succeeded. |
925
- | <a id="switch-not-exhaustive"></a>[`switch-not-exhaustive`](docs/rules/switch-not-exhaustive.md) | medium | A switch over a union or enum has no default and misses members, so the missing value leaves the result undefined. |
926
- | <a id="throw-non-error"></a>[`throw-non-error`](docs/rules/throw-non-error.md) | medium | A string, number or object literal is thrown instead of an Error, so there is no stack trace. |
927
- | <a id="typeorm-transaction-client-escape"></a>[`typeorm-transaction-client-escape`](docs/rules/typeorm-transaction-client-escape.md) | critical | A write inside a TypeORM transaction goes through a repository not bound to it. |
928
- | <a id="unbounded-promise-all"></a>[`unbounded-promise-all`](docs/rules/unbounded-promise-all.md) | high | Promise.all runs over an unbounded collection without a concurrency limit, risking memory spikes or downstream saturation. |
929
- | <a id="uncaught-exception-continues"></a>[`uncaught-exception-continues`](docs/rules/uncaught-exception-continues.md) | high | An uncaughtException handler neither exits nor rethrows, so the process keeps running in an undefined state. |
930
- | <a id="unguarded-boundary-access"></a>[`unguarded-boundary-access`](docs/rules/unguarded-boundary-access.md) | medium | A nested property is read from outside input or a lookup that can be missing, so absent data throws a TypeError. |
931
- | <a id="unreachable-code"></a>[`unreachable-code`](docs/rules/unreachable-code.md) | medium | Statements follow a return, throw, break or continue in the same block and never run. |
932
- | <a id="upload-without-size-limit"></a>[`upload-without-size-limit`](docs/rules/upload-without-size-limit.md) | high | A multer or Nest upload interceptor has no file size limit. |
933
- | <a id="webhook-missing-idempotency-check"></a>[`webhook-missing-idempotency-check`](docs/rules/webhook-missing-idempotency-check.md) | medium | A webhook route inserts rows without first checking whether the event was already processed. |
633
+ | Rule | Impact | What it flags |
634
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
635
+ | <a id="assignment-in-condition"></a>[`assignment-in-condition`](docs/rules/reliability/assignment-in-condition.md) | high | A condition assigns with = where a comparison was probably meant. |
636
+ | <a id="async-callback-unhandled-rejection"></a>[`async-callback-unhandled-rejection`](docs/rules/reliability/async-callback-unhandled-rejection.md) | high | An async callback given to an event emitter, timer or scheduler has no error handling, so a rejection is unhandled. |
637
+ | <a id="async-route-unhandled-rejection"></a>[`async-route-unhandled-rejection`](docs/rules/reliability/async-route-unhandled-rejection.md) | high | An Express 4 async route handler has no error handling, so a rejection never reaches the error middleware. |
638
+ | <a id="browser-not-closed"></a>[`browser-not-closed`](docs/rules/reliability/browser-not-closed.md) | high | A Playwright or Puppeteer browser is not closed in a finally block, so an error leaves the process running. |
639
+ | <a id="check-then-update-race"></a>[`check-then-update-race`](docs/rules/reliability/check-then-update-race.md) | high | A Mongoose or Sequelize document's numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates. |
640
+ | <a id="child-process-without-error-listener"></a>[`child-process-without-error-listener`](docs/rules/reliability/child-process-without-error-listener.md) | high | A spawned child process has no 'error' listener, so a failed spawn crashes the parent process. |
641
+ | <a id="crlf-unsafe-line-split"></a>[`crlf-unsafe-line-split`](docs/rules/reliability/crlf-unsafe-line-split.md) | medium | Splitting file text on a bare newline leaves carriage returns on CRLF lines and can change exact comparisons. |
642
+ | <a id="csharp-async-void"></a>[`csharp-async-void`](docs/rules/reliability/csharp-async-void.md) | high | An async void method cannot be awaited and can crash the process on unhandled exceptions. |
643
+ | <a id="csharp-disposable-without-using"></a>[`csharp-disposable-without-using`](docs/rules/reliability/csharp-disposable-without-using.md) | medium | A C# stream, connection or other IDisposable is created without using, so an exception leaks it. |
644
+ | <a id="discarded-error-result"></a>[`discarded-error-result`](docs/rules/reliability/discarded-error-result.md) | high | A call discards a typed Either or Result that can carry a failure as a value. |
645
+ | <a id="drizzle-unfiltered-write"></a>[`drizzle-unfiltered-write`](docs/rules/reliability/drizzle-unfiltered-write.md) | critical | A Drizzle update or delete executes without an effective where clause. |
646
+ | <a id="drizzle-write-preflight"></a>[`drizzle-write-preflight`](docs/rules/reliability/drizzle-write-preflight.md) | medium | A separate existence check before a Drizzle write can race with another request. |
647
+ | <a id="error-logged-without-stack"></a>[`error-logged-without-stack`](docs/rules/reliability/error-logged-without-stack.md) | low | A catch block logs only error.message and carries on, so the stack trace is lost. |
648
+ | <a id="error-rethrown-without-cause"></a>[`error-rethrown-without-cause`](docs/rules/reliability/error-rethrown-without-cause.md) | low | A catch block throws a new error without the caught one, so the original message and stack are lost. |
649
+ | <a id="file-handle-not-closed"></a>[`file-handle-not-closed`](docs/rules/reliability/file-handle-not-closed.md) | high | A FileHandle from fs/promises open() is not closed on every path, leaking a file descriptor. |
650
+ | <a id="find-then-create-race"></a>[`find-then-create-race`](docs/rules/reliability/find-then-create-race.md) | high | A lookup by key is followed by an insert with that key, with no unique constraint to stop duplicates. |
651
+ | <a id="floating-promise"></a>[`floating-promise`](docs/rules/reliability/floating-promise.md) | high | A promise-returning call is neither awaited, returned nor handled, so its failure goes unseen. |
652
+ | <a id="go-defer-before-error-check"></a>[`go-defer-before-error-check`](docs/rules/reliability/go-defer-before-error-check.md) | high | A Go defer closes a resource before its error is checked, so a failed open dereferences nil. |
653
+ | <a id="go-error-discarded"></a>[`go-error-discarded`](docs/rules/reliability/go-error-discarded.md) | high | A Go error result is assigned to the blank identifier and never checked. |
654
+ | <a id="http-call-without-timeout"></a>[`http-call-without-timeout`](docs/rules/reliability/http-call-without-timeout.md) | high | A fetch or axios call has no timeout or abort signal. |
655
+ | <a id="interval-not-cleared"></a>[`interval-not-cleared`](docs/rules/reliability/interval-not-cleared.md) | medium | A setInterval handle is discarded or never cleared, so the timer outlives its owner. |
656
+ | <a id="invalid-typeof-comparison"></a>[`invalid-typeof-comparison`](docs/rules/reliability/invalid-typeof-comparison.md) | high | A typeof result is compared to a string typeof never returns, so the check never matches. |
657
+ | <a id="java-resource-without-try"></a>[`java-resource-without-try`](docs/rules/reliability/java-resource-without-try.md) | high | A Java stream, reader or connection is opened outside try-with-resources, so an exception leaks it. |
658
+ | <a id="json-parse-unguarded"></a>[`json-parse-unguarded`](docs/rules/reliability/json-parse-unguarded.md) | medium | JSON.parse runs on outside input with no try/catch, so malformed input throws where it is not handled. |
659
+ | <a id="loop-index-past-length"></a>[`loop-index-past-length`](docs/rules/reliability/loop-index-past-length.md) | high | A loop runs its index up to and including length, so the last pass reads past the end. |
660
+ | <a id="mongoose-aggregate-uncast-id"></a>[`mongoose-aggregate-uncast-id`](docs/rules/reliability/mongoose-aggregate-uncast-id.md) | high | A Mongoose aggregate $match compares _id to an uncast string instead of an ObjectId. |
661
+ | <a id="nan-comparison"></a>[`nan-comparison`](docs/rules/reliability/nan-comparison.md) | high | A value is compared to NaN with an equality operator, which is never true. |
662
+ | <a id="next-server-env-in-client"></a>[`next-server-env-in-client`](docs/rules/reliability/next-server-env-in-client.md) | high | A 'use client' file reads a process.env variable without the NEXT_PUBLIC_ prefix, so it is unavailable in the browser by default. |
663
+ | <a id="parse-failure-resets-file"></a>[`parse-failure-resets-file`](docs/rules/reliability/parse-failure-resets-file.md) | high | A write after a read or parse failure can replace unreadable contents at the same path. |
664
+ | <a id="payment-missing-idempotency-key"></a>[`payment-missing-idempotency-key`](docs/rules/reliability/payment-missing-idempotency-key.md) | high | A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice. |
665
+ | <a id="pg-transaction-on-pool"></a>[`pg-transaction-on-pool`](docs/rules/reliability/pg-transaction-on-pool.md) | critical | A transaction statement is sent to a pool, so its statements can run on different connections. |
666
+ | <a id="pool-without-connection-timeout"></a>[`pool-without-connection-timeout`](docs/rules/reliability/pool-without-connection-timeout.md) | medium | A pg Pool or Client sets no connectionTimeoutMillis, so its default of 0 waits for a connection forever. |
667
+ | <a id="prisma-dependent-writes"></a>[`prisma-dependent-writes`](docs/rules/reliability/prisma-dependent-writes.md) | high | Adjacent Prisma creates pass a value from the first record into the next write. |
668
+ | <a id="prisma-read-modify-write"></a>[`prisma-read-modify-write`](docs/rules/reliability/prisma-read-modify-write.md) | critical | A Prisma read feeds a numeric update of the same row, losing concurrent updates. |
669
+ | <a id="prisma-transaction-client-escape"></a>[`prisma-transaction-client-escape`](docs/rules/reliability/prisma-transaction-client-escape.md) | critical | A Prisma call inside an interactive transaction uses the outer client instead of the transaction client. |
670
+ | <a id="promise-return-escapes-catch"></a>[`promise-return-escapes-catch`](docs/rules/reliability/promise-return-escapes-catch.md) | high | Returning a promise directly from a protected try block can bypass its catch on rejection. |
671
+ | <a id="python-bare-except"></a>[`python-bare-except`](docs/rules/reliability/python-bare-except.md) | medium | A bare except also catches SystemExit and KeyboardInterrupt, hiding shutdowns and bugs. |
672
+ | <a id="python-swallowed-exception"></a>[`python-swallowed-exception`](docs/rules/reliability/python-swallowed-exception.md) | medium | A Python except block only passes, so the failure is dropped silently. |
673
+ | <a id="query-runner-not-released"></a>[`query-runner-not-released`](docs/rules/reliability/query-runner-not-released.md) | critical | A TypeORM QueryRunner is not released in a finally block, so an error leaks its pooled connection. |
674
+ | <a id="react-async-effect-callback"></a>[`react-async-effect-callback`](docs/rules/reliability/react-async-effect-callback.md) | medium | An async function is passed to useEffect, so its promise is treated as the cleanup function and its errors go unhandled. |
675
+ | <a id="react-effect-sets-state-every-render"></a>[`react-effect-sets-state-every-render`](docs/rules/reliability/react-effect-sets-state-every-render.md) | high | An effect with no dependency array sets state to a new value on every run, so the component re-renders forever. |
676
+ | <a id="react-list-missing-key"></a>[`react-list-missing-key`](docs/rules/reliability/react-list-missing-key.md) | medium | An element or fragment returned from .map() has no key prop, so React cannot track items when the list changes. |
677
+ | <a id="react-state-mutated-in-place"></a>[`react-state-mutated-in-place`](docs/rules/reliability/react-state-mutated-in-place.md) | high | A useState value is mutated in place and passed to its own setter, so React sees the same reference and skips the re-render. |
678
+ | <a id="redis-incr-then-expire"></a>[`redis-incr-then-expire`](docs/rules/reliability/redis-incr-then-expire.md) | medium | A Redis counter increment and its expire on the same key are two round trips and not atomic. |
679
+ | <a id="request-number-unvalidated"></a>[`request-number-unvalidated`](docs/rules/reliability/request-number-unvalidated.md) | medium | A number parsed from request input reaches a query or calculation with no NaN or range check. |
680
+ | <a id="retry-without-backoff"></a>[`retry-without-backoff`](docs/rules/reliability/retry-without-backoff.md) | medium | A retry loop calls the network again with no delay between attempts. |
681
+ | <a id="return-in-finally"></a>[`return-in-finally`](docs/rules/reliability/return-in-finally.md) | high | Returning from finally can replace a pending return value or suppress a thrown error. |
682
+ | <a id="return-newline"></a>[`return-newline`](docs/rules/reliability/return-newline.md) | high | A line break after return ends the statement before the apparent return value. |
683
+ | <a id="rust-unwrap-in-production"></a>[`rust-unwrap-in-production`](docs/rules/reliability/rust-unwrap-in-production.md) | medium | Rust code outside tests calls unwrap(), turning an Err or None into a panic. |
684
+ | <a id="sql-insert-truncated-at-semicolon"></a>[`sql-insert-truncated-at-semicolon`](docs/rules/reliability/sql-insert-truncated-at-semicolon.md) | high | A SQL dump parser ends INSERT values at a semicolon inside quoted text. |
685
+ | <a id="stream-pipe-unhandled-error"></a>[`stream-pipe-unhandled-error`](docs/rules/reliability/stream-pipe-unhandled-error.md) | high | A stream is piped with .pipe() and no error handling, so a stream error can crash the process or leak the file. |
686
+ | <a id="swallowed-error"></a>[`swallowed-error`](docs/rules/reliability/swallowed-error.md) | medium | A catch block drops the error and the code after the try carries on as if it succeeded. |
687
+ | <a id="switch-not-exhaustive"></a>[`switch-not-exhaustive`](docs/rules/reliability/switch-not-exhaustive.md) | medium | A switch over a union or enum has no default and misses members, so the missing value leaves the result undefined. |
688
+ | <a id="test-cleanup-after-await"></a>[`test-cleanup-after-await`](docs/rules/reliability/test-cleanup-after-await.md) | medium | A test waits before cleaning up a local resource, so a rejection can leave it running. |
689
+ | <a id="throw-non-error"></a>[`throw-non-error`](docs/rules/reliability/throw-non-error.md) | medium | A string, number or object literal is thrown instead of an Error, so there is no stack trace. |
690
+ | <a id="typeorm-transaction-client-escape"></a>[`typeorm-transaction-client-escape`](docs/rules/reliability/typeorm-transaction-client-escape.md) | critical | A write inside a TypeORM transaction goes through a repository not bound to it. |
691
+ | <a id="unbounded-promise-all"></a>[`unbounded-promise-all`](docs/rules/reliability/unbounded-promise-all.md) | high | Promise.all runs over an unbounded collection without a concurrency limit, risking memory spikes or downstream saturation. |
692
+ | <a id="uncaught-exception-continues"></a>[`uncaught-exception-continues`](docs/rules/reliability/uncaught-exception-continues.md) | high | An uncaughtException handler neither exits nor rethrows, so the process keeps running in an undefined state. |
693
+ | <a id="unguarded-boundary-access"></a>[`unguarded-boundary-access`](docs/rules/reliability/unguarded-boundary-access.md) | medium | A nested property is read from outside input or a lookup that can be missing, so absent data throws a TypeError. |
694
+ | <a id="unreachable-code"></a>[`unreachable-code`](docs/rules/reliability/unreachable-code.md) | medium | Statements follow a return, throw, break or continue in the same block and never run. |
695
+ | <a id="upload-without-size-limit"></a>[`upload-without-size-limit`](docs/rules/reliability/upload-without-size-limit.md) | high | A multer or Nest upload interceptor has no file size limit. |
696
+ | <a id="webhook-missing-idempotency-check"></a>[`webhook-missing-idempotency-check`](docs/rules/reliability/webhook-missing-idempotency-check.md) | medium | A webhook route inserts rows without first checking whether the event was already processed. |
934
697
 
935
698
  <!-- loadwise:rules:end -->
936
699
 
@@ -940,113 +703,86 @@ The rules from `pg-transaction-on-pool` to `swallowed-error` moved from the perf
940
703
 
941
704
  <!-- loadwise:rules:start checker=reliability group=migration-safety -->
942
705
 
943
- | Rule | Impact | What it flags |
944
- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------- |
945
- | <a id="migration-breaking-drop"></a>[`migration-breaking-drop`](docs/rules/migration-breaking-drop.md) | critical | A migration drops a column or table that running code may still use. |
946
- | <a id="migration-breaking-rename"></a>[`migration-breaking-rename`](docs/rules/migration-breaking-rename.md) | high | A migration renames a column or table that running code may still use. |
947
- | <a id="migration-column-type-rewrite"></a>[`migration-column-type-rewrite`](docs/rules/migration-column-type-rewrite.md) | critical | A migration changes a column type in a way that rewrites the table. |
948
- | <a id="migration-concurrent-in-transaction"></a>[`migration-concurrent-in-transaction`](docs/rules/migration-concurrent-in-transaction.md) | high | A CONCURRENTLY index statement runs inside a transaction, where PostgreSQL rejects it. |
949
- | <a id="migration-constraint-not-valid"></a>[`migration-constraint-not-valid`](docs/rules/migration-constraint-not-valid.md) | high | A constraint is added and validated in one step instead of NOT VALID first. |
950
- | <a id="migration-constraint-without-index"></a>[`migration-constraint-without-index`](docs/rules/migration-constraint-without-index.md) | high | A unique or primary key constraint builds its index while blocking writes. |
951
- | <a id="migration-index-not-concurrent"></a>[`migration-index-not-concurrent`](docs/rules/migration-index-not-concurrent.md) | critical | A PostgreSQL index is built without CONCURRENTLY, blocking writes to the table. |
952
- | <a id="migration-missing-lock-timeout"></a>[`migration-missing-lock-timeout`](docs/rules/migration-missing-lock-timeout.md) | high | A migration statement takes a lock with no lock_timeout set. |
953
- | <a id="migration-mysql-lock-unspecified"></a>[`migration-mysql-lock-unspecified`](docs/rules/migration-mysql-lock-unspecified.md) | high | A MySQL ALTER does not state its LOCK level. |
954
- | <a id="migration-mysql-table-copy"></a>[`migration-mysql-table-copy`](docs/rules/migration-mysql-table-copy.md) | critical | A MySQL ALTER copies the whole table. |
955
- | <a id="migration-not-null-without-default"></a>[`migration-not-null-without-default`](docs/rules/migration-not-null-without-default.md) | high | A NOT NULL column is added without a default, which fails once rows exist. |
956
- | <a id="migration-set-not-null-scan"></a>[`migration-set-not-null-scan`](docs/rules/migration-set-not-null-scan.md) | high | SET NOT NULL scans the whole table while holding a lock. |
957
- | <a id="migration-table-rewrite-command"></a>[`migration-table-rewrite-command`](docs/rules/migration-table-rewrite-command.md) | critical | A migration runs VACUUM FULL, CLUSTER or REINDEX, which rewrites or locks the table. |
958
- | <a id="migration-unparsed"></a>[`migration-unparsed`](docs/rules/migration-unparsed.md) | low | A migration statement could not be parsed and needs a manual review. |
959
- | <a id="migration-volatile-default"></a>[`migration-volatile-default`](docs/rules/migration-volatile-default.md) | high | A column is added with a volatile default, which rewrites the table. |
706
+ | Rule | Impact | What it flags |
707
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------- |
708
+ | <a id="migration-breaking-drop"></a>[`migration-breaking-drop`](docs/rules/reliability/migration-breaking-drop.md) | critical | A migration drops a column or table that running code may still use. |
709
+ | <a id="migration-breaking-rename"></a>[`migration-breaking-rename`](docs/rules/reliability/migration-breaking-rename.md) | high | A migration renames a column or table that running code may still use. |
710
+ | <a id="migration-column-type-rewrite"></a>[`migration-column-type-rewrite`](docs/rules/reliability/migration-column-type-rewrite.md) | critical | A migration changes a column type in a way that rewrites the table. |
711
+ | <a id="migration-concurrent-in-transaction"></a>[`migration-concurrent-in-transaction`](docs/rules/reliability/migration-concurrent-in-transaction.md) | high | A CONCURRENTLY index statement runs inside a transaction, where PostgreSQL rejects it. |
712
+ | <a id="migration-constraint-not-valid"></a>[`migration-constraint-not-valid`](docs/rules/reliability/migration-constraint-not-valid.md) | high | A constraint is added and validated in one step instead of NOT VALID first. |
713
+ | <a id="migration-constraint-without-index"></a>[`migration-constraint-without-index`](docs/rules/reliability/migration-constraint-without-index.md) | high | A unique or primary key constraint builds its index while blocking writes. |
714
+ | <a id="migration-index-not-concurrent"></a>[`migration-index-not-concurrent`](docs/rules/reliability/migration-index-not-concurrent.md) | critical | A PostgreSQL index is built without CONCURRENTLY, blocking writes to the table. |
715
+ | <a id="migration-missing-lock-timeout"></a>[`migration-missing-lock-timeout`](docs/rules/reliability/migration-missing-lock-timeout.md) | high | A migration statement takes a lock with no lock_timeout set. |
716
+ | <a id="migration-mysql-lock-unspecified"></a>[`migration-mysql-lock-unspecified`](docs/rules/reliability/migration-mysql-lock-unspecified.md) | high | A MySQL ALTER does not state its LOCK level. |
717
+ | <a id="migration-mysql-table-copy"></a>[`migration-mysql-table-copy`](docs/rules/reliability/migration-mysql-table-copy.md) | critical | A MySQL ALTER copies the whole table. |
718
+ | <a id="migration-not-null-without-default"></a>[`migration-not-null-without-default`](docs/rules/reliability/migration-not-null-without-default.md) | high | A NOT NULL column is added without a default, which fails once rows exist. |
719
+ | <a id="migration-set-not-null-scan"></a>[`migration-set-not-null-scan`](docs/rules/reliability/migration-set-not-null-scan.md) | high | SET NOT NULL scans the whole table while holding a lock. |
720
+ | <a id="migration-table-rewrite-command"></a>[`migration-table-rewrite-command`](docs/rules/reliability/migration-table-rewrite-command.md) | critical | A migration runs VACUUM FULL, CLUSTER or REINDEX, which rewrites or locks the table. |
721
+ | <a id="migration-unparsed"></a>[`migration-unparsed`](docs/rules/reliability/migration-unparsed.md) | low | A migration statement could not be parsed and needs a manual review. |
722
+ | <a id="migration-volatile-default"></a>[`migration-volatile-default`](docs/rules/reliability/migration-volatile-default.md) | high | A column is added with a volatile default, which rewrites the table. |
960
723
 
961
724
  <!-- loadwise:rules:end -->
962
725
 
963
- Only new migrations fail the run. Older migrations are contextual: counted, listed with `--include-contextual`, and never exit 1.
964
-
965
- **CI recipe.** Enforce only what the branch adds or changes (files modified since the merge base, plus untracked files). Use a full-history checkout (`fetch-depth: 0`) so the ref resolves.
726
+ Only new migrations fail the run; older ones are contextual (counted, listed with `--include-contextual`, never exit 1). In CI, `--changed-since origin/main` enforces only migrations the branch adds or changes (plus untracked files) and needs a full-history checkout (`fetch-depth: 0`). For a project with existing migrations, accept them once:
966
727
 
967
728
  ```sh
968
- npx loadwise rel migrations --changed-since origin/main
969
- ```
970
-
971
- **Baseline workflow.** For a project with existing migrations, accept them once and enforce the rest.
972
-
973
- ```sh
974
- npx loadwise rel migrations --write-baseline # writes loadwise.migrations-baseline.json
729
+ npx loadwise rel migrations --write-baseline # writes loadwise.migrations-baseline.json; commit it
975
730
  npx loadwise rel migrations # new migrations fail; baselined ones do not
976
731
  ```
977
732
 
978
- Commit the baseline. `--baseline FILE` reads or writes another path. Exit codes match the source checks: 0 passed, 1 findings in enforced migrations, 2 invalid input.
733
+ `--baseline FILE` reads or writes another path. Exit codes: 0 passed, 1 findings in enforced migrations, 2 invalid input.
979
734
 
980
735
  ## API contract safety
981
736
 
982
- `npx loadwise rel contracts [--changed-since REF] [--json]` compares the working tree with the merge base of `REF` (default `HEAD`) and flags changes that break API clients. `loadwise check --changed-since REF` includes the same findings in the performance report. Both commands respect workspace selection, ignored paths and rules, configured rule levels, and minimum impact. Visible breaking changes fail by default. Rules set to warn appear in the report and do not fail the check. Invalid input exits 2. Use a full-history checkout (`fetch-depth: 0`) so the ref resolves.
983
-
984
- It compares three kinds of source:
985
-
986
- - **OpenAPI and Swagger JSON** (`openapi.json`, `swagger.json`). YAML documents are skipped with a note, because no YAML parser ships with loadwise; commit or check a JSON export instead.
987
- - **GraphQL SDL** (`*.graphql`, `*.gql`, for example the `schema.gql` a code-first server emits). Query documents are skipped.
988
- - **NestJS classes** used as `@Body()` types or as controller return types (also `@ApiResponse({ type })`), found in `*.controller.ts` and read from the file that declares them (relative imports only). Only property names, `?`, `@IsOptional()` and the written type text are compared.
737
+ `npx loadwise rel contracts [--changed-since REF] [--json]` compares the working tree with the merge base of `REF` (default `HEAD`) and flags changes that break API clients; `loadwise check --changed-since REF` includes the same findings in the reliability report. Both respect workspace selection, ignored paths and rules, configured rule levels and minimum impact, and need a full-history checkout so the ref resolves. It compares OpenAPI and Swagger JSON (`openapi.json`, `swagger.json`; YAML is skipped with a note), GraphQL SDL (`*.graphql`, `*.gql`; query documents are skipped) and NestJS classes used as `@Body()` types or controller return types (also `@ApiResponse({ type })`) in `*.controller.ts`, read through relative imports. Only property names, `?`, `@IsOptional()` and the written type text are compared, and properties inherited from a base class in a relative import count as the class's own. A removed request property is flagged only when the project builds a `ValidationPipe` with `forbidNonWhitelisted: true`. Removals point at the line in the old version; a new version next to the old one (`/v2/users` beside `/v1/users`) is not flagged.
989
738
 
990
739
  <!-- loadwise:rules:start checker=reliability group=api-contract-safety -->
991
740
 
992
- | Rule | Impact | What it flags |
993
- | --------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------ |
994
- | <a id="api-enum-value-removed"></a>[`api-enum-value-removed`](docs/rules/api-enum-value-removed.md) | high | An enum value or string-literal option that clients could send was removed. |
995
- | <a id="api-removed-field"></a>[`api-removed-field`](docs/rules/api-removed-field.md) | high | A response field, GraphQL type, field, argument or union member, or returned DTO property was removed. |
996
- | <a id="api-removed-operation"></a>[`api-removed-operation`](docs/rules/api-removed-operation.md) | critical | An OpenAPI operation or a GraphQL Query, Mutation or Subscription field was removed. |
997
- | <a id="api-required-input"></a>[`api-required-input`](docs/rules/api-required-input.md) | high | A request field, parameter or GraphQL argument is new and required, or became required. |
998
- | <a id="api-type-changed"></a>[`api-type-changed`](docs/rules/api-type-changed.md) | high | A field or parameter changed type, or a GraphQL type changed nullability in a breaking direction. |
741
+ | Rule | Impact | What it flags |
742
+ | --------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------ |
743
+ | <a id="api-enum-value-removed"></a>[`api-enum-value-removed`](docs/rules/reliability/api-enum-value-removed.md) | high | An enum value or string-literal option that clients could send was removed. |
744
+ | <a id="api-removed-field"></a>[`api-removed-field`](docs/rules/reliability/api-removed-field.md) | high | A response field, GraphQL type, field, argument or union member, or returned DTO property was removed. |
745
+ | <a id="api-removed-operation"></a>[`api-removed-operation`](docs/rules/reliability/api-removed-operation.md) | critical | An OpenAPI operation or a GraphQL Query, Mutation or Subscription field was removed. |
746
+ | <a id="api-required-input"></a>[`api-required-input`](docs/rules/reliability/api-required-input.md) | high | A request field, parameter or GraphQL argument is new and required, or became required. |
747
+ | <a id="api-type-changed"></a>[`api-type-changed`](docs/rules/reliability/api-type-changed.md) | high | A field or parameter changed type, or a GraphQL type changed nullability in a breaking direction. |
999
748
 
1000
749
  <!-- loadwise:rules:end -->
1001
750
 
1002
- Removals point at the line in the old version (the message says so); every other finding points at the new line. A new version next to the old one (`/v2/users` added while `/v1/users` stays) breaks nothing and is not flagged. A removed request property is flagged only when the project builds a `ValidationPipe` with `forbidNonWhitelisted: true`, because only then do clients that still send it get a 400. Properties inherited from a base class in a relative import count as the class's own.
1003
-
1004
- ```sh
1005
- npx loadwise rel contracts --changed-since origin/main
1006
- npx loadwise check --changed-since origin/main
1007
- ```
1008
-
1009
- ## Impact levels
1010
-
1011
- The levels and the `--min-impact` flag work as described under the performance checker's impact levels. `loadwise rel` and the reliability section of `loadwise check` use the impact levels in the rule index.
1012
-
1013
751
  # Maintainability checker
1014
752
 
1015
- `loadwise maint` finds code that would benefit from a design review and enforces the architectural decisions a team has already made. Run it on a project folder with `npx loadwise maint .`, or `npx loadwise maint . --json` for structured output.
753
+ `loadwise maint` finds code that would benefit from a design review and enforces the architectural decisions a team has already made. Run it on a project folder with `npx loadwise maint .`, or `npx loadwise maint . --json`. The default `--fail-on contract` exits 1 only for a declared folder, data-access or query contract violation; design advisories stay visible and exit 0 on their own. A non-JavaScript file a native parser cannot read and missing required parser binaries exit 2. Contextual findings include documented independent test oracles, before/after source snapshots with a live counterpart, marked generated code, certain flat data mappings and literal message lists, and a Nest module cycle whose internal eager edges are all explicit `forwardRef` callbacks (not available for graph input).
1016
754
 
1017
755
  ## What gets checked
1018
756
 
1019
757
  <!-- loadwise:rules:start checker=maintainability group=what-gets-checked -->
1020
758
 
1021
- | Rule | Impact | What it flags |
1022
- | ------------------------------------------------------------------------------------------------------------------------ | ------ | ----------------------------------------------------------------------------------------------- |
1023
- | <a id="data-access-boundary"></a>[`data-access-boundary`](docs/rules/data-access-boundary.md) | medium | A file outside the approved paths imports a configured database driver or ORM. |
1024
- | <a id="deep-control-flow"></a>[`deep-control-flow`](docs/rules/deep-control-flow.md) | low | Control structures are nested four levels deep. |
1025
- | <a id="dependency-cycle"></a>[`dependency-cycle`](docs/rules/dependency-cycle.md) | high | An eager chain of internal imports leads back to the module it started from. |
1026
- | <a id="deprecated-node-api"></a>[`deprecated-node-api`](docs/rules/deprecated-node-api.md) | medium | A deprecated Node.js API is used: new Buffer(), url.parse() or fs.exists(). |
1027
- | <a id="double-type-assertion"></a>[`double-type-assertion`](docs/rules/double-type-assertion.md) | low | A value is cast through unknown or any to a second type, bypassing the type checker. |
1028
- | <a id="duplicate-implementation"></a>[`duplicate-implementation`](docs/rules/duplicate-implementation.md) | medium | Substantial functions share the same implementation. |
1029
- | <a id="file-placement"></a>[`file-placement`](docs/rules/file-placement.md) | low | A file with a configured suffix sits outside its allowed folders. |
1030
- | <a id="focused-test-committed"></a>[`focused-test-committed`](docs/rules/focused-test-committed.md) | medium | A committed .only, fit or fdescribe makes the test runner skip every other test. |
1031
- | <a id="folder-boundary"></a>[`folder-boundary`](docs/rules/folder-boundary.md) | medium | An import crosses a folder boundary the team declared. |
1032
- | <a id="high-branch-complexity"></a>[`high-branch-complexity`](docs/rules/high-branch-complexity.md) | medium | A function reaches a branch complexity score of 15. |
1033
- | <a id="large-class"></a>[`large-class`](docs/rules/large-class.md) | low | A class has more than 30 methods, accessors, constructors or function-valued fields. |
1034
- | <a id="large-module"></a>[`large-module`](docs/rules/large-module.md) | low | A file has more than 600 lines of code. |
1035
- | <a id="long-parameter-list"></a>[`long-parameter-list`](docs/rules/long-parameter-list.md) | low | A function takes more than 5 positional parameters. |
1036
- | <a id="query-mutates-state"></a>[`query-mutates-state`](docs/rules/query-mutates-state.md) | medium | A method marked @maintainabilityQuery writes through this. |
1037
- | <a id="stray-console"></a>[`stray-console`](docs/rules/stray-console.md) | low | A console call in production code bypasses the logger, so its output has no level or structure. |
1038
- | <a id="ts-suppression-without-reason"></a>[`ts-suppression-without-reason`](docs/rules/ts-suppression-without-reason.md) | low | A @ts-ignore, @ts-expect-error or @ts-nocheck directive has no explanation. |
1039
- | <a id="tsconfig-strict-disabled"></a>[`tsconfig-strict-disabled`](docs/rules/tsconfig-strict-disabled.md) | medium | A tsconfig turns off strict type checking. |
1040
- | <a id="unreferenced-file"></a>[`unreferenced-file`](docs/rules/unreferenced-file.md) | low | A source file that nothing imports and that is not an entry point. |
1041
- | <a id="unused-export"></a>[`unused-export`](docs/rules/unused-export.md) | low | An export that no scanned file imports. |
1042
- | <a id="unused-import"></a>[`unused-import`](docs/rules/unused-import.md) | low | An imported name is never used in the file. |
1043
- | <a id="unused-local-variable"></a>[`unused-local-variable`](docs/rules/unused-local-variable.md) | low | A local variable is assigned but never read. |
759
+ | Rule | Impact | What it flags |
760
+ | ---------------------------------------------------------------------------------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------- |
761
+ | <a id="data-access-boundary"></a>[`data-access-boundary`](docs/rules/maintainability/data-access-boundary.md) | medium | A file outside the approved paths imports a configured database driver or ORM. |
762
+ | <a id="deep-control-flow"></a>[`deep-control-flow`](docs/rules/maintainability/deep-control-flow.md) | low | Control structures are nested four levels deep. |
763
+ | <a id="dependency-cycle"></a>[`dependency-cycle`](docs/rules/maintainability/dependency-cycle.md) | high | An eager chain of internal imports leads back to the module it started from. |
764
+ | <a id="deprecated-node-api"></a>[`deprecated-node-api`](docs/rules/maintainability/deprecated-node-api.md) | medium | A deprecated Node.js API is used: new Buffer(), url.parse() or fs.exists(). |
765
+ | <a id="double-type-assertion"></a>[`double-type-assertion`](docs/rules/maintainability/double-type-assertion.md) | low | A value is cast through unknown or any to a second type, bypassing the type checker. |
766
+ | <a id="duplicate-implementation"></a>[`duplicate-implementation`](docs/rules/maintainability/duplicate-implementation.md) | medium | Substantial functions share the same implementation. |
767
+ | <a id="file-placement"></a>[`file-placement`](docs/rules/maintainability/file-placement.md) | low | A file with a configured suffix sits outside its allowed folders. |
768
+ | <a id="focused-test-committed"></a>[`focused-test-committed`](docs/rules/maintainability/focused-test-committed.md) | medium | A committed .only, only: true, fit or fdescribe can make the test runner skip other tests. |
769
+ | <a id="folder-boundary"></a>[`folder-boundary`](docs/rules/maintainability/folder-boundary.md) | medium | An import crosses a folder boundary the team declared. |
770
+ | <a id="high-branch-complexity"></a>[`high-branch-complexity`](docs/rules/maintainability/high-branch-complexity.md) | medium | A function reaches a branch complexity score of 15. |
771
+ | <a id="large-class"></a>[`large-class`](docs/rules/maintainability/large-class.md) | low | A class has more than 30 methods, accessors, constructors or function-valued fields. |
772
+ | <a id="large-module"></a>[`large-module`](docs/rules/maintainability/large-module.md) | low | A file has more than 600 lines of code. |
773
+ | <a id="long-parameter-list"></a>[`long-parameter-list`](docs/rules/maintainability/long-parameter-list.md) | low | A function takes more than 5 positional parameters. |
774
+ | <a id="query-mutates-state"></a>[`query-mutates-state`](docs/rules/maintainability/query-mutates-state.md) | medium | A method marked @maintainabilityQuery writes through this. |
775
+ | <a id="stray-console"></a>[`stray-console`](docs/rules/maintainability/stray-console.md) | low | A console call in production code bypasses the logger, so its output has no level or structure. |
776
+ | <a id="ts-suppression-without-reason"></a>[`ts-suppression-without-reason`](docs/rules/maintainability/ts-suppression-without-reason.md) | low | A @ts-ignore, @ts-expect-error or @ts-nocheck directive has no explanation. |
777
+ | <a id="tsconfig-strict-disabled"></a>[`tsconfig-strict-disabled`](docs/rules/maintainability/tsconfig-strict-disabled.md) | medium | A tsconfig turns off strict type checking. |
778
+ | <a id="unreferenced-file"></a>[`unreferenced-file`](docs/rules/maintainability/unreferenced-file.md) | low | A source file that nothing imports and that is not an entry point. |
779
+ | <a id="unused-export"></a>[`unused-export`](docs/rules/maintainability/unused-export.md) | low | An export that no scanned file imports. |
780
+ | <a id="unused-import"></a>[`unused-import`](docs/rules/maintainability/unused-import.md) | low | An imported name is never used in the file. |
781
+ | <a id="unused-local-variable"></a>[`unused-local-variable`](docs/rules/maintainability/unused-local-variable.md) | low | A local variable is assigned but never read. |
1044
782
 
1045
783
  <!-- loadwise:rules:end -->
1046
784
 
1047
- JS and TS source checks use the TypeScript parser. The optional ast-grep executable supplies native parsers for Python, Go, Java, C#, Rust, PHP, Ruby, Kotlin, C and C++. The nesting rule recognizes specific grammar constructs. Braceless forms and pattern-matching constructs have different coverage across languages. A `.h` file uses the C grammar. Use a C++ header extension for C++ grammar.
1048
-
1049
- For any language, filename placement works directly on the inventory and module graphs can be supplied by a compiler, build system or dependency extractor. Direct import extraction is provided for JS/TS. It resolves project-local modules and TypeScript paths and ignores explicitly type-only imports. Unresolved aliases, compiler-specific metadata, runtime-generated imports, and some re-exports can change the actual runtime graph. JSON includes per-language parsed-file counts and the number of files eligible for automatic dependency analysis.
785
+ JS and TS use the TypeScript parser; the optional ast-grep executable supplies parsers for Python, Go, Java, C#, Rust, PHP, Ruby, Kotlin, C and C++ (a `.h` file uses the C grammar). Direct import extraction is provided for JS/TS: it resolves project-local modules and TypeScript paths and ignores type-only imports. Discovery uses tracked and nonignored untracked Git files where available and a directory walk elsewhere, skipping dependency directories and minified files; `build`, `dist`, `coverage`, `target` and `vendor` are skipped only at the scanned root or beside a project manifest such as `package.json`.
1050
786
 
1051
787
  ## Project rules
1052
788
 
@@ -1062,26 +798,7 @@ Save team decisions in the `maintainability` section of `loadwise.config.json` a
1062
798
  }
1063
799
  ```
1064
800
 
1065
- `limits` sets the thresholds of `large-module`, `large-class` and `long-parameter-list`. Each is a positive integer, and the values shown are the defaults.
1066
-
1067
- `dataAccess` restricts runtime imports of named packages, their subpaths, module aliases (`#models`, `@/db`) or project-local entry points (entries starting with `./`) to the project-relative directories or files in `allowIn`. Local entries match the resolved file, so `./store` and `./store/index.ts` are different targets. `import type`, `export type` and, outside `verbatimModuleSyntax` projects, all-inline-`type` specifier lists are erased and not reported. Both `modules` and `allowIn` are required and nonempty. Findings are contract violations and fail the default `--fail-on contract`. Resolution is syntactic per file, with no type checker, so an ambient `declare module` does not count as a local file.
1068
-
1069
- Paths use project-relative directory or file names. Directory boundaries match complete segments. The longest matching filename suffix wins. With no configuration, each project keeps its own folder conventions. Discovery uses tracked and nonignored untracked Git files where available and a directory walk elsewhere. Dependency directories and minified files are skipped. `build`, `dist`, `coverage`, `target` and `vendor` are skipped as build output only at the scanned root or beside a project manifest such as `package.json`; a source folder with one of those names, such as `src/build/`, is scanned. Use explicit exclusions for other checked-in vendor code.
1070
-
1071
- ## Inline fixes
1072
-
1073
- Findings with a safe rewrite carry it as `fix = { changes: [{ file, line, before, after }], note? }` in `--json` output, and the text output prints it as a diff.
1074
-
1075
- ```sh
1076
- npx loadwise maint . --fix # asks y/n/a/q for each fix; needs a terminal
1077
- npx loadwise maint . --fix --yes # applies every fix without asking
1078
- ```
1079
-
1080
- `--fix` is refused with `--json` or `--graph`, and `--yes` alone is refused. Without a terminal, `--fix` requires `--yes`. A fix applies only where the original lines still exist. One that an earlier fix made stale is skipped and reappears, rebuilt, on the next run. Review the diff and run your tests afterwards.
1081
-
1082
- The rules with an automatic rewrite are `deep-control-flow`, `high-branch-complexity`, `duplicate-implementation` and `dependency-cycle`. Each rule page describes its rewrite.
1083
-
1084
- Other rules have no automatic rewrite.
801
+ `limits` sets the thresholds of `large-module`, `large-class` and `long-parameter-list` (positive integers; the values shown are the defaults). `dataAccess` restricts runtime imports of named packages, their subpaths, module aliases (`#models`, `@/db`) or project-local entry points (starting with `./`, matched by resolved file) to the paths in `allowIn`; both lists are required and nonempty, type-only imports are not reported, and findings are contract violations. Paths are project-relative, directory boundaries match complete segments, and the longest matching filename suffix wins.
1085
802
 
1086
803
  ## A module graph in any language
1087
804
 
@@ -1098,50 +815,11 @@ Other rules have no automatic rewrite.
1098
815
  npx loadwise maint . --graph modules.json --config policy.json
1099
816
  ```
1100
817
 
1101
- List each project-relative module once. Edges use one-based source coordinates. Set `"kind": "deferred"` for an edge that loads lazily. Graph mode operates entirely on the supplied inventory and edges.
1102
-
1103
- ## CI and design review
1104
-
1105
- Source checks count lower-priority findings separately. Use `--include-contextual` to display them with a reason. The JSON field `contextualFindingCount` is the additional count in the default view and a subset of `findings` in the expanded view. `--fail-on all` applies to displayed findings. Explicit folder and query contracts always remain visible.
1106
-
1107
- Context includes documented independent test oracles, before/after source snapshots with a corresponding live file, marked generated code, certain flat data mappings, and flat lists of optional literal messages selected by simple field checks. Two ordinary implementations still form a default duplicate finding even when an archive or test oracle also contains a copy. A Nest module cycle can receive context when every internal eager edge is used solely in an explicit module `forwardRef` callback. A cycle supplied through graph input has no such source evidence.
1108
-
1109
- The default `--fail-on contract` exits 1 for a declared folder, data-access or query contract violation. Design advisories remain visible and exit 0 on their own. Use `--fail-on all` to fail on any finding. Invalid configurations, a non-JavaScript file a native parser cannot read and missing required parser binaries exit 2. A JavaScript or TypeScript file that does not parse is skipped, named in a stderr note and in `skippedFiles` in `--json` output, and the run exits 2.
1110
-
1111
- DRY candidates can represent intentional copies between isolated modules. Deep nesting can accurately reflect a protocol. Use the reported locations to decide whether extracting a function, changing a dependency or retaining the current implementation makes the next change easier. YAGNI, Tell Don't Ask, the Law of Demeter and CUPID depend on domain knowledge. Fluent call chains and unused extension points alone do not establish a violation. [CUPID and the properties of good code](https://dannorth.net/cupid-for-joyful-coding/)
1112
-
1113
- ## Apply fixes by id
1114
-
1115
- Every finding in `--json` output has a stable `id` (also shown as `#id` in text output), `fixable`, and `fix` when a rewrite exists. The id hashes the rule, the file and the flagged line's text, so it survives edits above the finding.
1116
-
1117
- ```sh
1118
- npx loadwise maint . --fix --only <id>[,<id>...] [--json]
1119
- ```
1120
-
1121
- `--only` applies exactly those fixes with no prompt and no terminal. `--json` prints `{ applied, alreadyApplied, failed }`. An id whose change an earlier id in the same run already made is reported in `alreadyApplied`; an unknown id, a finding without a fix or a stale fix is in `failed` and the exit code is 2.
1122
-
1123
- To dismiss a false positive, put `// loadwise-reviewed <rule-id> -- <specific reason>` on the line above it (line 1 itself for a finding about a whole file, such as `large-module`). The finding becomes contextual with that reason. Only a real line comment counts, and declared contracts (`file-placement`, `folder-boundary`, `data-access-boundary`, `query-mutates-state`) cannot be dismissed this way.
1124
-
1125
- ## Changed lines
1126
-
1127
- ```sh
1128
- npx loadwise maint --staged .
1129
- npx loadwise maint --changed-since <git-ref> .
1130
- ```
1131
-
1132
- `--staged` reports only findings on lines added or changed in `git diff --cached`; `--changed-since <git-ref>` does the same for the working tree against that ref. A JS/TS function-level finding (`high-branch-complexity`, `deep-control-flow`) is kept when a changed line falls anywhere inside its function. In other supported languages, deep nesting is reported when its flagged line changes. Text output is one block per finding (`path:line [rule-id #id] message`, then a `fix:` command when a rewrite exists and a `dismiss:` comment for a reviewable JS/TS finding), ending with `N new finding(s) in changed lines.`. `--json` works too, with the same shape filtered. Changed files in any supported source language are checked. With `--changed-since`, untracked source files count as entirely new. When no supported source changed, text output is empty and the checker exits 0 before loading TypeScript. In these modes `--fail-on` defaults to `all`, so the exit code is 1 whenever a finding remains.
1133
-
1134
- Only the changed files are analysed, while imports still resolve through the whole project. When as many files changed as the full scan's parallel threshold (600), the full scan runs instead and its findings are filtered to the changed lines, so every rule applies. Otherwise rules that need every file are limited: `duplicate-implementation` is skipped and `dependency-cycle` only sees cycles made of changed files' imports. Boundary and placement rules still run. Analysis reads working-tree files, so a file with unstaged edits can report shifted lines.
1135
-
1136
- ## Impact levels
1137
-
1138
- The levels and the `--min-impact` flag work as described under the performance checker's impact levels.
818
+ List each project-relative module once. Edges use one-based source coordinates; set `"kind": "deferred"` for an edge that loads lazily. Graph mode operates entirely on the supplied inventory and edges, for a graph from a compiler, build system or dependency extractor.
1139
819
 
1140
820
  # Security checker
1141
821
 
1142
- `loadwise sec` reports code paths where input or missing scope can expose data: runtime text composed into SQL and, when the project declares them, Prisma and Drizzle queries that do not prove their row scope. Findings are review prompts with a location, a rule ID, an impact level, a generic fix example and, where it is safe, a source-based fix.
1143
-
1144
- ## Run it
822
+ `loadwise sec` reports code paths where input or missing scope can expose data. Findings are review prompts with a location, a rule ID, an impact level, a generic fix example and, where it is safe, a source-based fix.
1145
823
 
1146
824
  ```sh
1147
825
  npx loadwise sec # tsconfig.json or jsconfig.json in the current folder
@@ -1152,193 +830,165 @@ npx loadwise sec deps --online # known-vulnerable packages in the lockfil
1152
830
  npx loadwise sec polyglot src/ # ast-grep rules for Python, Go, Java, C#, Rust
1153
831
  ```
1154
832
 
1155
- It accepts the source-check flags of `loadwise perf`, including `--format`, `--min-impact`, `--baseline`, `--write-baseline`, `--loadwise-config`, `--workspace`, `--policy`, `--json`, `--include-contextual`, `--ignore`, `--fail-on`, `--fix` with `--yes` or `--only` and `--no-comments` or `--no-format`, `--staged` and `--changed-since`. It uses the TypeScript 6 compiler: `--engine auto` (the default) and `--engine js` both run the JS engine, because the native engine finds less. `--engine native` (alias `--native`) runs the TypeScript 7 native compiler and prints a stderr note that cross-file taint through JavaScript constructor functions and rate-limit detection are reduced. Rules that need a package's types stay silent until the package is installed; rules that recognise a library by its import work without `node_modules`. Test, fixture, mock, example and story files are contextual: they are counted, and `--include-contextual` shows them with the reason `Test or example source.`. `--fail-on contract` enforces no security rule by default. `--fix --yes` leaves changes to ValidationPipe whitelisting for individual review because enabling it can strip undecorated DTO properties.
833
+ It accepts the source-check flags of `loadwise perf`, including `--format`, `--min-impact`, `--baseline`, `--write-baseline`, `--loadwise-config`, `--workspace`, `--policy`, `--json`, `--include-contextual`, `--ignore`, `--fail-on`, `--fix` with `--yes` or `--only` and `--no-comments` or `--no-format`, `--staged` and `--changed-since`. `--engine auto` (the default) and `--engine js` both run TypeScript 6, because the native engine finds less; `--engine native` (alias `--native`) prints a note that cross-file taint through JavaScript constructor functions and rate-limit detection are reduced. Rules that need a package's types stay silent until it is installed. Test, fixture, mock, example and story files are contextual (`Test or example source.`). `--fail-on contract` enforces no security rule by default. `--fix --yes` leaves ValidationPipe whitelisting for individual review because it can strip undecorated DTO properties.
1156
834
 
1157
835
  ## Rules
1158
836
 
1159
837
  <!-- loadwise:rules:start checker=security group=rules -->
1160
838
 
1161
- | Rule | Impact | What it flags |
1162
- | ------------------------------------------------------------------------------------------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
1163
- | <a id="angular-bypass-security-trust"></a>[`angular-bypass-security-trust`](docs/rules/angular-bypass-security-trust.md) | high | DomSanitizer.bypassSecurityTrust* is called on a dynamic value, which turns off Angular's built-in sanitization. |
1164
- | <a id="auth-route-without-rate-limit"></a>[`auth-route-without-rate-limit`](docs/rules/auth-route-without-rate-limit.md) | medium | A login, signup or password-reset route has no rate limiter. |
1165
- | <a id="bcrypt-low-cost"></a>[`bcrypt-low-cost`](docs/rules/bcrypt-low-cost.md) | medium | A bcrypt password hash uses a work factor below the recommended minimum. |
1166
- | <a id="client-env-secret-exposed"></a>[`client-env-secret-exposed`](docs/rules/client-env-secret-exposed.md) | critical | A secret-named env variable is read under a browser prefix (NEXT_PUBLIC_, VITE_, REACT_APP_...), so the build ships it to every visitor. |
1167
- | <a id="code-injection"></a>[`code-injection`](docs/rules/code-injection.md) | critical | Request-controlled input becomes source code evaluated by the application. |
1168
- | <a id="command-injection"></a>[`command-injection`](docs/rules/command-injection.md) | critical | Request-controlled input reaches a shell command string. |
1169
- | <a id="committed-secret"></a>[`committed-secret`](docs/rules/committed-secret.md) | critical | A tracked file contains a value that appears to be a credential. |
1170
- | <a id="compose-hardcoded-secret"></a>[`compose-hardcoded-secret`](docs/rules/compose-hardcoded-secret.md) | high | A Docker Compose service supplies a secret as a literal environment value. |
1171
- | <a id="cookie-missing-security-flags"></a>[`cookie-missing-security-flags`](docs/rules/cookie-missing-security-flags.md) | high | A sensitive cookie is set without the expected security attributes. |
1172
- | <a id="cors-credentials-any-origin"></a>[`cors-credentials-any-origin`](docs/rules/cors-credentials-any-origin.md) | high | A credentialed CORS response allows arbitrary origins. |
1173
- | <a id="cors-origin-regex-unanchored"></a>[`cors-origin-regex-unanchored`](docs/rules/cors-origin-regex-unanchored.md) | medium | A CORS origin regex also accepts look-alike hosts. |
1174
- | <a id="database-error-in-response"></a>[`database-error-in-response`](docs/rules/database-error-in-response.md) | medium | An HTTP response includes a raw database error message. |
1175
- | <a id="dockerfile-add-remote-url"></a>[`dockerfile-add-remote-url`](docs/rules/dockerfile-add-remote-url.md) | medium | A Dockerfile ADD instruction retrieves a resource from a remote URL. |
1176
- | <a id="dockerfile-runs-as-root"></a>[`dockerfile-runs-as-root`](docs/rules/dockerfile-runs-as-root.md) | medium | The final image selects root or inherits an unverified base-image user. |
1177
- | <a id="dockerfile-secret-in-build"></a>[`dockerfile-secret-in-build`](docs/rules/dockerfile-secret-in-build.md) | high | A Dockerfile exposes a secret through a build argument or environment variable. |
1178
- | <a id="dockerfile-unpinned-base-image"></a>[`dockerfile-unpinned-base-image`](docs/rules/dockerfile-unpinned-base-image.md) | low | A Dockerfile uses a base image reference that can change between builds. |
1179
- | <a id="dom-xss-sink"></a>[`dom-xss-sink`](docs/rules/dom-xss-sink.md) | high | Untrusted or dynamic HTML reaches innerHTML, outerHTML, insertAdjacentHTML, document.write or createContextualFragment (DOM XSS). |
1180
- | <a id="drizzle-scope-unverified"></a>[`drizzle-scope-unverified`](docs/rules/drizzle-scope-unverified.md) | high | A Drizzle operation lacks the row scope required by the declared policy. |
1181
- | <a id="drizzle-sql-raw-dynamic"></a>[`drizzle-sql-raw-dynamic`](docs/rules/drizzle-sql-raw-dynamic.md) | critical | A dynamic SQL fragment reaches Drizzle without parameter binding. |
1182
- | <a id="error-stack-in-response"></a>[`error-stack-in-response`](docs/rules/error-stack-in-response.md) | medium | An HTTP response includes an internal error stack. |
1183
- | <a id="express-cookie-auth-missing-csrf"></a>[`express-cookie-auth-missing-csrf`](docs/rules/express-cookie-auth-missing-csrf.md) | high | Cookie-based session or auth is paired with state-changing routes without CSRF protection or `sameSite: "strict"`. |
1184
- | <a id="express-missing-helmet"></a>[`express-missing-helmet`](docs/rules/express-missing-helmet.md) | low | The Express or NestJS server starts without helmet security headers middleware (contextual: a proxy may set them). |
1185
- | <a id="frontend-storage-secret-token"></a>[`frontend-storage-secret-token`](docs/rules/frontend-storage-secret-token.md) | medium | A token, JWT, password or API key is stored in localStorage or sessionStorage, readable by any script on the page. |
1186
- | <a id="graphql-batching-unbounded"></a>[`graphql-batching-unbounded`](docs/rules/graphql-batching-unbounded.md) | medium | GraphQL query batching is enabled without a batch size, query depth, or cost/complexity limit. |
1187
- | <a id="graphql-introspection-enabled"></a>[`graphql-introspection-enabled`](docs/rules/graphql-introspection-enabled.md) | medium | A GraphQL server explicitly enables schema introspection. |
1188
- | <a id="graphql-query-depth-unbounded"></a>[`graphql-query-depth-unbounded`](docs/rules/graphql-query-depth-unbounded.md) | medium | A GraphQL server accepts queries of any depth. |
1189
- | <a id="hardcoded-secret"></a>[`hardcoded-secret`](docs/rules/hardcoded-secret.md) | critical | The source supplies a literal credential or cryptographic secret. |
1190
- | <a id="insecure-cipher"></a>[`insecure-cipher`](docs/rules/insecure-cipher.md) | medium | A cryptographic operation selects an insecure cipher or mode. |
1191
- | <a id="insecure-random-for-secret"></a>[`insecure-random-for-secret`](docs/rules/insecure-random-for-secret.md) | high | A sensitive token or secret uses a non-cryptographic random source. |
1192
- | <a id="jsx-javascript-url"></a>[`jsx-javascript-url`](docs/rules/jsx-javascript-url.md) | high | In React 18 and older or Preact, a URL search parameter or location hash starts a JSX href, action or iframe src (javascript: XSS). |
1193
- | <a id="jwt-decode-for-auth"></a>[`jwt-decode-for-auth`](docs/rules/jwt-decode-for-auth.md) | high | Authentication uses decoded JWT claims without verifying the token signature. |
1194
- | <a id="jwt-none-algorithm"></a>[`jwt-none-algorithm`](docs/rules/jwt-none-algorithm.md) | critical | JWT signing or verification allows an unsigned token. |
1195
- | <a id="jwt-sign-without-expiry"></a>[`jwt-sign-without-expiry`](docs/rules/jwt-sign-without-expiry.md) | medium | A signed JWT has no explicit expiration. |
1196
- | <a id="jwt-verify-without-algorithms"></a>[`jwt-verify-without-algorithms`](docs/rules/jwt-verify-without-algorithms.md) | high | JWT verification does not restrict the accepted signing algorithms. |
1197
- | <a id="jwt-weak-secret-literal"></a>[`jwt-weak-secret-literal`](docs/rules/jwt-weak-secret-literal.md) | high | JWT signing or verification uses a short (< 32 chars) or weak literal secret susceptible to brute-force forgery. |
1198
- | <a id="knex-raw-dynamic-text"></a>[`knex-raw-dynamic-text`](docs/rules/knex-raw-dynamic-text.md) | critical | A dynamic SQL fragment reaches Knex without parameter binding. |
1199
- | <a id="mass-assignment"></a>[`mass-assignment`](docs/rules/mass-assignment.md) | high | An unfiltered request body reaches a persistence operation. |
1200
- | <a id="mysql-dynamic-query-text"></a>[`mysql-dynamic-query-text`](docs/rules/mysql-dynamic-query-text.md) | critical | Dynamic SQL text reaches a MySQL client without parameter binding. |
1201
- | <a id="nest-validation-without-whitelist"></a>[`nest-validation-without-whitelist`](docs/rules/nest-validation-without-whitelist.md) | medium | A NestJS ValidationPipe permits properties outside the validated DTO. |
1202
- | <a id="next-image-any-remote-host"></a>[`next-image-any-remote-host`](docs/rules/next-image-any-remote-host.md) | medium | A Next.js images.remotePatterns entry sets hostname '**', so the image optimizer fetches and serves any host (open proxy). |
1203
- | <a id="nosql-operator-injection"></a>[`nosql-operator-injection`](docs/rules/nosql-operator-injection.md) | high | Request data can introduce query operators into a NoSQL filter. |
1204
- | <a id="open-redirect"></a>[`open-redirect`](docs/rules/open-redirect.md) | medium | An HTTP redirect destination is controlled by request data. |
1205
- | <a id="password-hash-in-response"></a>[`password-hash-in-response`](docs/rules/password-hash-in-response.md) | high | A response returns a user record that still holds its password hash. |
1206
- | <a id="path-traversal"></a>[`path-traversal`](docs/rules/path-traversal.md) | high | Request data controls a filesystem path without a recognized containment check. |
1207
- | <a id="pg-dynamic-query-text"></a>[`pg-dynamic-query-text`](docs/rules/pg-dynamic-query-text.md) | medium | Dynamic SQL text reaches the PostgreSQL client without parameter binding. |
1208
- | <a id="plaintext-password-storage"></a>[`plaintext-password-storage`](docs/rules/plaintext-password-storage.md) | critical | A password is stored or written without being hashed. |
1209
- | <a id="postmessage-missing-origin-check"></a>[`postmessage-missing-origin-check`](docs/rules/postmessage-missing-origin-check.md) | medium | postMessage targets '*', or a window message listener reads event.data without checking origin or source. |
1210
- | <a id="prisma-raw-unsafe-dynamic"></a>[`prisma-raw-unsafe-dynamic`](docs/rules/prisma-raw-unsafe-dynamic.md) | critical | Dynamic SQL text reaches an unsafe Prisma raw-query method. |
1211
- | <a id="prisma-scope-unverified"></a>[`prisma-scope-unverified`](docs/rules/prisma-scope-unverified.md) | high | A Prisma operation lacks the row scope required by the declared policy. |
1212
- | <a id="prototype-pollution"></a>[`prototype-pollution`](docs/rules/prototype-pollution.md) | high | Request data can supply keys to a write or merge that can modify an object prototype. |
1213
- | <a id="react-dangerously-set-inner-html"></a>[`react-dangerously-set-inner-html`](docs/rules/react-dangerously-set-inner-html.md) | high | dangerouslySetInnerHTML receives HTML that is not a constant or sanitized. |
1214
- | <a id="reflected-xss-response"></a>[`reflected-xss-response`](docs/rules/reflected-xss-response.md) | low | An HTML response reflects request data without recognized escaping. |
1215
- | <a id="regex-catastrophic-backtracking"></a>[`regex-catastrophic-backtracking`](docs/rules/regex-catastrophic-backtracking.md) | high | A regular expression that can backtrack exponentially or in polynomial time runs on request input. |
1216
- | <a id="regex-from-input"></a>[`regex-from-input`](docs/rules/regex-from-input.md) | medium | Request input supplies a regular expression pattern without recognized escaping. |
1217
- | <a id="secret-compared-non-constant-time"></a>[`secret-compared-non-constant-time`](docs/rules/secret-compared-non-constant-time.md) | medium | A secret is compared with an operation that can vary in timing with its contents. |
1218
- | <a id="secret-in-log"></a>[`secret-in-log`](docs/rules/secret-in-log.md) | high | A log statement can expose a credential, token, or other secret. |
1219
- | <a id="secret-in-url-query"></a>[`secret-in-url-query`](docs/rules/secret-in-url-query.md) | medium | A password, token or API key is passed in a URL query string. |
1220
- | <a id="sequelize-dynamic-query-text"></a>[`sequelize-dynamic-query-text`](docs/rules/sequelize-dynamic-query-text.md) | critical | Dynamic SQL text reaches Sequelize without parameter binding. |
1221
- | <a id="server-action-missing-auth"></a>[`server-action-missing-auth`](docs/rules/server-action-missing-auth.md) | high | An exported Next.js Server Action performs work without verifying authentication or session state. |
1222
- | <a id="ssrf-redirect-bypass"></a>[`ssrf-redirect-bypass`](docs/rules/ssrf-redirect-bypass.md) | high | An outbound HTTP request with a dynamic URL does not disable redirects, allowing SSRF allowlist bypasses. |
1223
- | <a id="ssrf-request-url"></a>[`ssrf-request-url`](docs/rules/ssrf-request-url.md) | high | Request data controls the destination of a server-side network request. |
1224
- | <a id="storage-object-public-acl"></a>[`storage-object-public-acl`](docs/rules/storage-object-public-acl.md) | high | A storage upload makes the object publicly readable. |
1225
- | <a id="template-autoescape-disabled"></a>[`template-autoescape-disabled`](docs/rules/template-autoescape-disabled.md) | medium | A template engine is configured to render values without HTML escaping. |
1226
- | <a id="template-injection"></a>[`template-injection`](docs/rules/template-injection.md) | critical | Request data is interpreted as template source rather than a template value. |
1227
- | <a id="tls-verification-disabled"></a>[`tls-verification-disabled`](docs/rules/tls-verification-disabled.md) | high | A TLS client skips certificate or server hostname verification. |
1228
- | <a id="typeorm-dynamic-query-text"></a>[`typeorm-dynamic-query-text`](docs/rules/typeorm-dynamic-query-text.md) | critical | A dynamic SQL fragment reaches TypeORM without parameter binding. |
1229
- | <a id="upload-client-filename"></a>[`upload-client-filename`](docs/rules/upload-client-filename.md) | medium | A file upload is stored under the original name supplied by the client. |
1230
- | <a id="vm-sandbox-escape"></a>[`vm-sandbox-escape`](docs/rules/vm-sandbox-escape.md) | critical | Node `vm` or `vm2` executes dynamic code or an untrusted context, risking sandbox escape and host RCE. |
1231
- | <a id="vue-v-html-unsanitized"></a>[`vue-v-html-unsanitized`](docs/rules/vue-v-html-unsanitized.md) | high | A Vue render function binds unsanitized dynamic HTML to innerHTML. |
1232
- | <a id="weak-password-hash"></a>[`weak-password-hash`](docs/rules/weak-password-hash.md) | high | A password is hashed with an algorithm unsuitable for password storage. |
1233
- | <a id="xml-external-entities"></a>[`xml-external-entities`](docs/rules/xml-external-entities.md) | medium | An XML parser allows processing of external entities. |
1234
- | <a id="zip-slip-extraction"></a>[`zip-slip-extraction`](docs/rules/zip-slip-extraction.md) | high | An archive entry controls an extraction path without a recognized containment check. |
839
+ | Rule | Impact | What it flags |
840
+ | --------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
841
+ | <a id="angular-bypass-security-trust"></a>[`angular-bypass-security-trust`](docs/rules/security/angular-bypass-security-trust.md) | high | DomSanitizer.bypassSecurityTrust* is called on a dynamic value, which turns off Angular's built-in sanitization. |
842
+ | <a id="auth-route-without-rate-limit"></a>[`auth-route-without-rate-limit`](docs/rules/security/auth-route-without-rate-limit.md) | medium | A login, signup or password-reset route has no rate limiter. |
843
+ | <a id="bcrypt-low-cost"></a>[`bcrypt-low-cost`](docs/rules/security/bcrypt-low-cost.md) | medium | A bcrypt password hash uses a work factor below the recommended minimum. |
844
+ | <a id="client-env-secret-exposed"></a>[`client-env-secret-exposed`](docs/rules/security/client-env-secret-exposed.md) | critical | A secret-named env variable is read under a browser prefix (NEXT_PUBLIC_, VITE_, REACT_APP_...), so the build ships it to every visitor. |
845
+ | <a id="code-injection"></a>[`code-injection`](docs/rules/security/code-injection.md) | critical | Request-controlled input becomes source code evaluated by the application. |
846
+ | <a id="command-injection"></a>[`command-injection`](docs/rules/security/command-injection.md) | critical | Request-controlled input reaches a shell command string. |
847
+ | <a id="committed-secret"></a>[`committed-secret`](docs/rules/security/committed-secret.md) | critical | A tracked file contains a value that appears to be a credential. |
848
+ | <a id="compose-hardcoded-secret"></a>[`compose-hardcoded-secret`](docs/rules/security/compose-hardcoded-secret.md) | high | A Docker Compose service supplies a secret as a literal environment value. |
849
+ | <a id="cookie-missing-security-flags"></a>[`cookie-missing-security-flags`](docs/rules/security/cookie-missing-security-flags.md) | high | A sensitive cookie is set without the expected security attributes. |
850
+ | <a id="cors-credentials-any-origin"></a>[`cors-credentials-any-origin`](docs/rules/security/cors-credentials-any-origin.md) | high | A credentialed CORS response allows arbitrary origins. |
851
+ | <a id="cors-origin-regex-unanchored"></a>[`cors-origin-regex-unanchored`](docs/rules/security/cors-origin-regex-unanchored.md) | medium | A CORS origin regex also accepts look-alike hosts. |
852
+ | <a id="database-error-in-response"></a>[`database-error-in-response`](docs/rules/security/database-error-in-response.md) | medium | An HTTP response includes a raw database error message. |
853
+ | <a id="dockerfile-add-remote-url"></a>[`dockerfile-add-remote-url`](docs/rules/security/dockerfile-add-remote-url.md) | medium | A Dockerfile ADD instruction retrieves a resource from a remote URL. |
854
+ | <a id="dockerfile-runs-as-root"></a>[`dockerfile-runs-as-root`](docs/rules/security/dockerfile-runs-as-root.md) | medium | The final image selects root or inherits an unverified base-image user. |
855
+ | <a id="dockerfile-secret-in-build"></a>[`dockerfile-secret-in-build`](docs/rules/security/dockerfile-secret-in-build.md) | high | A Dockerfile exposes a secret through a build argument or environment variable. |
856
+ | <a id="dockerfile-unpinned-base-image"></a>[`dockerfile-unpinned-base-image`](docs/rules/security/dockerfile-unpinned-base-image.md) | low | A Dockerfile uses a base image reference that can change between builds. |
857
+ | <a id="dom-xss-sink"></a>[`dom-xss-sink`](docs/rules/security/dom-xss-sink.md) | high | Untrusted or dynamic HTML reaches innerHTML, outerHTML, insertAdjacentHTML, document.write or createContextualFragment (DOM XSS). |
858
+ | <a id="drizzle-scope-unverified"></a>[`drizzle-scope-unverified`](docs/rules/security/drizzle-scope-unverified.md) | high | A Drizzle operation lacks the row scope required by the declared policy. |
859
+ | <a id="drizzle-sql-raw-dynamic"></a>[`drizzle-sql-raw-dynamic`](docs/rules/security/drizzle-sql-raw-dynamic.md) | critical | A dynamic SQL fragment reaches Drizzle without parameter binding. |
860
+ | <a id="error-stack-in-response"></a>[`error-stack-in-response`](docs/rules/security/error-stack-in-response.md) | medium | An HTTP response includes an internal error stack. |
861
+ | <a id="escape-replace-incomplete"></a>[`escape-replace-incomplete`](docs/rules/security/escape-replace-incomplete.md) | medium | A hand-written string escape replaces only the first match, or escapes a delimiter without escaping backslashes first. |
862
+ | <a id="express-cookie-auth-missing-csrf"></a>[`express-cookie-auth-missing-csrf`](docs/rules/security/express-cookie-auth-missing-csrf.md) | high | Cookie-based session or auth is paired with state-changing routes without CSRF protection or `sameSite: "strict"`. |
863
+ | <a id="express-missing-helmet"></a>[`express-missing-helmet`](docs/rules/security/express-missing-helmet.md) | low | The Express or NestJS server starts without helmet security headers middleware (contextual: a proxy may set them). |
864
+ | <a id="frontend-storage-secret-token"></a>[`frontend-storage-secret-token`](docs/rules/security/frontend-storage-secret-token.md) | medium | A token, JWT, password or API key is stored in localStorage or sessionStorage, readable by any script on the page. |
865
+ | <a id="graphql-batching-unbounded"></a>[`graphql-batching-unbounded`](docs/rules/security/graphql-batching-unbounded.md) | medium | GraphQL query batching is enabled without a batch size, query depth, or cost/complexity limit. |
866
+ | <a id="graphql-introspection-enabled"></a>[`graphql-introspection-enabled`](docs/rules/security/graphql-introspection-enabled.md) | medium | A GraphQL server explicitly enables schema introspection. |
867
+ | <a id="graphql-query-depth-unbounded"></a>[`graphql-query-depth-unbounded`](docs/rules/security/graphql-query-depth-unbounded.md) | medium | A GraphQL server accepts queries of any depth. |
868
+ | <a id="hardcoded-secret"></a>[`hardcoded-secret`](docs/rules/security/hardcoded-secret.md) | critical | The source supplies a literal credential or cryptographic secret. |
869
+ | <a id="insecure-cipher"></a>[`insecure-cipher`](docs/rules/security/insecure-cipher.md) | medium | A cryptographic operation selects an insecure cipher or mode. |
870
+ | <a id="insecure-random-for-secret"></a>[`insecure-random-for-secret`](docs/rules/security/insecure-random-for-secret.md) | high | A sensitive token or secret uses a non-cryptographic random source. |
871
+ | <a id="jsx-javascript-url"></a>[`jsx-javascript-url`](docs/rules/security/jsx-javascript-url.md) | high | In React 18 and older or Preact, a URL search parameter or location hash starts a JSX href, action or iframe src (javascript: XSS). |
872
+ | <a id="jwt-decode-for-auth"></a>[`jwt-decode-for-auth`](docs/rules/security/jwt-decode-for-auth.md) | high | Authentication uses decoded JWT claims without verifying the token signature. |
873
+ | <a id="jwt-none-algorithm"></a>[`jwt-none-algorithm`](docs/rules/security/jwt-none-algorithm.md) | critical | JWT signing or verification allows an unsigned token. |
874
+ | <a id="jwt-sign-without-expiry"></a>[`jwt-sign-without-expiry`](docs/rules/security/jwt-sign-without-expiry.md) | medium | A signed JWT has no explicit expiration. |
875
+ | <a id="jwt-verify-without-algorithms"></a>[`jwt-verify-without-algorithms`](docs/rules/security/jwt-verify-without-algorithms.md) | high | JWT verification does not restrict the accepted signing algorithms. |
876
+ | <a id="jwt-weak-secret-literal"></a>[`jwt-weak-secret-literal`](docs/rules/security/jwt-weak-secret-literal.md) | high | JWT signing or verification uses a short (< 32 chars) or weak literal secret susceptible to brute-force forgery. |
877
+ | <a id="knex-raw-dynamic-text"></a>[`knex-raw-dynamic-text`](docs/rules/security/knex-raw-dynamic-text.md) | critical | A dynamic SQL fragment reaches Knex without parameter binding. |
878
+ | <a id="mass-assignment"></a>[`mass-assignment`](docs/rules/security/mass-assignment.md) | high | An unfiltered request body reaches a persistence operation. |
879
+ | <a id="mysql-dynamic-query-text"></a>[`mysql-dynamic-query-text`](docs/rules/security/mysql-dynamic-query-text.md) | critical | Dynamic SQL text reaches a MySQL client without parameter binding. |
880
+ | <a id="nest-validation-without-whitelist"></a>[`nest-validation-without-whitelist`](docs/rules/security/nest-validation-without-whitelist.md) | medium | A NestJS ValidationPipe permits properties outside the validated DTO. |
881
+ | <a id="next-image-any-remote-host"></a>[`next-image-any-remote-host`](docs/rules/security/next-image-any-remote-host.md) | medium | A Next.js images.remotePatterns entry sets hostname '**', so the image optimizer fetches and serves any host (open proxy). |
882
+ | <a id="nosql-operator-injection"></a>[`nosql-operator-injection`](docs/rules/security/nosql-operator-injection.md) | high | Request data can introduce query operators into a NoSQL filter. |
883
+ | <a id="open-redirect"></a>[`open-redirect`](docs/rules/security/open-redirect.md) | medium | An HTTP redirect destination is controlled by request data. |
884
+ | <a id="password-hash-in-response"></a>[`password-hash-in-response`](docs/rules/security/password-hash-in-response.md) | high | A response returns a user record that still holds its password hash. |
885
+ | <a id="path-traversal"></a>[`path-traversal`](docs/rules/security/path-traversal.md) | high | Request data controls a filesystem path without a recognized containment check. |
886
+ | <a id="pg-dynamic-query-text"></a>[`pg-dynamic-query-text`](docs/rules/security/pg-dynamic-query-text.md) | medium | Dynamic SQL text reaches the PostgreSQL client without parameter binding. |
887
+ | <a id="plaintext-password-storage"></a>[`plaintext-password-storage`](docs/rules/security/plaintext-password-storage.md) | critical | A password is stored or written without being hashed. |
888
+ | <a id="postmessage-missing-origin-check"></a>[`postmessage-missing-origin-check`](docs/rules/security/postmessage-missing-origin-check.md) | medium | postMessage targets '*', or a window message listener reads event.data without checking origin or source. |
889
+ | <a id="prisma-raw-unsafe-dynamic"></a>[`prisma-raw-unsafe-dynamic`](docs/rules/security/prisma-raw-unsafe-dynamic.md) | critical | Dynamic SQL text reaches an unsafe Prisma raw-query method. |
890
+ | <a id="prisma-scope-unverified"></a>[`prisma-scope-unverified`](docs/rules/security/prisma-scope-unverified.md) | high | A Prisma operation lacks the row scope required by the declared policy. |
891
+ | <a id="prototype-pollution"></a>[`prototype-pollution`](docs/rules/security/prototype-pollution.md) | high | Request data can supply keys to a write or merge that can modify an object prototype. |
892
+ | <a id="react-dangerously-set-inner-html"></a>[`react-dangerously-set-inner-html`](docs/rules/security/react-dangerously-set-inner-html.md) | high | dangerouslySetInnerHTML receives HTML that is not a constant or sanitized. |
893
+ | <a id="reflected-xss-response"></a>[`reflected-xss-response`](docs/rules/security/reflected-xss-response.md) | low | An HTML response reflects request data without recognized escaping. |
894
+ | <a id="regex-catastrophic-backtracking"></a>[`regex-catastrophic-backtracking`](docs/rules/security/regex-catastrophic-backtracking.md) | high | A regular expression that can backtrack exponentially or in polynomial time runs on request input. |
895
+ | <a id="regex-from-input"></a>[`regex-from-input`](docs/rules/security/regex-from-input.md) | medium | Request input supplies a regular expression pattern without recognized escaping. |
896
+ | <a id="secret-compared-non-constant-time"></a>[`secret-compared-non-constant-time`](docs/rules/security/secret-compared-non-constant-time.md) | medium | A secret is compared with an operation that can vary in timing with its contents. |
897
+ | <a id="secret-in-log"></a>[`secret-in-log`](docs/rules/security/secret-in-log.md) | high | A log statement can expose a credential, token, or other secret. |
898
+ | <a id="secret-in-url-query"></a>[`secret-in-url-query`](docs/rules/security/secret-in-url-query.md) | medium | A password, token or API key is passed in a URL query string. |
899
+ | <a id="sequelize-dynamic-query-text"></a>[`sequelize-dynamic-query-text`](docs/rules/security/sequelize-dynamic-query-text.md) | critical | Dynamic SQL text reaches Sequelize without parameter binding. |
900
+ | <a id="server-action-missing-auth"></a>[`server-action-missing-auth`](docs/rules/security/server-action-missing-auth.md) | high | An exported Next.js Server Action performs work without verifying authentication or session state. |
901
+ | <a id="ssrf-redirect-bypass"></a>[`ssrf-redirect-bypass`](docs/rules/security/ssrf-redirect-bypass.md) | high | An outbound HTTP request with a dynamic URL does not disable redirects, allowing SSRF allowlist bypasses. |
902
+ | <a id="ssrf-request-url"></a>[`ssrf-request-url`](docs/rules/security/ssrf-request-url.md) | high | Request data controls the destination of a server-side network request. |
903
+ | <a id="storage-object-public-acl"></a>[`storage-object-public-acl`](docs/rules/security/storage-object-public-acl.md) | high | A storage upload makes the object publicly readable. |
904
+ | <a id="template-autoescape-disabled"></a>[`template-autoescape-disabled`](docs/rules/security/template-autoescape-disabled.md) | medium | A template engine is configured to render values without HTML escaping. |
905
+ | <a id="template-injection"></a>[`template-injection`](docs/rules/security/template-injection.md) | critical | Request data is interpreted as template source rather than a template value. |
906
+ | <a id="tls-verification-disabled"></a>[`tls-verification-disabled`](docs/rules/security/tls-verification-disabled.md) | high | A TLS client skips certificate or server hostname verification. |
907
+ | <a id="typeorm-dynamic-query-text"></a>[`typeorm-dynamic-query-text`](docs/rules/security/typeorm-dynamic-query-text.md) | critical | A dynamic SQL fragment reaches TypeORM without parameter binding. |
908
+ | <a id="upload-client-filename"></a>[`upload-client-filename`](docs/rules/security/upload-client-filename.md) | medium | A file upload is stored under the original name supplied by the client. |
909
+ | <a id="vm-sandbox-escape"></a>[`vm-sandbox-escape`](docs/rules/security/vm-sandbox-escape.md) | critical | Node `vm` or `vm2` executes dynamic code or an untrusted context, risking sandbox escape and host RCE. |
910
+ | <a id="vue-v-html-unsanitized"></a>[`vue-v-html-unsanitized`](docs/rules/security/vue-v-html-unsanitized.md) | high | A Vue render function binds unsanitized dynamic HTML to innerHTML. |
911
+ | <a id="weak-password-hash"></a>[`weak-password-hash`](docs/rules/security/weak-password-hash.md) | high | A password is hashed with an algorithm unsuitable for password storage. |
912
+ | <a id="xml-external-entities"></a>[`xml-external-entities`](docs/rules/security/xml-external-entities.md) | medium | An XML parser allows processing of external entities. |
913
+ | <a id="zip-slip-extraction"></a>[`zip-slip-extraction`](docs/rules/security/zip-slip-extraction.md) | high | An archive entry controls an extraction path without a recognized containment check. |
1235
914
 
1236
915
  <!-- loadwise:rules:end -->
1237
916
 
1238
- The SQL rules report text assembled from a runtime value. When a part of that text traces to request data the finding is default and names the source; when no part does, it is contextual, because the value is usually an internal schema or table name. Every injection rule other than the SQL rules reports only values traced to request data.
1239
-
1240
- The first six rules read project files rather than TypeScript: `loadwise sec -p <tsconfig>` scans the project folder (not explicit source files) with `git ls-files`, so ignored files are skipped; outside a git repository it walks the folder and never opens `.env*` files. `.env.example`, `.env.sample` and `.env.template` are checked for token formats only. Placeholder values (`changeme`, `example`, `your-...`, `${...}`, test or dummy values) and default credentials for a local service are not reported or are contextual. Dockerfile checks follow multi-stage builds: only the final stage matters for `dockerfile-runs-as-root`.
1241
-
1242
- These rules moved from the performance checker with the same ids, so existing `// loadwise-reviewed` comments and `--ignore` flags keep working; `loadwise perf --ignore` still accepts them.
1243
-
1244
- Example: `pool.query('SELECT * FROM orders ORDER BY ' + req.query.sort)` reports `pg-dynamic-query-text`; `pool.query('SELECT * FROM orders WHERE id = $1', [id])` does not.
917
+ `committed-secret`, `compose-hardcoded-secret` and the `dockerfile-` rules read project files rather than TypeScript: `loadwise sec -p <tsconfig>` scans the project folder (not explicit source files) with `git ls-files`, so ignored files are skipped; outside a git repository it walks the folder and never opens `.env*` files. `.env.example`, `.env.sample` and `.env.template` are checked for token formats only, and placeholder values (`changeme`, `example`, `your-...`, `${...}`, test or dummy values) and default credentials for a local service are not reported or are contextual. Rules that moved from the performance checker kept their ids, and `loadwise perf --ignore` still accepts them.
1245
918
 
1246
919
  ## Polyglot source checks
1247
920
 
1248
- `npx loadwise sec polyglot src/` accepts directories or individual `.py`, `.go`, `.java`, `.cs` and `.rs` files. It uses the optional ast-grep native binary and its syntax-tree patterns. These are syntactic patterns without taint tracking, so each finding is a review prompt: confirm that untrusted input can reach the call. They are not `--ignore` rule ids of the TypeScript source checks. [ast-grep](https://ast-grep.github.io/)
921
+ `npx loadwise sec polyglot src/` accepts directories or individual `.py`, `.go`, `.java`, `.cs` and `.rs` files and needs the optional ast-grep binary. These are syntactic patterns without taint tracking: confirm that untrusted input can reach the call. They are not `--ignore` rule ids of the TypeScript source checks.
1249
922
 
1250
923
  <!-- loadwise:rules:start checker=security group=polyglot-source-checks -->
1251
924
 
1252
- | Rule | Impact | What it flags |
1253
- | ------------------------------------------------------------------------------------------------------------------------------ | ------ | -------------------------------------------------------------------------------------------------- |
1254
- | <a id="csharp-ef-from-sql-raw"></a>[`csharp-ef-from-sql-raw`](docs/rules/csharp-ef-from-sql-raw.md) | high | FromSqlRaw or ExecuteSqlRaw receives a concatenated or interpolated string, risking SQL injection. |
1255
- | <a id="csharp-process-start"></a>[`csharp-process-start`](docs/rules/csharp-process-start.md) | medium | Process.Start launches an external process and risks command injection with untrusted arguments. |
1256
- | <a id="go-exec-command-shell"></a>[`go-exec-command-shell`](docs/rules/go-exec-command-shell.md) | high | exec.Command invokes a shell, which risks command injection. |
1257
- | <a id="go-sql-sprintf-injection"></a>[`go-sql-sprintf-injection`](docs/rules/go-sql-sprintf-injection.md) | high | SQL text formatted with fmt.Sprintf risks SQL injection. |
1258
- | <a id="java-runtime-exec"></a>[`java-runtime-exec`](docs/rules/java-runtime-exec.md) | medium | Runtime.getRuntime().exec runs an OS command and risks command injection with untrusted arguments. |
1259
- | <a id="java-sql-string-concat"></a>[`java-sql-string-concat`](docs/rules/java-sql-string-concat.md) | high | A SQL query built by string concatenation risks SQL injection. |
1260
- | <a id="python-insecure-deserialization"></a>[`python-insecure-deserialization`](docs/rules/python-insecure-deserialization.md) | high | pickle or marshal deserialization of untrusted data can execute arbitrary code. |
1261
- | <a id="python-subprocess-shell-true"></a>[`python-subprocess-shell-true`](docs/rules/python-subprocess-shell-true.md) | high | subprocess with shell=True or os.system passes input through a shell, risking command injection. |
1262
- | <a id="python-unsafe-yaml-load"></a>[`python-unsafe-yaml-load`](docs/rules/python-unsafe-yaml-load.md) | high | yaml.load without SafeLoader can construct arbitrary Python objects. |
1263
- | <a id="rust-command-shell"></a>[`rust-command-shell`](docs/rules/rust-command-shell.md) | high | Command::new("sh") or Command::new("bash") spawns a shell and risks command injection. |
1264
- | <a id="rust-unsafe-raw-pointer-deref"></a>[`rust-unsafe-raw-pointer-deref`](docs/rules/rust-unsafe-raw-pointer-deref.md) | medium | A raw pointer dereference in an unsafe block bypasses Rust memory safety guarantees. |
925
+ | Rule | Impact | What it flags |
926
+ | --------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------- |
927
+ | <a id="csharp-ef-from-sql-raw"></a>[`csharp-ef-from-sql-raw`](docs/rules/security/csharp-ef-from-sql-raw.md) | high | FromSqlRaw or ExecuteSqlRaw receives a concatenated or interpolated string, risking SQL injection. |
928
+ | <a id="csharp-process-start"></a>[`csharp-process-start`](docs/rules/security/csharp-process-start.md) | medium | Process.Start launches an external process and risks command injection with untrusted arguments. |
929
+ | <a id="go-exec-command-shell"></a>[`go-exec-command-shell`](docs/rules/security/go-exec-command-shell.md) | high | exec.Command invokes a shell, which risks command injection. |
930
+ | <a id="go-sql-sprintf-injection"></a>[`go-sql-sprintf-injection`](docs/rules/security/go-sql-sprintf-injection.md) | high | SQL text formatted with fmt.Sprintf risks SQL injection. |
931
+ | <a id="java-runtime-exec"></a>[`java-runtime-exec`](docs/rules/security/java-runtime-exec.md) | medium | Runtime.getRuntime().exec runs an OS command and risks command injection with untrusted arguments. |
932
+ | <a id="java-sql-string-concat"></a>[`java-sql-string-concat`](docs/rules/security/java-sql-string-concat.md) | high | A SQL query built by string concatenation risks SQL injection. |
933
+ | <a id="python-insecure-deserialization"></a>[`python-insecure-deserialization`](docs/rules/security/python-insecure-deserialization.md) | high | pickle or marshal deserialization of untrusted data can execute arbitrary code. |
934
+ | <a id="python-subprocess-shell-true"></a>[`python-subprocess-shell-true`](docs/rules/security/python-subprocess-shell-true.md) | high | subprocess with shell=True or os.system passes input through a shell, risking command injection. |
935
+ | <a id="python-unsafe-yaml-load"></a>[`python-unsafe-yaml-load`](docs/rules/security/python-unsafe-yaml-load.md) | high | yaml.load without SafeLoader can construct arbitrary Python objects. |
936
+ | <a id="rust-command-shell"></a>[`rust-command-shell`](docs/rules/security/rust-command-shell.md) | high | Command::new("sh") or Command::new("bash") spawns a shell and risks command injection. |
937
+ | <a id="rust-unsafe-raw-pointer-deref"></a>[`rust-unsafe-raw-pointer-deref`](docs/rules/security/rust-unsafe-raw-pointer-deref.md) | medium | A raw pointer dereference in an unsafe block bypasses Rust memory safety guarantees. |
1265
938
 
1266
939
  <!-- loadwise:rules:end -->
1267
940
 
1268
941
  ## Dependency checks
1269
942
 
1270
- `loadwise sec deps --online [directory]` reads `package-lock.json` (lockfile version 2 or 3), `pnpm-lock.yaml` or `yarn.lock` (version 1 or Berry) from the directory or the nearest parent that has one, and asks the [OSV database](https://osv.dev) (which includes the GitHub Advisory Database) about every pinned package version. It sends package names and versions and nothing else. Answers are cached for 24 hours in the `loadwise` folder of the OS cache directory. It takes `--format text|json` (or `--json`), `--include-contextual`, `--ignore` and `--fail-on`. A network failure exits 2 rather than passing.
1271
-
1272
- The network is opt-in: `loadwise sec --online` and `loadwise check --online` add these findings to their security report, and without `--online` they print one note that dependency checks were skipped.
943
+ `loadwise sec deps --online [directory]` reads `package-lock.json` (lockfile version 2 or 3), `pnpm-lock.yaml` or `yarn.lock` (version 1 or Berry) from the directory or the nearest parent that has one, and asks the [OSV database](https://osv.dev) (which includes the GitHub Advisory Database) about every pinned package version. It sends package names and versions and nothing else. Answers are cached for 24 hours in the `loadwise` folder of the OS cache directory. It takes `--format text|json` (or `--json`), `--include-contextual`, `--ignore` and `--fail-on`. A network failure exits 2 rather than passing. The network is opt-in: `loadwise sec --online` and `loadwise check --online` add these findings to their security report, and without `--online` they print one note that dependency checks were skipped.
1273
944
 
1274
945
  <!-- loadwise:rules:start checker=security group=dependency-checks -->
1275
946
 
1276
- | Rule | Impact | What it flags |
1277
- | --------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------ |
1278
- | <a id="dependency-known-vulnerability"></a>[`dependency-known-vulnerability`](docs/rules/dependency-known-vulnerability.md) | medium | A resolved dependency version is listed in a published vulnerability advisory. |
947
+ | Rule | Impact | What it flags |
948
+ | ------------------------------------------------------------------------------------------------------------------------------------ | ------ | ------------------------------------------------------------------------------ |
949
+ | <a id="dependency-known-vulnerability"></a>[`dependency-known-vulnerability`](docs/rules/security/dependency-known-vulnerability.md) | medium | A resolved dependency version is listed in a published vulnerability advisory. |
1279
950
 
1280
951
  <!-- loadwise:rules:end -->
1281
952
 
1282
- ## Security impact levels
1283
-
1284
- `--min-impact` sets the minimum level to report. Dependency findings use the advisory severity.
1285
-
1286
953
  ## Project-defined row scopes
1287
954
 
1288
- Row-scope checks read `prismaScopes` and `drizzleScopes` from the `performance` section of `loadwise.config.json`, found the same way as for the performance checker (see [Project-defined access policy](#project-defined-access-policy)). Every other rule runs without a scope policy. Row-scope checks start when the project identifies the existing model or table, its scoped property, and the helper that supplies an authorized scalar. Columns such as `tenantId`, `organizationId` and `workspace_id` have no special meaning to the checker on their own. Database mappings can keep the original storage column name. [Prisma database mapping](https://www.prisma.io/docs/orm/prisma-schema/data-model/database-mapping) · [Drizzle schema declarations](https://orm.drizzle.team/docs/sql-schema-declaration)
1289
-
1290
- Drizzle also supports configuring quoted properties such as `"org-id"` and accessing them with brackets. In Prisma's generated filters, `AND`, `OR` and `NOT` are logical operators. If a physical column uses one of these names, configure the Prisma property that maps to it.
1291
-
1292
- `prismaScopes` maps each generated model to its own protected field and a named export from the project's trusted authorization module. With the supplied example, `db.invoice.findMany({ where: { organizationId: requireOrganization() } })` has the expected scope. Choose the names already used by the project. The scanner handles common reads, writes and upsert branches, and requires every alternative in an OR to preserve the scope. For dynamic or nested shapes it cannot establish, it emits `prisma-scope-unverified`. Proof requires strict null checks. With explicit source files and a policy, the CLI enables strict null checks for its analysis.
1293
-
1294
- `drizzleScopes` names an exported table, its schema module, its scoped property and the trusted helper. For a direct executed query, `.where(eq(invoices.workspace_id, currentWorkspace()))` establishes the configured predicate in the example. Use the property exposed by the ORM. A project with `organizationId: text('org_id')` would configure `"field": "organizationId"`. Each table can use a different convention. A later `.where()` can replace the earlier condition. The rule checks the effective condition and can report `drizzle-scope-unverified` when a protected table appears in a recognized chain and scope, projection or write data needs review. Stored builders, prepared aliases, raw SQL and arbitrary helper-generated statements can fall outside this check.
1295
-
1296
- The import boundary for database modules is a maintainability rule; configure it through the `dataAccess` field of the `maintainability` section in `loadwise.config.json`.
1297
-
1298
- These checks assume the configured helper authenticates the caller and authorizes the returned scope. Middleware, injected or previously obtained clients, raw SQL, unrecognized query shapes and database row-level policies require separate verification. A clean run only describes the covered operations.
955
+ Row-scope checks read `prismaScopes` and `drizzleScopes` from the `performance` section of `loadwise.config.json` (see [Project-defined access policy](#project-defined-access-policy)) and start only when the project names the model or table, its scoped property and the trusted helper that supplies an authorized scalar; column names such as `tenantId` mean nothing on their own. `prismaScopes` maps each generated model to its protected field and a named export of the project's authorization module, so `db.invoice.findMany({ where: { organizationId: requireOrganization() } })` is scoped; proof requires strict null checks, which the CLI enables for explicit source files with a policy. `drizzleScopes` names an exported table, its schema module, its scoped property (the ORM property, not the column name) and the trusted helper. A later `.where()` replaces the earlier condition, and every OR alternative must keep the scope. If a physical column is named `AND`, `OR` or `NOT`, configure the Prisma property that maps to it; quoted Drizzle properties such as `"org-id"` work with bracket access. Shapes the scanner cannot establish are reported as `prisma-scope-unverified` or `drizzle-scope-unverified`. These checks assume the helper authenticates the caller; middleware, injected clients, raw SQL and database row-level policies need separate verification. The import boundary for database modules is the maintainability `dataAccess` setting.
1299
956
 
1300
957
  # Accessibility checker
1301
958
 
1302
- `loadwise a11y` finds markup that people using screen readers, keyboards or zoom cannot use: images without alt text, unlabelled form controls, click handlers on non-interactive elements, invalid ARIA, a missing page language and similar. It reads JSX and inline Angular templates from the TypeScript program, and `.html`, `.htm`, `.vue` and `.svelte` files from the project folders, leaving out ignored folders, build output, minified and vendored files and the config's `ignore` paths. It shares the source check of `loadwise perf`, so project discovery, config, engines, baselines and fix flags are the same, and `loadwise check` type-checks the project once for all of them. A project with no frontend sources (no JSX, HTML, Vue or Svelte files and no frontend package in any `package.json`) is skipped by `loadwise check` with a note; `loadwise a11y` on it reports 0 findings.
959
+ `loadwise a11y` finds markup that people using screen readers, keyboards or zoom cannot use. It reads JSX and inline Angular templates from the TypeScript program, and `.html`, `.htm`, `.vue` and `.svelte` files from the project folders, leaving out ignored folders, build output, minified and vendored files and the config's `ignore` paths. It shares the source check of `loadwise perf`. A project with no frontend sources (no JSX, HTML, Vue or Svelte files and no frontend package in any `package.json`) is skipped by `loadwise check` with a note; `loadwise a11y` on it reports 0 findings.
1303
960
 
1304
961
  ```sh
1305
962
  npx loadwise a11y -p tsconfig.json # JSX, Angular templates and the project's markup files
1306
963
  npx loadwise a11y src/index.html # explicit markup files
1307
- npx loadwise a11y --staged # only findings on staged lines
1308
964
  npx loadwise a11y --fix --only <id> # apply one generated fix
1309
965
  ```
1310
966
 
1311
- `npx loadwise a11y --help` lists every flag. A `loadwise.config.json` `rules` or `overrides` entry for an accessibility rule applies here, and findings live in the `accessibility` section of the baseline file.
1312
-
1313
967
  ## Rules
1314
968
 
1315
969
  <!-- loadwise:rules:start checker=accessibility group=rules -->
1316
970
 
1317
- | Rule | Impact | What it flags |
1318
- | --------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
1319
- | <a id="a11y-button-missing-type"></a>[`a11y-button-missing-type`](docs/rules/a11y-button-missing-type.md) | medium | A button inside a form has no type, so it submits the form even when it only meant to run a handler. |
1320
- | <a id="a11y-clickable-non-interactive"></a>[`a11y-clickable-non-interactive`](docs/rules/a11y-clickable-non-interactive.md) | high | A click handler sits on a non-interactive element without a role and keyboard support, so keyboard users cannot activate it. |
1321
- | <a id="a11y-html-missing-lang"></a>[`a11y-html-missing-lang`](docs/rules/a11y-html-missing-lang.md) | medium | The html element has no lang attribute, so screen readers guess the pronunciation. |
1322
- | <a id="a11y-iframe-missing-title"></a>[`a11y-iframe-missing-title`](docs/rules/a11y-iframe-missing-title.md) | medium | An iframe has no title, so screen readers cannot say what it contains. |
1323
- | <a id="a11y-img-missing-alt"></a>[`a11y-img-missing-alt`](docs/rules/a11y-img-missing-alt.md) | high | An image has no alt text, so screen readers announce its file name or nothing. |
1324
- | <a id="a11y-invalid-aria"></a>[`a11y-invalid-aria`](docs/rules/a11y-invalid-aria.md) | high | An ARIA attribute or role is misspelled or invalid, so assistive technology ignores it. |
1325
- | <a id="a11y-missing-form-label"></a>[`a11y-missing-form-label`](docs/rules/a11y-missing-form-label.md) | high | A form control has no label, so screen readers announce it without its purpose. |
1326
- | <a id="a11y-positive-tabindex"></a>[`a11y-positive-tabindex`](docs/rules/a11y-positive-tabindex.md) | medium | A positive tabindex reorders keyboard focus away from the visual order. |
1327
- | <a id="a11y-viewport-zoom-disabled"></a>[`a11y-viewport-zoom-disabled`](docs/rules/a11y-viewport-zoom-disabled.md) | high | The viewport meta tag disables zoom, so people with low vision cannot enlarge the page. |
971
+ | Rule | Impact | What it flags |
972
+ | -------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
973
+ | <a id="a11y-button-missing-type"></a>[`a11y-button-missing-type`](docs/rules/accessibility/a11y-button-missing-type.md) | medium | A button associated with a form has a click handler but no explicit type, so clicking it can also submit the form. |
974
+ | <a id="a11y-clickable-non-interactive"></a>[`a11y-clickable-non-interactive`](docs/rules/accessibility/a11y-clickable-non-interactive.md) | high | A click handler sits on a non-interactive element without a role and keyboard support, so keyboard users cannot activate it. |
975
+ | <a id="a11y-heading-level-skipped"></a>[`a11y-heading-level-skipped`](docs/rules/accessibility/a11y-heading-level-skipped.md) | low | A heading jumps more than one level down, which leaves a gap in the page outline. |
976
+ | <a id="a11y-html-missing-lang"></a>[`a11y-html-missing-lang`](docs/rules/accessibility/a11y-html-missing-lang.md) | medium | The html element has no lang attribute, so screen readers guess the pronunciation. |
977
+ | <a id="a11y-iframe-missing-title"></a>[`a11y-iframe-missing-title`](docs/rules/accessibility/a11y-iframe-missing-title.md) | medium | An iframe has no title, so screen readers cannot say what it contains. |
978
+ | <a id="a11y-img-missing-alt"></a>[`a11y-img-missing-alt`](docs/rules/accessibility/a11y-img-missing-alt.md) | high | An image has no alt text, so screen readers announce its file name or nothing. |
979
+ | <a id="a11y-input-missing-autocomplete"></a>[`a11y-input-missing-autocomplete`](docs/rules/accessibility/a11y-input-missing-autocomplete.md) | low | An input for personal data has no autocomplete, so browsers cannot fill it in for people who find typing hard. |
980
+ | <a id="a11y-invalid-aria"></a>[`a11y-invalid-aria`](docs/rules/accessibility/a11y-invalid-aria.md) | high | An ARIA attribute or role is misspelled or invalid, so assistive technology ignores it. |
981
+ | <a id="a11y-link-text-not-descriptive"></a>[`a11y-link-text-not-descriptive`](docs/rules/accessibility/a11y-link-text-not-descriptive.md) | medium | A link says only "click here" or "read more", so it means nothing out of context. |
982
+ | <a id="a11y-media-autoplay"></a>[`a11y-media-autoplay`](docs/rules/accessibility/a11y-media-autoplay.md) | medium | A video or audio element plays on its own with sound, so it talks over screen readers. |
983
+ | <a id="a11y-missing-form-label"></a>[`a11y-missing-form-label`](docs/rules/accessibility/a11y-missing-form-label.md) | high | A form control has no label, so screen readers announce it without its purpose. |
984
+ | <a id="a11y-positive-tabindex"></a>[`a11y-positive-tabindex`](docs/rules/accessibility/a11y-positive-tabindex.md) | medium | A positive tabindex reorders keyboard focus away from the visual order. |
985
+ | <a id="a11y-viewport-zoom-disabled"></a>[`a11y-viewport-zoom-disabled`](docs/rules/accessibility/a11y-viewport-zoom-disabled.md) | high | The viewport meta tag disables zoom, so people with low vision cannot enlarge the page. |
1328
986
 
1329
987
  <!-- loadwise:rules:end -->
1330
988
 
1331
- ## Impact levels
1332
-
1333
- The levels and the `--min-impact` flag work as described under the performance checker's impact levels. `loadwise a11y` and the accessibility section of `loadwise check` use the impact levels in the rule index.
1334
-
1335
- # Developing locally
1336
-
1337
- Use Node.js 22.13+ for the development tools and run `npm ci --include=optional`. Open this repository folder as a trusted workspace in VS Code or Cursor and enable the recommended Prettier extension. Saving a supported file formats it with the repository settings.
1338
-
1339
- Run `npm run format` to format files, `npm run lint` for correctness checks, or `npm run check` to verify formatting, lint and tests together.
989
+ # Verification and development
1340
990
 
1341
- From this checkout, run `node bin/loadwise.js check --config scripts/self-scan/loadwise.config.json` to scan Loadwise itself; that config excludes vendored files, tests, examples, and benchmark workloads so they keep their intended behavior.
991
+ [PERFORMANCE.md](PERFORMANCE.md) has the scan-time and memory measurements, and the [corpus rule scorecard](bench/corpus/scorecard.md) the measured precision and recall per rule. To develop Loadwise itself, see [CONTRIBUTING.md](CONTRIBUTING.md).
1342
992
 
1343
993
  # License
1344
994