@opensip-cli/checks-typescript 0.1.9 → 0.1.11

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 (244) hide show
  1. package/README.md +4 -2
  2. package/dist/__tests__/all-checks-execute.test.d.ts.map +1 -1
  3. package/dist/__tests__/all-checks-execute.test.js +0 -1
  4. package/dist/__tests__/all-checks-execute.test.js.map +1 -1
  5. package/dist/__tests__/behavior-fixtures-2.test.d.ts.map +1 -1
  6. package/dist/__tests__/behavior-fixtures-2.test.js +0 -1
  7. package/dist/__tests__/behavior-fixtures-2.test.js.map +1 -1
  8. package/dist/__tests__/behavior-fixtures-3.test.d.ts.map +1 -1
  9. package/dist/__tests__/behavior-fixtures-3.test.js +0 -1
  10. package/dist/__tests__/behavior-fixtures-3.test.js.map +1 -1
  11. package/dist/__tests__/behavior-fixtures-4.test.d.ts.map +1 -1
  12. package/dist/__tests__/behavior-fixtures-4.test.js +0 -1
  13. package/dist/__tests__/behavior-fixtures-4.test.js.map +1 -1
  14. package/dist/__tests__/behavior-fixtures-5.test.d.ts.map +1 -1
  15. package/dist/__tests__/behavior-fixtures-5.test.js +0 -1
  16. package/dist/__tests__/behavior-fixtures-5.test.js.map +1 -1
  17. package/dist/__tests__/behavior-fixtures-6.test.js +10 -0
  18. package/dist/__tests__/behavior-fixtures-6.test.js.map +1 -1
  19. package/dist/__tests__/behavior-fixtures.test.d.ts.map +1 -1
  20. package/dist/__tests__/behavior-fixtures.test.js +2 -4
  21. package/dist/__tests__/behavior-fixtures.test.js.map +1 -1
  22. package/dist/__tests__/branch-fixtures-2.test.d.ts.map +1 -1
  23. package/dist/__tests__/branch-fixtures-2.test.js +0 -1
  24. package/dist/__tests__/branch-fixtures-2.test.js.map +1 -1
  25. package/dist/__tests__/branch-fixtures-3.test.d.ts.map +1 -1
  26. package/dist/__tests__/branch-fixtures-3.test.js +0 -1
  27. package/dist/__tests__/branch-fixtures-3.test.js.map +1 -1
  28. package/dist/__tests__/branch-fixtures.test.d.ts.map +1 -1
  29. package/dist/__tests__/branch-fixtures.test.js +0 -1
  30. package/dist/__tests__/branch-fixtures.test.js.map +1 -1
  31. package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.d.ts +2 -0
  32. package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.d.ts.map +1 -0
  33. package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.js +13 -0
  34. package/dist/checks/architecture/__tests__/live-view-through-cli-live.test.js.map +1 -0
  35. package/dist/checks/architecture/contracts-schema-consistency.d.ts.map +1 -1
  36. package/dist/checks/architecture/contracts-schema-consistency.js +0 -3
  37. package/dist/checks/architecture/contracts-schema-consistency.js.map +1 -1
  38. package/dist/checks/architecture/drizzle-orm-migration-guardrails.d.ts.map +1 -1
  39. package/dist/checks/architecture/drizzle-orm-migration-guardrails.js +1 -0
  40. package/dist/checks/architecture/drizzle-orm-migration-guardrails.js.map +1 -1
  41. package/dist/checks/architecture/index.d.ts +1 -0
  42. package/dist/checks/architecture/index.d.ts.map +1 -1
  43. package/dist/checks/architecture/index.js +1 -0
  44. package/dist/checks/architecture/index.js.map +1 -1
  45. package/dist/checks/architecture/live-view-through-cli-live.d.ts +8 -0
  46. package/dist/checks/architecture/live-view-through-cli-live.d.ts.map +1 -0
  47. package/dist/checks/architecture/live-view-through-cli-live.js +43 -0
  48. package/dist/checks/architecture/live-view-through-cli-live.js.map +1 -0
  49. package/dist/checks/architecture/missing-type-exports.d.ts.map +1 -1
  50. package/dist/checks/architecture/missing-type-exports.js +1 -1
  51. package/dist/checks/architecture/missing-type-exports.js.map +1 -1
  52. package/dist/checks/architecture/module-coupling-fan-out.d.ts.map +1 -1
  53. package/dist/checks/architecture/module-coupling-fan-out.js +6 -2
  54. package/dist/checks/architecture/module-coupling-fan-out.js.map +1 -1
  55. package/dist/checks/architecture/no-bootstrap-tool-import.d.ts.map +1 -1
  56. package/dist/checks/architecture/no-bootstrap-tool-import.js +1 -0
  57. package/dist/checks/architecture/no-bootstrap-tool-import.js.map +1 -1
  58. package/dist/checks/architecture/no-run-done-result.d.ts.map +1 -1
  59. package/dist/checks/architecture/no-run-done-result.js +1 -0
  60. package/dist/checks/architecture/no-run-done-result.js.map +1 -1
  61. package/dist/checks/architecture/package-json-exports-field.d.ts.map +1 -1
  62. package/dist/checks/architecture/package-json-exports-field.js +1 -1
  63. package/dist/checks/architecture/package-json-exports-field.js.map +1 -1
  64. package/dist/checks/architecture/phantom-dependency-detection.d.ts.map +1 -1
  65. package/dist/checks/architecture/phantom-dependency-detection.js +0 -3
  66. package/dist/checks/architecture/phantom-dependency-detection.js.map +1 -1
  67. package/dist/checks/architecture/tsconfig-extends-validation.d.ts.map +1 -1
  68. package/dist/checks/architecture/tsconfig-extends-validation.js +0 -2
  69. package/dist/checks/architecture/tsconfig-extends-validation.js.map +1 -1
  70. package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.d.ts +5 -0
  71. package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.d.ts.map +1 -0
  72. package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.js +17 -0
  73. package/dist/checks/quality/code-structure/__tests__/duplicate-utility-lang-substrate.test.js.map +1 -0
  74. package/dist/checks/quality/code-structure/duplicate-utility-functions-config.d.ts +18 -0
  75. package/dist/checks/quality/code-structure/duplicate-utility-functions-config.d.ts.map +1 -0
  76. package/dist/checks/quality/code-structure/duplicate-utility-functions-config.js +36 -0
  77. package/dist/checks/quality/code-structure/duplicate-utility-functions-config.js.map +1 -0
  78. package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.d.ts +15 -0
  79. package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.d.ts.map +1 -0
  80. package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.js +288 -0
  81. package/dist/checks/quality/code-structure/duplicate-utility-functions-helpers.js.map +1 -0
  82. package/dist/checks/quality/code-structure/duplicate-utility-functions.d.ts +1 -26
  83. package/dist/checks/quality/code-structure/duplicate-utility-functions.d.ts.map +1 -1
  84. package/dist/checks/quality/code-structure/duplicate-utility-functions.js +3 -407
  85. package/dist/checks/quality/code-structure/duplicate-utility-functions.js.map +1 -1
  86. package/dist/checks/quality/data-integrity/__tests__/null-safety-fp.test.js +39 -2
  87. package/dist/checks/quality/data-integrity/__tests__/null-safety-fp.test.js.map +1 -1
  88. package/dist/checks/quality/data-integrity/array-validation-detectors.d.ts +17 -0
  89. package/dist/checks/quality/data-integrity/array-validation-detectors.d.ts.map +1 -0
  90. package/dist/checks/quality/data-integrity/array-validation-detectors.js +184 -0
  91. package/dist/checks/quality/data-integrity/array-validation-detectors.js.map +1 -0
  92. package/dist/checks/quality/data-integrity/array-validation.d.ts +0 -2
  93. package/dist/checks/quality/data-integrity/array-validation.d.ts.map +1 -1
  94. package/dist/checks/quality/data-integrity/array-validation.js +2 -360
  95. package/dist/checks/quality/data-integrity/array-validation.js.map +1 -1
  96. package/dist/checks/quality/data-integrity/database-schema-validation.d.ts.map +1 -1
  97. package/dist/checks/quality/data-integrity/database-schema-validation.js +0 -1
  98. package/dist/checks/quality/data-integrity/database-schema-validation.js.map +1 -1
  99. package/dist/checks/quality/data-integrity/null-safety-analyze.d.ts +33 -0
  100. package/dist/checks/quality/data-integrity/null-safety-analyze.d.ts.map +1 -0
  101. package/dist/checks/quality/data-integrity/null-safety-analyze.js +164 -0
  102. package/dist/checks/quality/data-integrity/null-safety-analyze.js.map +1 -0
  103. package/dist/checks/quality/data-integrity/null-safety-config.d.ts +50 -0
  104. package/dist/checks/quality/data-integrity/null-safety-config.d.ts.map +1 -0
  105. package/dist/checks/quality/data-integrity/null-safety-config.js +69 -0
  106. package/dist/checks/quality/data-integrity/null-safety-config.js.map +1 -0
  107. package/dist/checks/quality/data-integrity/null-safety-heuristics.d.ts +76 -0
  108. package/dist/checks/quality/data-integrity/null-safety-heuristics.d.ts.map +1 -0
  109. package/dist/checks/quality/data-integrity/null-safety-heuristics.js +276 -0
  110. package/dist/checks/quality/data-integrity/null-safety-heuristics.js.map +1 -0
  111. package/dist/checks/quality/data-integrity/null-safety-prefixes.d.ts +13 -0
  112. package/dist/checks/quality/data-integrity/null-safety-prefixes.d.ts.map +1 -0
  113. package/dist/checks/quality/data-integrity/null-safety-prefixes.js +333 -0
  114. package/dist/checks/quality/data-integrity/null-safety-prefixes.js.map +1 -0
  115. package/dist/checks/quality/data-integrity/null-safety.d.ts +2 -82
  116. package/dist/checks/quality/data-integrity/null-safety.d.ts.map +1 -1
  117. package/dist/checks/quality/data-integrity/null-safety.js +3 -796
  118. package/dist/checks/quality/data-integrity/null-safety.js.map +1 -1
  119. package/dist/checks/quality/frontend/test-only-frontend-modules.d.ts.map +1 -1
  120. package/dist/checks/quality/frontend/test-only-frontend-modules.js +0 -2
  121. package/dist/checks/quality/frontend/test-only-frontend-modules.js.map +1 -1
  122. package/dist/checks/quality/linting/typescript-frontend.d.ts.map +1 -1
  123. package/dist/checks/quality/linting/typescript-frontend.js +1 -0
  124. package/dist/checks/quality/linting/typescript-frontend.js.map +1 -1
  125. package/dist/checks/quality/observability/logger-event-name-format.d.ts.map +1 -1
  126. package/dist/checks/quality/observability/logger-event-name-format.js +0 -1
  127. package/dist/checks/quality/observability/logger-event-name-format.js.map +1 -1
  128. package/dist/checks/quality/observability/no-hardcoded-correlation-id.d.ts.map +1 -1
  129. package/dist/checks/quality/observability/no-hardcoded-correlation-id.js +2 -3
  130. package/dist/checks/quality/observability/no-hardcoded-correlation-id.js.map +1 -1
  131. package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.d.ts +8 -0
  132. package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.d.ts.map +1 -0
  133. package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.js +87 -0
  134. package/dist/checks/quality/patterns/__tests__/async-waterfall-sequential.test.js.map +1 -0
  135. package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.d.ts +2 -0
  136. package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.d.ts.map +1 -0
  137. package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.js +51 -0
  138. package/dist/checks/quality/patterns/__tests__/error-handling-probes.test.js.map +1 -0
  139. package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.d.ts +2 -0
  140. package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.d.ts.map +1 -0
  141. package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.js +89 -0
  142. package/dist/checks/quality/patterns/__tests__/result-pattern-registration-guards.test.js.map +1 -0
  143. package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.d.ts +5 -0
  144. package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.d.ts.map +1 -0
  145. package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.js +78 -0
  146. package/dist/checks/quality/patterns/__tests__/throws-documentation-analyze.test.js.map +1 -0
  147. package/dist/checks/quality/patterns/__tests__/toctou-fp.test.js +44 -0
  148. package/dist/checks/quality/patterns/__tests__/toctou-fp.test.js.map +1 -1
  149. package/dist/checks/quality/patterns/async-waterfall-analysis.d.ts +17 -0
  150. package/dist/checks/quality/patterns/async-waterfall-analysis.d.ts.map +1 -0
  151. package/dist/checks/quality/patterns/async-waterfall-analysis.js +215 -0
  152. package/dist/checks/quality/patterns/async-waterfall-analysis.js.map +1 -0
  153. package/dist/checks/quality/patterns/async-waterfall-branch-keys.d.ts +6 -0
  154. package/dist/checks/quality/patterns/async-waterfall-branch-keys.d.ts.map +1 -0
  155. package/dist/checks/quality/patterns/async-waterfall-branch-keys.js +54 -0
  156. package/dist/checks/quality/patterns/async-waterfall-branch-keys.js.map +1 -0
  157. package/dist/checks/quality/patterns/async-waterfall-detection.d.ts.map +1 -1
  158. package/dist/checks/quality/patterns/async-waterfall-detection.js +3 -352
  159. package/dist/checks/quality/patterns/async-waterfall-detection.js.map +1 -1
  160. package/dist/checks/quality/patterns/containing-function-name.d.ts +3 -0
  161. package/dist/checks/quality/patterns/containing-function-name.d.ts.map +1 -0
  162. package/dist/checks/quality/patterns/containing-function-name.js +21 -0
  163. package/dist/checks/quality/patterns/containing-function-name.js.map +1 -0
  164. package/dist/checks/quality/patterns/error-handling-quality.d.ts +3 -0
  165. package/dist/checks/quality/patterns/error-handling-quality.d.ts.map +1 -1
  166. package/dist/checks/quality/patterns/error-handling-quality.js +150 -30
  167. package/dist/checks/quality/patterns/error-handling-quality.js.map +1 -1
  168. package/dist/checks/quality/patterns/result-pattern-consistency.d.ts +3 -0
  169. package/dist/checks/quality/patterns/result-pattern-consistency.d.ts.map +1 -1
  170. package/dist/checks/quality/patterns/result-pattern-consistency.js +136 -69
  171. package/dist/checks/quality/patterns/result-pattern-consistency.js.map +1 -1
  172. package/dist/checks/quality/patterns/throws-documentation-analyze.d.ts +14 -0
  173. package/dist/checks/quality/patterns/throws-documentation-analyze.d.ts.map +1 -0
  174. package/dist/checks/quality/patterns/throws-documentation-analyze.js +352 -0
  175. package/dist/checks/quality/patterns/throws-documentation-analyze.js.map +1 -0
  176. package/dist/checks/quality/patterns/throws-documentation-constants.d.ts +15 -0
  177. package/dist/checks/quality/patterns/throws-documentation-constants.d.ts.map +1 -0
  178. package/dist/checks/quality/patterns/throws-documentation-constants.js +94 -0
  179. package/dist/checks/quality/patterns/throws-documentation-constants.js.map +1 -0
  180. package/dist/checks/quality/patterns/throws-documentation.d.ts +1 -11
  181. package/dist/checks/quality/patterns/throws-documentation.d.ts.map +1 -1
  182. package/dist/checks/quality/patterns/throws-documentation.js +4 -472
  183. package/dist/checks/quality/patterns/throws-documentation.js.map +1 -1
  184. package/dist/checks/quality/patterns/toctou-race-condition-classify.d.ts +23 -0
  185. package/dist/checks/quality/patterns/toctou-race-condition-classify.d.ts.map +1 -0
  186. package/dist/checks/quality/patterns/toctou-race-condition-classify.js +125 -0
  187. package/dist/checks/quality/patterns/toctou-race-condition-classify.js.map +1 -0
  188. package/dist/checks/quality/patterns/toctou-race-condition-collection.d.ts +24 -0
  189. package/dist/checks/quality/patterns/toctou-race-condition-collection.d.ts.map +1 -0
  190. package/dist/checks/quality/patterns/toctou-race-condition-collection.js +248 -0
  191. package/dist/checks/quality/patterns/toctou-race-condition-collection.js.map +1 -0
  192. package/dist/checks/quality/patterns/toctou-race-condition-constants.d.ts +32 -0
  193. package/dist/checks/quality/patterns/toctou-race-condition-constants.d.ts.map +1 -0
  194. package/dist/checks/quality/patterns/toctou-race-condition-constants.js +115 -0
  195. package/dist/checks/quality/patterns/toctou-race-condition-constants.js.map +1 -0
  196. package/dist/checks/quality/patterns/toctou-race-condition.d.ts +1 -29
  197. package/dist/checks/quality/patterns/toctou-race-condition.d.ts.map +1 -1
  198. package/dist/checks/quality/patterns/toctou-race-condition.js +11 -536
  199. package/dist/checks/quality/patterns/toctou-race-condition.js.map +1 -1
  200. package/dist/checks/quality/unused-config-options.d.ts.map +1 -1
  201. package/dist/checks/quality/unused-config-options.js +0 -4
  202. package/dist/checks/quality/unused-config-options.js.map +1 -1
  203. package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.d.ts +2 -0
  204. package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.d.ts.map +1 -0
  205. package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.js +98 -0
  206. package/dist/checks/resilience/__tests__/detached-promises-sync-detection.test.js.map +1 -0
  207. package/dist/checks/resilience/callback-invocation-safe.d.ts.map +1 -1
  208. package/dist/checks/resilience/callback-invocation-safe.js +0 -1
  209. package/dist/checks/resilience/callback-invocation-safe.js.map +1 -1
  210. package/dist/checks/resilience/context-leakage.d.ts.map +1 -1
  211. package/dist/checks/resilience/context-leakage.js +1 -0
  212. package/dist/checks/resilience/context-leakage.js.map +1 -1
  213. package/dist/checks/resilience/detached-promises-detection.d.ts +7 -0
  214. package/dist/checks/resilience/detached-promises-detection.d.ts.map +1 -0
  215. package/dist/checks/resilience/detached-promises-detection.js +228 -0
  216. package/dist/checks/resilience/detached-promises-detection.js.map +1 -0
  217. package/dist/checks/resilience/detached-promises-sync-constants.d.ts +36 -0
  218. package/dist/checks/resilience/detached-promises-sync-constants.d.ts.map +1 -0
  219. package/dist/checks/resilience/detached-promises-sync-constants.js +299 -0
  220. package/dist/checks/resilience/detached-promises-sync-constants.js.map +1 -0
  221. package/dist/checks/resilience/detached-promises-sync-detection.d.ts +14 -0
  222. package/dist/checks/resilience/detached-promises-sync-detection.d.ts.map +1 -0
  223. package/dist/checks/resilience/detached-promises-sync-detection.js +69 -0
  224. package/dist/checks/resilience/detached-promises-sync-detection.js.map +1 -0
  225. package/dist/checks/resilience/detached-promises.d.ts +1 -14
  226. package/dist/checks/resilience/detached-promises.d.ts.map +1 -1
  227. package/dist/checks/resilience/detached-promises.js +2 -598
  228. package/dist/checks/resilience/detached-promises.js.map +1 -1
  229. package/dist/checks/resilience/no-raw-fetch.d.ts.map +1 -1
  230. package/dist/checks/resilience/no-raw-fetch.js +1 -0
  231. package/dist/checks/resilience/no-raw-fetch.js.map +1 -1
  232. package/dist/checks/resilience/no-unbounded-concurrency.d.ts.map +1 -1
  233. package/dist/checks/resilience/no-unbounded-concurrency.js +1 -0
  234. package/dist/checks/resilience/no-unbounded-concurrency.js.map +1 -1
  235. package/dist/checks/security/sql-injection.d.ts.map +1 -1
  236. package/dist/checks/security/sql-injection.js +0 -1
  237. package/dist/checks/security/sql-injection.js.map +1 -1
  238. package/dist/display/architecture.d.ts.map +1 -1
  239. package/dist/display/architecture.js +1 -0
  240. package/dist/display/architecture.js.map +1 -1
  241. package/dist/display/types.d.ts.map +1 -1
  242. package/dist/display/types.js +0 -1
  243. package/dist/display/types.js.map +1 -1
  244. package/package.json +5 -5
