@memberjunction/react-test-harness 5.37.0 → 5.38.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 (342) hide show
  1. package/README.md +30 -0
  2. package/dist/cli/index.js +5 -1
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/index.d.ts +1 -5
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +10 -5
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/browser-context.d.ts +43 -0
  9. package/dist/lib/browser-context.d.ts.map +1 -1
  10. package/dist/lib/browser-context.js +87 -12
  11. package/dist/lib/browser-context.js.map +1 -1
  12. package/dist/lib/component-runner.d.ts +11 -22
  13. package/dist/lib/component-runner.d.ts.map +1 -1
  14. package/dist/lib/component-runner.js +1 -1
  15. package/dist/lib/component-runner.js.map +1 -1
  16. package/dist/lib/linter-test-tool.js +1 -1
  17. package/dist/lib/linter-test-tool.js.map +1 -1
  18. package/dist/lib/test-harness.d.ts +10 -0
  19. package/dist/lib/test-harness.d.ts.map +1 -1
  20. package/dist/lib/test-harness.js +10 -0
  21. package/dist/lib/test-harness.js.map +1 -1
  22. package/package.json +14 -13
  23. package/dist/lib/component-linter.d.ts +0 -77
  24. package/dist/lib/component-linter.d.ts.map +0 -1
  25. package/dist/lib/component-linter.js +0 -1205
  26. package/dist/lib/component-linter.js.map +0 -1
  27. package/dist/lib/control-flow-analyzer.d.ts +0 -184
  28. package/dist/lib/control-flow-analyzer.d.ts.map +0 -1
  29. package/dist/lib/control-flow-analyzer.js +0 -798
  30. package/dist/lib/control-flow-analyzer.js.map +0 -1
  31. package/dist/lib/library-lint-cache.d.ts +0 -50
  32. package/dist/lib/library-lint-cache.d.ts.map +0 -1
  33. package/dist/lib/library-lint-cache.js +0 -173
  34. package/dist/lib/library-lint-cache.js.map +0 -1
  35. package/dist/lib/lint-rule.d.ts +0 -70
  36. package/dist/lib/lint-rule.d.ts.map +0 -1
  37. package/dist/lib/lint-rule.js +0 -41
  38. package/dist/lib/lint-rule.js.map +0 -1
  39. package/dist/lib/lint-utils.d.ts +0 -131
  40. package/dist/lib/lint-utils.d.ts.map +0 -1
  41. package/dist/lib/lint-utils.js +0 -358
  42. package/dist/lib/lint-utils.js.map +0 -1
  43. package/dist/lib/prop-value-extractor.d.ts +0 -147
  44. package/dist/lib/prop-value-extractor.d.ts.map +0 -1
  45. package/dist/lib/prop-value-extractor.js +0 -472
  46. package/dist/lib/prop-value-extractor.js.map +0 -1
  47. package/dist/lib/runtime-rules/ai-tools-availability-check.d.ts +0 -9
  48. package/dist/lib/runtime-rules/ai-tools-availability-check.d.ts.map +0 -1
  49. package/dist/lib/runtime-rules/ai-tools-availability-check.js +0 -223
  50. package/dist/lib/runtime-rules/ai-tools-availability-check.js.map +0 -1
  51. package/dist/lib/runtime-rules/callback-event-validation.d.ts +0 -22
  52. package/dist/lib/runtime-rules/callback-event-validation.d.ts.map +0 -1
  53. package/dist/lib/runtime-rules/callback-event-validation.js +0 -561
  54. package/dist/lib/runtime-rules/callback-event-validation.js.map +0 -1
  55. package/dist/lib/runtime-rules/chart-field-validation.d.ts +0 -10
  56. package/dist/lib/runtime-rules/chart-field-validation.d.ts.map +0 -1
  57. package/dist/lib/runtime-rules/chart-field-validation.js +0 -270
  58. package/dist/lib/runtime-rules/chart-field-validation.js.map +0 -1
  59. package/dist/lib/runtime-rules/child-component-prop-validation.d.ts +0 -10
  60. package/dist/lib/runtime-rules/child-component-prop-validation.d.ts.map +0 -1
  61. package/dist/lib/runtime-rules/child-component-prop-validation.js +0 -443
  62. package/dist/lib/runtime-rules/child-component-prop-validation.js.map +0 -1
  63. package/dist/lib/runtime-rules/component-name-mismatch.d.ts +0 -19
  64. package/dist/lib/runtime-rules/component-name-mismatch.d.ts.map +0 -1
  65. package/dist/lib/runtime-rules/component-name-mismatch.js +0 -82
  66. package/dist/lib/runtime-rules/component-name-mismatch.js.map +0 -1
  67. package/dist/lib/runtime-rules/component-not-in-dependencies.d.ts +0 -20
  68. package/dist/lib/runtime-rules/component-not-in-dependencies.d.ts.map +0 -1
  69. package/dist/lib/runtime-rules/component-not-in-dependencies.js +0 -92
  70. package/dist/lib/runtime-rules/component-not-in-dependencies.js.map +0 -1
  71. package/dist/lib/runtime-rules/component-props-validation.d.ts +0 -25
  72. package/dist/lib/runtime-rules/component-props-validation.d.ts.map +0 -1
  73. package/dist/lib/runtime-rules/component-props-validation.js +0 -228
  74. package/dist/lib/runtime-rules/component-props-validation.js.map +0 -1
  75. package/dist/lib/runtime-rules/component-usage-without-destructuring.d.ts +0 -20
  76. package/dist/lib/runtime-rules/component-usage-without-destructuring.d.ts.map +0 -1
  77. package/dist/lib/runtime-rules/component-usage-without-destructuring.js +0 -124
  78. package/dist/lib/runtime-rules/component-usage-without-destructuring.js.map +0 -1
  79. package/dist/lib/runtime-rules/data-result-validation.d.ts +0 -9
  80. package/dist/lib/runtime-rules/data-result-validation.d.ts.map +0 -1
  81. package/dist/lib/runtime-rules/data-result-validation.js +0 -763
  82. package/dist/lib/runtime-rules/data-result-validation.js.map +0 -1
  83. package/dist/lib/runtime-rules/datagrid-field-validation.d.ts +0 -10
  84. package/dist/lib/runtime-rules/datagrid-field-validation.d.ts.map +0 -1
  85. package/dist/lib/runtime-rules/datagrid-field-validation.js +0 -249
  86. package/dist/lib/runtime-rules/datagrid-field-validation.js.map +0 -1
  87. package/dist/lib/runtime-rules/dependency-shadowing.d.ts +0 -20
  88. package/dist/lib/runtime-rules/dependency-shadowing.d.ts.map +0 -1
  89. package/dist/lib/runtime-rules/dependency-shadowing.js +0 -147
  90. package/dist/lib/runtime-rules/dependency-shadowing.js.map +0 -1
  91. package/dist/lib/runtime-rules/entity-field-access-validation.d.ts +0 -12
  92. package/dist/lib/runtime-rules/entity-field-access-validation.d.ts.map +0 -1
  93. package/dist/lib/runtime-rules/entity-field-access-validation.js +0 -304
  94. package/dist/lib/runtime-rules/entity-field-access-validation.js.map +0 -1
  95. package/dist/lib/runtime-rules/event-parameter-validation.d.ts +0 -22
  96. package/dist/lib/runtime-rules/event-parameter-validation.d.ts.map +0 -1
  97. package/dist/lib/runtime-rules/event-parameter-validation.js +0 -406
  98. package/dist/lib/runtime-rules/event-parameter-validation.js.map +0 -1
  99. package/dist/lib/runtime-rules/index.d.ts +0 -61
  100. package/dist/lib/runtime-rules/index.d.ts.map +0 -1
  101. package/dist/lib/runtime-rules/index.js +0 -62
  102. package/dist/lib/runtime-rules/index.js.map +0 -1
  103. package/dist/lib/runtime-rules/library-variable-names.d.ts +0 -24
  104. package/dist/lib/runtime-rules/library-variable-names.d.ts.map +0 -1
  105. package/dist/lib/runtime-rules/library-variable-names.js +0 -88
  106. package/dist/lib/runtime-rules/library-variable-names.js.map +0 -1
  107. package/dist/lib/runtime-rules/no-child-implementation.d.ts +0 -18
  108. package/dist/lib/runtime-rules/no-child-implementation.d.ts.map +0 -1
  109. package/dist/lib/runtime-rules/no-child-implementation.js +0 -57
  110. package/dist/lib/runtime-rules/no-child-implementation.js.map +0 -1
  111. package/dist/lib/runtime-rules/no-data-prop.d.ts +0 -22
  112. package/dist/lib/runtime-rules/no-data-prop.d.ts.map +0 -1
  113. package/dist/lib/runtime-rules/no-data-prop.js +0 -111
  114. package/dist/lib/runtime-rules/no-data-prop.js.map +0 -1
  115. package/dist/lib/runtime-rules/no-export-statements.d.ts +0 -18
  116. package/dist/lib/runtime-rules/no-export-statements.d.ts.map +0 -1
  117. package/dist/lib/runtime-rules/no-export-statements.js +0 -143
  118. package/dist/lib/runtime-rules/no-export-statements.js.map +0 -1
  119. package/dist/lib/runtime-rules/no-iife-wrapper.d.ts +0 -18
  120. package/dist/lib/runtime-rules/no-iife-wrapper.d.ts.map +0 -1
  121. package/dist/lib/runtime-rules/no-iife-wrapper.js +0 -217
  122. package/dist/lib/runtime-rules/no-iife-wrapper.js.map +0 -1
  123. package/dist/lib/runtime-rules/no-import-statements.d.ts +0 -18
  124. package/dist/lib/runtime-rules/no-import-statements.d.ts.map +0 -1
  125. package/dist/lib/runtime-rules/no-import-statements.js +0 -65
  126. package/dist/lib/runtime-rules/no-import-statements.js.map +0 -1
  127. package/dist/lib/runtime-rules/no-react-destructuring.d.ts +0 -18
  128. package/dist/lib/runtime-rules/no-react-destructuring.d.ts.map +0 -1
  129. package/dist/lib/runtime-rules/no-react-destructuring.js +0 -60
  130. package/dist/lib/runtime-rules/no-react-destructuring.js.map +0 -1
  131. package/dist/lib/runtime-rules/no-require-statements.d.ts +0 -18
  132. package/dist/lib/runtime-rules/no-require-statements.d.ts.map +0 -1
  133. package/dist/lib/runtime-rules/no-require-statements.js +0 -109
  134. package/dist/lib/runtime-rules/no-require-statements.js.map +0 -1
  135. package/dist/lib/runtime-rules/no-return-component.d.ts +0 -18
  136. package/dist/lib/runtime-rules/no-return-component.d.ts.map +0 -1
  137. package/dist/lib/runtime-rules/no-return-component.js +0 -106
  138. package/dist/lib/runtime-rules/no-return-component.js.map +0 -1
  139. package/dist/lib/runtime-rules/no-unwrap-utility-libs.d.ts +0 -20
  140. package/dist/lib/runtime-rules/no-unwrap-utility-libs.d.ts.map +0 -1
  141. package/dist/lib/runtime-rules/no-unwrap-utility-libs.js +0 -75
  142. package/dist/lib/runtime-rules/no-unwrap-utility-libs.js.map +0 -1
  143. package/dist/lib/runtime-rules/no-use-reducer.d.ts +0 -19
  144. package/dist/lib/runtime-rules/no-use-reducer.d.ts.map +0 -1
  145. package/dist/lib/runtime-rules/no-use-reducer.js +0 -78
  146. package/dist/lib/runtime-rules/no-use-reducer.js.map +0 -1
  147. package/dist/lib/runtime-rules/no-window-access.d.ts +0 -23
  148. package/dist/lib/runtime-rules/no-window-access.d.ts.map +0 -1
  149. package/dist/lib/runtime-rules/no-window-access.js +0 -136
  150. package/dist/lib/runtime-rules/no-window-access.js.map +0 -1
  151. package/dist/lib/runtime-rules/noisy-settings-updates.d.ts +0 -18
  152. package/dist/lib/runtime-rules/noisy-settings-updates.d.ts.map +0 -1
  153. package/dist/lib/runtime-rules/noisy-settings-updates.js +0 -110
  154. package/dist/lib/runtime-rules/noisy-settings-updates.js.map +0 -1
  155. package/dist/lib/runtime-rules/overflow-hidden-on-layout-container.d.ts +0 -30
  156. package/dist/lib/runtime-rules/overflow-hidden-on-layout-container.d.ts.map +0 -1
  157. package/dist/lib/runtime-rules/overflow-hidden-on-layout-container.js +0 -220
  158. package/dist/lib/runtime-rules/overflow-hidden-on-layout-container.js.map +0 -1
  159. package/dist/lib/runtime-rules/pass-standard-props.d.ts +0 -19
  160. package/dist/lib/runtime-rules/pass-standard-props.d.ts.map +0 -1
  161. package/dist/lib/runtime-rules/pass-standard-props.js +0 -82
  162. package/dist/lib/runtime-rules/pass-standard-props.js.map +0 -1
  163. package/dist/lib/runtime-rules/prefer-async-await.d.ts +0 -17
  164. package/dist/lib/runtime-rules/prefer-async-await.d.ts.map +0 -1
  165. package/dist/lib/runtime-rules/prefer-async-await.js +0 -52
  166. package/dist/lib/runtime-rules/prefer-async-await.js.map +0 -1
  167. package/dist/lib/runtime-rules/prefer-jsx-syntax.d.ts +0 -17
  168. package/dist/lib/runtime-rules/prefer-jsx-syntax.d.ts.map +0 -1
  169. package/dist/lib/runtime-rules/prefer-jsx-syntax.js +0 -51
  170. package/dist/lib/runtime-rules/prefer-jsx-syntax.js.map +0 -1
  171. package/dist/lib/runtime-rules/prop-state-sync.d.ts +0 -19
  172. package/dist/lib/runtime-rules/prop-state-sync.d.ts.map +0 -1
  173. package/dist/lib/runtime-rules/prop-state-sync.js +0 -76
  174. package/dist/lib/runtime-rules/prop-state-sync.js.map +0 -1
  175. package/dist/lib/runtime-rules/property-name-consistency.d.ts +0 -20
  176. package/dist/lib/runtime-rules/property-name-consistency.d.ts.map +0 -1
  177. package/dist/lib/runtime-rules/property-name-consistency.js +0 -172
  178. package/dist/lib/runtime-rules/property-name-consistency.js.map +0 -1
  179. package/dist/lib/runtime-rules/query-result-field-access-validation.d.ts +0 -10
  180. package/dist/lib/runtime-rules/query-result-field-access-validation.d.ts.map +0 -1
  181. package/dist/lib/runtime-rules/query-result-field-access-validation.js +0 -304
  182. package/dist/lib/runtime-rules/query-result-field-access-validation.js.map +0 -1
  183. package/dist/lib/runtime-rules/react-component-naming.d.ts +0 -19
  184. package/dist/lib/runtime-rules/react-component-naming.d.ts.map +0 -1
  185. package/dist/lib/runtime-rules/react-component-naming.js +0 -72
  186. package/dist/lib/runtime-rules/react-component-naming.js.map +0 -1
  187. package/dist/lib/runtime-rules/react-hooks-rules.d.ts +0 -27
  188. package/dist/lib/runtime-rules/react-hooks-rules.d.ts.map +0 -1
  189. package/dist/lib/runtime-rules/react-hooks-rules.js +0 -223
  190. package/dist/lib/runtime-rules/react-hooks-rules.js.map +0 -1
  191. package/dist/lib/runtime-rules/required-queries-not-called.d.ts +0 -19
  192. package/dist/lib/runtime-rules/required-queries-not-called.d.ts.map +0 -1
  193. package/dist/lib/runtime-rules/required-queries-not-called.js +0 -146
  194. package/dist/lib/runtime-rules/required-queries-not-called.js.map +0 -1
  195. package/dist/lib/runtime-rules/runquery-call-validation.d.ts +0 -11
  196. package/dist/lib/runtime-rules/runquery-call-validation.d.ts.map +0 -1
  197. package/dist/lib/runtime-rules/runquery-call-validation.js +0 -886
  198. package/dist/lib/runtime-rules/runquery-call-validation.js.map +0 -1
  199. package/dist/lib/runtime-rules/runview-call-validation.d.ts +0 -10
  200. package/dist/lib/runtime-rules/runview-call-validation.d.ts.map +0 -1
  201. package/dist/lib/runtime-rules/runview-call-validation.js +0 -336
  202. package/dist/lib/runtime-rules/runview-call-validation.js.map +0 -1
  203. package/dist/lib/runtime-rules/saved-user-settings-pattern.d.ts +0 -19
  204. package/dist/lib/runtime-rules/saved-user-settings-pattern.d.ts.map +0 -1
  205. package/dist/lib/runtime-rules/saved-user-settings-pattern.js +0 -90
  206. package/dist/lib/runtime-rules/saved-user-settings-pattern.js.map +0 -1
  207. package/dist/lib/runtime-rules/search-availability-check.d.ts +0 -9
  208. package/dist/lib/runtime-rules/search-availability-check.d.ts.map +0 -1
  209. package/dist/lib/runtime-rules/search-availability-check.js +0 -220
  210. package/dist/lib/runtime-rules/search-availability-check.js.map +0 -1
  211. package/dist/lib/runtime-rules/search-call-validation.d.ts +0 -9
  212. package/dist/lib/runtime-rules/search-call-validation.d.ts.map +0 -1
  213. package/dist/lib/runtime-rules/search-call-validation.js +0 -336
  214. package/dist/lib/runtime-rules/search-call-validation.js.map +0 -1
  215. package/dist/lib/runtime-rules/server-reload-on-client-operation.d.ts +0 -18
  216. package/dist/lib/runtime-rules/server-reload-on-client-operation.d.ts.map +0 -1
  217. package/dist/lib/runtime-rules/server-reload-on-client-operation.js +0 -107
  218. package/dist/lib/runtime-rules/server-reload-on-client-operation.js.map +0 -1
  219. package/dist/lib/runtime-rules/single-function-only.d.ts +0 -18
  220. package/dist/lib/runtime-rules/single-function-only.d.ts.map +0 -1
  221. package/dist/lib/runtime-rules/single-function-only.js +0 -103
  222. package/dist/lib/runtime-rules/single-function-only.js.map +0 -1
  223. package/dist/lib/runtime-rules/string-replace-all-occurrences.d.ts +0 -19
  224. package/dist/lib/runtime-rules/string-replace-all-occurrences.d.ts.map +0 -1
  225. package/dist/lib/runtime-rules/string-replace-all-occurrences.js +0 -109
  226. package/dist/lib/runtime-rules/string-replace-all-occurrences.js.map +0 -1
  227. package/dist/lib/runtime-rules/string-template-validation.d.ts +0 -22
  228. package/dist/lib/runtime-rules/string-template-validation.d.ts.map +0 -1
  229. package/dist/lib/runtime-rules/string-template-validation.js +0 -163
  230. package/dist/lib/runtime-rules/string-template-validation.js.map +0 -1
  231. package/dist/lib/runtime-rules/styles-validation.d.ts +0 -10
  232. package/dist/lib/runtime-rules/styles-validation.d.ts.map +0 -1
  233. package/dist/lib/runtime-rules/styles-validation.js +0 -153
  234. package/dist/lib/runtime-rules/styles-validation.js.map +0 -1
  235. package/dist/lib/runtime-rules/type-inference-errors.d.ts +0 -23
  236. package/dist/lib/runtime-rules/type-inference-errors.d.ts.map +0 -1
  237. package/dist/lib/runtime-rules/type-inference-errors.js +0 -53
  238. package/dist/lib/runtime-rules/type-inference-errors.js.map +0 -1
  239. package/dist/lib/runtime-rules/type-mismatch-operation.d.ts +0 -23
  240. package/dist/lib/runtime-rules/type-mismatch-operation.d.ts.map +0 -1
  241. package/dist/lib/runtime-rules/type-mismatch-operation.js +0 -141
  242. package/dist/lib/runtime-rules/type-mismatch-operation.js.map +0 -1
  243. package/dist/lib/runtime-rules/undefined-component-usage.d.ts +0 -20
  244. package/dist/lib/runtime-rules/undefined-component-usage.d.ts.map +0 -1
  245. package/dist/lib/runtime-rules/undefined-component-usage.js +0 -138
  246. package/dist/lib/runtime-rules/undefined-component-usage.js.map +0 -1
  247. package/dist/lib/runtime-rules/undefined-jsx-component.d.ts +0 -25
  248. package/dist/lib/runtime-rules/undefined-jsx-component.d.ts.map +0 -1
  249. package/dist/lib/runtime-rules/undefined-jsx-component.js +0 -269
  250. package/dist/lib/runtime-rules/undefined-jsx-component.js.map +0 -1
  251. package/dist/lib/runtime-rules/unsafe-array-operations.d.ts +0 -25
  252. package/dist/lib/runtime-rules/unsafe-array-operations.d.ts.map +0 -1
  253. package/dist/lib/runtime-rules/unsafe-array-operations.js +0 -347
  254. package/dist/lib/runtime-rules/unsafe-array-operations.js.map +0 -1
  255. package/dist/lib/runtime-rules/unsafe-formatting-methods.d.ts +0 -24
  256. package/dist/lib/runtime-rules/unsafe-formatting-methods.d.ts.map +0 -1
  257. package/dist/lib/runtime-rules/unsafe-formatting-methods.js +0 -277
  258. package/dist/lib/runtime-rules/unsafe-formatting-methods.js.map +0 -1
  259. package/dist/lib/runtime-rules/unused-component-dependencies.d.ts +0 -19
  260. package/dist/lib/runtime-rules/unused-component-dependencies.d.ts.map +0 -1
  261. package/dist/lib/runtime-rules/unused-component-dependencies.js +0 -90
  262. package/dist/lib/runtime-rules/unused-component-dependencies.js.map +0 -1
  263. package/dist/lib/runtime-rules/unused-libraries.d.ts +0 -19
  264. package/dist/lib/runtime-rules/unused-libraries.d.ts.map +0 -1
  265. package/dist/lib/runtime-rules/unused-libraries.js +0 -127
  266. package/dist/lib/runtime-rules/unused-libraries.js.map +0 -1
  267. package/dist/lib/runtime-rules/use-function-declaration.d.ts +0 -18
  268. package/dist/lib/runtime-rules/use-function-declaration.d.ts.map +0 -1
  269. package/dist/lib/runtime-rules/use-function-declaration.js +0 -127
  270. package/dist/lib/runtime-rules/use-function-declaration.js.map +0 -1
  271. package/dist/lib/runtime-rules/use-unwrap-components.d.ts +0 -19
  272. package/dist/lib/runtime-rules/use-unwrap-components.d.ts.map +0 -1
  273. package/dist/lib/runtime-rules/use-unwrap-components.js +0 -84
  274. package/dist/lib/runtime-rules/use-unwrap-components.js.map +0 -1
  275. package/dist/lib/runtime-rules/useeffect-unstable-dependencies.d.ts +0 -23
  276. package/dist/lib/runtime-rules/useeffect-unstable-dependencies.d.ts.map +0 -1
  277. package/dist/lib/runtime-rules/useeffect-unstable-dependencies.js +0 -215
  278. package/dist/lib/runtime-rules/useeffect-unstable-dependencies.js.map +0 -1
  279. package/dist/lib/runtime-rules/utilities-api-validation.d.ts +0 -24
  280. package/dist/lib/runtime-rules/utilities-api-validation.d.ts.map +0 -1
  281. package/dist/lib/runtime-rules/utilities-api-validation.js +0 -121
  282. package/dist/lib/runtime-rules/utilities-api-validation.js.map +0 -1
  283. package/dist/lib/runtime-rules/utilities-no-direct-instantiation.d.ts +0 -20
  284. package/dist/lib/runtime-rules/utilities-no-direct-instantiation.d.ts.map +0 -1
  285. package/dist/lib/runtime-rules/utilities-no-direct-instantiation.js +0 -58
  286. package/dist/lib/runtime-rules/utilities-no-direct-instantiation.js.map +0 -1
  287. package/dist/lib/runtime-rules/validate-component-references.d.ts +0 -19
  288. package/dist/lib/runtime-rules/validate-component-references.d.ts.map +0 -1
  289. package/dist/lib/runtime-rules/validate-component-references.js +0 -255
  290. package/dist/lib/runtime-rules/validate-component-references.js.map +0 -1
  291. package/dist/lib/schema-validation/component-prop-rule.d.ts +0 -125
  292. package/dist/lib/schema-validation/component-prop-rule.d.ts.map +0 -1
  293. package/dist/lib/schema-validation/component-prop-rule.js +0 -624
  294. package/dist/lib/schema-validation/component-prop-rule.js.map +0 -1
  295. package/dist/lib/schema-validation/index.d.ts +0 -26
  296. package/dist/lib/schema-validation/index.d.ts.map +0 -1
  297. package/dist/lib/schema-validation/index.js +0 -26
  298. package/dist/lib/schema-validation/index.js.map +0 -1
  299. package/dist/lib/schema-validation/semantic-validators/index.d.ts +0 -23
  300. package/dist/lib/schema-validation/semantic-validators/index.d.ts.map +0 -1
  301. package/dist/lib/schema-validation/semantic-validators/index.js +0 -23
  302. package/dist/lib/schema-validation/semantic-validators/index.js.map +0 -1
  303. package/dist/lib/schema-validation/semantic-validators/required-when-validator.d.ts +0 -43
  304. package/dist/lib/schema-validation/semantic-validators/required-when-validator.d.ts.map +0 -1
  305. package/dist/lib/schema-validation/semantic-validators/required-when-validator.js +0 -94
  306. package/dist/lib/schema-validation/semantic-validators/required-when-validator.js.map +0 -1
  307. package/dist/lib/schema-validation/semantic-validators/semantic-validator-registry.d.ts +0 -122
  308. package/dist/lib/schema-validation/semantic-validators/semantic-validator-registry.d.ts.map +0 -1
  309. package/dist/lib/schema-validation/semantic-validators/semantic-validator-registry.js +0 -166
  310. package/dist/lib/schema-validation/semantic-validators/semantic-validator-registry.js.map +0 -1
  311. package/dist/lib/schema-validation/semantic-validators/semantic-validator.d.ts +0 -260
  312. package/dist/lib/schema-validation/semantic-validators/semantic-validator.d.ts.map +0 -1
  313. package/dist/lib/schema-validation/semantic-validators/semantic-validator.js +0 -301
  314. package/dist/lib/schema-validation/semantic-validators/semantic-validator.js.map +0 -1
  315. package/dist/lib/schema-validation/semantic-validators/sql-where-clause-validator.d.ts +0 -115
  316. package/dist/lib/schema-validation/semantic-validators/sql-where-clause-validator.d.ts.map +0 -1
  317. package/dist/lib/schema-validation/semantic-validators/sql-where-clause-validator.js +0 -381
  318. package/dist/lib/schema-validation/semantic-validators/sql-where-clause-validator.js.map +0 -1
  319. package/dist/lib/schema-validation/semantic-validators/subset-of-entity-fields-validator.d.ts +0 -60
  320. package/dist/lib/schema-validation/semantic-validators/subset-of-entity-fields-validator.d.ts.map +0 -1
  321. package/dist/lib/schema-validation/semantic-validators/subset-of-entity-fields-validator.js +0 -195
  322. package/dist/lib/schema-validation/semantic-validators/subset-of-entity-fields-validator.js.map +0 -1
  323. package/dist/lib/schema-validation/semantic-validators/validation-context.d.ts +0 -335
  324. package/dist/lib/schema-validation/semantic-validators/validation-context.d.ts.map +0 -1
  325. package/dist/lib/schema-validation/semantic-validators/validation-context.js +0 -13
  326. package/dist/lib/schema-validation/semantic-validators/validation-context.js.map +0 -1
  327. package/dist/lib/styles-type-analyzer.d.ts +0 -64
  328. package/dist/lib/styles-type-analyzer.d.ts.map +0 -1
  329. package/dist/lib/styles-type-analyzer.js +0 -242
  330. package/dist/lib/styles-type-analyzer.js.map +0 -1
  331. package/dist/lib/type-context.d.ts +0 -184
  332. package/dist/lib/type-context.d.ts.map +0 -1
  333. package/dist/lib/type-context.js +0 -415
  334. package/dist/lib/type-context.js.map +0 -1
  335. package/dist/lib/type-inference-engine.d.ts +0 -181
  336. package/dist/lib/type-inference-engine.d.ts.map +0 -1
  337. package/dist/lib/type-inference-engine.js +0 -1151
  338. package/dist/lib/type-inference-engine.js.map +0 -1
  339. package/dist/lib/type-rules/type-compatibility-rule.d.ts +0 -79
  340. package/dist/lib/type-rules/type-compatibility-rule.d.ts.map +0 -1
  341. package/dist/lib/type-rules/type-compatibility-rule.js +0 -211
  342. package/dist/lib/type-rules/type-compatibility-rule.js.map +0 -1
