loadwise 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +542 -627
  2. package/bin/loadwise.js +4 -0
  3. package/lib/accessibility/frontend-detect.js +2 -1
  4. package/lib/accessibility/rule-ids.js +12 -9
  5. package/{editor/accessibility-examples.cjs → lib/editor/accessibility-examples.js} +20 -21
  6. package/lib/editor/actions.js +117 -0
  7. package/{editor/apply-fix.cjs → lib/editor/apply-fix.js} +1 -6
  8. package/{editor/control-flow-comparison.cjs → lib/editor/control-flow-comparison.js} +1 -3
  9. package/lib/editor/diagnostics.js +365 -0
  10. package/lib/editor/dismissals.js +111 -0
  11. package/lib/editor/editor-document.js +99 -0
  12. package/{editor/finding-comparison.cjs → lib/editor/finding-comparison.js} +4 -7
  13. package/lib/editor/fix-edits.js +200 -0
  14. package/lib/editor/language-server.js +437 -0
  15. package/{editor/maintainability-examples.cjs → lib/editor/maintainability-examples.js} +1 -3
  16. package/{editor/perf-site-comparison.cjs → lib/editor/perf-site-comparison.js} +1 -3
  17. package/lib/editor/perf-watch.js +78 -0
  18. package/{editor/performance-examples.cjs → lib/editor/performance-examples.js} +129 -128
  19. package/{editor/reliability-examples.cjs → lib/editor/reliability-examples.js} +100 -41
  20. package/lib/editor/scan-session.js +334 -0
  21. package/{editor/security-examples.cjs → lib/editor/security-examples.js} +28 -32
  22. package/lib/editor/server-commands.js +232 -0
  23. package/{editor/source-example.cjs → lib/editor/source-example.js} +3 -5
  24. package/{editor/standalone-performance-examples.cjs → lib/editor/standalone-performance-examples.js} +349 -333
  25. package/lib/editor/types/dismissal.js +1 -0
  26. package/lib/editor/types/fix-example.js +1 -0
  27. package/lib/editor/types/source-document.js +1 -0
  28. package/lib/editor/workspace-files.js +78 -0
  29. package/lib/editor/workspace-paths.js +22 -0
  30. package/lib/maintainability/analyze-source.js +2 -0
  31. package/lib/maintainability/apply-fix.js +1 -1
  32. package/lib/maintainability/cli.js +1 -1
  33. package/lib/maintainability/examples.js +58 -41
  34. package/lib/maintainability/rule-ids.js +29 -14
  35. package/lib/maintainability/scan-changed.js +3 -0
  36. package/lib/maintainability/scan.js +13 -9
  37. package/lib/maintainability/tsconfig-strict.js +69 -0
  38. package/lib/maintainability/type-safety-hygiene.js +204 -0
  39. package/lib/performance/analyze.js +2 -0
  40. package/lib/performance/cli-arguments.js +0 -2
  41. package/lib/performance/cli-policy.js +17 -9
  42. package/lib/performance/cli-scan.js +10 -8
  43. package/lib/performance/cli.js +4 -23
  44. package/lib/performance/editor-signal.js +1 -1
  45. package/lib/performance/finding-text.js +3 -3
  46. package/lib/performance/fix-cli.js +1 -1
  47. package/lib/performance/frontend-perf.js +7 -0
  48. package/lib/performance/frontend-render-perf.js +200 -0
  49. package/lib/performance/llm-max-tokens.js +56 -0
  50. package/lib/performance/native.js +46 -26
  51. package/lib/performance/polyglot.js +22 -1
  52. package/lib/performance/pooling.js +38 -23
  53. package/lib/performance/projects.js +42 -21
  54. package/lib/performance/rule-ids.js +236 -222
  55. package/lib/performance/site-fixes/database.js +3 -1
  56. package/lib/performance/site-fixes/integrity.js +15 -1
  57. package/lib/performance/source-inputs.js +18 -6
  58. package/lib/performance/unscanned-javascript.js +66 -19
  59. package/lib/reliability/analyze.js +12 -0
  60. package/lib/reliability/child-process.js +106 -0
  61. package/lib/reliability/error-values.js +177 -0
  62. package/lib/reliability/pool-timeout.js +79 -0
  63. package/lib/reliability/react-bugs.js +602 -0
  64. package/lib/reliability/resource-leaks.js +3 -6
  65. package/lib/reliability/rule-ids.js +169 -127
  66. package/lib/reliability/switch-exhaustive.js +284 -0
  67. package/lib/reliability/uncaught-exception.js +223 -0
  68. package/lib/security/auth-crypto/rule-ids.js +3 -2
  69. package/lib/security/cli.js +6 -5
  70. package/lib/security/deps/rule-ids.js +1 -0
  71. package/lib/security/examples/auth-crypto.cjs +5 -4
  72. package/lib/security/examples/deps.cjs +1 -0
  73. package/lib/security/examples/exposure.cjs +55 -42
  74. package/lib/security/examples/files.cjs +1 -0
  75. package/lib/security/examples/injection.cjs +1 -0
  76. package/lib/security/examples/moved.cjs +5 -4
  77. package/lib/security/examples/request-forgery.cjs +1 -0
  78. package/lib/security/exposure/client-env.js +113 -0
  79. package/lib/security/exposure/frontend-security.js +12 -10
  80. package/lib/security/exposure/index.js +14 -3
  81. package/lib/security/exposure/jsx-url.js +267 -0
  82. package/lib/security/exposure/next-image-config.js +34 -0
  83. package/lib/security/exposure/package-manifest.js +45 -0
  84. package/lib/security/exposure/react-version.js +45 -0
  85. package/lib/security/exposure/rule-ids.js +16 -12
  86. package/lib/security/files/index.js +1 -1
  87. package/lib/security/files/rule-ids.js +1 -0
  88. package/lib/security/injection/code.js +24 -10
  89. package/lib/security/injection/command.js +81 -28
  90. package/lib/security/injection/nosql.js +109 -22
  91. package/lib/security/injection/redos.js +152 -308
  92. package/lib/security/injection/regex-pattern.js +290 -0
  93. package/lib/security/injection/regex.js +30 -11
  94. package/lib/security/injection/rule-ids.js +2 -1
  95. package/lib/security/injection/shared.js +19 -1
  96. package/lib/security/injection/sql.js +83 -2
  97. package/lib/security/request-forgery/rule-ids.js +1 -0
  98. package/lib/security/rule-descriptions.js +36 -32
  99. package/lib/security/rule-ids.js +74 -67
  100. package/lib/security/taint/filename-guard.js +3 -1
  101. package/lib/security/taint/guards.js +84 -10
  102. package/lib/security/taint/index.js +124 -13
  103. package/lib/security/taint/propagate.js +10 -7
  104. package/lib/security/taint/sanitizers.js +7 -3
  105. package/lib/security/taint/sources.js +6 -3
  106. package/lib/security/taint/summaries.js +13 -1
  107. package/lib/security/taint/url-parts.js +14 -5
  108. package/lib/shared/agent-session.js +2 -2
  109. package/lib/shared/check.js +9 -6
  110. package/lib/shared/explain.js +5 -5
  111. package/lib/shared/fix-convergence.js +1 -1
  112. package/lib/shared/formats/finding-location.js +6 -2
  113. package/lib/shared/formats/sarif.js +3 -3
  114. package/lib/shared/heap-limit.js +6 -0
  115. package/lib/shared/pillars.js +7 -7
  116. package/lib/shared/rule-docs.js +12 -0
  117. package/lib/shared/scan-cache.js +0 -1
  118. package/lib/shared/workspaces.js +31 -9
  119. package/package.json +9 -16
  120. package/plugin/.claude-plugin/plugin.json +1 -1
  121. package/schema/loadwise.config.schema.json +44 -0
  122. package/editor/README.md +0 -47
  123. package/examples/redis-keys.otlp.json +0 -22
  124. package/lib/maintainability/notify-editor.js +0 -1
  125. package/lib/performance/editor-report.js +0 -191
  126. package/lib/performance/editor-setup.js +0 -189
  127. package/lib/performance/editor-watch-supervisor.js +0 -104
  128. package/lib/performance/editor-watch.js +0 -193
  129. package/lib/performance/notify-editor.js +0 -1
  130. package/lib/performance/recursive-watch.js +0 -181
  131. /package/lib/{performance/types/editor-report.js → editor/types/comparison.js} +0 -0