@@ -0,0 +1,17 @@
1
+ import * as ts from 'typescript';
2
+ import type { CheckViolation } from '@opensip-cli/fitness';
3
+ export declare const MAX_LINE_GAP = 1;
4
+ export interface AwaitInfo {
5
+ line: number;
6
+ column: number;
7
+ assignedVariable: string | null;
8
+ destructuredBindings: readonly string[];
9
+ expressionText: string;
10
+ isDynamicImport: boolean;
11
+ branchKey: string | null;
12
+ node: ts.AwaitExpression;
13
+ }
14
+ export declare function collectAwaitExpressions(node: ts.Node, sourceFile: ts.SourceFile): AwaitInfo[];
15
+ export declare function detectWaterfalls(awaitInfos: AwaitInfo[]): CheckViolation[];
16
+ export declare function analyzeFile(absolutePath: string, content: string): CheckViolation[];
17
+ //# sourceMappingURL=async-waterfall-analysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-waterfall-analysis.d.ts","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/async-waterfall-analysis.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC;CAC1B;AAgHD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,SAAS,EAAE,CAgC7F;AA6ED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CA2B1E;AAED,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAiBnF"}
@@ -0,0 +1,215 @@
1
+ // @fitness-ignore-file null-safety -- null checks are intentional guards
2
+ import { getSharedSourceFile, isAsync } from '@opensip-cli/lang-typescript';
3
+ import * as ts from 'typescript';
4
+ import { getBranchKey } from './async-waterfall-branch-keys.js';
5
+ export const MAX_LINE_GAP = 1;
6
+ const SLEEP_DELAY_NAMES = new Set([
7
+ 'sleep',
8
+ 'delay',
9
+ 'wait',
10
+ 'setTimeout',
11
+ 'pause',
12
+ 'backoff',
13
+ 'yieldToEventLoop',
14
+ 'yield',
15
+ 'nextTick',
16
+ ]);
17
+ const LOCK_ACQUIRE_NAMES = new Set(['acquire', 'lock', 'runExclusive', 'withLock']);
18
+ /** Last identifier before `(` on an awaited call expression text. */
19
+ function getCalleeName(expressionText) {
20
+ const afterAwait = expressionText.replace(/^await\s+/, '').trim();
21
+ const dotted = /\.(\w+)\s*\([^)]*\)\s*$/.exec(afterAwait);
22
+ if (dotted?.[1] !== undefined) {
23
+ return dotted[1];
24
+ }
25
+ const direct = /^(\w+)\s*\(/.exec(afterAwait);
26
+ return direct?.[1] ?? null;
27
+ }
28
+ const SETUP_THEN_RUN_FIRST = /^(?:ensure|load|maybeShow|save|check)/i;
29
+ const SETUP_THEN_RUN_SECOND = /^(?:build|emit|render|deliver|maybeShow)/i;
30
+ const SEQUENTIAL_SCAN_FIRST = /^collect/i;
31
+ const SEQUENTIAL_SCAN_SECOND = /^count/i;
32
+ function isAsyncFunction(node) {
33
+ if (ts.isFunctionDeclaration(node) ||
34
+ ts.isMethodDeclaration(node) ||
35
+ ts.isArrowFunction(node) ||
36
+ ts.isFunctionExpression(node)) {
37
+ return isAsync(node);
38
+ }
39
+ return false;
40
+ }
41
+ function extractDestructuredBindings(pattern, sourceFile) {
42
+ const names = [];
43
+ for (const element of pattern.elements) {
44
+ if (ts.isBindingElement(element)) {
45
+ if (ts.isIdentifier(element.name)) {
46
+ names.push(element.name.getText(sourceFile));
47
+ }
48
+ else if (ts.isObjectBindingPattern(element.name) ||
49
+ ts.isArrayBindingPattern(element.name)) {
50
+ names.push(...extractDestructuredBindings(element.name, sourceFile));
51
+ }
52
+ }
53
+ }
54
+ return names;
55
+ }
56
+ function getAssignedVariable(awaitNode, sourceFile) {
57
+ const parent = awaitNode.parent;
58
+ if (ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name)) {
59
+ return parent.name.getText(sourceFile);
60
+ }
61
+ if (ts.isVariableDeclaration(parent) &&
62
+ (ts.isObjectBindingPattern(parent.name) || ts.isArrayBindingPattern(parent.name))) {
63
+ return parent.name.getText(sourceFile);
64
+ }
65
+ if (ts.isBinaryExpression(parent) &&
66
+ parent.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
67
+ ts.isIdentifier(parent.left)) {
68
+ return parent.left.getText(sourceFile);
69
+ }
70
+ return null;
71
+ }
72
+ function getDestructuredBindings(awaitNode, sourceFile) {
73
+ const parent = awaitNode.parent;
74
+ if (ts.isVariableDeclaration(parent) &&
75
+ (ts.isObjectBindingPattern(parent.name) || ts.isArrayBindingPattern(parent.name))) {
76
+ return extractDestructuredBindings(parent.name, sourceFile);
77
+ }
78
+ return [];
79
+ }
80
+ function isDynamicImportExpression(awaitNode) {
81
+ const expr = awaitNode.expression;
82
+ return ts.isCallExpression(expr) && expr.expression.kind === ts.SyntaxKind.ImportKeyword;
83
+ }
84
+ export function collectAwaitExpressions(node, sourceFile) {
85
+ const awaitInfos = [];
86
+ const visit = (n) => {
87
+ if (n !== node && isAsyncFunction(n)) {
88
+ return;
89
+ }
90
+ if (ts.isAwaitExpression(n)) {
91
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(n.getStart());
92
+ const assignedVariable = getAssignedVariable(n, sourceFile);
93
+ const destructuredBindings = getDestructuredBindings(n, sourceFile);
94
+ const isDynamicImport = isDynamicImportExpression(n);
95
+ const branchKey = getBranchKey(n, sourceFile, node);
96
+ awaitInfos.push({
97
+ line: line + 1,
98
+ column: character + 1,
99
+ assignedVariable,
100
+ destructuredBindings,
101
+ expressionText: n.getText(sourceFile),
102
+ isDynamicImport,
103
+ branchKey,
104
+ node: n,
105
+ });
106
+ }
107
+ ts.forEachChild(n, visit);
108
+ };
109
+ ts.forEachChild(node, visit);
110
+ return awaitInfos;
111
+ }
112
+ function isSleepOrDelay(expressionText) {
113
+ const callee = getCalleeName(expressionText);
114
+ return callee !== null && SLEEP_DELAY_NAMES.has(callee);
115
+ }
116
+ function isLockAcquire(expressionText) {
117
+ const callee = getCalleeName(expressionText);
118
+ return callee !== null && LOCK_ACQUIRE_NAMES.has(callee);
119
+ }
120
+ function isSequentialOrchestration(current, next) {
121
+ const first = getCalleeName(current.expressionText);
122
+ const second = getCalleeName(next.expressionText);
123
+ if (first === null || second === null) {
124
+ return false;
125
+ }
126
+ if (SETUP_THEN_RUN_FIRST.test(first) && SETUP_THEN_RUN_SECOND.test(second)) {
127
+ return true;
128
+ }
129
+ // Post-emit auth/cache cleanup must run after the sink attempt, not in parallel.
130
+ if (first === 'emit' && second.startsWith('invalidate')) {
131
+ return true;
132
+ }
133
+ return SEQUENTIAL_SCAN_FIRST.test(first) && SEQUENTIAL_SCAN_SECOND.test(second);
134
+ }
135
+ function nextUsesDestructuredBindings(current, next) {
136
+ if (current.destructuredBindings.length === 0) {
137
+ return false;
138
+ }
139
+ return current.destructuredBindings.some((binding) => next.expressionText.includes(binding));
140
+ }
141
+ function isAwaitingFunctionCall(expressionText) {
142
+ const afterAwait = expressionText.replace(/^await\s+/, '');
143
+ // eslint-disable-next-line sonarjs/slow-regex -- trailing call parens on a single await expression; bounded slice
144
+ return /\([^)]*\)\s*$/.test(afterAwait);
145
+ }
146
+ function shouldSkipAwaitPair(current, next) {
147
+ if (next.line - current.line > MAX_LINE_GAP + 1)
148
+ return true;
149
+ if (current.branchKey !== null &&
150
+ next.branchKey !== null &&
151
+ // @fitness-ignore-next-line unsafe-secret-comparison -- Comparing AST branch identifiers, not cryptographic keys
152
+ current.branchKey !== next.branchKey) {
153
+ return true;
154
+ }
155
+ if (isSleepOrDelay(current.expressionText) || isSleepOrDelay(next.expressionText))
156
+ return true;
157
+ if (isLockAcquire(current.expressionText))
158
+ return true;
159
+ if (isSequentialOrchestration(current, next))
160
+ return true;
161
+ if (current.assignedVariable !== null && next.expressionText.includes(current.assignedVariable)) {
162
+ return true;
163
+ }
164
+ if (nextUsesDestructuredBindings(current, next))
165
+ return true;
166
+ if (current.isDynamicImport)
167
+ return true;
168
+ if (!isAwaitingFunctionCall(current.expressionText) ||
169
+ !isAwaitingFunctionCall(next.expressionText)) {
170
+ return true;
171
+ }
172
+ return false;
173
+ }
174
+ export function detectWaterfalls(awaitInfos) {
175
+ const violations = [];
176
+ const sorted = [...awaitInfos].sort((a, b) => a.line - b.line);
177
+ for (let i = 0; i < sorted.length - 1; i++) {
178
+ const current = sorted[i];
179
+ const next = sorted[i + 1];
180
+ if (current === undefined || next === undefined)
181
+ continue;
182
+ if (shouldSkipAwaitPair(current, next))
183
+ continue;
184
+ violations.push({
185
+ line: current.line,
186
+ column: current.column,
187
+ message: 'Sequential await statements may be parallelizable with Promise.all()',
188
+ severity: 'warning',
189
+ suggestion: 'Consider using Promise.all() to parallelize independent async operations. ' +
190
+ 'Example: const [result1, result2] = await Promise.all([asyncOp1(), asyncOp2()]);',
191
+ type: 'async-waterfall',
192
+ match: `${current.expressionText} followed by ${next.expressionText}`,
193
+ });
194
+ i++;
195
+ }
196
+ return violations;
197
+ }
198
+ export function analyzeFile(absolutePath, content) {
199
+ const violations = [];
200
+ const sourceFile = getSharedSourceFile(absolutePath, content);
201
+ if (!sourceFile)
202
+ return [];
203
+ const visit = (node) => {
204
+ if (isAsyncFunction(node)) {
205
+ const asyncNode = node;
206
+ const awaitInfos = collectAwaitExpressions(asyncNode, sourceFile);
207
+ const newViolations = detectWaterfalls(awaitInfos);
208
+ violations.push(...newViolations);
209
+ }
210
+ ts.forEachChild(node, visit);
211
+ };
212
+ visit(sourceFile);
213
+ return violations;
214
+ }
215
+ //# sourceMappingURL=async-waterfall-analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-waterfall-analysis.js","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/async-waterfall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,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,SAAS,GAAG,IAAwE,CAAC;YAC3F,MAAM,UAAU,GAAG,uBAAuB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAClE,MAAM,aAAa,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACnD,UAAU,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QACpC,CAAC;QACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,KAAK,CAAC,UAAU,CAAC,CAAC;IAClB,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as ts from 'typescript';
2
+ export declare function getIfElseBranchKey(current: ts.Node, sourceFile: ts.SourceFile): string | null;
3
+ export declare function getTernaryBranchKey(current: ts.Node, sourceFile: ts.SourceFile): string | null;
4
+ export declare function getSwitchBranchKey(current: ts.Node, sourceFile: ts.SourceFile): string | null;
5
+ export declare function getBranchKey(node: ts.Node, sourceFile: ts.SourceFile, functionNode: ts.Node): string | null;
6
+ //# sourceMappingURL=async-waterfall-branch-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-waterfall-branch-keys.d.ts","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/async-waterfall-branch-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAQ7F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAQ9F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAa7F;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,YAAY,EAAE,EAAE,CAAC,IAAI,GACpB,MAAM,GAAG,IAAI,CAiBf"}
@@ -0,0 +1,54 @@
1
+ import * as ts from 'typescript';
2
+ export function getIfElseBranchKey(current, sourceFile) {
3
+ const parentNode = current.parent;
4
+ if (!ts.isIfStatement(parentNode))
5
+ return null;
6
+ const ifLine = sourceFile.getLineAndCharacterOfPosition(parentNode.getStart()).line;
7
+ if (current === parentNode.thenStatement)
8
+ return `if@L${ifLine}`;
9
+ if (current === parentNode.elseStatement)
10
+ return `else@L${ifLine}`;
11
+ return null;
12
+ }
13
+ export function getTernaryBranchKey(current, sourceFile) {
14
+ const parentNode = current.parent;
15
+ if (!ts.isConditionalExpression(parentNode))
16
+ return null;
17
+ const condLine = sourceFile.getLineAndCharacterOfPosition(parentNode.getStart()).line;
18
+ if (current === parentNode.whenTrue)
19
+ return `ternary-true@L${condLine}`;
20
+ if (current === parentNode.whenFalse)
21
+ return `ternary-false@L${condLine}`;
22
+ return null;
23
+ }
24
+ export function getSwitchBranchKey(current, sourceFile) {
25
+ if (!ts.isCaseClause(current) && !ts.isDefaultClause(current))
26
+ return null;
27
+ // @fitness-ignore-next-line null-safety -- CaseClause/DefaultClause parent is CaseBlock, grandparent is SwitchStatement per TS AST spec
28
+ const switchStmt = current.parent.parent;
29
+ if (!ts.isSwitchStatement(switchStmt))
30
+ return null;
31
+ const switchLine = sourceFile.getLineAndCharacterOfPosition(switchStmt.getStart()).line;
32
+ if (ts.isCaseClause(current)) {
33
+ const caseText = current.expression.getText(sourceFile);
34
+ return `case-${caseText}@L${switchLine}`;
35
+ }
36
+ return `default@L${switchLine}`;
37
+ }
38
+ export function getBranchKey(node, sourceFile, functionNode) {
39
+ let current = node;
40
+ while (current !== functionNode) {
41
+ const ifElseKey = getIfElseBranchKey(current, sourceFile);
42
+ if (ifElseKey)
43
+ return ifElseKey;
44
+ const ternaryKey = getTernaryBranchKey(current, sourceFile);
45
+ if (ternaryKey)
46
+ return ternaryKey;
47
+ const switchKey = getSwitchBranchKey(current, sourceFile);
48
+ if (switchKey)
49
+ return switchKey;
50
+ current = current.parent;
51
+ }
52
+ return null;
53
+ }
54
+ //# sourceMappingURL=async-waterfall-branch-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-waterfall-branch-keys.js","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/async-waterfall-branch-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAE,UAAyB;IAC5E,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAClC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IAE/C,MAAM,MAAM,GAAG,UAAU,CAAC,6BAA6B,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC;IACpF,IAAI,OAAO,KAAK,UAAU,CAAC,aAAa;QAAE,OAAO,OAAO,MAAM,EAAE,CAAC;IACjE,IAAI,OAAO,KAAK,UAAU,CAAC,aAAa;QAAE,OAAO,SAAS,MAAM,EAAE,CAAC;IACnE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAgB,EAAE,UAAyB;IAC7E,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAClC,IAAI,CAAC,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IAEzD,MAAM,QAAQ,GAAG,UAAU,CAAC,6BAA6B,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC;IACtF,IAAI,OAAO,KAAK,UAAU,CAA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,SAAS,GAAG,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC1D,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC;QAEhC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"async-waterfall-detection.d.ts","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/async-waterfall-detection.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAybH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,sCAsClC,CAAC"}
1
+ {"version":3,"file":"async-waterfall-detection.d.ts","sourceRoot":"","sources":["../../../../src/checks/quality/patterns/async-waterfall-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,sCAoClC,CAAC"}