@@ -1,763 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { traverse } from '../lint-utils.js';
8
- import { RegisterClass } from '@memberjunction/global';
9
- import * as t from '@babel/types';
10
- import { BaseLintRule } from '../lint-rule.js';
11
- /**
12
- * Rule: data-result-validation
13
- *
14
- * Consolidates all RunView AND RunQuery RESULT USAGE validation into one rule.
15
- * Absorbs checks from:
16
- * - runview-runquery-result-validation (all)
17
- * - runquery-runview-spread-operator (all)
18
- * - runview-result-null-safety (all)
19
- *
20
- * Architecture:
21
- * - Phase 1: Collect result variables from await utilities.rv.RunView/RunViews/rq.RunQuery
22
- * - Phase 2: Validate usage of tracked result variables
23
- *
24
- * Checks:
25
- * 1. Invalid property access (.data, .rows, .records -> suggest .Results)
26
- * 2. Direct array method on result (.map, .filter, etc. -> use .Results.map)
27
- * 3. Passing result to setState without .Results
28
- * 4. Array.isArray pattern on result (always false since result is object)
29
- * 5. .length on result object
30
- * 6. Incorrect nested property access (result.data.entities)
31
- * 7. Destructuring invalid properties (const { data } = result)
32
- * 8. Weak fallback pattern (result?.records ?? result?.Rows ?? [])
33
- * 9. Spread operator on result object ([...result] or {...result})
34
- * 10. Missing Success check - .Results accessed without Success guard (medium severity)
35
- * 11. Incorrect optional check (.length on result)
36
- *
37
- * Severity: critical/high/medium
38
- * Applies to: all components
39
- */
40
- const RULE_NAME = 'data-result-validation';
41
- // Valid properties per result type
42
- const RUNVIEW_RESULT_PROPS = [
43
- 'Success', 'Results', 'UserViewRunID', 'RowCount', 'TotalRowCount', 'ExecutionTime', 'ErrorMessage',
44
- ];
45
- const RUNQUERY_RESULT_PROPS = [
46
- 'QueryID', 'QueryName', 'Success', 'Results', 'RowCount', 'TotalRowCount',
47
- 'ExecutionTime', 'ErrorMessage', 'AppliedParameters', 'CacheHit', 'CacheKey', 'CacheTTLRemaining',
48
- ];
49
- const VALID_RUNVIEW_RESULT = new Set(RUNVIEW_RESULT_PROPS);
50
- const VALID_RUNQUERY_RESULT = new Set(RUNQUERY_RESULT_PROPS);
51
- const SEARCH_RESULT_PROPS = [
52
- 'Success', 'Results', 'TotalCount', 'ElapsedMs', 'SourceCounts', 'Providers', 'ErrorMessage',
53
- ];
54
- const VALID_SEARCH_RESULT = new Set(SEARCH_RESULT_PROPS);
55
- const ARRAY_METHODS = new Set(['map', 'filter', 'forEach', 'reduce', 'find', 'some', 'every', 'sort', 'concat']);
56
- const ARRAY_EXPECTING_FUNCS = new Set([
57
- 'map', 'filter', 'forEach', 'reduce', 'sort', 'concat',
58
- 'processChartData', 'processData', 'transformData',
59
- 'setData', 'setItems', 'setResults', 'setRows',
60
- ]);
61
- const INCORRECT_TO_CORRECT = {
62
- data: 'Results', Data: 'Results',
63
- rows: 'Results', Rows: 'Results',
64
- records: 'Results', Records: 'Results',
65
- items: 'Results', Items: 'Results',
66
- values: 'Results', Values: 'Results',
67
- result: 'Results', Result: 'Results',
68
- resultSet: 'Results', ResultSet: 'Results',
69
- dataset: 'Results', Dataset: 'Results',
70
- response: 'Results', Response: 'Results',
71
- };
72
- // ── Phase 1: Collect result variables ────────────────────────────────
73
- /**
74
- * Attempts to extract utilities sub-object name and method name from a callee node.
75
- * Handles both MemberExpression (direct) and OptionalMemberExpression (optional chaining) patterns.
76
- * Returns [subObject, method] if matched, null otherwise.
77
- */
78
- function extractUtilitiesCallInfo(callee) {
79
- // Get the method name from the outermost property
80
- let methodName = null;
81
- let objectNode = null;
82
- if (t.isMemberExpression(callee) && t.isIdentifier(callee.property)) {
83
- methodName = callee.property.name;
84
- objectNode = callee.object;
85
- }
86
- else if (t.isOptionalMemberExpression(callee) && t.isIdentifier(callee.property)) {
87
- methodName = callee.property.name;
88
- objectNode = callee.object;
89
- }
90
- if (!methodName || !objectNode)
91
- return null;
92
- // Check if the object is utilities.xxx (direct or optional)
93
- let subObject = null;
94
- if (t.isMemberExpression(objectNode) && t.isIdentifier(objectNode.object) &&
95
- objectNode.object.name === 'utilities' && t.isIdentifier(objectNode.property)) {
96
- subObject = objectNode.property.name;
97
- }
98
- else if (t.isOptionalMemberExpression(objectNode) && t.isIdentifier(objectNode.object) &&
99
- objectNode.object.name === 'utilities' && t.isIdentifier(objectNode.property)) {
100
- subObject = objectNode.property.name;
101
- }
102
- if (!subObject)
103
- return null;
104
- return [subObject, methodName];
105
- }
106
- /**
107
- * Resolves a MethodType from a utilities sub-object name and method name.
108
- */
109
- function resolveMethodType(subObject, method) {
110
- if (subObject === 'rv' && (method === 'RunView' || method === 'RunViews')) {
111
- return method;
112
- }
113
- if (subObject === 'rq' && method === 'RunQuery')
114
- return 'RunQuery';
115
- if (subObject === 'search' && method === 'Search')
116
- return 'Search';
117
- if (subObject === 'search' && method === 'PreviewSearch')
118
- return 'PreviewSearch';
119
- return null;
120
- }
121
- /**
122
- * Records a result variable from an AwaitExpression's parent (variable declarator or assignment).
123
- */
124
- function recordResultVariable(path, methodType, resultVariables) {
125
- const parent = path.parent;
126
- if (t.isVariableDeclarator(parent) && t.isIdentifier(parent.id)) {
127
- resultVariables.set(parent.id.name, {
128
- line: parent.id.loc?.start.line || 0,
129
- column: parent.id.loc?.start.column || 0,
130
- method: methodType,
131
- varName: parent.id.name,
132
- });
133
- }
134
- else if (t.isAssignmentExpression(parent) && t.isIdentifier(parent.left)) {
135
- resultVariables.set(parent.left.name, {
136
- line: parent.left.loc?.start.line || 0,
137
- column: parent.left.loc?.start.column || 0,
138
- method: methodType,
139
- varName: parent.left.name,
140
- });
141
- }
142
- }
143
- function collectResultVariables(ast) {
144
- const resultVariables = new Map();
145
- traverse(ast, {
146
- AwaitExpression(path) {
147
- const callExpr = path.node.argument;
148
- // Handle both CallExpression and OptionalCallExpression
149
- if (!t.isCallExpression(callExpr) && !t.isOptionalCallExpression(callExpr))
150
- return;
151
- const info = extractUtilitiesCallInfo(callExpr.callee);
152
- if (!info)
153
- return;
154
- const methodType = resolveMethodType(info[0], info[1]);
155
- if (!methodType)
156
- return;
157
- recordResultVariable(path, methodType, resultVariables);
158
- },
159
- });
160
- return resultVariables;
161
- }
162
- // ── Scope-based binding check ────────────────────────────────────────
163
- function isVariableFromRunQueryOrView(path, varName, methodName) {
164
- const binding = path.scope.getBinding(varName);
165
- if (!binding)
166
- return false;
167
- const bindingPath = binding.path;
168
- if (!t.isVariableDeclarator(bindingPath.node))
169
- return false;
170
- const init = bindingPath.node.init;
171
- if (!init)
172
- return false;
173
- // Handle both CallExpression and OptionalCallExpression inside AwaitExpression
174
- if (t.isAwaitExpression(init) && (t.isCallExpression(init.argument) || t.isOptionalCallExpression(init.argument))) {
175
- const call = init.argument;
176
- const info = extractUtilitiesCallInfo(call.callee);
177
- if (info) {
178
- const [subObj, calledMethod] = info;
179
- if (methodName === 'RunView' && subObj === 'rv' && (calledMethod === 'RunView' || calledMethod === 'RunViews'))
180
- return true;
181
- if (methodName === 'RunQuery' && subObj === 'rq' && calledMethod === 'RunQuery')
182
- return true;
183
- if (methodName === 'Search' && subObj === 'search' && calledMethod === 'Search')
184
- return true;
185
- if (methodName === 'PreviewSearch' && subObj === 'search' && calledMethod === 'PreviewSearch')
186
- return true;
187
- }
188
- // Fallback: check just the method name without full utilities path
189
- if (t.isCallExpression(call) && t.isMemberExpression(call.callee) && t.isIdentifier(call.callee.property)) {
190
- const calledMethod = call.callee.property.name;
191
- const isFromMethod = calledMethod === methodName || (methodName === 'RunView' && calledMethod === 'RunViews');
192
- return isFromMethod;
193
- }
194
- }
195
- return false;
196
- }
197
- // ── Success guard checking ───────────────────────────────────────────
198
- function testChecksSuccess(test, varName) {
199
- if (t.isMemberExpression(test) &&
200
- t.isIdentifier(test.object) &&
201
- test.object.name === varName &&
202
- t.isIdentifier(test.property) &&
203
- (test.property.name === 'Success' || test.property.name === 'Results'))
204
- return true;
205
- if (t.isOptionalMemberExpression(test) &&
206
- t.isIdentifier(test.object) &&
207
- test.object.name === varName &&
208
- t.isIdentifier(test.property) &&
209
- (test.property.name === 'Success' || test.property.name === 'Results'))
210
- return true;
211
- if (t.isLogicalExpression(test) && test.operator === '&&') {
212
- return testChecksSuccess(test.left, varName) || testChecksSuccess(test.right, varName);
213
- }
214
- return false;
215
- }
216
- function testChecksNegatedSuccess(test, varName) {
217
- if (t.isUnaryExpression(test) && test.operator === '!') {
218
- return testChecksSuccess(test.argument, varName);
219
- }
220
- return false;
221
- }
222
- function blockContainsReturn(node) {
223
- if (t.isReturnStatement(node))
224
- return true;
225
- if (t.isBlockStatement(node))
226
- return node.body.some(s => t.isReturnStatement(s));
227
- return false;
228
- }
229
- function isDescendantOf(targetNode, containerNode) {
230
- if (targetNode === containerNode)
231
- return true;
232
- let found = false;
233
- traverse(containerNode, {
234
- enter(innerPath) {
235
- if (innerPath.node === targetNode) {
236
- found = true;
237
- innerPath.stop();
238
- }
239
- },
240
- noScope: true,
241
- });
242
- return found;
243
- }
244
- function isPrecededByEarlyReturnGuard(path, varName) {
245
- let blockPath = path;
246
- while (blockPath && !blockPath.isBlockStatement() && !blockPath.isProgram()) {
247
- blockPath = blockPath.parentPath;
248
- }
249
- if (!blockPath)
250
- return false;
251
- const container = blockPath.node;
252
- const body = t.isBlockStatement(container) ? container.body : t.isProgram(container) ? container.body : [];
253
- const targetLine = path.node.loc?.start.line ?? 0;
254
- for (const stmt of body) {
255
- if ((stmt.loc?.start.line ?? 0) >= targetLine)
256
- break;
257
- if (t.isIfStatement(stmt) &&
258
- testChecksNegatedSuccess(stmt.test, varName) &&
259
- blockContainsReturn(stmt.consequent))
260
- return true;
261
- }
262
- return false;
263
- }
264
- function isInsideSuccessGuard(path, varName) {
265
- let current = path.parentPath;
266
- while (current) {
267
- if (current.isIfStatement()) {
268
- if (testChecksSuccess(current.node.test, varName) && isDescendantOf(path.node, current.node.consequent)) {
269
- return true;
270
- }
271
- }
272
- if (current.isLogicalExpression() && current.node.operator === '&&') {
273
- if (testChecksSuccess(current.node.left, varName))
274
- return true;
275
- }
276
- if (current.isConditionalExpression()) {
277
- if (testChecksSuccess(current.node.test, varName))
278
- return true;
279
- }
280
- current = current.parentPath;
281
- }
282
- return isPrecededByEarlyReturnGuard(path, varName);
283
- }
284
- // ── Property access validation helper ────────────────────────────────
285
- function validatePropertyAccess(objName, propName, isFromRunQuery, isFromRunView, isFromSearch, line, column, code, violations) {
286
- if (!isFromRunQuery && !isFromRunView && !isFromSearch)
287
- return;
288
- const isValidQueryProp = VALID_RUNQUERY_RESULT.has(propName);
289
- const isValidViewProp = VALID_RUNVIEW_RESULT.has(propName);
290
- const isValidSearchProp = VALID_SEARCH_RESULT.has(propName);
291
- if (isFromRunQuery && !isValidQueryProp) {
292
- const suggestion = INCORRECT_TO_CORRECT[propName];
293
- violations.push({
294
- rule: RULE_NAME,
295
- severity: 'critical',
296
- line, column,
297
- message: suggestion
298
- ? `RunQuery results don't have a ".${propName}" property. Use ".${suggestion}" instead. Change "${objName}.${propName}" to "${objName}.${suggestion}"`
299
- : `Invalid property "${propName}" on RunQuery result. Valid properties: ${RUNQUERY_RESULT_PROPS.join(', ')}`,
300
- code,
301
- });
302
- }
303
- else if (isFromRunView && !isValidViewProp) {
304
- const suggestion = INCORRECT_TO_CORRECT[propName];
305
- violations.push({
306
- rule: RULE_NAME,
307
- severity: 'critical',
308
- line, column,
309
- message: suggestion
310
- ? `RunView results don't have a ".${propName}" property. Use ".${suggestion}" instead. Change "${objName}.${propName}" to "${objName}.${suggestion}"`
311
- : `Invalid property "${propName}" on RunView result. Valid properties: ${RUNVIEW_RESULT_PROPS.join(', ')}`,
312
- code,
313
- });
314
- }
315
- else if (isFromSearch && !isValidSearchProp) {
316
- const suggestion = INCORRECT_TO_CORRECT[propName];
317
- violations.push({
318
- rule: RULE_NAME,
319
- severity: 'critical',
320
- line, column,
321
- message: suggestion
322
- ? `Search results don't have a ".${propName}" property. Use ".${suggestion}" instead. Change "${objName}.${propName}" to "${objName}.${suggestion}"`
323
- : `Invalid property "${propName}" on Search result. Valid properties: ${SEARCH_RESULT_PROPS.join(', ')}`,
324
- code,
325
- });
326
- }
327
- }
328
- // ── Main Rule ────────────────────────────────────────────────────────
329
- let DataResultValidationRule = class DataResultValidationRule extends BaseLintRule {
330
- get Name() { return 'data-result-validation'; }
331
- get AppliesTo() { return 'all'; }
332
- Test(ast) {
333
- const violations = [];
334
- // Phase 1: Collect result variables
335
- const resultVariables = collectResultVariables(ast);
336
- if (resultVariables.size === 0)
337
- return violations;
338
- // Collect simple set for null-safety (just variable names)
339
- const resultVarNames = new Set(resultVariables.keys());
340
- // Phase 2: Validate usage
341
- traverse(ast, {
342
- // ── Array methods + setState + array-expecting funcs ──────
343
- CallExpression(path) {
344
- const callee = path.node.callee;
345
- // Check 2: result.map(), result.filter(), etc.
346
- if (t.isMemberExpression(callee) && t.isIdentifier(callee.object) && t.isIdentifier(callee.property)) {
347
- const objName = callee.object.name;
348
- const methodName = callee.property.name;
349
- if (ARRAY_METHODS.has(methodName)) {
350
- const isFromRunView = isVariableFromRunQueryOrView(path, objName, 'RunView');
351
- const isFromRunQuery = isVariableFromRunQueryOrView(path, objName, 'RunQuery');
352
- const isFromSearch = isVariableFromRunQueryOrView(path, objName, 'Search');
353
- const isFromPreviewSearch = isVariableFromRunQueryOrView(path, objName, 'PreviewSearch');
354
- if (isFromRunView || isFromRunQuery || isFromSearch || isFromPreviewSearch) {
355
- const methodType = isFromRunView ? 'RunView' : isFromRunQuery ? 'RunQuery' : isFromSearch ? 'Search' : 'PreviewSearch';
356
- violations.push({
357
- rule: RULE_NAME,
358
- severity: 'critical',
359
- line: path.node.loc?.start.line || 0,
360
- column: path.node.loc?.start.column || 0,
361
- message: `Cannot call array method "${methodName}" directly on ${methodType} result. Use "${objName}.Results.${methodName}(...)" instead. ${methodType} returns an object with { Success, Results, ... }, not an array.`,
362
- code: `${objName}.${methodName}(...)`,
363
- });
364
- }
365
- }
366
- }
367
- // Check 3 & 4: setState patterns
368
- if (t.isIdentifier(callee)) {
369
- const funcName = callee.name;
370
- const setStatePatterns = [/^set[A-Z]/, /^update[A-Z]/];
371
- const isSetStateFunction = setStatePatterns.some((pattern) => pattern.test(funcName));
372
- if (isSetStateFunction && path.node.arguments.length > 0) {
373
- const firstArg = path.node.arguments[0];
374
- // Check 4: Array.isArray ternary pattern in setState
375
- if (t.isConditionalExpression(firstArg)) {
376
- const test = firstArg.test;
377
- const consequent = firstArg.consequent;
378
- if (t.isCallExpression(test) &&
379
- t.isMemberExpression(test.callee) &&
380
- t.isIdentifier(test.callee.object) &&
381
- test.callee.object.name === 'Array' &&
382
- t.isIdentifier(test.callee.property) &&
383
- test.callee.property.name === 'isArray' &&
384
- test.arguments.length === 1 &&
385
- t.isIdentifier(test.arguments[0])) {
386
- const varName = test.arguments[0].name;
387
- if (resultVariables.has(varName) && t.isIdentifier(consequent) && consequent.name === varName) {
388
- const resultInfo = resultVariables.get(varName);
389
- violations.push({
390
- rule: RULE_NAME,
391
- severity: 'critical',
392
- line: firstArg.loc?.start.line || 0,
393
- column: firstArg.loc?.start.column || 0,
394
- message: `Passing ${resultInfo.method} result with incorrect Array.isArray check to ${funcName}. This will always pass an empty array because ${resultInfo.method} returns an object, not an array.
395
-
396
- Correct pattern:
397
- if (${varName}.Success) {
398
- ${funcName}(${varName}.Results || []);
399
- } else {
400
- console.error('Failed to load data:', ${varName}.ErrorMessage);
401
- }`,
402
- code: `${funcName}(Array.isArray(${varName}) ? ${varName} : [])`,
403
- });
404
- }
405
- }
406
- }
407
- // Check 3: Passing result directly to setState
408
- if (t.isIdentifier(firstArg) && resultVariables.has(firstArg.name)) {
409
- const resultInfo = resultVariables.get(firstArg.name);
410
- violations.push({
411
- rule: RULE_NAME,
412
- severity: 'critical',
413
- line: firstArg.loc?.start.line || 0,
414
- column: firstArg.loc?.start.column || 0,
415
- message: `Passing ${resultInfo.method} result directly to ${funcName}. Use "${firstArg.name}.Results" or check "${firstArg.name}.Success" first. ${resultInfo.method} returns { Success, Results, ErrorMessage }, not the data array.`,
416
- code: `${funcName}(${firstArg.name})`,
417
- });
418
- }
419
- }
420
- }
421
- // Check: passing result to array-expecting functions
422
- for (const arg of path.node.arguments) {
423
- if (!t.isIdentifier(arg) || !resultVariables.has(arg.name))
424
- continue;
425
- const resultInfo = resultVariables.get(arg.name);
426
- let funcName = '';
427
- if (t.isIdentifier(path.node.callee)) {
428
- funcName = path.node.callee.name;
429
- }
430
- else if (t.isMemberExpression(path.node.callee) && t.isIdentifier(path.node.callee.property)) {
431
- funcName = path.node.callee.property.name;
432
- }
433
- if (ARRAY_EXPECTING_FUNCS.has(funcName.toLowerCase()) ||
434
- Array.from(ARRAY_EXPECTING_FUNCS).some((f) => funcName.toLowerCase().includes(f.toLowerCase()))) {
435
- violations.push({
436
- rule: RULE_NAME,
437
- severity: 'critical',
438
- line: arg.loc?.start.line || 0,
439
- column: arg.loc?.start.column || 0,
440
- message: `Passing ${resultInfo.method} result object directly to ${funcName}() which expects an array.
441
- Correct pattern:
442
- if (${resultInfo.varName}?.Success) {
443
- ${funcName}(${resultInfo.varName}.Results);
444
- } else {
445
- console.error('${resultInfo.method} failed:', ${resultInfo.varName}?.ErrorMessage);
446
- ${funcName}([]); // Provide empty array as fallback
447
- }`,
448
- code: `${funcName}(${arg.name})`,
449
- });
450
- }
451
- }
452
- },
453
- // ── Property access (MemberExpression) ─────────────────────
454
- MemberExpression(path) {
455
- if (!t.isIdentifier(path.node.object) || !t.isIdentifier(path.node.property))
456
- return;
457
- const objName = path.node.object.name;
458
- const propName = path.node.property.name;
459
- const hasBinding = path.scope.hasBinding(objName);
460
- const isFromRunQuery = hasBinding && isVariableFromRunQueryOrView(path, objName, 'RunQuery');
461
- const isFromRunView = hasBinding && isVariableFromRunQueryOrView(path, objName, 'RunView');
462
- const isFromSearch = hasBinding && (isVariableFromRunQueryOrView(path, objName, 'Search') || isVariableFromRunQueryOrView(path, objName, 'PreviewSearch'));
463
- // Check 5: .length on result
464
- if (propName === 'length' && resultVariables.has(objName)) {
465
- const resultInfo = resultVariables.get(objName);
466
- violations.push({
467
- rule: RULE_NAME,
468
- severity: 'critical',
469
- line: path.node.loc?.start.line || 0,
470
- column: path.node.loc?.start.column || 0,
471
- message: `Cannot check .length on ${resultInfo.method} result directly. ${resultInfo.method} returns an object with Success and Results properties.
472
- Correct pattern:
473
- if (${resultInfo.varName}?.Success && ${resultInfo.varName}?.Results?.length > 0) {
474
- // Process ${resultInfo.varName}.Results array
475
- }`,
476
- code: `${objName}.length`,
477
- });
478
- }
479
- // Check 1: Invalid property access
480
- validatePropertyAccess(objName, propName, isFromRunQuery, isFromRunView, isFromSearch, path.node.loc?.start.line || 0, path.node.loc?.start.column || 0, `${objName}.${propName}`, violations);
481
- // Check 6: Nested incorrect access like result.data.entities
482
- if ((isFromRunQuery || isFromRunView || isFromSearch) &&
483
- t.isMemberExpression(path.parent) &&
484
- t.isIdentifier(path.parent.property) &&
485
- (propName === 'data' || propName === 'Data')) {
486
- const nestedProp = path.parent.property.name;
487
- const sourceType = isFromSearch ? 'Search' : 'RunQuery/RunView';
488
- violations.push({
489
- rule: RULE_NAME,
490
- severity: 'critical',
491
- line: path.parent.loc?.start.line || 0,
492
- column: path.parent.loc?.start.column || 0,
493
- message: `Incorrect nested property access "${objName}.${propName}.${nestedProp}". ${sourceType} results use ".Results" directly for the data array. Change to "${objName}.Results"`,
494
- code: `${objName}.${propName}.${nestedProp}`,
495
- });
496
- }
497
- // Check 10: Missing Success check (null safety)
498
- if (propName === 'Results' && resultVarNames.has(objName)) {
499
- if (!isInsideSuccessGuard(path, objName)) {
500
- const resultInfo = resultVariables.get(objName);
501
- const sourceDesc = resultInfo && (resultInfo.method === 'Search' || resultInfo.method === 'PreviewSearch')
502
- ? 'Search' : 'RunView/RunQuery';
503
- violations.push({
504
- rule: RULE_NAME,
505
- severity: 'medium',
506
- line: path.node.loc?.start.line ?? 0,
507
- column: path.node.loc?.start.column ?? 0,
508
- message: `Accessing "${objName}.Results" without checking "${objName}.Success" first. ${sourceDesc} can fail, and .Results may be undefined when Success is false.`,
509
- code: `${objName}.Results`,
510
- suggestion: {
511
- text: `Wrap in a Success check before accessing Results`,
512
- example: `if (${objName}.Success) {\n ${objName}.Results.map(...);\n} else {\n console.error('Query failed:', ${objName}.ErrorMessage);\n}`,
513
- },
514
- });
515
- }
516
- }
517
- },
518
- // ── Optional member expressions ────────────────────────────
519
- OptionalMemberExpression(path) {
520
- if (!t.isIdentifier(path.node.object) || !t.isIdentifier(path.node.property))
521
- return;
522
- const objName = path.node.object.name;
523
- const propName = path.node.property.name;
524
- const hasBinding = path.scope.hasBinding(objName);
525
- const isFromRunQuery = hasBinding && isVariableFromRunQueryOrView(path, objName, 'RunQuery');
526
- const isFromRunView = hasBinding && isVariableFromRunQueryOrView(path, objName, 'RunView');
527
- const isFromSearch = hasBinding && (isVariableFromRunQueryOrView(path, objName, 'Search') || isVariableFromRunQueryOrView(path, objName, 'PreviewSearch'));
528
- // Check 1 (optional chaining variant)
529
- validatePropertyAccess(objName, propName, isFromRunQuery, isFromRunView, isFromSearch, path.node.loc?.start.line || 0, path.node.loc?.start.column || 0, `${objName}?.${propName}`, violations);
530
- // Note: result?.Results is inherently null-safe — do NOT flag for missing Success check
531
- },
532
- // ── Check 8: Weak fallback patterns ────────────────────────
533
- LogicalExpression(path) {
534
- if (path.node.operator !== '??')
535
- return;
536
- const invalidAccesses = [];
537
- const checkNode = (node) => {
538
- if (t.isOptionalMemberExpression(node) && t.isIdentifier(node.object) && t.isIdentifier(node.property)) {
539
- const objName = node.object.name;
540
- const propName = node.property.name;
541
- const hasBinding = path.scope.hasBinding(objName);
542
- const isFromRunQuery = hasBinding && isVariableFromRunQueryOrView(path, objName, 'RunQuery');
543
- const isFromRunView = hasBinding && isVariableFromRunQueryOrView(path, objName, 'RunView');
544
- const isFromSearch = hasBinding && (isVariableFromRunQueryOrView(path, objName, 'Search') || isVariableFromRunQueryOrView(path, objName, 'PreviewSearch'));
545
- if (isFromRunQuery || isFromRunView || isFromSearch) {
546
- const isValidQueryProp = VALID_RUNQUERY_RESULT.has(propName);
547
- const isValidViewProp = VALID_RUNVIEW_RESULT.has(propName);
548
- const isValidSearchProp = VALID_SEARCH_RESULT.has(propName);
549
- if ((isFromRunQuery && !isValidQueryProp) || (isFromRunView && !isValidViewProp) || (isFromSearch && !isValidSearchProp)) {
550
- invalidAccesses.push({ objName, propName, line: node.loc?.start.line || 0 });
551
- }
552
- }
553
- }
554
- else if (t.isLogicalExpression(node) && node.operator === '??') {
555
- checkNode(node.left);
556
- checkNode(node.right);
557
- }
558
- };
559
- checkNode(path.node);
560
- if (invalidAccesses.length >= 2) {
561
- const objName = invalidAccesses[0].objName;
562
- const props = invalidAccesses.map((a) => a.propName).join(', ');
563
- violations.push({
564
- rule: RULE_NAME,
565
- severity: 'critical',
566
- line: path.node.loc?.start.line || 0,
567
- column: path.node.loc?.start.column || 0,
568
- message: `Weak fallback pattern detected: "${objName}?.${invalidAccesses[0].propName} ?? ${objName}?.${invalidAccesses[1].propName} ?? ..." uses multiple INVALID properties (${props}). This masks the real issue. Use "${objName}?.Results ?? []" instead.`,
569
- code: path.toString().substring(0, 100),
570
- });
571
- }
572
- },
573
- // ── Check 7: Destructuring invalid properties ──────────────
574
- VariableDeclarator(path) {
575
- if (!t.isObjectPattern(path.node.id) || !t.isIdentifier(path.node.init))
576
- return;
577
- const sourceName = path.node.init.name;
578
- const hasBinding = path.scope.hasBinding(sourceName);
579
- const isFromRunQuery = hasBinding && isVariableFromRunQueryOrView(path, sourceName, 'RunQuery');
580
- const isFromRunView = hasBinding && isVariableFromRunQueryOrView(path, sourceName, 'RunView');
581
- const isFromSearch = hasBinding && (isVariableFromRunQueryOrView(path, sourceName, 'Search') || isVariableFromRunQueryOrView(path, sourceName, 'PreviewSearch'));
582
- if (!isFromRunQuery && !isFromRunView && !isFromSearch)
583
- return;
584
- for (const prop of path.node.id.properties) {
585
- if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key))
586
- continue;
587
- const propName = prop.key.name;
588
- const isValidQueryProp = VALID_RUNQUERY_RESULT.has(propName);
589
- const isValidViewProp = VALID_RUNVIEW_RESULT.has(propName);
590
- const isValidSearchProp = VALID_SEARCH_RESULT.has(propName);
591
- if (isFromRunQuery && !isValidQueryProp) {
592
- const suggestion = INCORRECT_TO_CORRECT[propName];
593
- violations.push({
594
- rule: RULE_NAME,
595
- severity: 'critical',
596
- line: prop.loc?.start.line || 0,
597
- column: prop.loc?.start.column || 0,
598
- message: suggestion
599
- ? `Destructuring invalid property "${propName}" from RunQuery result. Use "${suggestion}" instead.`
600
- : `Destructuring invalid property "${propName}" from RunQuery result. Valid properties: ${RUNQUERY_RESULT_PROPS.join(', ')}`,
601
- code: `{ ${propName} }`,
602
- });
603
- }
604
- else if (isFromRunView && !isValidViewProp) {
605
- const suggestion = INCORRECT_TO_CORRECT[propName];
606
- violations.push({
607
- rule: RULE_NAME,
608
- severity: 'critical',
609
- line: prop.loc?.start.line || 0,
610
- column: prop.loc?.start.column || 0,
611
- message: suggestion
612
- ? `Destructuring invalid property "${propName}" from RunView result. Use "${suggestion}" instead.`
613
- : `Destructuring invalid property "${propName}" from RunView result. Valid properties: ${RUNVIEW_RESULT_PROPS.join(', ')}`,
614
- code: `{ ${propName} }`,
615
- });
616
- }
617
- else if (isFromSearch && !isValidSearchProp) {
618
- const suggestion = INCORRECT_TO_CORRECT[propName];
619
- violations.push({
620
- rule: RULE_NAME,
621
- severity: 'critical',
622
- line: prop.loc?.start.line || 0,
623
- column: prop.loc?.start.column || 0,
624
- message: suggestion
625
- ? `Destructuring invalid property "${propName}" from Search result. Use "${suggestion}" instead.`
626
- : `Destructuring invalid property "${propName}" from Search result. Valid properties: ${SEARCH_RESULT_PROPS.join(', ')}`,
627
- code: `{ ${propName} }`,
628
- });
629
- }
630
- }
631
- },
632
- // ── Check 4 & 11: ConditionalExpression patterns ───────────
633
- ConditionalExpression(path) {
634
- const test = path.node.test;
635
- const consequent = path.node.consequent;
636
- const alternate = path.node.alternate;
637
- if (t.isCallExpression(test) &&
638
- t.isMemberExpression(test.callee) &&
639
- t.isIdentifier(test.callee.object) &&
640
- test.callee.object.name === 'Array' &&
641
- t.isIdentifier(test.callee.property) &&
642
- test.callee.property.name === 'isArray' &&
643
- test.arguments.length === 1 &&
644
- t.isIdentifier(test.arguments[0])) {
645
- const varName = test.arguments[0].name;
646
- if (resultVariables.has(varName) &&
647
- t.isIdentifier(consequent) &&
648
- consequent.name === varName &&
649
- t.isArrayExpression(alternate) &&
650
- alternate.elements.length === 0) {
651
- const resultInfo = resultVariables.get(varName);
652
- violations.push({
653
- rule: RULE_NAME,
654
- severity: 'critical',
655
- line: test.loc?.start.line || 0,
656
- column: test.loc?.start.column || 0,
657
- message: `${resultInfo.method} never returns an array directly. The pattern "Array.isArray(${varName}) ? ${varName} : []" will always evaluate to [] because ${varName} is an object with { Success, Results, ErrorMessage }.
658
-
659
- Correct patterns:
660
- // Option 1: Simple with fallback
661
- ${varName}.Results || []
662
-
663
- // Option 2: Check success first
664
- if (${varName}.Success) {
665
- setData(${varName}.Results || []);
666
- } else {
667
- console.error('Failed:', ${varName}.ErrorMessage);
668
- setData([]);
669
- }`,
670
- code: `Array.isArray(${varName}) ? ${varName} : []`,
671
- });
672
- }
673
- }
674
- },
675
- // ── Check 9: Spread operator on result object ──────────────
676
- SpreadElement(path) {
677
- if (!t.isIdentifier(path.node.argument))
678
- return;
679
- const varName = path.node.argument.name;
680
- if (!resultVariables.has(varName))
681
- return;
682
- const resultInfo = resultVariables.get(varName);
683
- violations.push({
684
- rule: RULE_NAME,
685
- severity: 'critical',
686
- line: path.node.loc?.start.line || 0,
687
- column: path.node.loc?.start.column || 0,
688
- message: `Cannot use spread operator on ${resultInfo.method} result object. Use ...${varName}.Results to spread the data array.
689
-
690
- Correct pattern:
691
- const allData = [...existingData, ...${varName}.Results];
692
-
693
- // Or with null safety:
694
- const allData = [...existingData, ...(${varName}.Results || [])];`,
695
- code: `...${varName}`,
696
- });
697
- },
698
- // ── Check 11: IfStatement patterns ─────────────────────────
699
- IfStatement(path) {
700
- const test = path.node.test;
701
- // Pattern: if (result) - check for Results access without Success check
702
- if (t.isIdentifier(test) && resultVariables.has(test.name)) {
703
- const resultInfo = resultVariables.get(test.name);
704
- let checksSuccess = false;
705
- let checksResults = false;
706
- path.traverse({
707
- MemberExpression(innerPath) {
708
- if (t.isIdentifier(innerPath.node.object) && innerPath.node.object.name === test.name) {
709
- const prop = t.isIdentifier(innerPath.node.property) ? innerPath.node.property.name : '';
710
- if (prop === 'Success')
711
- checksSuccess = true;
712
- if (prop === 'Results')
713
- checksResults = true;
714
- }
715
- },
716
- });
717
- if (checksResults && !checksSuccess) {
718
- violations.push({
719
- rule: RULE_NAME,
720
- severity: 'high',
721
- line: test.loc?.start.line || 0,
722
- column: test.loc?.start.column || 0,
723
- message: `Checking ${resultInfo.method} result without verifying Success property.
724
- Correct pattern:
725
- if (${resultInfo.varName}?.Success) {
726
- const data = ${resultInfo.varName}.Results;
727
- } else {
728
- // Handle error: ${resultInfo.varName}.ErrorMessage
729
- }`,
730
- code: `if (${test.name})`,
731
- });
732
- }
733
- }
734
- // Pattern: if (result?.length)
735
- if (t.isOptionalMemberExpression(test) &&
736
- t.isIdentifier(test.object) &&
737
- t.isIdentifier(test.property) &&
738
- test.property.name === 'length' &&
739
- resultVariables.has(test.object.name)) {
740
- const resultInfo = resultVariables.get(test.object.name);
741
- violations.push({
742
- rule: RULE_NAME,
743
- severity: 'critical',
744
- line: test.loc?.start.line || 0,
745
- column: test.loc?.start.column || 0,
746
- message: `Incorrect check: "${test.object.name}?.length" on ${resultInfo.method} result.
747
- Correct pattern:
748
- if (${resultInfo.varName}?.Success && ${resultInfo.varName}?.Results?.length > 0) {
749
- const processedData = processChartData(${resultInfo.varName}.Results);
750
- }`,
751
- code: `if (${test.object.name}?.length)`,
752
- });
753
- }
754
- },
755
- });
756
- return violations;
757
- }
758
- };
759
- DataResultValidationRule = __decorate([
760
- RegisterClass(BaseLintRule, 'data-result-validation')
761
- ], DataResultValidationRule);
762
- export { DataResultValidationRule };
763
- //# sourceMappingURL=data-result-validation.js.map