@@ -275,17 +275,39 @@ function selectWorkspaces(packages, root, selectors, caller = process.cwd()) {
275
275
  }
276
276
  return packages.filter((entry) => chosen.has(entry));
277
277
  }
278
- // Configless Node packages can use the explicit-JavaScript compiler options. Keep mixed-language
279
- // projects and workspace roots on the config-based path so an incomplete scan cannot authorize
280
- // fixes.
281
- function plainJavaScriptSources(directory) {
278
+ const implementationSource = /(?<!\.d)\.[cm]?[jt]sx?$/i;
279
+ // Whether a source sits under a sub-folder's own tsconfig.json or jsconfig.json, found on disk so a
280
+ // git-ignored config counts too.
281
+ function hasNestedSourceConfig(directory, file) {
282
+ const packageRoot = path.resolve(directory);
283
+ for (let folder = path.dirname(path.resolve(packageRoot, file)); folder !== packageRoot && folder !== path.dirname(folder); folder = path.dirname(folder)) {
284
+ if (isFile(path.join(folder, 'tsconfig.json')) || isFile(path.join(folder, 'jsconfig.json')))
285
+ return true;
286
+ }
287
+ return false;
288
+ }
289
+ // The sources of a Node package without a config of its own, which are checked with the standalone
290
+ // defaults (ES2022, NodeNext). A workspace root keeps to its packages' configs. A source under a
291
+ // sub-folder's own tsconfig.json or jsconfig.json needs that config's settings, such as paths and
292
+ // decorators, so such a package is left out rather than checked with defaults that would misread it
293
+ // and let fixes through.
294
+ function configlessSources(directory) {
282
295
  if (!isFile(path.join(directory, 'package.json')) || projectConfig(directory) || workspacePatterns(directory).length)
283
296
  return undefined;
284
- const files = listFiles(directory);
285
- if (files.some((file) => /\.[cm]?tsx?$/i.test(file) && !/\.d\.[cm]?ts$/i.test(file)))
297
+ const files = listFiles(directory).filter((file) => implementationSource.test(file));
298
+ if (files.some((file) => hasNestedSourceConfig(directory, file)))
286
299
  return undefined;
287
- const sources = files.filter((file) => /\.[cm]?jsx?$/i.test(file)).map((file) => path.join(directory, file));
288
- return sources.length ? sources : undefined;
300
+ return files.length ? files.map((file) => path.join(directory, file)) : undefined;
301
+ }
302
+ // Whether a monorepo root has a package the source checkers can read, with its own config or without.
303
+ function hasWorkspaceSources(root) {
304
+ const { packages, withoutConfig } = discoverWorkspaces(root);
305
+ return packages.length > 0 || withoutConfig.some(({ directory }) => configlessSources(directory) !== undefined);
306
+ }
307
+ // Packages without a config whose sources cannot be checked with the standalone defaults.
308
+ function uncheckedWorkspaces(withoutConfig) {
309
+ return withoutConfig.filter(({ directory }) => configlessSources(directory) === undefined &&
310
+ listFiles(directory).some((file) => implementationSource.test(file)));
289
311
  }
290
312
  const missingFileCode = 6053;
291
313
  // A missing non-relative tsconfig base (`"extends": "@org/tsconfig/base.json"`) is a package that
@@ -296,4 +318,4 @@ function missingPackageBase(diagnostic) {
296
318
  const missing = /'([^']+)'/.exec(ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '))?.[1];
297
319
  return missing !== undefined && !/^(?:\.|\/|[a-z]:)/i.test(missing) ? missing : undefined;
298
320
  }
299
- export { coveringConfig, discoverWorkspaces, isWithin, missingPackageBase, projectConfig, selectWorkspaces, plainJavaScriptSources, isProjectDirectory, workspacePackagesAround, workspaceSourceEntry, };
321
+ export { coveringConfig, discoverWorkspaces, isWithin, missingPackageBase, projectConfig, selectWorkspaces, configlessSources, hasWorkspaceSources, uncheckedWorkspaces, isProjectDirectory, workspacePackagesAround, workspaceSourceEntry, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loadwise",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Find performance, reliability, maintainability, security and accessibility issues, review suggested fixes, and check changed code locally or in CI.",
6
6
  "license": "Apache-2.0",
@@ -36,7 +36,8 @@
36
36
  "static-analysis",
37
37
  "security",
38
38
  "cli",
39
- "vscode"
39
+ "language-server",
40
+ "lsp"
40
41
  ],
41
42
  "bin": {
42
43
  "loadwise": "bin/loadwise.js"
@@ -48,18 +49,6 @@
48
49
  "polyglot/",
49
50
  "schema/",
50
51
  "examples/",
51
- "editor/README.md",
52
- "editor/control-flow-comparison.cjs",
53
- "editor/finding-comparison.cjs",
54
- "editor/performance-examples.cjs",
55
- "editor/reliability-examples.cjs",
56
- "editor/accessibility-examples.cjs",
57
- "editor/standalone-performance-examples.cjs",
58
- "editor/perf-site-comparison.cjs",
59
- "editor/maintainability-examples.cjs",
60
- "editor/security-examples.cjs",
61
- "editor/source-example.cjs",
62
- "editor/apply-fix.cjs",
63
52
  "PERFORMANCE.md",
64
53
  "LICENSE",
65
54
  "!**/*.cts",
@@ -88,14 +77,18 @@
88
77
  "bench:traces": "node bench/traces.js",
89
78
  "bench:recall": "node bench/recall/runner.js",
90
79
  "build": "tsc -p tsconfig.json",
91
- "clean": "node -e \"import('node:fs').then(fs=>import('node:path').then(p=>{const walk=d=>{if(!fs.existsSync(d))return;for(const e of fs.readdirSync(d,{withFileTypes:true})){const f=p.join(d,e.name);if(e.isDirectory()&&e.name!=='node_modules'&&!f.includes('vendor'))walk(f);else if((e.name.endsWith('.js')&&fs.existsSync(f.slice(0,-3)+'.ts'))||(e.name.endsWith('.cjs')&&fs.existsSync(f.slice(0,-4)+'.cts')))fs.unlinkSync(f);}};['bin','lib','editor','plugin','polyglot','scripts','bench','test'].forEach(walk);fs.rmSync('.tsbuildinfo',{force:true});}))\"",
80
+ "changelog": "npm run build && node scripts/changelog.js",
81
+ "docs:rules": "npm run build && node scripts/rule-docs.js",
82
+ "clean": "node -e \"import('node:fs').then(fs=>import('node:path').then(p=>{const walk=d=>{if(!fs.existsSync(d))return;for(const e of fs.readdirSync(d,{withFileTypes:true})){const f=p.join(d,e.name);if(e.isDirectory()&&e.name!=='node_modules'&&!f.includes('vendor'))walk(f);else if((e.name.endsWith('.js')&&fs.existsSync(f.slice(0,-3)+'.ts'))||(e.name.endsWith('.cjs')&&fs.existsSync(f.slice(0,-4)+'.cts')))fs.unlinkSync(f);}};['bin','lib','plugin','polyglot','scripts','bench','test'].forEach(walk);fs.rmSync('.tsbuildinfo',{force:true});}))\"",
92
83
  "prepack": "npm run build",
93
84
  "prepare": "node -e \"import('node:child_process').then(c=>{c.execSync('git rev-parse --git-dir',{stdio:'ignore'});c.execSync('git config core.hooksPath hooks')}).catch(()=>{})\"",
94
85
  "lint:fix": "oxlint --fix ."
95
86
  },
96
87
  "dependencies": {
97
88
  "libpg-query": "18.3.0",
98
- "typescript": "6.0.3"
89
+ "typescript": "6.0.3",
90
+ "vscode-languageserver": "11.0.0",
91
+ "vscode-languageserver-textdocument": "1.0.16"
99
92
  },
100
93
  "optionalDependencies": {
101
94
  "@ast-grep/cli": "0.51.3",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loadwise",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Runs the project's local loadwise checkers on each file Claude edits and sends findings back with their fix commands.",
5
5
  "author": { "name": "Ibrahim Hafez" },
6
6
  "homepage": "https://github.com/IbrahimHafez1/loadwise#readme",
@@ -37,6 +37,7 @@
37
37
  "a11y-viewport-zoom-disabled",
38
38
  "angular-bypass-security-trust",
39
39
  "angular-default-change-detection",
40
+ "angular-ngfor-missing-trackby",
40
41
  "angular-subscribe-without-cleanup",
41
42
  "api-enum-value-removed",
42
43
  "api-removed-field",
@@ -53,6 +54,8 @@
53
54
  "bcrypt-low-cost",
54
55
  "browser-not-closed",
55
56
  "check-then-update-race",
57
+ "child-process-without-error-listener",
58
+ "client-env-secret-exposed",
56
59
  "code-injection",
57
60
  "command-injection",
58
61
  "committed-secret",
@@ -82,6 +85,7 @@
82
85
  "dom-listener-without-cleanup",
83
86
  "dom-unthrottled-scroll-resize",
84
87
  "dom-xss-sink",
88
+ "double-type-assertion",
85
89
  "drizzle-last-insert-id",
86
90
  "drizzle-query-in-loop",
87
91
  "drizzle-scope-unverified",
@@ -89,6 +93,8 @@
89
93
  "drizzle-unfiltered-write",
90
94
  "drizzle-write-preflight",
91
95
  "duplicate-implementation",
96
+ "error-logged-without-stack",
97
+ "error-rethrown-without-cause",
92
98
  "error-stack-in-response",
93
99
  "express-cookie-auth-missing-csrf",
94
100
  "express-missing-compression",
@@ -99,6 +105,7 @@
99
105
  "filter-for-existence",
100
106
  "find-then-create-race",
101
107
  "floating-promise",
108
+ "focused-test-committed",
102
109
  "folder-boundary",
103
110
  "frontend-barrel-heavy-import",
104
111
  "frontend-storage-secret-token",
@@ -124,6 +131,7 @@
124
131
  "json-parse-unguarded",
125
132
  "json-roundtrip-clone",
126
133
  "json-stringify-in-loop",
134
+ "jsx-javascript-url",
127
135
  "jwt-decode-for-auth",
128
136
  "jwt-none-algorithm",
129
137
  "jwt-sign-without-expiry",
@@ -135,6 +143,7 @@
135
143
  "large-module",
136
144
  "list-count-per-request",
137
145
  "list-query-overfetch",
146
+ "llm-call-without-max-tokens",
138
147
  "long-parameter-list",
139
148
  "loop-copy-accumulator",
140
149
  "loop-index-past-length",
@@ -161,6 +170,8 @@
161
170
  "mysql-dynamic-query-text",
162
171
  "nan-comparison",
163
172
  "nest-validation-without-whitelist",
173
+ "next-image-any-remote-host",
174
+ "next-server-env-in-client",
164
175
  "node-event-listener-leak",
165
176
  "node-sync-compression-in-async",
166
177
  "node-sync-crypto-in-async",
@@ -189,6 +200,7 @@
189
200
  "pg-unreleased-checkout",
190
201
  "plaintext-password-storage",
191
202
  "pool-created-per-request-or-item",
203
+ "pool-without-connection-timeout",
192
204
  "postmessage-missing-origin-check",
193
205
  "prisma-count-for-existence",
194
206
  "prisma-count-materialization",
@@ -209,12 +221,17 @@
209
221
  "query-mutates-state",
210
222
  "query-runner-not-released",
211
223
  "queue-add-in-loop",
224
+ "react-async-effect-callback",
225
+ "react-component-defined-in-component",
212
226
  "react-context-value-recreated",
213
227
  "react-dangerously-set-inner-html",
228
+ "react-effect-sets-state-every-render",
214
229
  "react-fetch-in-effect-no-abort",
215
230
  "react-index-as-key",
216
231
  "react-inline-object-in-jsx-prop",
232
+ "react-list-missing-key",
217
233
  "react-missing-cleanup",
234
+ "react-state-mutated-in-place",
218
235
  "rebuild-lookup-in-loop",
219
236
  "redis-command-in-loop",
220
237
  "redis-incr-then-expire",
@@ -245,9 +262,13 @@
245
262
  "stray-console",
246
263
  "stream-pipe-unhandled-error",
247
264
  "swallowed-error",
265
+ "switch-not-exhaustive",
248
266
  "template-autoescape-disabled",
249
267
  "template-injection",
268
+ "throw-non-error",
250
269
  "tls-verification-disabled",
270
+ "ts-suppression-without-reason",
271
+ "tsconfig-strict-disabled",
251
272
  "typeorm-dynamic-query-text",
252
273
  "typeorm-existence-materialization",
253
274
  "typeorm-load-then-save",
@@ -258,6 +279,7 @@
258
279
  "unbounded-list-query",
259
280
  "unbounded-module-cache",
260
281
  "unbounded-promise-all",
282
+ "uncaught-exception-continues",
261
283
  "unguarded-boundary-access",
262
284
  "unreachable-code",
263
285
  "unreferenced-file",
@@ -365,6 +387,7 @@
365
387
  "a11y-viewport-zoom-disabled",
366
388
  "angular-bypass-security-trust",
367
389
  "angular-default-change-detection",
390
+ "angular-ngfor-missing-trackby",
368
391
  "angular-subscribe-without-cleanup",
369
392
  "api-enum-value-removed",
370
393
  "api-removed-field",
@@ -381,6 +404,8 @@
381
404
  "bcrypt-low-cost",
382
405
  "browser-not-closed",
383
406
  "check-then-update-race",
407
+ "child-process-without-error-listener",
408
+ "client-env-secret-exposed",
384
409
  "code-injection",
385
410
  "command-injection",
386
411
  "committed-secret",
@@ -410,6 +435,7 @@
410
435
  "dom-listener-without-cleanup",
411
436
  "dom-unthrottled-scroll-resize",
412
437
  "dom-xss-sink",
438
+ "double-type-assertion",
413
439
  "drizzle-last-insert-id",
414
440
  "drizzle-query-in-loop",
415
441
  "drizzle-scope-unverified",
@@ -417,6 +443,8 @@
417
443
  "drizzle-unfiltered-write",
418
444
  "drizzle-write-preflight",
419
445
  "duplicate-implementation",
446
+ "error-logged-without-stack",
447
+ "error-rethrown-without-cause",
420
448
  "error-stack-in-response",
421
449
  "express-cookie-auth-missing-csrf",
422
450
  "express-missing-compression",
@@ -427,6 +455,7 @@
427
455
  "filter-for-existence",
428
456
  "find-then-create-race",
429
457
  "floating-promise",
458
+ "focused-test-committed",
430
459
  "folder-boundary",
431
460
  "frontend-barrel-heavy-import",
432
461
  "frontend-storage-secret-token",
@@ -452,6 +481,7 @@
452
481
  "json-parse-unguarded",
453
482
  "json-roundtrip-clone",
454
483
  "json-stringify-in-loop",
484
+ "jsx-javascript-url",
455
485
  "jwt-decode-for-auth",
456
486
  "jwt-none-algorithm",
457
487
  "jwt-sign-without-expiry",
@@ -463,6 +493,7 @@
463
493
  "large-module",
464
494
  "list-count-per-request",
465
495
  "list-query-overfetch",
496
+ "llm-call-without-max-tokens",
466
497
  "long-parameter-list",
467
498
  "loop-copy-accumulator",
468
499
  "loop-index-past-length",
@@ -489,6 +520,8 @@
489
520
  "mysql-dynamic-query-text",
490
521
  "nan-comparison",
491
522
  "nest-validation-without-whitelist",
523
+ "next-image-any-remote-host",
524
+ "next-server-env-in-client",
492
525
  "node-event-listener-leak",
493
526
  "node-sync-compression-in-async",
494
527
  "node-sync-crypto-in-async",
@@ -517,6 +550,7 @@
517
550
  "pg-unreleased-checkout",
518
551
  "plaintext-password-storage",
519
552
  "pool-created-per-request-or-item",
553
+ "pool-without-connection-timeout",
520
554
  "postmessage-missing-origin-check",
521
555
  "prisma-count-for-existence",
522
556
  "prisma-count-materialization",
@@ -537,12 +571,17 @@
537
571
  "query-mutates-state",
538
572
  "query-runner-not-released",
539
573
  "queue-add-in-loop",
574
+ "react-async-effect-callback",
575
+ "react-component-defined-in-component",
540
576
  "react-context-value-recreated",
541
577
  "react-dangerously-set-inner-html",
578
+ "react-effect-sets-state-every-render",
542
579
  "react-fetch-in-effect-no-abort",
543
580
  "react-index-as-key",
544
581
  "react-inline-object-in-jsx-prop",
582
+ "react-list-missing-key",
545
583
  "react-missing-cleanup",
584
+ "react-state-mutated-in-place",
546
585
  "rebuild-lookup-in-loop",
547
586
  "redis-command-in-loop",
548
587
  "redis-incr-then-expire",
@@ -573,9 +612,13 @@
573
612
  "stray-console",
574
613
  "stream-pipe-unhandled-error",
575
614
  "swallowed-error",
615
+ "switch-not-exhaustive",
576
616
  "template-autoescape-disabled",
577
617
  "template-injection",
618
+ "throw-non-error",
578
619
  "tls-verification-disabled",
620
+ "ts-suppression-without-reason",
621
+ "tsconfig-strict-disabled",
579
622
  "typeorm-dynamic-query-text",
580
623
  "typeorm-existence-materialization",
581
624
  "typeorm-load-then-save",
@@ -586,6 +629,7 @@
586
629
  "unbounded-list-query",
587
630
  "unbounded-module-cache",
588
631
  "unbounded-promise-all",
632
+ "uncaught-exception-continues",
589
633
  "unguarded-boundary-access",
590
634
  "unreachable-code",
591
635
  "unreferenced-file",
package/editor/README.md DELETED
@@ -1,47 +0,0 @@
1
- # Loadwise
2
-
3
- Without this extension, `npx loadwise perf editor init` in the consuming project gives inline diagnostics and plain-text hovers through the editor's built-in task system (open the trusted folder and allow automatic tasks). It refreshes on saves, terminal source scans and checker package updates. Choose one integration per workspace to avoid duplicate diagnostics.
4
-
5
- This extension shows performance, reliability, maintainability and accessibility findings inline in VS Code or Cursor. Save a source file and hover over an underline to read the recommendation. Hover over the flagged code to compare the current snippet with a syntax-highlighted suggested rewrite; short comparisons also appear on the first diagnostic line. Rules without a site-specific rewrite show the flagged line and a labeled illustrative alternative.
6
-
7
- Open **View → Problems** to browse every checker. Each entry identifies its source and rule and links to the reported code. Use **Loadwise: Scan Workspace** from the Command Palette to refresh immediately. **Loadwise: Show Output** lists scan counts and errors. The status bar shows when a scan is running, the number of findings and the time of the last scan; click it to open the output.
8
-
9
- ## Fix or dismiss a finding
10
-
11
- Every finding is an optional suggestion. A line with a fix shows **Apply fix** and **Dismiss** buttons above it, the hover has the same two links, and the first line of a file with several fixes shows **Apply all**. Turn the buttons off with `loadwise.codeLens`.
12
-
13
- The keyboard shortcuts are the same on Windows, Linux and macOS (on macOS, Ctrl is Control and Alt is Option):
14
-
15
- | Keys | Action |
16
- | ---------------- | ---------------------------------------- |
17
- | Ctrl+Alt+. | Apply the fix on the cursor's line |
18
- | Ctrl+Alt+Shift+. | Apply all fixes in the file |
19
- | Ctrl+Alt+, | Dismiss the finding on the cursor's line |
20
-
21
- The editor's own Quick Fix menu (Ctrl+. on Windows and Linux, Cmd+. on macOS) offers the same actions:
22
-
23
- - **Apply fix: <rule>** applies the checker's rewrite when it has one. Hover first to compare the current code with the rewrite. Fixes that span several files, or create a migration file, apply all-or-nothing. A fix never overwrites an existing file or code that changed since the scan.
24
- - **Dismiss this finding** hides it until the flagged line changes. **Dismiss <rule> in this file** hides the rule for the whole file. Dismissals are kept per workspace and never written into your code. **Loadwise: Show dismissed findings** restores one or all of them.
25
- - **Loadwise: Apply all fixes in this file** groups eligible fixes into one undoable edit. The summary counts fixes that need individual review. Read the note for each of those and use **Apply fix** on its line. To apply eligible fixes on save, add `"editor.codeActionsOnSave": { "source.fixAll.loadwise": "explicit" }` to your settings.
26
-
27
- The Problems view honors rule levels from your project configuration. By default it shows declared contract violations as errors and other findings as warnings. Set `loadwise.severity` to `error`, `warning`, `information` or `hint` to show all of them at one level. Live-database findings, which name a table rather than a file, appear on the first line of `package.json`.
28
-
29
- ## Install
30
-
31
- Install the universal VSIX through **Extensions: Install from VSIX…**. The bundle includes the checkers and TypeScript. The native parser covers Windows x86, x64 and Arm64, Intel and Apple silicon Macs, and Linux x64 and Arm64 with glibc or musl. The editor itself must support your OS and architecture. Minimal musl images need the native parser's libgcc runtime. The editor needs Node.js 22 or newer on its PATH to launch the checkers. Source scanning runs locally.
32
-
33
- ## What gets scanned
34
-
35
- The extension scans on opening a supported workspace and refreshes whenever files change, whether saved in the editor or changed by git, another editor or a code generator. Source files, `schema.prisma`, SQL migrations, `package.json`, `tsconfig*.json`, `jsconfig*.json`, and `loadwise.config.json` are watched, and rapid changes are grouped. The performance checker runs in its incremental watch mode, so only changed files are re-analyzed; it restarts when a config file changes, and full rescans take over if it stops. The maintainability checker scans the folder. The performance checker uses its root `tsconfig.json` or `jsconfig.json` and also runs its polyglot source rules if it finds Python, Go, Java, C# or Rust. In a monorepo, open individual packages as workspace folders or set `loadwise.project` to the intended config. CLI traces and database plans are separate inputs.
36
-
37
- Each folder uses the checkers' default rules and its existing policy files. You can turn off diagnostics for a folder with `loadwise.enabled`. Developers using their own build can point the user setting `loadwise.cli` at the absolute path of its `bin/loadwise.js`.
38
-
39
- ## Build the extension
40
-
41
- Run the packager from the loadwise repository with Python 3.10+, Node.js 22+ and npm. It downloads the pinned `@vscode/vsce` and the locked runtime packages through npm.
42
-
43
- ```sh
44
- python editor/package-vsix.py
45
- ```
46
-
47
- It writes `editor/dist/loadwise-<version>.vsix`. Pass an output path to override it.
@@ -1,22 +0,0 @@
1
- {
2
- "resourceSpans": [
3
- {
4
- "scopeSpans": [
5
- {
6
- "spans": [
7
- {
8
- "traceId": "00000000000000000000000000000001",
9
- "spanId": "0000000000000001",
10
- "kind": 3,
11
- "name": "KEYS",
12
- "attributes": [
13
- { "key": "db.system.name", "value": { "stringValue": "redis" } },
14
- { "key": "db.operation.name", "value": { "stringValue": "KEYS" } }
15
- ]
16
- }
17
- ]
18
- }
19
- ]
20
- }
21
- ]
22
- }
@@ -1 +0,0 @@
1
- export * from '../shared/notify-editor.js';
@@ -1,191 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { exampleFor as reliabilityExample } from '../../editor/reliability-examples.cjs';
4
- import { exampleFor as maintainabilityExample } from '../../editor/maintainability-examples.cjs';
5
- import { exampleFor as securityExample } from '../../editor/security-examples.cjs';
6
- import { exampleFor as accessibilityExample } from '../../editor/accessibility-examples.cjs';
7
- import { hotPathLabel } from '../shared/hot-path.js';
8
- import { getFindingComparison, inlineComparison } from '../../editor/finding-comparison.cjs';
9
- const contractRules = new Set(['pg-transaction-on-pool', 'file-placement', 'folder-boundary', 'query-mutates-state']);
10
- const languageIds = {
11
- js: 'javascript',
12
- cjs: 'javascript',
13
- mjs: 'javascript',
14
- jsx: 'javascriptreact',
15
- ts: 'typescript',
16
- mts: 'typescript',
17
- cts: 'typescript',
18
- tsx: 'typescriptreact',
19
- html: 'html',
20
- htm: 'html',
21
- vue: 'vue',
22
- svelte: 'svelte',
23
- py: 'python',
24
- go: 'go',
25
- java: 'java',
26
- cs: 'csharp',
27
- rs: 'rust',
28
- php: 'php',
29
- rb: 'ruby',
30
- kt: 'kotlin',
31
- kts: 'kotlin',
32
- c: 'c',
33
- h: 'c',
34
- cpp: 'cpp',
35
- cc: 'cpp',
36
- cxx: 'cpp',
37
- hh: 'cpp',
38
- hpp: 'cpp',
39
- hxx: 'cpp',
40
- sql: 'sql',
41
- prisma: 'prisma',
42
- };
43
- const scriptLanguages = new Set(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);
44
- const lineBreak = '\u2028';
45
- const controlCharacters = /[\p{Cc}\p{Zl}\p{Zp}]/gu;
46
- const invalidFilename = /[\p{Cc}\p{Zl}\p{Zp}]| \| \d+ \| \d+ \| \d+ \| (?:error|warning) \| [a-z0-9-]+ \| /u;
47
- function sourceExample(ruleId, languageId, message) {
48
- // Reliability examples fall back to the performance ones, so one lookup covers the shared source pass.
49
- return (reliabilityExample(ruleId, languageId, message) ??
50
- securityExample(ruleId, languageId) ??
51
- accessibilityExample(ruleId, languageId));
52
- }
53
- function inside(root, file) {
54
- const relative = path.relative(root, file);
55
- return relative !== '' && relative !== '..' && !relative.startsWith('..' + path.sep) && !path.isAbsolute(relative);
56
- }
57
- function readLines(root, filename, cache) {
58
- if (cache.has(filename))
59
- return cache.get(filename);
60
- let lines;
61
- try {
62
- const realFile = fs.realpathSync.native(filename);
63
- if (inside(fs.realpathSync.native(root), realFile) && fs.statSync(realFile).isFile()) {
64
- lines = fs
65
- .readFileSync(realFile, 'utf8')
66
- .replace(/^\uFEFF/, '')
67
- .split(/\r\n?|\n/);
68
- }
69
- }
70
- catch (error) {
71
- // A file can move between the scan and the report.
72
- const code = error instanceof Error && 'code' in error ? error.code : undefined;
73
- if (typeof code !== 'string' || !['ENOENT', 'ENOTDIR', 'EACCES', 'EPERM'].includes(code))
74
- throw error;
75
- }
76
- cache.set(filename, lines);
77
- return lines;
78
- }
79
- function hasReportableIdentity(finding) {
80
- if (!finding || typeof finding.file !== 'string' || invalidFilename.test(finding.file))
81
- return false;
82
- return (typeof finding.ruleId === 'string' && /^[a-z0-9-]+$/.test(finding.ruleId) && typeof finding.message === 'string');
83
- }
84
- function findingPosition(finding) {
85
- const { line, column } = finding;
86
- if (typeof line !== 'number' || !Number.isSafeInteger(line) || line < 1)
87
- return;
88
- if (typeof column !== 'number' || !Number.isSafeInteger(column) || column < 1)
89
- return;
90
- return { line, column };
91
- }
92
- function codeLines(label, code) {
93
- return [label, ...code.split(/\r\n?|\n/).map((codeLine) => codeLine.replaceAll(controlCharacters, ' '))];
94
- }
95
- function messageParts(finding, message, example, comparison) {
96
- const parts = [message];
97
- const preview = inlineComparison(comparison);
98
- if (preview)
99
- parts.unshift(preview);
100
- if (finding.contextualReason)
101
- parts.push(String(finding.contextualReason).replaceAll(controlCharacters, ' '));
102
- const hotPath = hotPathLabel(finding);
103
- if (hotPath)
104
- parts.push('Hot path: ' + hotPath);
105
- if (comparison) {
106
- const paired = comparison.kind === 'source';
107
- parts.push(...codeLines(paired ? 'Current code:' : 'Flagged line:', comparison.before));
108
- if (comparison.kind === 'review') {
109
- if (preview !== 'Review: ' + comparison.inline)
110
- parts.push(comparison.inline);
111
- }
112
- else
113
- parts.push(...codeLines(paired ? 'Suggested rewrite:' : 'Illustrative alternative:', comparison.after));
114
- }
115
- else if (example)
116
- parts.push(...codeLines('Illustrative alternative:', example.code));
117
- const note = comparison ? comparison.note : example?.note;
118
- if (note)
119
- parts.push(note.replaceAll(controlCharacters, ' '));
120
- return parts;
121
- }
122
- function formatFinding(root, source, finding, fileCache = new Map()) {
123
- if (source !== 'loadwise perf' && source !== 'loadwise maint')
124
- return;
125
- if (!hasReportableIdentity(finding))
126
- return;
127
- const position = findingPosition(finding);
128
- if (!position)
129
- return;
130
- const { line, column } = position;
131
- const filename = path.resolve(root, finding.file);
132
- if (!inside(root, filename))
133
- return;
134
- const lines = readLines(root, filename, fileCache);
135
- if (!lines)
136
- return;
137
- const text = lines[line - 1];
138
- if (text === undefined)
139
- return;
140
- const extension = path.extname(filename).slice(1).toLowerCase();
141
- const languageId = Object.hasOwn(languageIds, extension) ? languageIds[extension] : 'plaintext';
142
- let offset = Math.min(column - 1, text.length);
143
- // TypeScript uses UTF-16 columns. ast-grep counts Unicode code points.
144
- offset = toUtf16Offset(languageId, text, offset);
145
- const message = finding.message.replaceAll(controlCharacters, ' ');
146
- const diagnostic = {
147
- source,
148
- code: finding.ruleId,
149
- message,
150
- suggestion: finding.suggestion,
151
- comparison: finding.comparison,
152
- range: { start: { line: line - 1, character: offset } },
153
- };
154
- const document = {
155
- languageId,
156
- isDirty: false,
157
- lineCount: lines.length,
158
- lineAt: (index) => ({ text: lines[index] }),
159
- };
160
- // The perf watcher also reports security findings, so its lookup falls back to the security
161
- // examples.
162
- const lookup = source === 'loadwise perf' ? sourceExample : maintainabilityExample;
163
- const example = lookup(finding.ruleId, languageId, message);
164
- const comparison = getFindingComparison(document, diagnostic, example);
165
- const parts = messageParts(finding, message, example, comparison);
166
- const tokenLength = /^[\p{L}\p{N}_$]+/u.exec(text.slice(offset))?.[0].length ?? 1;
167
- return [
168
- 'LOADWISE',
169
- path.relative(root, filename),
170
- line,
171
- offset + 1,
172
- Math.min(offset + tokenLength, text.length) + 1,
173
- contractRules.has(finding.ruleId) ? 'error' : 'warning',
174
- finding.ruleId,
175
- parts.join(lineBreak),
176
- ].join(' | ');
177
- }
178
- function toUtf16Offset(languageId, text, offset) {
179
- if (!scriptLanguages.has(languageId) && /[\uD800-\uDBFF]/.test(text.slice(0, offset))) {
180
- let remaining = offset;
181
- offset = 0;
182
- for (const character of text) {
183
- if (remaining === 0)
184
- break;
185
- offset += character.length;
186
- remaining--;
187
- }
188
- }
189
- return offset;
190
- }
191
- export { formatFinding };