@oracle/oraclejet-audit 10.1.0 → 12.0.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 (759) hide show
  1. package/LICENSE.md +1 -1
  2. package/jaf-amd.js +12 -4
  3. package/jaf.js +6 -1
  4. package/jafapi.js +6 -1
  5. package/lib/AST.js +6 -1
  6. package/lib/AST_Ts.js +6 -1
  7. package/lib/AstJson.js +6 -1
  8. package/lib/AstMd.js +6 -0
  9. package/lib/AstNodeTypes.js +6 -1
  10. package/lib/Comments.js +6 -1
  11. package/lib/ComponentSvcs.js +5 -0
  12. package/lib/Components.js +6 -1
  13. package/lib/Config.js +6 -1
  14. package/lib/ConfigLib.js +6 -1
  15. package/lib/CssLib.js +5 -0
  16. package/lib/CssUtils.js +5 -0
  17. package/lib/DomUtils.js +6 -1
  18. package/lib/FileIndex.js +5 -0
  19. package/lib/FileSet.js +5 -0
  20. package/lib/FsUtils.js +6 -1
  21. package/lib/Histo.js +6 -0
  22. package/lib/HtmlTree.js +6 -1
  23. package/lib/HtmlUtils.js +5 -0
  24. package/lib/Issue.js +6 -1
  25. package/lib/JafEvents.js +5 -0
  26. package/lib/JafLib.js +6 -1
  27. package/lib/Json.js +6 -0
  28. package/lib/JsonLoader.js +6 -1
  29. package/lib/Md.js +6 -0
  30. package/lib/MetaLib.js +6 -1
  31. package/lib/NetUtils.js +5 -0
  32. package/lib/NodeTypes.js +5 -0
  33. package/lib/Parser.js +6 -1
  34. package/lib/RegTypes.js +6 -1
  35. package/lib/Registry.js +6 -1
  36. package/lib/Reporter.js +6 -1
  37. package/lib/RuleContext.js +5 -0
  38. package/lib/RulePack.js +5 -0
  39. package/lib/RuleSet.js +6 -1
  40. package/lib/Rules.js +6 -1
  41. package/lib/Scope.js +6 -1
  42. package/lib/SemVer.js +5 -0
  43. package/lib/Server.js +5 -0
  44. package/lib/SevLib.js +5 -0
  45. package/lib/Severity.js +6 -1
  46. package/lib/Stats.js +6 -0
  47. package/lib/Ts.js +6 -1
  48. package/lib/Utils.js +6 -1
  49. package/lib/Watch.js +5 -0
  50. package/lib/Writer.js +5 -0
  51. package/lib/ZipUtils.js +5 -0
  52. package/lib/api.js +6 -0
  53. package/lib/builtinpacks.js +6 -0
  54. package/lib/cliStats.js +6 -0
  55. package/lib/clone.js +6 -1
  56. package/lib/cmdline.js +6 -1
  57. package/lib/colors.js +6 -1
  58. package/lib/defaults.js +6 -0
  59. package/lib/deflist.js +6 -0
  60. package/lib/dislist.js +6 -0
  61. package/lib/exportRules.js +6 -0
  62. package/lib/extends.js +6 -0
  63. package/lib/filetypes.js +6 -0
  64. package/lib/grouplist.js +6 -0
  65. package/lib/groups.js +6 -0
  66. package/lib/help.js +6 -1
  67. package/lib/jetver.js +6 -1
  68. package/lib/macros.js +6 -0
  69. package/lib/manual.js +6 -1
  70. package/lib/metaLoader.js +5 -0
  71. package/lib/metahist.js +5 -0
  72. package/lib/msgidLoader.js +6 -1
  73. package/lib/ns.js +6 -1
  74. package/lib/nslist.js +5 -0
  75. package/lib/outFormat.js +6 -0
  76. package/lib/outfile.js +5 -0
  77. package/lib/ruleLoader.js +5 -0
  78. package/lib/scaffold.js +6 -1
  79. package/lib/scaffoldRule.js +6 -1
  80. package/lib/schema.js +6 -1
  81. package/lib/scopewalker.js +6 -0
  82. package/lib/spinner.js +6 -1
  83. package/lib/spinnernoop.js +5 -0
  84. package/lib/tabs.js +5 -0
  85. package/libext/expparser.js +6 -1
  86. package/meta/11.0.0/jetauditmeta.js +9 -0
  87. package/meta/11.1.0/jetauditmeta.js +9 -0
  88. package/meta/12.0.0/jetauditmeta.js +9 -0
  89. package/meta/metaverlist.json +1 -1
  90. package/package.json +72 -69
  91. package/rulepacks/csp/csp-html-script-unsafe-inline.js +5 -0
  92. package/rulepacks/csp/csp-html-style-unsafe-inline.js +5 -0
  93. package/rulepacks/csp/csp-html-unsafe-expr.js +5 -0
  94. package/rulepacks/csp/csp-js-script-unsafe-eval.js +6 -1
  95. package/rulepacks/csp/csp-js-style-unsafe-inline.js +5 -0
  96. package/rulepacks/csp/csp-ts-script-unsafe-eval.js +6 -0
  97. package/rulepacks/csp/csp-ts-style-unsafe-inline.js +6 -0
  98. package/rulepacks/csp/msgid.json +6 -1
  99. package/rulepacks/csp/rules.json +6 -1
  100. package/rulepacks/jetwc/jetwc-absolute-jetversion.js +6 -1
  101. package/rulepacks/jetwc/jetwc-aria-redefinition.js +6 -1
  102. package/rulepacks/jetwc/jetwc-bootstrap.js +6 -1
  103. package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +6 -1
  104. package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +6 -1
  105. package/rulepacks/jetwc/jetwc-component-dependencies.js +6 -1
  106. package/rulepacks/jetwc/jetwc-component-displayname.js +6 -1
  107. package/rulepacks/jetwc/jetwc-component-foldername.js +6 -1
  108. package/rulepacks/jetwc/jetwc-component-location.js +6 -1
  109. package/rulepacks/jetwc/jetwc-component-type.js +6 -1
  110. package/rulepacks/jetwc/jetwc-css-oj-complete.js +6 -0
  111. package/rulepacks/jetwc/jetwc-data-property-prefix.js +6 -1
  112. package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +6 -1
  113. package/rulepacks/jetwc/jetwc-disabled-property.js +6 -1
  114. package/rulepacks/jetwc/jetwc-displayname.js +6 -1
  115. package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +6 -1
  116. package/rulepacks/jetwc/jetwc-dynamic-slots-naming.js +6 -1
  117. package/rulepacks/jetwc/jetwc-event-displayname.js +6 -1
  118. package/rulepacks/jetwc/jetwc-events.js +6 -1
  119. package/rulepacks/jetwc/jetwc-jet-version.js +6 -1
  120. package/rulepacks/jetwc/jetwc-loader-file.js +6 -1
  121. package/rulepacks/jetwc/jetwc-markdown-link.js +6 -0
  122. package/rulepacks/jetwc/jetwc-method-displayname.js +6 -1
  123. package/rulepacks/jetwc/jetwc-methods.js +6 -1
  124. package/rulepacks/jetwc/jetwc-namespace.js +6 -1
  125. package/rulepacks/jetwc/jetwc-nested-defaults.js +6 -1
  126. package/rulepacks/jetwc/jetwc-nls-languages.js +6 -1
  127. package/rulepacks/jetwc/jetwc-nls-root.js +6 -1
  128. package/rulepacks/jetwc/jetwc-oj-register.js +6 -1
  129. package/rulepacks/jetwc/jetwc-ojcss.js +6 -1
  130. package/rulepacks/jetwc/jetwc-pack-children.js +6 -1
  131. package/rulepacks/jetwc/jetwc-packable-components.js +6 -1
  132. package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +6 -1
  133. package/rulepacks/jetwc/jetwc-prerelease-pattern.js +6 -1
  134. package/rulepacks/jetwc/jetwc-prerelease-version.js +6 -1
  135. package/rulepacks/jetwc/jetwc-property-changed.js +6 -1
  136. package/rulepacks/jetwc/jetwc-property-displayname.js +6 -1
  137. package/rulepacks/jetwc/jetwc-property-nesting.js +6 -1
  138. package/rulepacks/jetwc/jetwc-public-modules.js +6 -1
  139. package/rulepacks/jetwc/jetwc-register-css.js +6 -1
  140. package/rulepacks/jetwc/jetwc-register-with-promises.js +6 -1
  141. package/rulepacks/jetwc/jetwc-require-paths.js +6 -1
  142. package/rulepacks/jetwc/jetwc-required-subproperty.js +6 -0
  143. package/rulepacks/jetwc/jetwc-reserved-property.js +6 -1
  144. package/rulepacks/jetwc/jetwc-schema.js +6 -1
  145. package/rulepacks/jetwc/jetwc-semantic-version.js +6 -1
  146. package/rulepacks/jetwc/jetwc-slot-displayname.js +6 -1
  147. package/rulepacks/jetwc/jetwc-slots.js +6 -1
  148. package/rulepacks/jetwc/jetwc-standard-files.js +6 -1
  149. package/rulepacks/jetwc/jetwc-subproperty-writeback.js +6 -0
  150. package/rulepacks/jetwc/jetwc-template-slots.js +6 -1
  151. package/rulepacks/jetwc/jetwc-unused-events.js +6 -1
  152. package/rulepacks/jetwc/jetwc-unused-slots.js +6 -1
  153. package/rulepacks/jetwc/jetwc-vb-category.js +6 -1
  154. package/rulepacks/jetwc/jetwc-vb-icon.js +6 -1
  155. package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +6 -0
  156. package/rulepacks/jetwc/jetwc-vcomponent-loader.js +6 -0
  157. package/rulepacks/jetwc/jetwc-vcomponent-version.js +6 -0
  158. package/rulepacks/jetwc/jetwc-version-openrange.js +6 -1
  159. package/rulepacks/jetwc/jetwc-writeback-required.js +6 -1
  160. package/rulepacks/jetwc/msgid.json +6 -0
  161. package/rulepacks/jetwc/rules.json +6 -1
  162. package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +6 -0
  163. package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +6 -0
  164. package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +6 -0
  165. package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +6 -0
  166. package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +6 -0
  167. package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +6 -0
  168. package/rulepacks/jetwco/jetwco-bootstrap.js +6 -1
  169. package/rulepacks/jetwco/jetwco-cacc-auditConstraints.js +6 -0
  170. package/rulepacks/jetwco/jetwco-cacc-dependencies.js +6 -0
  171. package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +6 -0
  172. package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +6 -0
  173. package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +6 -0
  174. package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +6 -0
  175. package/rulepacks/jetwco/jetwco-cacc-events.js +6 -0
  176. package/rulepacks/jetwco/jetwco-cacc-helpers.js +6 -0
  177. package/rulepacks/jetwco/jetwco-cacc-jetVer.js +6 -0
  178. package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +6 -0
  179. package/rulepacks/jetwco/jetwco-cacc-methodParams.js +6 -0
  180. package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +6 -0
  181. package/rulepacks/jetwco/jetwco-cacc-methods.js +6 -0
  182. package/rulepacks/jetwco/jetwco-cacc-packBundle.js +6 -0
  183. package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +6 -0
  184. package/rulepacks/jetwco/jetwco-cacc-packContent.js +6 -0
  185. package/rulepacks/jetwco/jetwco-cacc-properties.js +6 -0
  186. package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +6 -0
  187. package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +6 -0
  188. package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +6 -0
  189. package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +6 -0
  190. package/rulepacks/jetwco/jetwco-cacc-propertyType.js +6 -0
  191. package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +6 -0
  192. package/rulepacks/jetwco/jetwco-cacc-publicModules.js +6 -0
  193. package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +6 -0
  194. package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +6 -0
  195. package/rulepacks/jetwco/jetwco-cacc-slots.js +6 -0
  196. package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +6 -0
  197. package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +6 -0
  198. package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +6 -1
  199. package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +6 -0
  200. package/rulepacks/jetwco/jetwco-component-api-changes.js +6 -1
  201. package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +6 -0
  202. package/rulepacks/jetwco/jetwco-component-cdn.js +6 -1
  203. package/rulepacks/jetwco/jetwco-description-standards.js +6 -0
  204. package/rulepacks/jetwco/jetwco-displayname-standards.js +6 -0
  205. package/rulepacks/jetwco/jetwco-exchange-version-check.js +6 -1
  206. package/rulepacks/jetwco/jetwco-license-info.js +6 -1
  207. package/rulepacks/jetwco/jetwco-prerelease-cdn.js +6 -1
  208. package/rulepacks/jetwco/jetwco-thirdparty-ba.js +6 -1
  209. package/rulepacks/jetwco/msgid.json +6 -0
  210. package/rulepacks/jetwco/rules.json +6 -1
  211. package/rulepacks/spoc/msgid.json +5 -0
  212. package/rulepacks/spoc/rules.json +5 -0
  213. package/rulepacks/spoc/spoc-dom-manip-inv-tag.js +5 -0
  214. package/rulepacks/spoc/spoc-dom-manip-tag-pos.js +5 -0
  215. package/rulepacks/spoc/spoc-dom-manip.js +5 -0
  216. package/{tests/rules/oj-js-diagnose/js_FAIL_1.js → rulepacks/wdt/msgid.json} +3 -9
  217. package/rulepacks/wdt/rules.json +6 -0
  218. package/rulepacks/wdt/wd-driver-sleep.js +6 -0
  219. package/rulepacks/wdt/wd-xpath.js +6 -0
  220. package/rules/jaf/jaf-css-diagnose.js +5 -0
  221. package/rules/jaf/jaf-html-diagnose.js +5 -0
  222. package/rules/jaf/jaf-init-schema.js +5 -0
  223. package/rules/jaf/jaf-js-diagnose.js +5 -0
  224. package/rules/jaf/jaf-ts-diagnose.js +6 -0
  225. package/rules/jaf/msgid.json +6 -1
  226. package/rules/jaf/rules.json +6 -1
  227. package/rules/jet/helpers/acc-aria-label.js +6 -1
  228. package/rules/jet/helpers/bp-checkPropType.js +5 -0
  229. package/rules/jet/helpers/cssHelper.js +6 -1
  230. package/rules/jet/helpers/extractStylesFromClass.js +6 -1
  231. package/rules/jet/helpers/has-slot-name.js +6 -1
  232. package/rules/jet/helpers/has-slot.js +5 -0
  233. package/rules/jet/helpers/json-prop-pos.js +5 -0
  234. package/rules/jet/helpers/json-propname-pos.js +5 -0
  235. package/rules/jet/helpers/style-selector.js +6 -1
  236. package/rules/jet/helpers/valid-attr.js +5 -0
  237. package/rules/jet/helpers/vartrack.js +5 -0
  238. package/rules/jet/jet-css-ojselector.js +5 -0
  239. package/rules/jet/msgid.json +6 -1
  240. package/rules/jet/oj-acc-aria-labelledby.js +5 -0
  241. package/rules/jet/oj-acc-aria-prop.js +6 -1
  242. package/rules/jet/oj-acc-avatar-aria-role.js +6 -1
  243. package/rules/jet/oj-acc-combobox-aria-label.js +6 -1
  244. package/rules/jet/oj-acc-film-strip-aria-label.js +6 -1
  245. package/rules/jet/oj-acc-input-aria-label.js +6 -1
  246. package/rules/jet/oj-acc-select-aria-label.js +6 -1
  247. package/rules/jet/oj-cca-compjson-bp-ar.js +5 -0
  248. package/rules/jet/oj-cca-compjson-bp-dsplyname.js +5 -0
  249. package/rules/jet/oj-cca-compjson-bp-jetver.js +5 -0
  250. package/rules/jet/oj-cca-compjson-bp-obj.js +5 -0
  251. package/rules/jet/oj-cca-compjson-ns-reg.js +5 -0
  252. package/rules/jet/oj-css-bp-border-color.js +5 -0
  253. package/rules/jet/oj-css-bp-dir-flow.js +6 -1
  254. package/rules/jet/oj-css-bp-float.js +5 -0
  255. package/rules/jet/oj-css-bp-textalign.js +5 -0
  256. package/rules/jet/oj-css-style-abs-units.js +6 -1
  257. package/rules/jet/oj-css-style-bp-color.js +5 -0
  258. package/rules/jet/oj-css-style-bp-display.js +6 -1
  259. package/rules/jet/oj-css-style-bp-font-family.js +6 -1
  260. package/rules/jet/oj-css-style-bp-font.js +5 -0
  261. package/rules/jet/oj-css-style-deprecated.js +6 -1
  262. package/rules/jet/oj-css-style-override.js +6 -1
  263. package/rules/jet/oj-css-var-override.js +5 -0
  264. package/rules/jet/oj-form-maxcols.js +6 -1
  265. package/rules/jet/oj-html-5-attr-obs.js +5 -0
  266. package/rules/jet/oj-html-5-tag-obs.js +5 -0
  267. package/rules/jet/oj-html-alta-deprecated.js +6 -0
  268. package/rules/jet/oj-html-attr-$unique.js +5 -0
  269. package/rules/jet/oj-html-attr-2def.js +5 -0
  270. package/rules/jet/oj-html-attr-json.js +6 -1
  271. package/rules/jet/oj-html-attr-prefix-expr.js +6 -1
  272. package/rules/jet/oj-html-attr-prefix-ro.js +5 -0
  273. package/rules/jet/oj-html-attr-req.js +5 -0
  274. package/rules/jet/oj-html-bindforeach-data.js +6 -1
  275. package/rules/jet/oj-html-bindif-test.js +6 -1
  276. package/rules/jet/oj-html-binding-attr.js +6 -1
  277. package/rules/jet/oj-html-cca-count.js +5 -0
  278. package/rules/jet/oj-html-cca-tagname.js +6 -1
  279. package/rules/jet/oj-html-cdn.js +5 -0
  280. package/rules/jet/oj-html-combo-converter.js +5 -0
  281. package/rules/jet/oj-html-cspexpr.js +6 -1
  282. package/rules/jet/oj-html-databind-all.js +5 -0
  283. package/rules/jet/oj-html-dlg-title.js +6 -1
  284. package/rules/jet/oj-html-file-pick-accept.js +6 -1
  285. package/rules/jet/oj-html-form-bindif.js +6 -1
  286. package/rules/jet/oj-html-form-layout-maxcols.js +6 -1
  287. package/rules/jet/oj-html-form-noflex.js +5 -0
  288. package/rules/jet/oj-html-input-isodate.js +6 -0
  289. package/rules/jet/oj-html-invalid-doctype.js +6 -1
  290. package/rules/jet/oj-html-jq-databind.js +6 -1
  291. package/rules/jet/oj-html-ko-comment.js +5 -0
  292. package/rules/jet/oj-html-ko-databind.js +6 -1
  293. package/rules/jet/oj-html-label-for-prefix.js +5 -0
  294. package/rules/jet/oj-html-missing-doctype.js +6 -1
  295. package/rules/jet/oj-html-msgs-cat-text.js +6 -0
  296. package/rules/jet/oj-html-no-style-tag.js +6 -0
  297. package/rules/jet/oj-html-notag-style.js +6 -0
  298. package/rules/jet/oj-html-oj-lib.js +5 -0
  299. package/rules/jet/oj-html-ojattr-520.js +6 -1
  300. package/rules/jet/oj-html-ojattr-deprecated.js +6 -1
  301. package/rules/jet/oj-html-ojattr-enum-deprecated.js +6 -1
  302. package/rules/jet/oj-html-ojattr-evt-syntax.js +6 -1
  303. package/rules/jet/oj-html-ojattr-value.js +6 -1
  304. package/rules/jet/oj-html-ojattr.js +6 -1
  305. package/rules/jet/oj-html-ojevent.js +6 -1
  306. package/rules/jet/oj-html-ojslot.js +6 -1
  307. package/rules/jet/oj-html-ojstyle.js +5 -0
  308. package/rules/jet/oj-html-ojtag-datacmd.js +6 -1
  309. package/rules/jet/oj-html-ojtag-datactx.js +5 -0
  310. package/rules/jet/oj-html-ojtag-deprecated.js +6 -1
  311. package/rules/jet/oj-html-ojtag-globattr-noprefix.js +6 -1
  312. package/rules/jet/oj-html-ojtag-id.js +5 -0
  313. package/rules/jet/oj-html-ojtag-nonglobattr-prefix.js +6 -1
  314. package/rules/jet/oj-html-ojtag-ns.js +5 -0
  315. package/rules/jet/oj-html-picker-attrs.js +6 -0
  316. package/rules/jet/oj-html-redwood-cssnovars.js +6 -0
  317. package/rules/jet/oj-html-redwood-cssvars.js +6 -0
  318. package/rules/jet/oj-html-self-close.js +5 -0
  319. package/rules/jet/oj-html-slot-item-minmax.js +6 -0
  320. package/rules/jet/oj-html-slot-name.js +6 -1
  321. package/rules/jet/oj-html-slot-pref-content.js +6 -0
  322. package/rules/jet/oj-html-style-abs-units.js +5 -0
  323. package/rules/jet/oj-html-style-bp-color.js +5 -0
  324. package/rules/jet/oj-html-style-bp-display.js +6 -1
  325. package/rules/jet/oj-html-style-bp-font-family.js +5 -0
  326. package/rules/jet/oj-html-style-bp-font.js +5 -0
  327. package/rules/jet/oj-html-style-deprecated.js +6 -1
  328. package/rules/jet/oj-html-style.js +6 -1
  329. package/rules/jet/oj-html-stylesel.js +6 -1
  330. package/rules/jet/oj-html-tag-attr-noprefix.js +6 -1
  331. package/rules/jet/oj-html-template-index.js +6 -1
  332. package/rules/jet/oj-html-unsup-theme.js +6 -1
  333. package/rules/jet/oj-html-wctag-$props.js +6 -1
  334. package/rules/jet/oj-html-wctag-arialabelledby.js +5 -0
  335. package/rules/jet/oj-html-wctag-for.js +5 -0
  336. package/rules/jet/oj-html-wctag-id.js +6 -1
  337. package/rules/jet/oj-html-wctag-nested.js +6 -0
  338. package/rules/jet/oj-html-wctag-packprivate.js +6 -0
  339. package/rules/jet/oj-js-comp-attr-deprecated.js +6 -1
  340. package/rules/jet/oj-js-comp-meth-deprecated.js +6 -1
  341. package/rules/jet/oj-js-no-ext-final.js +5 -0
  342. package/rules/jet/oj-js-noconsole.js +5 -0
  343. package/rules/jet/oj-js-ojcomp-deprecated.js +6 -1
  344. package/rules/jet/oj-js-ojcomp-exist.js +5 -0
  345. package/rules/jet/oj-js-ojcomp-new.js +5 -0
  346. package/rules/jet/oj-js-poly-promise.js +6 -1
  347. package/rules/jet/oj-js-var-undef.js +5 -0
  348. package/rules/jet/oj-json-syntax.js +5 -0
  349. package/rules/jet/oj-ts-comp-attr-deprecated.js +6 -1
  350. package/rules/jet/oj-ts-comp-meth-deprecated.js +6 -1
  351. package/rules/jet/oj-ts-no-ext-final.js +6 -0
  352. package/rules/jet/oj-ts-noconsole.js +6 -1
  353. package/rules/jet/oj-ts-ojcomp-deprecated.js +6 -1
  354. package/rules/jet/oj-ts-ojcomp-exist.js +6 -1
  355. package/rules/jet/oj-ts-ojcomp-new.js +6 -1
  356. package/rules/jet/oj-ts-poly-promise.js +6 -1
  357. package/rules/jet/rules.json +6 -1
  358. package/schema/component-schema.json +125 -2
  359. package/src/JafCore.js +6 -1
  360. package/types/index.d.ts +175 -37
  361. package/lib/stats.js +0 -1
  362. package/rulepacks/jetwc-lib/component-audit-utils.js +0 -1
  363. package/rules/exch/helpers/json-prop-pos.js +0 -1
  364. package/rules/exch/msgid.json +0 -1
  365. package/rules/exch/oj-cca-comp-zip-content-composite.js +0 -1
  366. package/rules/exch/oj-cca-comp-zip-content-pack.js +0 -1
  367. package/rules/exch/oj-cca-comp-zip-expand.js +0 -1
  368. package/rules/exch/oj-cca-compjson-evnames.js +0 -1
  369. package/rules/exch/oj-cca-compjson-file.js +0 -1
  370. package/rules/exch/oj-cca-compjson-prefix.js +0 -1
  371. package/rules/exch/oj-cca-compjson-prop-compdeps.js +0 -1
  372. package/rules/exch/oj-cca-compjson-prop-deps.js +0 -1
  373. package/rules/exch/oj-cca-compjson-prop-jetver.js +0 -1
  374. package/rules/exch/oj-cca-compjson-prop-obs.js +0 -1
  375. package/rules/exch/oj-cca-compjson-prop-type.js +0 -1
  376. package/rules/exch/oj-cca-compjson-prop-types.js +0 -1
  377. package/rules/exch/oj-cca-compjson-prop-undef.js +0 -1
  378. package/rules/exch/oj-cca-compjson-prop-version.js +0 -1
  379. package/rules/exch/oj-cca-compjson-schema.js +0 -1
  380. package/rules/exch/oj-cca-zip-compjson.js +0 -1
  381. package/rules/exch/rules.json +0 -1
  382. package/rules/jet/oj-css-bp-bgcolor.js +0 -1
  383. package/tests/components/attr-req-test/component.json +0 -1
  384. package/tests/components/demo-analog-clock/component.json +0 -1
  385. package/tests/components/demo-analog-clock/demo-analog-clock-viewModel.js +0 -1
  386. package/tests/components/demo-analog-clock/extension/demo/js/viewModels/demo.js +0 -1
  387. package/tests/components/demo-analog-clock/loader.js +0 -1
  388. package/tests/components/demo-card/component.json +0 -1
  389. package/tests/components/demo-chart-orientation-control/component.json +0 -1
  390. package/tests/components/demo-chart-stack-control/component.json +0 -1
  391. package/tests/components/made-up/component.json +0 -1
  392. package/tests/components/oj-made-up/component.json +0 -1
  393. package/tests/components/sp-activity-item/component.json +0 -1
  394. package/tests/config/config_base.json +0 -1
  395. package/tests/golden/10.0.0/golden_base.json +0 -1
  396. package/tests/golden/8.1.0/golden_base.json +0 -1
  397. package/tests/golden/9.0.0/golden_base.json +0 -1
  398. package/tests/rulepacks/hooks/hook-rpext.js +0 -1
  399. package/tests/rulepacks/hooks/hook-start-close-rulepack.js +0 -1
  400. package/tests/rulepacks/hooks/rule-rpext.js +0 -1
  401. package/tests/rulepacks/hooks/rules.json +0 -1
  402. package/tests/rulepacks/tags/proc_directive.js +0 -1
  403. package/tests/rulepacks/tags/rules.json +0 -1
  404. package/tests/rulepacks/tags/tag-count-setup.js +0 -1
  405. package/tests/rulepacks/tags/tag-count.js +0 -1
  406. package/tests/rules/bugs/JET-4770_PASS_1.html +0 -9
  407. package/tests/rules/comments/com_FAIL_1.js +0 -57
  408. package/tests/rules/comments/com_FAIL_2.js +0 -96
  409. package/tests/rules/comments/com_PASS_1.js +0 -42
  410. package/tests/rules/comments/com_PASS_2.js +0 -63
  411. package/tests/rules/comments/com_PASS_3.js +0 -40
  412. package/tests/rules/comments/com_PASS_4.js +0 -36
  413. package/tests/rules/comments/com_PASS_5.js +0 -19
  414. package/tests/rules/csp/html-script-unsafe-inline/FAIL_1.html +0 -11
  415. package/tests/rules/csp/html-script-unsafe-inline/FAIL_2.html +0 -8
  416. package/tests/rules/csp/html-script-unsafe-inline/PASS_1.html +0 -8
  417. package/tests/rules/csp/html-script-unsafe-inline/PASS_2.html +0 -8
  418. package/tests/rules/csp/html-script-unsafe-inline/PASS_3.html +0 -8
  419. package/tests/rules/csp/html-style-unsafe-inline/FAIL_1.html +0 -11
  420. package/tests/rules/csp/html-style-unsafe-inline/PASS_1.html +0 -11
  421. package/tests/rules/csp/html-unsafe-expr/FAIL_1.html +0 -14
  422. package/tests/rules/csp/html-unsafe-expr/PASS_1.html +0 -23
  423. package/tests/rules/csp/js-script-unsafe-eval/FAIL_1.js +0 -17
  424. package/tests/rules/csp/js-script-unsafe-eval/FAIL_2.js +0 -40
  425. package/tests/rules/csp/js-script-unsafe-eval/FAIL_3.js +0 -22
  426. package/tests/rules/csp/js-script-unsafe-eval/PASS_1.js +0 -20
  427. package/tests/rules/csp/js-script-unsafe-eval/PASS_2.js +0 -44
  428. package/tests/rules/csp/js-script-unsafe-eval/PASS_3.js +0 -16
  429. package/tests/rules/csp/js-style-unsafe-inline/FAIL_1.js +0 -25
  430. package/tests/rules/csp/js-style-unsafe-inline/PASS.js +0 -22
  431. package/tests/rules/demo/noself_FAIL_1.js +0 -101
  432. package/tests/rules/import/import_FAIL_1.js +0 -11
  433. package/tests/rules/import/import_PASS_1.js +0 -10
  434. package/tests/rules/jet-composites/demo-buttonset-enum/component.json +0 -57
  435. package/tests/rules/jet-composites/demo-buttonset-enum/loader.js +0 -19
  436. package/tests/rules/jet-composites/demo-buttonset-enum/view.html +0 -48
  437. package/tests/rules/jet-composites/demo-card/component.json +0 -28
  438. package/tests/rules/jet-composites/demo-card/loader.js +0 -16
  439. package/tests/rules/jet-composites/demo-card/view.html +0 -30
  440. package/tests/rules/jet-composites/demo-card/viewModel.js +0 -46
  441. package/tests/rules/jet-composites/demo-card/view_PASS_1.html +0 -21
  442. package/tests/rules/jet-composites/demo-contact-form/component.json +0 -23
  443. package/tests/rules/jet-composites/demo-contact-form/loader.js +0 -16
  444. package/tests/rules/jet-composites/demo-contact-form/view.html +0 -9
  445. package/tests/rules/jet-composites/demo-grocery-list/component.json +0 -18
  446. package/tests/rules/jet-composites/demo-grocery-list/loader.js +0 -19
  447. package/tests/rules/jet-composites/demo-grocery-list/view.html +0 -22
  448. package/tests/rules/jet-composites/demo-grocery-list/viewModel.js +0 -48
  449. package/tests/rules/jet-composites/dummy-component-1/component.json +0 -82
  450. package/tests/rules/jet-composites/dummy-component-2/component.json +0 -72
  451. package/tests/rules/jet-composites/foo-my-cca/component.json +0 -14
  452. package/tests/rules/jet-composites/foo-unsup-theme/component.json +0 -29
  453. package/tests/rules/jet-composites/header/component.json +0 -12
  454. package/tests/rules/jet-composites/oj-cgbu-omc/attribute-selection/component.json +0 -154
  455. package/tests/rules/jet-composites/oj-cgbu-omc/component.json +0 -11
  456. package/tests/rules/jet-composites/oj-cgbu-omc/reference/component.json +0 -185
  457. package/tests/rules/jet-composites/oj-cgbu-omc/wctag_props_FAIL_1.html +0 -34
  458. package/tests/rules/jet-composites/oj-enum-depr/component.json +0 -69
  459. package/tests/rules/jet-composites/oj-html-wctag-id/id_FAIL_1.html +0 -10
  460. package/tests/rules/jet-composites/oj-html-wctag-id/id_PASS_1.html +0 -6
  461. package/tests/rules/misc/oj.js +0 -12
  462. package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_FAIL_1.html +0 -23
  463. package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_FAIL_2.html +0 -22
  464. package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_1.html +0 -23
  465. package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_2.html +0 -22
  466. package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_3.html +0 -22
  467. package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_4.html +0 -22
  468. package/tests/rules/oj-acc-aria-labelledby/aria_labelledby_PASS_5.html +0 -22
  469. package/tests/rules/oj-acc-aria-prop/aria_prop_FAIL_1.html +0 -22
  470. package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_FAIL_1.html +0 -20
  471. package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_1.html +0 -23
  472. package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_2.html +0 -24
  473. package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_3.html +0 -21
  474. package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_4.html +0 -22
  475. package/tests/rules/oj-acc-avatar-aria-role/aria_avatar_role_PASS_5.html +0 -22
  476. package/tests/rules/oj-acc-combobox-aria-label/aria_combo_many_FAIL_1.html +0 -20
  477. package/tests/rules/oj-acc-combobox-aria-label/aria_combo_many_FAIL_2.html +0 -21
  478. package/tests/rules/oj-acc-combobox-aria-label/aria_combo_many_PASS_1.html +0 -20
  479. package/tests/rules/oj-acc-combobox-aria-label/aria_combo_one_FAIL_1.html +0 -21
  480. package/tests/rules/oj-acc-combobox-aria-label/aria_combo_one_FAIL_2.html +0 -22
  481. package/tests/rules/oj-acc-combobox-aria-label/aria_combo_one_PASS_1.html +0 -22
  482. package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_FAIL_1.html +0 -18
  483. package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_FAIL_2.html +0 -18
  484. package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_PASS_1.html +0 -18
  485. package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_PASS_2.html +0 -19
  486. package/tests/rules/oj-acc-film-strip-aria-label/aria_filmstrip_PASS_3.html +0 -22
  487. package/tests/rules/oj-acc-input-aria-label/oj_input_date_FAIL_1.html +0 -21
  488. package/tests/rules/oj-acc-input-aria-label/oj_input_date_FAIL_2.html +0 -22
  489. package/tests/rules/oj-acc-input-aria-label/oj_input_date_PASS_1.html +0 -16
  490. package/tests/rules/oj-acc-input-aria-label/oj_input_date_PASS_2.html +0 -17
  491. package/tests/rules/oj-acc-input-aria-label/oj_input_date_PASS_3.html +0 -26
  492. package/tests/rules/oj-acc-input-aria-label/oj_input_date_time_FAIL_1.html +0 -19
  493. package/tests/rules/oj-acc-input-aria-label/oj_input_date_time_FAIL_2.html +0 -20
  494. package/tests/rules/oj-acc-input-aria-label/oj_input_date_time_PASS_1.html +0 -19
  495. package/tests/rules/oj-acc-input-aria-label/oj_input_number_FAIL_1.html +0 -17
  496. package/tests/rules/oj-acc-input-aria-label/oj_input_number_FAIL_2.html +0 -18
  497. package/tests/rules/oj-acc-input-aria-label/oj_input_number_PASS_1.html +0 -17
  498. package/tests/rules/oj-acc-input-aria-label/oj_input_password_FAIL_1.html +0 -17
  499. package/tests/rules/oj-acc-input-aria-label/oj_input_password_FAIL_2.html +0 -17
  500. package/tests/rules/oj-acc-input-aria-label/oj_input_password_PASS_1.html +0 -17
  501. package/tests/rules/oj-acc-input-aria-label/oj_input_text_3_PASS_1.html +0 -20
  502. package/tests/rules/oj-acc-input-aria-label/oj_input_text_FAIL_1.html +0 -20
  503. package/tests/rules/oj-acc-input-aria-label/oj_input_text_FAIL_2.html +0 -21
  504. package/tests/rules/oj-acc-input-aria-label/oj_input_text_PASS_2.html +0 -62
  505. package/tests/rules/oj-acc-input-aria-label/oj_input_text_nolabel_PASS_2.html +0 -17
  506. package/tests/rules/oj-acc-input-aria-label/oj_input_time_FAIL_1.html +0 -19
  507. package/tests/rules/oj-acc-input-aria-label/oj_input_time_FAIL_2.html +0 -20
  508. package/tests/rules/oj-acc-input-aria-label/oj_input_time_PASS_1.html +0 -19
  509. package/tests/rules/oj-acc-select-aria-label/aria_selectmany_FAIL_1.html +0 -19
  510. package/tests/rules/oj-acc-select-aria-label/aria_selectmany_FAIL_2.html +0 -20
  511. package/tests/rules/oj-acc-select-aria-label/aria_selectmany_PASS_1.html +0 -19
  512. package/tests/rules/oj-acc-select-aria-label/aria_selectone_FAIL_1.html +0 -20
  513. package/tests/rules/oj-acc-select-aria-label/aria_selectone_FAIL_2.html +0 -21
  514. package/tests/rules/oj-cca-comp-zip/zip_FAIL_1.zip +0 -1
  515. package/tests/rules/oj-cca-comp-zip/zip_FAIL_2.zip +0 -0
  516. package/tests/rules/oj-cca-comp-zip/zip_FAIL_3.zip +0 -0
  517. package/tests/rules/oj-cca-comp-zip/zip_FAIL_4.zip +0 -0
  518. package/tests/rules/oj-cca-comp-zip/zip_FAIL_5.zip +0 -0
  519. package/tests/rules/oj-cca-comp-zip/zip_FAIL_6.zip +0 -0
  520. package/tests/rules/oj-cca-comp-zip/zip_FAIL_7.zip +0 -0
  521. package/tests/rules/oj-cca-comp-zip/zip_FAIL_8.zip +0 -0
  522. package/tests/rules/oj-cca-comp-zip/zip_PASS_1.zip +0 -0
  523. package/tests/rules/oj-cca-ns-reg/oj-cca-ns-FAIL_1/component.json +0 -19
  524. package/tests/rules/oj-cca-ns-reg/oj-cca-ns-PASS_1/component.json +0 -19
  525. package/tests/rules/oj-cgbu-omc_tests/html_ojevent_FAIL_1.html +0 -15
  526. package/tests/rules/oj-cgbu-omc_tests/html_ojevent_PASS_1.html +0 -17
  527. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_1/component.json +0 -16
  528. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_10/component.json +0 -103
  529. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_11/component.json +0 -24
  530. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_12/component.json +0 -17
  531. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_13/component.json +0 -17
  532. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_14/component.json +0 -40
  533. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_15/component.json +0 -24
  534. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_16/component.json +0 -44
  535. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_17/component.json +0 -8
  536. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_18/component.json +0 -8
  537. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_19/component.json +0 -8
  538. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_2/component.json +0 -15
  539. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_20/component.json +0 -18
  540. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_21/component.json +0 -16
  541. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_22/component.json +0 -19
  542. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_3/component.json +0 -15
  543. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_4/component.json +0 -16
  544. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_5/component.json +0 -16
  545. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_6/component.json +0 -18
  546. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_7/component.json +0 -15
  547. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_8/component.json +0 -15
  548. package/tests/rules/oj-compjson-syntax/ojcomp-FAIL_9/component.json +0 -52
  549. package/tests/rules/oj-compjson-syntax/ojcomp-PASS_1/component.json +0 -17
  550. package/tests/rules/oj-compjson-syntax/ojcomp-PASS_2/component.json +0 -88
  551. package/tests/rules/oj-compjson-syntax/ojcomp-PASS_3/component.json +0 -19
  552. package/tests/rules/oj-css-bp-dir-flow/dirflow_FAIL_1.html +0 -22
  553. package/tests/rules/oj-css-bp-dir-flow/dirflow_FAIL_2.html +0 -22
  554. package/tests/rules/oj-css-diagnose/css_FAIL_1.html +0 -14
  555. package/tests/rules/oj-css-diagnose/css_PASS_1.html +0 -14
  556. package/tests/rules/oj-css-var-override/varovr_FAIL_1.html +0 -8
  557. package/tests/rules/oj-html-5-attr-depr/attrdepr_FAIL_1.html +0 -16
  558. package/tests/rules/oj-html-5-attr-depr/attrdepr_PASS_1.html +0 -16
  559. package/tests/rules/oj-html-5-tag-depr/tagdepr_FAIL_1.html +0 -9
  560. package/tests/rules/oj-html-attr/attr_FAIL_1.html +0 -27
  561. package/tests/rules/oj-html-attr-$unique/attr_$unique1_FAIL_1.html +0 -19
  562. package/tests/rules/oj-html-attr-$unique/attr_$unique_FAIL_2.html +0 -25
  563. package/tests/rules/oj-html-attr-2def/attr2def_FAIL_1.html +0 -10
  564. package/tests/rules/oj-html-attr-2def/attr2def_PASS_1.html +0 -10
  565. package/tests/rules/oj-html-attr-json/attr-json_FAIL_1.html +0 -20
  566. package/tests/rules/oj-html-attr-json/attr-json_FAIL_2.html +0 -20
  567. package/tests/rules/oj-html-attr-json/attr-json_FAIL_3.html +0 -20
  568. package/tests/rules/oj-html-attr-json/attr-json_PASS_1.html +0 -20
  569. package/tests/rules/oj-html-attr-json/attr-json_PASS_2.html +0 -20
  570. package/tests/rules/oj-html-attr-json/attr-json_PASS_3.html +0 -8
  571. package/tests/rules/oj-html-attr-prefix-expr/attrprefixexpr_FAIL_1.html +0 -10
  572. package/tests/rules/oj-html-attr-prefix-expr/attrprefixexpr_PASS_1.html +0 -10
  573. package/tests/rules/oj-html-attr-prefix-ro/attrprefixro_FAIL_1.html +0 -10
  574. package/tests/rules/oj-html-attr-prefix-ro/attrprefixro_PASS_1.html +0 -10
  575. package/tests/rules/oj-html-attr-req/attrreq_FAIL_1.html +0 -17
  576. package/tests/rules/oj-html-attr-req/attrreq_FAIL_2.html +0 -13
  577. package/tests/rules/oj-html-attr-req/attrreq_FAIL_3.html +0 -8
  578. package/tests/rules/oj-html-attr-req/attrreq_FAIL_4.html +0 -13
  579. package/tests/rules/oj-html-attr-req/attrreq_FAIL_5.html +0 -17
  580. package/tests/rules/oj-html-attr-req/attrreq_PASS_1.html +0 -24
  581. package/tests/rules/oj-html-attr-req/attrreq_PASS_2.html +0 -24
  582. package/tests/rules/oj-html-attr-req/attrreq_PASS_3.html +0 -10
  583. package/tests/rules/oj-html-attr-req/attrreq_PASS_4.html +0 -11
  584. package/tests/rules/oj-html-bindforeach-data/bindforeach_data_FAIL_1.html +0 -19
  585. package/tests/rules/oj-html-bindforeach-data/bindforeach_data_PASS_1.html +0 -10
  586. package/tests/rules/oj-html-bindif-test/bindif_test_FAIL_1.html +0 -22
  587. package/tests/rules/oj-html-bindif-test/bindif_test_PASS_1.html +0 -11
  588. package/tests/rules/oj-html-binding-attr/binding-foreach_FAIL_2.html +0 -28
  589. package/tests/rules/oj-html-binding-attr/binding-if_FAIL_1.html +0 -23
  590. package/tests/rules/oj-html-binding-attr/binding-if_PASS_1.html +0 -23
  591. package/tests/rules/oj-html-cca-count/cca-count_FAIL_1.html +0 -119
  592. package/tests/rules/oj-html-cca-tagname/ccatag_FAIL_1.html +0 -7
  593. package/tests/rules/oj-html-cca-tagname/ccatag_PASS_1.html +0 -7
  594. package/tests/rules/oj-html-cca-tagname/tag_ns_FAIL_1.html +0 -8
  595. package/tests/rules/oj-html-cca-tagname/tag_ns_FAIL_2.html +0 -8
  596. package/tests/rules/oj-html-cca-tagname/tag_ns_FAIL_3.html +0 -8
  597. package/tests/rules/oj-html-cca-tagname/tag_ns_PASS_1.html +0 -10
  598. package/tests/rules/oj-html-cdn/html_cdn_FAIL_1.html +0 -18
  599. package/tests/rules/oj-html-cspexpr/cspexpr_FAIL_1.html +0 -14
  600. package/tests/rules/oj-html-cspexpr/cspexpr_FAIL_2.html +0 -10
  601. package/tests/rules/oj-html-cspexpr/cspexpr_PASS_1.html +0 -23
  602. package/tests/rules/oj-html-cspexpr/cspexpr_PASS_2.html +0 -10
  603. package/tests/rules/oj-html-cspexpr/cspexpr_PASS_3.html +0 -13
  604. package/tests/rules/oj-html-dlg-title/dlgtitle_FAIL_1.html +0 -12
  605. package/tests/rules/oj-html-dlg-title/dlgtitle_PASS_1.html +0 -12
  606. package/tests/rules/oj-html-form-noflex/noflex_FAIL_1.html +0 -10
  607. package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_1.html +0 -20
  608. package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_2.html +0 -13
  609. package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_3.html +0 -16
  610. package/tests/rules/oj-html-invalid-doctype/doctype_invalid_FAIL_4.html +0 -13
  611. package/tests/rules/oj-html-invalid-doctype/doctype_invalid_PASS_1.html +0 -6
  612. package/tests/rules/oj-html-invalid-doctype/doctype_invalid_PASS_2.html +0 -7
  613. package/tests/rules/oj-html-invalid-doctype/doctype_invalid_PASS_3.html +0 -7
  614. package/tests/rules/oj-html-jq-databind/jq-databind_FAIL_1.html +0 -37
  615. package/tests/rules/oj-html-jq-databind/jq-databind_FAIL_2.html +0 -34
  616. package/tests/rules/oj-html-jq-databind/jq-databind_FAIL_3.html +0 -27
  617. package/tests/rules/oj-html-jq-databind/jq-databind_PASS_1.html +0 -30
  618. package/tests/rules/oj-html-ko-comment/ko-comment_FAIL_1.html +0 -47
  619. package/tests/rules/oj-html-ko-comment/ko-comment_FAIL_2.html +0 -36
  620. package/tests/rules/oj-html-ko-databind/ko-databind_FAIL_1.html +0 -24
  621. package/tests/rules/oj-html-ko-databind/ko-databind_FAIL_2.html +0 -36
  622. package/tests/rules/oj-html-ko-databind/ko-databind_FAIL_3.html +0 -29
  623. package/tests/rules/oj-html-label-for-prefix/for_FAIL_1.html +0 -8
  624. package/tests/rules/oj-html-label-for-prefix/for_PASS_1.html +0 -8
  625. package/tests/rules/oj-html-missing-doctype/doctype_missing_FAIL_1.html +0 -12
  626. package/tests/rules/oj-html-missing-doctype/doctype_missing_FAIL_2.html +0 -11
  627. package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_1.html +0 -14
  628. package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_2.html +0 -5
  629. package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_3.html +0 -12
  630. package/tests/rules/oj-html-missing-doctype/doctype_missing_PASS_5.html +0 -6
  631. package/tests/rules/oj-html-nonvoid-close/close_FAIL_1.html +0 -28
  632. package/tests/rules/oj-html-nonvoid-close/close_FAIL_2.html +0 -14
  633. package/tests/rules/oj-html-nonvoid-close/close_FAIL_3.html +0 -13
  634. package/tests/rules/oj-html-nonvoid-close/close_FAIL_5.html +0 -28
  635. package/tests/rules/oj-html-nonvoid-close/close_FAIL_6.html +0 -28
  636. package/tests/rules/oj-html-nonvoid-close/close_PASS_1.html +0 -7
  637. package/tests/rules/oj-html-oj-lib/oj_lib_FAIL_1.html +0 -15
  638. package/tests/rules/oj-html-ojattr/ojattr_PASS_1.html +0 -8
  639. package/tests/rules/oj-html-ojattr/ojattr_PASS_2.html +0 -10
  640. package/tests/rules/oj-html-ojattr/ojattr_PASS_3.html +0 -7
  641. package/tests/rules/oj-html-ojattr/ojattr_PASS_4.html +0 -7
  642. package/tests/rules/oj-html-ojattr-deprecated/ojattr-dep_FAIL1.html +0 -156
  643. package/tests/rules/oj-html-ojattr-enum-deprecated/enum_FAIL_1.html +0 -19
  644. package/tests/rules/oj-html-ojattr-enum-deprecated/enum_FAIL_2.html +0 -20
  645. package/tests/rules/oj-html-ojattr-enum-deprecated/enum_PASS_1.html +0 -25
  646. package/tests/rules/oj-html-ojattr-evt-syntax/evt-attr-syntax_FAIL_1.html +0 -6
  647. package/tests/rules/oj-html-ojattr-evt-syntax/evt-attr-syntax_PASS_1.html +0 -6
  648. package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_1.html +0 -26
  649. package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_2.html +0 -26
  650. package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_3.html +0 -8
  651. package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_4.html +0 -8
  652. package/tests/rules/oj-html-ojattr-value/attr-value_FAIL_5.html +0 -8
  653. package/tests/rules/oj-html-ojattr-value/attr-value_PASS_1.html +0 -26
  654. package/tests/rules/oj-html-ojattr-value/attr-value_PASS_2.html +0 -8
  655. package/tests/rules/oj-html-ojattr-value/attr-value_PASS_3.html +0 -7
  656. package/tests/rules/oj-html-ojattr-value/attr-value_PASS_6.html +0 -7
  657. package/tests/rules/oj-html-ojattr-value/attr-value_PASS_7.html +0 -10
  658. package/tests/rules/oj-html-ojattr-value/attr_value_PASS_4.html +0 -7
  659. package/tests/rules/oj-html-ojattr-value/attr_value_PASS_5.html +0 -9
  660. package/tests/rules/oj-html-ojslot/ojslot_FAIL_1.html +0 -11
  661. package/tests/rules/oj-html-ojslot/ojslot_PASS_1.html +0 -12
  662. package/tests/rules/oj-html-ojstyle/style_FAIL_1.html +0 -103
  663. package/tests/rules/oj-html-ojstyle/style_PASS_2.html +0 -7
  664. package/tests/rules/oj-html-ojtag-datacmd/datacmd_FAIL_1.html +0 -10
  665. package/tests/rules/oj-html-ojtag-datacmd/datacmd_FAIL_2.html +0 -18
  666. package/tests/rules/oj-html-ojtag-datacmd/datacmd_FAIL_3.html +0 -10
  667. package/tests/rules/oj-html-ojtag-datacmd/datacmd_PASS_1.html +0 -28
  668. package/tests/rules/oj-html-ojtag-datacmd/datacmd_PASS_2.html +0 -15
  669. package/tests/rules/oj-html-ojtag-datactx/datactx_FAIL_1.html +0 -14
  670. package/tests/rules/oj-html-ojtag-datactx/datactx_PASS_1.html +0 -14
  671. package/tests/rules/oj-html-ojtag-globattr-noprefix/globattr-noprefix_FAIL_1.html +0 -36
  672. package/tests/rules/oj-html-ojtag-nonglobattr-prefix/nonglobattr-prefix_FAIL_1.html +0 -26
  673. package/tests/rules/oj-html-slot-name/slot_name.FAIL_1.html +0 -24
  674. package/tests/rules/oj-html-slot-name/slot_name.FAIL_2.html +0 -46
  675. package/tests/rules/oj-html-slot-name/slot_name.FAIL_3.html +0 -10
  676. package/tests/rules/oj-html-slot-name/slot_name.PASS_1.html +0 -24
  677. package/tests/rules/oj-html-slot-name/slot_name.PASS_2.html +0 -39
  678. package/tests/rules/oj-html-slot-name/slot_name.PASS_3.html +0 -10
  679. package/tests/rules/oj-html-slot-name/slot_name_PASS_4.html +0 -16
  680. package/tests/rules/oj-html-slot-name/slot_name_PASS_5.html +0 -11
  681. package/tests/rules/oj-html-slot-name/slot_name_PASS_6.html +0 -14
  682. package/tests/rules/oj-html-slot-name/slot_name_PASS_7.html +0 -10
  683. package/tests/rules/oj-html-style/style_FAIL_1.html +0 -7
  684. package/tests/rules/oj-html-style/style_PASS_1.html +0 -12
  685. package/tests/rules/oj-html-style/style_PASS_2.html +0 -7
  686. package/tests/rules/oj-html-style-bp-color/color-FAIL_1.html +0 -17
  687. package/tests/rules/oj-html-style-bp-color/color-FAIL_2.html +0 -15
  688. package/tests/rules/oj-html-style-bp-color/color-FAIL_3.html +0 -7
  689. package/tests/rules/oj-html-style-bp-color/color-PASS_1.html +0 -7
  690. package/tests/rules/oj-html-style-bp-font-family/fam_FAIL_1.html +0 -23
  691. package/tests/rules/oj-html-tag-attr-noprefix/attr-noprefix_FAIL_1.html +0 -15
  692. package/tests/rules/oj-html-tag-attr-noprefix/attr-noprefix_FAIL_2.html +0 -9
  693. package/tests/rules/oj-html-tag-attr-noprefix/attr-noprefix_PASS_1.html +0 -9
  694. package/tests/rules/oj-html-unsup-theme/unsup_FAIL_1.html +0 -8
  695. package/tests/rules/oj-html-wctag-for/for_FAIL_1.html +0 -8
  696. package/tests/rules/oj-html-wctag-for/for_PASS_1.html +0 -8
  697. package/tests/rules/oj-js-comp-attr-deprecated/attr-del_FAIL_1.js +0 -20
  698. package/tests/rules/oj-js-comp-attr-deprecated/attr-dep_FAIL_1.js +0 -20
  699. package/tests/rules/oj-js-comp-meth-deprecated/meth-del_FAIL_1.js +0 -20
  700. package/tests/rules/oj-js-comp-meth-deprecated/meth-dep_FAIL_1.js +0 -20
  701. package/tests/rules/oj-js-define-promise/def-prom_FAIL_1.js +0 -16
  702. package/tests/rules/oj-js-define-promise/def-prom_FAIL_2.js +0 -16
  703. package/tests/rules/oj-js-diagnose/es6_PASS_1.js +0 -24
  704. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_1.js +0 -30
  705. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_2.js +0 -23
  706. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_3.js +0 -22
  707. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_4.js +0 -20
  708. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_5.js +0 -24
  709. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_6.js +0 -30
  710. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_7.js +0 -15
  711. package/tests/rules/oj-js-no-ext-final/noextfinal_FAIL_8.js +0 -16
  712. package/tests/rules/oj-js-no-ext-final/noextfinal_PASS_1.js +0 -17
  713. package/tests/rules/oj-js-no-ext-final/noextfinal_PASS_2.js +0 -17
  714. package/tests/rules/oj-js-noconsole/nocons_FAIL_1.js +0 -11
  715. package/tests/rules/oj-js-ojcomp-deprecated/jscomp_FAIL_1.js +0 -27
  716. package/tests/rules/oj-json-syntax/json_FAIL_1.json +0 -8
  717. package/tests/rules/oj-json-syntax/json_FAIL_2.json +0 -12
  718. package/tests/rules/oj-json-syntax/json_PASS_1.json +0 -25
  719. package/tests/rules/oj-json-syntax/json_PASS_2.json +0 -12
  720. package/tests/rules/oj-json-syntax/json_PASS_3.json +0 -14
  721. package/tests/rules/ojcompjson/attrreq_FAIL_1/component.json +0 -69
  722. package/tests/rules/pack-compjson/audit-pack/component-1/component-1-view.html +0 -6
  723. package/tests/rules/pack-compjson/audit-pack/component-1/component-1-viewModel.js +0 -56
  724. package/tests/rules/pack-compjson/audit-pack/component-1/component.json +0 -13
  725. package/tests/rules/pack-compjson/audit-pack/component-1/loader.js +0 -20
  726. package/tests/rules/pack-compjson/audit-pack/component-1/resources/nls/component-1-strings.js +0 -18
  727. package/tests/rules/pack-compjson/audit-pack/component-2/component-2-view.html +0 -5
  728. package/tests/rules/pack-compjson/audit-pack/component-2/component-2-viewModel.js +0 -56
  729. package/tests/rules/pack-compjson/audit-pack/component-2/component.json +0 -13
  730. package/tests/rules/pack-compjson/audit-pack/component-2/loader.js +0 -20
  731. package/tests/rules/pack-compjson/audit-pack/component-2/resources/nls/component-1-strings.js +0 -18
  732. package/tests/rules/pack-compjson/audit-pack/component.json +0 -12
  733. package/tests/rules/pack-compjson/audit-singleton-1/audit-singleton-1-view.html +0 -5
  734. package/tests/rules/pack-compjson/audit-singleton-1/audit-singleton-1-viewModel.js +0 -56
  735. package/tests/rules/pack-compjson/audit-singleton-1/component.json +0 -20
  736. package/tests/rules/pack-compjson/audit-singleton-1/loader.js +0 -20
  737. package/tests/rules/pack-compjson/audit-singleton-1/resources/nls/audit-singleton-1-strings.js +0 -18
  738. package/tests/rules/pack-compjson/audit-singleton-2/audit-singleton-2-view.html +0 -8
  739. package/tests/rules/pack-compjson/audit-singleton-2/audit-singleton-2-viewModel.js +0 -56
  740. package/tests/rules/pack-compjson/audit-singleton-2/component.json +0 -15
  741. package/tests/rules/pack-compjson/audit-singleton-2/loader.js +0 -20
  742. package/tests/rules/pack-compjson/audit-singleton-2/resources/nls/audit-singleton-2-strings.js +0 -18
  743. package/tests/rules/parse-html/proc_instr.html +0 -9
  744. package/tests/rules/spoc-dom-manip/dom-manip_FAIL_1.js +0 -113
  745. package/tests/rules/spoc-dom-manip/dom-manip_FAIL_2.js +0 -151
  746. package/tests/rules/spoc-dom-manip/dom-manip_PASS_1.js +0 -149
  747. package/tests/rules/spoc-dom-manip/dom-manip_PASS_2.js +0 -147
  748. package/tests/rules/spoc-dom-manip/dom-manip_PASS_3.js +0 -147
  749. package/tests/rules/spoc-dom-manip/dom-manip_PASS_4.js +0 -20
  750. package/tests/rules/spoc-dom-manip/dom-manip_PASS_5.js +0 -246
  751. package/tests/rules/tab-tests/tab-test_FAIL_1.html +0 -37
  752. package/tests/rules/tab-tests/tab-test_FAIL_2.html +0 -8
  753. package/tests/rules/webcomptests/jet-composites/oj-html-wctag-$props/prop_PASS_1.html +0 -8
  754. package/tests/rules/webcomptests/jet-composites/oj-html-wctag-$props/prop_PASS_2.html +0 -8
  755. package/tests/rules/webcomptests/jet-composites/oj-html-wctag-for/for_FAIL_1.html +0 -8
  756. package/tests/rules/webcomptests/jet-composites/oj-html-wctag-for/for_PASS_1.html +0 -8
  757. package/tests/src/JetTest.js +0 -1
  758. package/tests/src/server.js +0 -1
  759. package/tests/test.js +0 -1
package/jaf.js CHANGED
@@ -1,2 +1,7 @@
1
1
  #! /usr/bin/env node
2
- (function(){const ac=require("./src/JafCore");var nd={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:require("./lib/scaffold.js"),scaffoldRule:require("./lib/scaffoldRule.js"),fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:require("./lib/Watch"),colors:require("./lib/colors"),cmdLine:require("./lib/cmdline"),manual:require("./lib/manual"),help:require("./lib/help"),jetver:require("./lib/jetver"),nslist:require("./lib/nslist"),metahist:require("./lib/metahist"),stats:require("./lib/stats"),spinner:require("./lib/spinnernoop")};let rc=new ac(nd).start();if(rc!==99){process.exit(rc)}})();
2
+ /*
3
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
4
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
5
+ * as shown at https://oss.oracle.com/licenses/upl/
6
+ */
7
+ (function(){const ac=require("./src/JafCore");var nd={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),builtinpacks:require("./lib/builtinpacks"),extends:require("./lib/extends"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:require("./lib/scaffold.js"),scaffoldRule:require("./lib/scaffoldRule.js"),fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:require("./lib/Watch"),colors:require("./lib/colors"),cmdLine:require("./lib/cmdline"),manual:require("./lib/manual"),help:require("./lib/help"),jetver:require("./lib/jetver"),defList:require("./lib/deflist"),exportRules:require("./lib/exportRules"),nslist:require("./lib/nslist"),grouplist:require("./lib/grouplist"),dislist:require("./lib/dislist"),metahist:require("./lib/metahist"),cliStats:require("./lib/cliStats"),spinner:require("./lib/spinnernoop")};let rc=new ac(nd).start();if(rc!==99){process.exit(rc)}})();
package/jafapi.js CHANGED
@@ -1 +1,6 @@
1
- var Jaf=function(){this._audit=require("./src/JafCore");this._nodeDeps={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:null,scaffoldRule:null,fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:null,colors:null,cmdLine:null,manual:null,help:null,jetver:require("./lib/jetver"),nslist:null,metahist:null,spinner:require("./lib/spinnernoop")};this._audit=new this._audit(this._nodeDeps,"api");this._error=1};Jaf.prototype.initSync=function(config,cbIssue,cbMsg,cbSummary){this._error=this._audit.API_startSync({config:config,cbIssue:cbIssue,cbMsg:cbMsg,cbSummary:cbSummary});return this._error};Jaf.prototype.init=function(config){var _self=this;return new Promise(function(resolve,reject){_self._audit.API_start({config:config}).then(function(result){_self._error=result;resolve(result)}).catch(function(error){reject(error)})})};Jaf.prototype.auditSync=function(filespec){var i,rc=this._error;if(!this._error){if(this._audit._regListenerTypesSet){return rc}if(Array.isArray(filespec)&&filespec.length){for(i=0;i<filespec.length;i++){rc=this._audit.API_auditSync(filespec[i])}}else{rc=this._audit.API_auditSync(filespec)}}return rc};Jaf.prototype.audit=function(filespec){var _self;_self=this;return new Promise(function(resolve,reject){if(_self._error){reject(_self._error)}else{_self._audit.API_audit(filespec).then(function(resultObj){resolve(resultObj)}).catch(function(error){reject(error)})}})};Jaf.prototype.on=function(evName,fn,extra){this._audit.API_on(evName,fn,extra);return this};Jaf.prototype.removeAllListeners=function(evName){this._audit.API_removeAllListeners(evName);return this};Jaf.prototype.removeListener=function(evName,fn){this._audit.API_removeListener(evName,fn);return this};Jaf.prototype.getDescription=function(issue,short){return this._audit.API_getDescription(issue,short)};Jaf.prototype.getActiveRulesetInfo=function(fmt){fmt=fmt!=="json"&&fmt!=="prose"&&fmt!=="sonar"?"json":fmt;return this._audit.API_getActiveRulesetInfo(fmt)};Jaf.prototype.setCallbacks=function(fnIssue,fnMsg,fnSummary){this._audit.setApiCallbacks(fnIssue,fnMsg,fnSummary)};Jaf.prototype.enableMsgId=function(msgid,state){return this._audit.API_enableMsgId(msgid,state)};Jaf.prototype.getConfig=function(){return this._audit.API_getConfig()};Jaf.prototype.getSevLib=function(){return this._audit.API_getSevLib()};Jaf.prototype.enableRule=function(ruleName,state){return this._audit.API_enableRule(ruleName,state)};Jaf.prototype.setVsCodeExtHint=function(isVsCodeExt){isVsCodeExt=isVsCodeExt!==undefined?!!isVsCodeExt:true;return this._audit.API_setVsCodeExtHint(isVsCodeExt)};module.exports=Jaf;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ var Jaf=function(){this._audit=require("./src/JafCore");this._api=require("./lib/api");this._nodeDeps={fs:require("fs"),path:require("path"),glob:require("glob"),process:process,os:require("os"),decomment:require("strip-json-comments"),decache:require("decache"),Config:require("./lib/Config"),metaLoader:require("./lib/metaLoader"),ruleLoader:require("./lib/ruleLoader"),msgidLoader:require("./lib/msgidLoader"),jsonLoader:require("./lib/JsonLoader"),Components:require("./lib/Components"),ComponentSvcs:require("./lib/ComponentSvcs"),schema:require("./lib/schema"),builtinpacks:null,extends:require("./lib/extends"),tsparse:require("@typescript-eslint/typescript-estree"),scaffold:null,scaffoldRule:null,fsUtils:require("./lib/FsUtils"),zipUtils:require("./lib/ZipUtils"),Watch:null,colors:null,cmdLine:null,manual:null,help:null,jetver:require("./lib/jetver"),defList:null,exportRules:require("./lib/exportRules"),nslist:null,grouplist:null,dislist:null,metahist:null,cliStats:null,spinner:require("./lib/spinnernoop")};this._audit=new this._audit(this._nodeDeps,"api");this._api=new this._api(this._nodeDeps,this._audit);this._error=1};Jaf.prototype.initSync=function(config,cbIssue,cbMsg,cbSummary){this._error=this._api.startSync({config:config,cbIssue:cbIssue,cbMsg:cbMsg,cbSummary:cbSummary});return this._error};Jaf.prototype.init=function(config){var _self=this;return new Promise(function(resolve,reject){_self._api.start({config:config}).then(function(result){_self._error=result;resolve(result)}).catch(function(error){reject(error)})})};Jaf.prototype.auditSync=function(filespec){var i,rc=this._error;if(!this._error){if(this._audit._regListenerTypesSet){return rc}if(Array.isArray(filespec)&&filespec.length){for(i=0;i<filespec.length;i++){rc=this._api.auditSync(filespec[i])}}else{rc=this._api.auditSync(filespec)}}return rc};Jaf.prototype.audit=function(filespec){var _self;_self=this;return new Promise(function(resolve,reject){if(_self._error){reject(_self._error)}else{_self._api.audit(filespec).then(function(resultObj){resolve(resultObj)}).catch(function(error){reject(error)})}})};Jaf.prototype.on=function(evName,fn,extra){this._api.on(evName,fn,extra);return this};Jaf.prototype.removeAllListeners=function(evName){this._api.removeAllListeners(evName);return this};Jaf.prototype.removeListener=function(evName,fn){this._api.removeListener(evName,fn);return this};Jaf.prototype.getDescription=function(issue,short){return this._api.getDescription(issue,short)};Jaf.prototype.getActiveRulesetInfo=function(fmt){fmt=fmt!=="json"&&fmt!=="prose"&&fmt!=="sonar"?"json":fmt;return this._api.getActiveRulesetInfo(fmt)};Jaf.prototype.setCallbacks=function(fnIssue,fnMsg,fnSummary){this._audit.setApiCallbacks(fnIssue,fnMsg,fnSummary)};Jaf.prototype.enableMsgId=function(msgid,state){return this._api.enableMsgId(msgid,state)};Jaf.prototype.getConfig=function(){return this._api.getConfig()};Jaf.prototype.getSevLib=function(){return this._api.getSevLib()};Jaf.prototype.enableRule=function(ruleName,state){return this._api.enableRule(ruleName,state)};Jaf.prototype.getInfo=function(){return this._api.getInfo()};Jaf.prototype.setVsCodeExtHint=function(isVsCodeExt){isVsCodeExt=isVsCodeExt!==undefined?!!isVsCodeExt:true;return this._api.setVsCodeExtHint(isVsCodeExt)};module.exports=Jaf;
package/lib/AST.js CHANGED
@@ -1 +1,6 @@
1
- const JsParser=require("espree");var _types;const BLOCK_STMT="BlockStatement";const PROGRAM="Program";const IDENTIFIER="Identifier";const EXPR_STMT="ExpressionStatement";const RETURN_STMT="ReturnStatement";const ASSIGNMENT_EXPR="AssignmentExpression";const MEMBER_EXPR="MemberExpression";const NEW_EXPR="NewExpression";const FUNC_EXPR="FunctionExpression";const CALL_EXPR="CallExpression";const BINARY_EXPR="BinaryExpression";const CONDITIONAL_EXPR="ConditionalExpression";const THIS_EXPR="ThisExpression";const OBJ_EXPR="ObjectExpression";const ARRAY_EXPR="ArrayExpression";const IF_STMT="IfStatement";const FUNC_DECLARATION="FunctionDeclaration";const VAR_DECLARATION="VariableDeclaration";const VAR_DECLARATOR="VariableDeclarator";const PROPERTY="Property";const LITERAL="Literal";const IMPORT_DEF_SPECIFIER="ImportDefaultSpecifier";const IMPORT_SPECIFIER="ImportSpecifier";const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};var AST=function(data,ecmaVer,comments){var opts={ecmaVersion:ecmaVer,comment:comments};if(ecmaVer>5){opts.sourceType="module"}this._ast=JsParser.parse(data,opts);this._data=data;this._utils=null;this._program=null;this._isComments=comments};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log("!!!!!! "+e)}};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.start){return node}if(index<node.start||index>node.end){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.start){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type==="IfStatement"){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){if(!_types){_types={BLOCK_STMT:BLOCK_STMT,PROGRAM:PROGRAM,IDENTIFIER:IDENTIFIER,EXPR_STMT:EXPR_STMT,RETURN_STMT:RETURN_STMT,ASSIGNMENT_EXPR:ASSIGNMENT_EXPR,MEMBER_EXPR:MEMBER_EXPR,NEW_EXPR:NEW_EXPR,CALL_EXPR:CALL_EXPR,FUNC_EXPR:FUNC_EXPR,BINARY_EXPR:BINARY_EXPR,CONDITIONAL_EXPR:CONDITIONAL_EXPR,OBJ_EXPR:OBJ_EXPR,THIS_EXPR:THIS_EXPR,ARRAY_EXPR:ARRAY_EXPR,IF_STMT:IF_STMT,FUNC_DECLARATION:FUNC_DECLARATION,VAR_DECLARATION:VAR_DECLARATION,VAR_DECLARATOR:VAR_DECLARATOR,LITERAL:LITERAL,PROPERTY:PROPERTY}}return _types};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===BLOCK_STMT||node.type===PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===FUNC_DECLARATION||node.type===PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===IMPORT_DEF_SPECIFIER||spec.type===IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(node.type==="Line"||node.type==="EmptyStatement"){continue}fn(node);for(key in node){if(key!=="parent"){child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const NT=require("./AstNodeTypes");const JsParser=require("espree");const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};var AST=function(data,ecmaVer,comments,msgCtx){var opts={ecmaVersion:ecmaVer,comment:comments};if(ecmaVer>5){opts.sourceType="module"}this._ast=JsParser.parse(data,opts);this._data=data;this._utils=null;this._program=null;this._isComments=comments;this._msgCtx=msgCtx};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log(`JAF internal JS WALK ERROR: ${e}`)}};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.start){return node}if(index<node.start||index>node.end){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.start){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type==="IfStatement"){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){return NT};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.BLOCK_STMT||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.FUNC_DECLARATION||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===NT.PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==NT.FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===NT.IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===NT.IMPORT_DEF_SPECIFIER||spec.type===NT.IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(node.type==="Line"||node.type==="EmptyStatement"){continue}fn(node);for(key in node){if(key!=="parent"){child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
package/lib/AST_Ts.js CHANGED
@@ -1 +1,6 @@
1
- const Scope=require("./Scope");var _types;const BLOCK_STMT="BlockStatement";const PROGRAM="Program";const IDENTIFIER="Identifier";const EXPR_STMT="ExpressionStatement";const RETURN_STMT="ReturnStatement";const ASSIGNMENT_EXPR="AssignmentExpression";const MEMBER_EXPR="MemberExpression";const NEW_EXPR="NewExpression";const FUNC_EXPR="FunctionExpression";const CALL_EXPR="CallExpression";const BINARY_EXPR="BinaryExpression";const CONDITIONAL_EXPR="ConditionalExpression";const THIS_EXPR="ThisExpression";const OBJ_EXPR="ObjectExpression";const ARRAY_EXPR="ArrayExpression";const IF_STMT="IfStatement";const FUNC_DECLARATION="FunctionDeclaration";const VAR_DECLARATION="VariableDeclaration";const VAR_DECLARATOR="VariableDeclarator";const PROPERTY="Property";const LITERAL="Literal";const IMPORT_DEF_SPECIFIER="ImportDefaultSpecifier";const IMPORT_SPECIFIER="ImportSpecifier";const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};var AST=function(data,nd,ecmaVer,comments){var opts={ecmaVersion:ecmaVer,comment:comments};opts.loc=true;opts.range=true;opts.errorOnUnknownASTType=true;opts.project="D:/vsprojects/JetAuditDev/tsconfig/tsconfig.json";try{this._ast=nd.tsparse.parse(data,opts)}catch(e){console.log(`TS ERROR [${e.lineNumber}, ${e.column}]: ${e.message}`)}this._data=data;this._scopes=null;this._utils=null;this._program=null;this._isComments=comments};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log("WALK ERROR: "+e)}};AST.prototype.getAst=function(){return this._ast};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.start){return node}if(index<node.start||index>node.end){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.start){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type==="IfStatement"){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getScopes:this._createVarScopes.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){if(!_types){_types={BLOCK_STMT:BLOCK_STMT,PROGRAM:PROGRAM,IDENTIFIER:IDENTIFIER,EXPR_STMT:EXPR_STMT,RETURN_STMT:RETURN_STMT,ASSIGNMENT_EXPR:ASSIGNMENT_EXPR,MEMBER_EXPR:MEMBER_EXPR,NEW_EXPR:NEW_EXPR,CALL_EXPR:CALL_EXPR,FUNC_EXPR:FUNC_EXPR,BINARY_EXPR:BINARY_EXPR,CONDITIONAL_EXPR:CONDITIONAL_EXPR,OBJ_EXPR:OBJ_EXPR,THIS_EXPR:THIS_EXPR,ARRAY_EXPR:ARRAY_EXPR,IF_STMT:IF_STMT,FUNC_DECLARATION:FUNC_DECLARATION,VAR_DECLARATION:VAR_DECLARATION,VAR_DECLARATOR:VAR_DECLARATOR,LITERAL:LITERAL,PROPERTY:PROPERTY}}return _types};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===BLOCK_STMT||node.type===PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===FUNC_DECLARATION||node.type===PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype._createVarScopes=function(){if(!this._scopes){this._scope=new Scope;this._scopeStacks=this._scope.build(this._ast);this._accessor=this._scope.getAccessor()}return this._accessor};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===IMPORT_DEF_SPECIFIER||spec.type===IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(typeof node==="number"){continue}if(node.type==="Line"||node.type==="EmptyStatement"){continue}fn(node);for(key in node){if(key!=="parent"){child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const NT=require("./AstNodeTypes");const Scope=require("./Scope");const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};const LOC="loc";const RANGE="range";const PARENT="parent";var AST=function(data,file,fileType,nd,ecmaVer,comments,msgCtx,config){var opts={ecmaVersion:ecmaVer,comment:comments};if(fileType==="tsx"){opts.jsx=true}opts.loc=true;opts.range=true;opts.errorOnUnknownASTType=true;opts.project="D:/vsprojects/JetAuditDev/tsconfig/tsconfig.json";this._ast=nd.tsparse.parse(data,opts);this._data=data;this._file=file;this._scope=null;this._utils=null;this._program=null;this._isComments=comments;this._msgCtx=msgCtx;this._config=config;this._nd=nd};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log(`JAF internal TS WALK ERROR: ${e}`)}};AST.prototype.getAst=function(){return this._ast};AST.prototype.getFilePath=function(){return this._file};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.range[0]){return node}if(index<node.range[0]||index>node.range[1]){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.range[0]){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type==="IfStatement"){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getScopes:this._createVarScopes.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){return NT};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.BLOCK_STMT||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.FUNC_DECLARATION||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===NT.PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype._createVarScopes=function(){if(!this._scope){this._scope=new Scope(this._msgCtx,this._config,this._nd);this._scopeStacks=this._scope.build(this._ast);this._accessor=this._scope.getAccessor()}return this._accessor};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==NT.FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===NT.IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===NT.IMPORT_DEF_SPECIFIER||spec.type===NT.IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(node.type==="Line"||node.type==="EmptyStatement"){continue}fn(node);for(key in node){if(key!==PARENT){if(key===RANGE||key===LOC){continue}child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
package/lib/AstJson.js CHANGED
@@ -1 +1,6 @@
1
- const PROP="P";const RBRACE="}";const LBRACE="{";const LSQUARE="[";const RSQUARE="]";const NUMBER="N";const STRING="S";const BOOL="B";const NULL="NL";const COLON=":";const DQUOTE="\"";const ESCAPE="\\";const COMMA=",";const UNARY_MINUS="-";const $DIGIT="$digit";const EOF="";function AstJson(msgContext){this._msgContext=msgContext};AstJson.prototype.parse=function(data){this._data=data;this._index=-1;this._row=1;this._col=0;this._curChar=null;this._objStack=[];this._listStack=[];this._curProp=null;this._curObj=null;this._tokValue=null;var ret=this._parse();return ret};AstJson.prototype._parse=function(){var tok;do{switch(tok){case STRING:case NUMBER:case BOOL:case NULL:{if(this._curProp){this._curProp.value=this._tokValue}else{this._curProp=this._tokValue}this._curList.push(this._curProp);this._curProp=null;break}case PROP:{this._curProp={name:this._tokValue.rawValue,pos:{row:this._startRow,col:this._startCol,index:this._startIndex}};this._next(COLON);break}case LBRACE:{if(this._curProp){this._curProp.value=this._tokValue}if(this._curObj){this._objStack.push(this._curObj)}this._curObj=this._tokValue;this._curObj.members=[];if(this._curList){this._curList.push(this._curProp)}this._listStack.push(this._curList);this._curList=this._curObj.members;break}case RBRACE:{if(this._objStack.length){this._curObj=this._objStack.pop()}if(this._listStack.length){this._curList=this._listStack.pop()}break}case LSQUARE:{if(this._curList){this._listStack.push(this._curList)}if(this._curProp){this._curProp.value=this._tokValue;this._curList.push(this._curProp)}else if(this._curList){this._curList.push(this._tokValue)}this._curList=this._tokValue.members;this._curProp=null;break}case RSQUARE:{this._curList=this._listStack.pop();break}}}while((tok=this._getToken())!==EOF);return this._startToken===LBRACE?this._curObj:this._curList};AstJson.prototype._getToken=function(){var s;while(true){s=this._getNextChar();if(s===DQUOTE){this._tokValue=this._getString();this._getTokValue("string",this._tokValue,true);return this._peekNext(COLON)?PROP:STRING}else if(this._isNumber(s)){this._tokValue=this._getNumber(s);this._getTokValue("number",this._tokValue,true);return NUMBER}else if(s==="t"||s==="f"){this._tokValue=this._getBoolean(s);this._getTokValue("boolean",this._tokValue,true);return BOOL}else if(s==="n"){this._tokValue=this._getNull();this._getTokValue("null",this._tokValue,true);return NULL}else if(s===LBRACE){this._tokValue={type:"Object",value:"{",pos:{row:this._row,col:this._col,index:this._index}};if(!this._startToken){this._startToken=LBRACE}return LBRACE}else if(s===RBRACE){return RBRACE}else if(s===LSQUARE){this._tokValue={type:"array",pos:{row:this._row,col:this._col,index:this._index},members:[]};if(!this._startToken){this._startToken=LSQUARE}return LSQUARE}else if(s===RSQUARE){return RSQUARE}else if(s===EOF){return EOF}else if(s===COMMA){continue}else{if(this._msgContext){this._msgContext.assert("JSON -> AST - unexpected char '"+s+"'")}return s}}};AstJson.prototype._getString=function(){var str="",s,inEscape;this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;while(true){s=this._getChar();if(s===ESCAPE){inEscape=true;continue}if(!inEscape){if(s===DQUOTE){return{value:str,rawValue:str}}}inEscape=false;str+=s}};AstJson.prototype._getNumber=function(s){var str=s;this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;while(true){s=this._getChar();if(this._isNumber(s)){if(s!==UNARY_MINUS){str+=s;continue}}this._unget();break}return{value:parseInt(str),rawValue:str}};AstJson.prototype._getBoolean=function(s){var ret={};this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;if(s==="t"){this._next("r");this._next("u");this._next("e");ret.value=true;ret.rawValue="true"}else{this._next("a");this._next("l");this._next("s");this._next("e");ret.value=false;ret.rawValue="false"}return ret};AstJson.prototype._getNull=function(){this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;this._next("u");this._next("l");this._next("l");return{value:null,rawValue:"null"}};AstJson.prototype._getTokValue=function(type,tokValue,startRc){this._tokValue={type:type,value:this._tokValue.value,rawValue:this._tokValue.rawValue,pos:{row:startRc?this._startRow:this._row,col:startRc?this._startCol:this._col,index:this._startIndex}}};AstJson.prototype._next=function(s){while(true){if(this._getNextChar()===s){break}}};AstJson.prototype._peekNext=function(s){var n,r,c,val,ret=false;n=this._index;r=this._row;c=this._col;if(s===$DIGIT){val=this._getNextChar();ret=!isNaN(parseInt(val,10))}else{ret=this._getNextChar()===s}this._index=n;this._row=r;this._col=c;return ret};AstJson.prototype._getNextChar=function(){var s;while(true){s=this._getChar();if(s===EOF){return EOF}if(!_isWhite(s)){return s}}};AstJson.prototype._getChar=function(){if(!this._doNotadvance){this._index=this._index>=0?++this._index:0}else{this._unget=false}if(this._index<this._data.length){this._curChar=this._data.substr(this._index,1);if(this._curChar==="\n"){this._row++;this._col=0}else if(this._curChar!=="\r"){this._col++}return this._curChar}return EOF};AstJson.prototype._unget=function(){this._doNotAdvance=true};AstJson.prototype._isNumber=function(s){var num;if(s===UNARY_MINUS){num=this._peekNext($DIGIT);return num>="0"&&num<="9"}return!isNaN(parseInt(s,10))};function _isWhite(s){return s==" "||s==="\n"||s==="\r"||s==="\t"};module.exports=AstJson;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const PROP="P";const RBRACE="}";const LBRACE="{";const LSQUARE="[";const RSQUARE="]";const NUMBER="N";const STRING="S";const BOOL="B";const NULL="NL";const COLON=":";const DQUOTE="\"";const ESCAPE="\\";const COMMA=",";const UNARY_MINUS="-";const $DIGIT="$digit";const EOF="";function AstJson(msgContext){this._msgContext=msgContext};AstJson.prototype.parse=function(data){var ret;this._data=data;this._index=-1;this._row=1;this._col=0;this._curChar=null;this._objStack=[];this._listStack=[];this._curProp=null;this._curObj=null;this._tokValue=null;ret=this._parse();return ret};AstJson.prototype._parse=function(){var tok;do{switch(tok){case STRING:case NUMBER:case BOOL:case NULL:{if(this._curProp){this._curProp.value=this._tokValue}else{this._curProp=this._tokValue}this._curList.push(this._curProp);this._curProp=null;break}case PROP:{this._curProp={name:this._tokValue.rawValue,pos:{row:this._startRow,col:this._startCol,index:this._startIndex}};this._next(COLON);break}case LBRACE:{if(this._curProp){this._curProp.value=this._tokValue}if(this._curObj){this._objStack.push(this._curObj)}this._curObj=this._tokValue;this._curObj.members=[];if(this._curList){if(this._curProp)this._curList.push(this._curProp);else this._curList.push(this._curObj)}this._listStack.push(this._curList);this._curList=this._curObj.members;break}case RBRACE:{if(this._objStack.length){this._curObj=this._objStack.pop()}if(this._listStack.length){this._curList=this._listStack.pop()}break}case LSQUARE:{if(this._curList){this._listStack.push(this._curList)}if(this._curProp){this._curProp.value=this._tokValue;this._curList.push(this._curProp)}else if(this._curList){this._curList.push(this._tokValue)}this._curList=this._tokValue.members;this._curProp=null;break}case RSQUARE:{this._curList=this._listStack.pop();break}}}while((tok=this._getToken())!==EOF);return this._startToken===LBRACE?this._curObj:this._curList};AstJson.prototype._getToken=function(){var s;while(true){s=this._getNextChar();if(s===DQUOTE){this._tokValue=this._getString();this._getTokValue("string",this._tokValue,true);return this._peekNext(COLON)?PROP:STRING}else if(this._isNumber(s)){this._tokValue=this._getNumber(s);this._getTokValue("number",this._tokValue,true);return NUMBER}else if(s==="t"||s==="f"){this._tokValue=this._getBoolean(s);this._getTokValue("boolean",this._tokValue,true);return BOOL}else if(s==="n"){this._tokValue=this._getNull();this._getTokValue("null",this._tokValue,true);return NULL}else if(s===LBRACE){this._tokValue={type:"Object",value:"{",pos:{row:this._row,col:this._col,index:this._index}};if(!this._startToken){this._startToken=LBRACE}return LBRACE}else if(s===RBRACE){return RBRACE}else if(s===LSQUARE){this._tokValue={type:"array",pos:{row:this._row,col:this._col,index:this._index},members:[]};if(!this._startToken){this._startToken=LSQUARE}return LSQUARE}else if(s===RSQUARE){return RSQUARE}else if(s===EOF){return EOF}else if(s===COMMA){continue}else{if(this._msgContext){this._msgContext.assert("JSON -> AST - unexpected char '"+s+"'")}return s}}};AstJson.prototype._getString=function(){var str="",s,inEscape;this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;while(true){s=this._getChar();if(s===ESCAPE){inEscape=true;continue}if(!inEscape){if(s===DQUOTE){return{value:str,rawValue:str}}}inEscape=false;str+=s}};AstJson.prototype._getNumber=function(s){var str=s;this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;while(true){s=this._getChar();if(this._isNumber(s)){if(s!==UNARY_MINUS){str+=s;continue}}this._unget();break}return{value:parseInt(str),rawValue:str}};AstJson.prototype._getBoolean=function(s){var ret={};this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;if(s==="t"){this._next("r");this._next("u");this._next("e");ret.value=true;ret.rawValue="true"}else{this._next("a");this._next("l");this._next("s");this._next("e");ret.value=false;ret.rawValue="false"}return ret};AstJson.prototype._getNull=function(){this._startRow=this._row;this._startCol=this._col;this._startIndex=this._index;this._next("u");this._next("l");this._next("l");return{value:null,rawValue:"null"}};AstJson.prototype._getTokValue=function(type,tokValue,startRc){this._tokValue={type:type,value:this._tokValue.value,rawValue:this._tokValue.rawValue,pos:{row:startRc?this._startRow:this._row,col:startRc?this._startCol:this._col,index:this._startIndex}}};AstJson.prototype._next=function(s){while(true){if(this._getNextChar()===s){break}}};AstJson.prototype._peekNext=function(s){var n,r,c,val,ret=false;n=this._index;r=this._row;c=this._col;if(s===$DIGIT){val=this._getNextChar();ret=!isNaN(parseInt(val,10))}else{ret=this._getNextChar()===s}this._index=n;this._row=r;this._col=c;return ret};AstJson.prototype._getNextChar=function(){var s;while(true){s=this._getChar();if(s===EOF){return EOF}if(!_isWhite(s)){return s}}};AstJson.prototype._getChar=function(){if(!this._doNotadvance){this._index=this._index>=0?++this._index:0}else{this._unget=false}if(this._index<this._data.length){this._curChar=this._data.substr(this._index,1);if(this._curChar==="\n"){this._row++;this._col=0}else if(this._curChar!=="\r"){this._col++}return this._curChar}return EOF};AstJson.prototype._unget=function(){this._doNotAdvance=true};AstJson.prototype._isNumber=function(s){var num;if(s===UNARY_MINUS){num=this._peekNext($DIGIT);return num>="0"&&num<="9"}return!isNaN(parseInt(s,10))};function _isWhite(s){return s==" "||s==="\n"||s==="\r"||s==="\t"};module.exports=AstJson;
package/lib/AstMd.js ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ var parser=require("markdown-it");const PARA_OPEN="paragraph_open";const PARA_CLOSE="paragraph_close";const HEADING_OPEN="heading_open";const HEADING_CLOSE="heading_close";const LINK_OPEN="link_open";const IMAGE="image";const INLINE="inline";const FENCE="fence";const TEXT="text";const UL_OPEN="bullet_list_open";const UL_CLOSE="bullet_list_close";const OL_OPEN="ordered_list_open";const OL_CLOSE="ordered_list_close";const CODE="code";const HTTP="http://";const RE_BRACKET=/\[([^)]+)\].*:/g;const RE_DEL_BRACKET_COLON=/\[|\]|:/g;const RE_REFLINK=/\[[^[]*\]\s*\[([^[]*)\]/;function AstMd(appCtx){this._parser=new parser;this._parser.set({linkify:true});this._appCtx=appCtx;this._utils=appCtx.utils;this._state={};this._links=[];this._paras=[];this._images=[];this._code=[];this._lists=[];this._refLinks=undefined;this._lineMap=new Map};AstMd.prototype.parse=function(data){var state=this._state;state.para=state.heading=state.list=false;state.level=0;state.listType=undefined;this._curListItem=null;this._listsStack=[];this._listItemStack=[];this._stateStack=[];this._mapStack=[];this._links.length=this._paras.length=this._images.length=this._code.length=this._lists.length=0;this._refLinks={};this._ast=this._parser.parse(data,{});this._data=data;this._loadLineMap();return this._ast};AstMd.prototype.createHandler=function(){this._createHandlerContent();return{getLinks:this._getLinks.bind(this),getParas:this._getParas.bind(this),getImages:this._getImages.bind(this),getCode:this._getCode.bind(this),getLists:this._getLists.bind(this),getRefLinks:this._getRefLinks.bind(this),test:this._testParas.bind(this),getLine:this._getLine.bind(this),getLineDisp:this._getLineDisp.bind(this),getLineMap:this._getLineMap.bind(this)}};AstMd.prototype._createHandlerContent=function(){this._createRefs();this._walkChildren(this._ast,this._state)};AstMd.prototype._walkChildren=function(ast,state){var i,o,txt,link,refLink,obj,pos,pos2,start;for(i=0;i<ast.length;i++){o=ast[i];if(o.type===PARA_OPEN&&!state.list){state.para=true;this._map=this._setPos(o.map)}else if(o.type===PARA_CLOSE&&!state.list){state.para=false}else if(o.type===HEADING_OPEN&&!state.list){state.heading=true;this._map=this._setPos(o.map);state.level=_getLevel(o.tag)}else if(o.type===HEADING_CLOSE&&!state.list){state.heading=false;state.level=0}else if(o.type===UL_OPEN||o.type===OL_OPEN){if(this._curListItem){this._listItemStack.push(this._curListItem);this._stateStack.push(state);this._listsStack.push(this._lists);this._lists=this._curListItem.items[this._curListItem.items.length-1].children=[];state={};this._mapStack.push(this._map);this._map=this._setPos(o.map)}state.list=true;state.listType=o.tag;this._map=this._setPos(o.map);pos=this._lineMap.get(o.map[0]+1);pos2=null;if(o.map[0]+1<o.map[1]){pos2=this._lineMap.get(o.map[1])}this._curListItem={ordered:state.listType==="ol",items:[],pos:[{line:o.map[0]+1,start:pos.start,end:pos.end}]};if(pos2){this._curListItem.pos.push({line:o.map[1],start:pos2.start,end:pos2.end})}}else if(o.type===UL_CLOSE||o.type===OL_CLOSE){state.list=false;state.listType=undefined;this._lists.push(this._curListItem);this._curListItem=null;if(this._listItemStack.length){this._curListItem=this._listItemStack.pop();this._lists=this._listsStack.pop();state=this._stateStack.pop();this._map=this._mapStack.pop()}}else if(o.type===INLINE){if(state.list){this._curListItem.items.push({item:o.children[0].content})}else if(state.para||state.heading){pos=this._lineMap.get(o.map[0]+1);pos2=null;if(o.map[0]+1<o.map[1]){pos2=this._lineMap.get(o.map[1])}obj={level:state.level,text:o.content,pos:[{line:o.map[0]+1,start:pos.start,end:pos.end}]};if(pos2){obj.pos.push({line:o.map[1],start:pos2.start,end:pos2.end})}this._paras.push(obj)}else if(o.content.charAt(0)==="!"){var jj=42}}else if(o.type===LINK_OPEN){let bContinue=true;txt=_peekContent(ast,i,TEXT);link=o.attrs[0][1];if(this._map){pos=this._getColsExtent(txt?txt:link)}if(o.markup==="linkify"){let t=ast[i+1].content;if(t.toLowerCase().endsWith(".md")&&!t.startsWith("http")){bContinue=false}}if(bContinue){if(refLink=this._isRefLink(pos.line)){pos=this._getRefLinkPos(pos.line,refLink);obj={text:txt||null,inline:false,refKey:refLink,pos:pos}}else{start=this._getLineDisp(pos.line,pos.col);obj={inline:true,link:link,text:txt||null,pos:{line:pos.line,col:pos.col,start:start,end:start+=link.length-1}}}this._links.push(obj)}}else if(o.type===IMAGE){link=o.attrs[0][1];pos=this._getColsExtent(link);start=this._getLineDisp(pos.line,pos.col);obj={alt:o.content,pos:{line:pos.line,col:pos.col,start:start,end:start+=link.length-1}};if(this._refLinks[link]){obj.inline=false,obj.refKey=link}else{obj.inline=true,obj.link=link}this._images.push(obj)}else if(o.type===FENCE&&o.tag===CODE){pos=this._lineMap.get(o.map[0]+1);pos2=null;if(o.map[0]+1<o.map[1]){pos2=this._lineMap.get(o.map[1])}obj={code:o.content,pos:[{line:o.map[0]+1,start:pos.start,end:pos.end}]};if(pos2){obj.pos.push({line:o.map[1],start:pos2.start,end:pos2.end})}this._code.push(obj)}if(o.children){this._walkChildren(o.children,state)}}};AstMd.prototype._getLinks=function(){return this._links};AstMd.prototype._getParas=function(){return this._paras};AstMd.prototype._getImages=function(){return this._images};AstMd.prototype._getCode=function(){return this._code};AstMd.prototype._getLists=function(){return this._lists};AstMd.prototype._getRefLinks=function(){return this._refLinks};AstMd.prototype._getLineMap=function(){return this._lineMap};AstMd.prototype._testParas=function(regexp,firstMatch){var ret=null;var paras=this._getParas();try{for(let i=0;i<paras.length;i++){regexp.lastIndex=0;if(regexp.test(paras[i].text)){if(!ret){ret=[]}ret.push(paras[i]);if(firstMatch){break}}}}catch(e){}return ret?ret:null};AstMd.prototype._getColsExtent=function(txt){var lineNum,line,txt2,x=-1;for(lineNum=this._map[0];lineNum<=this._map[1];lineNum++){line=this._getLine(lineNum);if(txt.startsWith(HTTP)){txt2=txt.substr(HTTP.length)}if((x=line.indexOf(txt))<0){if(txt2){x=line.indexOf(txt2)}}if(x>=0){return{line:lineNum,col:x+1}}}return null};AstMd.prototype._getLineDisp=function(lineNum,col){var ret=-1;if(lineNum<=this._lineMap.size){ret=this._lineMap.get(lineNum).start;if(typeof col==="number"){ret+=col-1}}return ret};AstMd.prototype._getLine=function(lineNum){var start,end,line,pos;;if(lineNum<=this._lineMap.size){pos=this._lineMap.get(lineNum);start=pos.start;end=pos.end;line=this._data.substring(start,end+1)}return line};AstMd.prototype._isRefLink=function(line){var line=this._getLine(line);var match=line.match(RE_REFLINK);return match?match[1]:null};AstMd.prototype._getRefLinkPos=function(lineNum,refLink){var line=this._getLine(lineNum);var x=line.indexOf(refLink);var pos=this._lineMap.get(lineNum);var start=pos.start+x;return{line:lineNum,col:x+1,start:start,end:start+refLink.length-1}};AstMd.prototype._setPos=function(ar){return[ar[0]+1,ar[1]]};AstMd.prototype._loadLineMap=function(){let data,map,line=1,lastDisp,i;this._lineMap.clear();data=this._data;map=this._lineMap;if(data.length){lastDisp=0;for(i=0;i<data.length;i++){if(data.charAt(i)==="\n"){map.set(line++,{start:lastDisp,end:i});lastDisp=i+1;if(lastDisp===data.length){return map}}}map.set(line,{start:lastDisp,end:i-1})}return map};AstMd.prototype._createRefs=function(){var line,col,match,ref,start,i,j,x;var link,title,obj;var lineCount=this._lineMap.size;for(i=1;i<=lineCount;i++){line=this._getLine(i);if((x=this._utils.eatWhitespace(line,0))<0){continue}if(line.charAt(x)==="["){if(match=line.match(RE_BRACKET)){match=match[0];j=match.indexOf(":");match=match.substring(0,j+1);ref=match.replace(RE_DEL_BRACKET_COLON,"").trim();x+=match.length;link=line.substr(x).trim();title=undefined;if(link.charAt(0)==="<"){j=link.indexOf(">",1);if(j>=0){title=link.substring(j+1).trim();title=title.replace(/[\'\\(\)"']*/g,"");link=link.substring(1,j)}}else{if((j=this._utils.getIndexToWhitespace(link))>=0){title=link.substring(j+1).trim();title=title.replace(/[\"\'"]/g,"");link=link.substring(0,j)}}col=x+1;for(j=x;j<line.length;j++){if(this._utils.isWhitespace(line.charAt(j))){col++}else{break}}start=this._getLineDisp(i,col);obj={link:link,pos:{line:i,col:col,start:start,end:start+link.length-1}};if(title){obj.title=title}this._refLinks[ref]=obj}}}};function _peekContent(ast,i,type){var o,ret;if(ast[i].markup!=="linkify"){o=ast[i+1];if(o.type===type){ret=o.content}}return ret?ret:""};function _getLevel(level){var val=0;if(level.charAt(0)==="h"){val=level.charCodeAt(1)-48}return val};module.exports=AstMd;
@@ -1 +1,6 @@
1
- module.exports.BLOCK_STMT="BlockStatement";module.exports.EXPR_STMT="ExpressionStatement";module.exports.RETURN_STMT="ReturnStatement";module.exports.CONTINUE_STMT="ContinueStatement";module.exports.BREAK_STMT="BreakStatement";module.exports.IF_STMT="IfStatement";module.exports.WHILE_STMT="WhileStatement";module.exports.DO_WHILE_STMT="DoWhileStatement";module.exports.PROGRAM="Program";module.exports.IDENTIFIER="Identifier";module.exports.ASSIGNMENT_EXPR="AssignmentExpression";module.exports.MEMBER_EXPR="MemberExpression";module.exports.NEW_EXPR="NewExpression";module.exports.CALL_EXPR="CallExpression";module.exports.FUNC_EXPR="FunctionExpression";module.exports.BINARY_EXPR="BinaryExpression";module.exports.CONDITIONAL_EXPR="ConditionalExpression";module.exports.OBJ_EXPR="ObjectExpression";module.exports.THIS_EXPR="ThisExpression";module.exports.ARRAY_EXPR="ArrayExpression";module.exports.FUNC_DECLARATION="FunctionDeclaration";module.exports.ClASS_DECLARATION="ClassDeclaration";module.exports.ClASS_BODY="ClassBody";module.exports.VAR_DECLARATION="VariableDeclaration";module.exports.VAR_DECLARATOR="VariableDeclarator";module.exports.SPREAD_ELEM="SpreadElement";module.exports.LITERAL="Literal";module.exports.PROPERTY="Property";
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ module.exports.ARRAY_EXPR="ArrayExpression";module.exports.ARROW_FUNC_EXPR="ArrowFunctionExpression";module.exports.ASSIGN_PATTERN="AssignmentPattern";module.exports.ASSIGN_EXPR="AssignmentExpression";module.exports.ASSIGNMENT_EXPR="AssignmentExpression";module.exports.AWAIT_EXPR="AwaitExpression";module.exports.BINARY_EXPR="BinaryExpression";module.exports.BLOCK_STMT="BlockStatement";module.exports.BREAK_STMT="BreakStatement";module.exports.CALL_EXPR="CallExpression";module.exports.CATCH_CLAUSE="CatchClause";module.exports.CLASS_BODY="ClassBody";module.exports.CLASS_DECLARATION="ClassDeclaration";module.exports.CLASS_EXPR="ClassExpression";module.exports.CLASS_PROP="ClassProperty";module.exports.CONDITIONAL_EXPR="ConditionalExpression";module.exports.CONTINUE_STMT="ContinueStatement";module.exports.DO_WHILE_STMT="DoWhileStatement";module.exports.DEBUG_STMT="DebuggerStatement";module.exports.EMPTY_STMT="EmptyStatement";module.exports.EX_REST_PROP="ExperimentalRestProperty";module.exports.EX_SPREAD_STMT="ExperimentalSpreadProperty";module.exports.EXPR_STMT="ExpressionStatement";module.exports.FOR_STMT="ForStatement";module.exports.FOR_IN_STMT="ForInStatement";module.exports.FOR_OF_STMT="ForOfStatement";module.exports.FUNC_DECLARATION="FunctionDeclaration";module.exports.FUNC_EXPR="FunctionExpression";module.exports.IDENTIFIER="Identifier";module.exports.IF_STMT="IfStatement";module.exports.LOGIC_EXPR="LogicalExpression";module.exports.LABELED_STMT="LabeledStatement";module.exports.LITERAL="Literal";module.exports.MEMBER_EXPR="MemberExpression";module.exports.META_PROP="MetaProperty";module.exports.METH_DEF="MethodDefinition";module.exports.NEW_EXPR="NewExpression";module.exports.OBJ_EXPR="ObjectExpression";module.exports.OBJ_PATTERN="ObjectPattern";module.exports.PROGRAM="Program";module.exports.PROPERTY="Property";module.exports.REST_ELEM="RestElement";module.exports.RETURN_STMT="ReturnStatement";module.exports.SEQUENCE_EXPR="SequenceExpression";module.exports.SPREAD_ELEM="SpreadElement";module.exports.SUPER="Super";module.exports.SWITCH_CASE="SwitchCase";module.exports.SWITCH_STMT="SwitchStatement";module.exports.TAGGED_TEMPLATE_EXPR="TaggedTemplateExpression";module.exports.TEMPLATE_ELEM="TemplateElement";module.exports.TEMPLATE_LIT="TemplateLiteral";module.exports.THIS_EXPR="ThisExpression";module.exports.THROW_EXPR="ThrowExpression";module.exports.TRY_STMT="TryStatement";module.exports.UNARY_EXPR="UnaryExpression";module.exports.UPDATE_EXPR="UpdateExpression";module.exports.VAR_DECLARATION="VariableDeclaration";module.exports.VAR_DECLARATOR="VariableDeclarator";module.exports.WHILE_STMT="WhileStatement";module.exports.WITH_STMT="WithStatement";module.exports.YIELD_EXPR="YieldExpression";module.exports.JSX_ID="JSXIdentifier";module.exports.JSX_NS_NAME="JSXNamespacedName";module.exports.JSX_EMPTY_EXPR="JSXEmptyExpression";module.exports.JSX_EXPR_CONTAINER="JSXExpressionContainer";module.exports.JSX_ELEM="JSXElement";module.exports.JSX_CLOSING_ELEM="JSXClosingElement";module.exports.JSX_OPENING_ELEM="JSXOpeningElement";module.exports.JSX_ATTRIB="JSXAttribute";module.exports.JSX_SPREAD_ATTRIB="JSXSpreadAttribute";module.exports.JSX_TEXT="JSXText";module.exports.EXPORT_DEFAULT_DECL="ExportDefaultDeclaration";module.exports.EXPORT_NAMED_DECL="ExportNamedDeclaration";module.exports.EXPORT_ALL_DECL="ExportAllDeclaration";module.exports.EXPORT_ASSIGNMENT="TSExportAssignment";module.exports.EXPORT_SPECIFIER="ExportSpecifier";module.exports.IMPORT_DECL="ImportDeclaration";module.exports.IMPORT_EQUALS_DECL="TSImportEqualsDeclaration";module.exports.IMPORT_SPECIFIER="ImportSpecifier";module.exports.IMPORT_DEF_SPECIFIER="ImportDefaultSpecifier";module.exports.IMPORT_NS_SPECIFIER="ImportNamespaceSpecifier";module.exports.ANY_KEYWORD="TSAnyKeyword";module.exports.ARRAY_TYPE="TSArrayType";module.exports.AS_EXPR="TSAsExpression";module.exports.BOOLEAN_KEYWORD="TSBooleanKeyword";module.exports.EXTERN_MOD_REF="TSExternalModuleReference";module.exports.FUNCTION_TYPE="TSFunctionType";module.exports.INTERFACE_BODY="TSInterfaceBody";module.exports.INTERFACE_DECL="TSInterfaceDeclaration";module.exports.INTERSECTION_TYPE="TSIntersectionType";module.exports.LITERAL_TYPE="TSLiteralType";module.exports.NUMBER_KEYWORD="TSNumberKeyword";module.exports.OBJECT_KEYWORD="TSObjectKeyword";module.exports.OPTIONAL_TYPE="TSOptionalType";module.exports.PROPERTY_SIGNATURE="TSPropertySignature";module.exports.STRING_KEYWORD="TSStringKeyword";module.exports.TUPLE_TYPE="TSTupleType";module.exports.TYPE_ALIAS_DECL="TSTypeAliasDeclaration";module.exports.TYPE_LITERAL="TSTypeLiteral";module.exports.TYPE_REF="TSTypeReference";module.exports.UNION_TYPE="TSUnionType";
package/lib/Comments.js CHANGED
@@ -1 +1,6 @@
1
- var comObj={};const PREFIX="jaf-";const JAF_DISABLE="jaf-disable";const JAF_ENABLE="jaf-enable";const JAF_DISABLE_NEXT_LINE="jaf-disable-next-line";const JAF_DISABLE_LINE="jaf-disable-line";const JAF_GROUP="jaf-group";const CMDS=[JAF_DISABLE,JAF_ENABLE,JAF_DISABLE_LINE,JAF_DISABLE_NEXT_LINE,JAF_GROUP];const EOF=Infinity;function Comments(nodeDeps,rules,msgCtx,utils){this._rules=rules;this._msgCtx=msgCtx;this._utils=utils};Comments.prototype.reset=function(fnAst){if(this._comments){this._comments.length=0}if(this._groups){this._groups.length=0}if(fnAst){this._Ast=fnAst;this._data=fnAst.getData();this._rawComments=fnAst.getRawComments();this._processRawComments();if(this._comments&&this._comments.length){this._rationalize()}}};Comments.prototype.isDisabled=function(node){var index=node.start,i,c,ret=null;if(this._comments){for(i=0;i<this._comments.length;i++){c=this._comments[i];if(c.end!=undefined&&index>=c.start&&index<c.end){comObj.rules=c.rules;comObj.invert=c.invert;ret=comObj;break}}}return ret};Comments.prototype._processRawComments=function(){var i,cmd,raw;raw=this._rawComments;if(raw===undefined){this._comments=null;return}for(i=0;i<raw.length;i++){cmd=this._getCmd(raw[i],this._data);if(!cmd){continue}if(cmd){if(cmd.cmd!==JAF_GROUP){if(!this._comments){this._comments=[]}this._comments.push(cmd)}else{if(!this._groups){this._groups={}}this._groups[cmd.group]=cmd.rules}}}};Comments.prototype._rationalize=function(){this._dump();this._check1();this._check2();this._check3();this._check4();this._check5();this._check6();this._check7();this._check8();this._compact()};Comments.prototype._check1=function(){var com,i,prev,haveEnable=false,haveDisable=false,a=this._comments;for(i=0;i<a.length;i++){com=a[i];if(com){if(!com.cmd.startsWith(JAF_ENABLE)){break}a[i]=null}}for(i=0;i<a.length;i++){com=a[i];if(!com){continue}if(com.cmd===JAF_ENABLE){haveDisable=false;if(haveEnable){if(!com.rules){a[i]=null;haveEnable=true;continue}haveEnable=false}}else if(com.cmd===JAF_DISABLE){haveEnable=false;if(haveDisable){if(!com.rules){a[i]=null;haveDisable=true;continue}}haveDisable=false}else{haveEnable=haveDisable=false}}haveDisable=false;for(i=0;i<a.length;i++){com=a[i];if(!com){continue}if(com.cmd===JAF_DISABLE){if(haveDisable){if(!prev.rules&&com.rules){a[i]=null}}else{prev=com;haveDisable=true}}else{haveDisable=false}}this._dump("end check1")};Comments.prototype._check2=function(){var a,com,i,j;a=this._comments;for(i=0;i<a.length;i++){com=a[i];if(com&&com.rules){for(j=0;j<com.rules.length;j++){if(!this._rules.isRuleEnabled(com.rules[j])){com.rules.splice(j,1);j--}}if(!com.rules.length){a.splice(i,1);i--}}}this._dump("end check2")};Comments.prototype._check3=function(){var com,i,len;len=this._comments.length;for(i=0;i<len;i++){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE_LINE){com.start=this._utils.eatWhitespace(this._data,com.start)}}this._dump("end check3")};Comments.prototype._check4=function(){var a,com,prev,lastQ,isLast,c,i,j,x,found=false;a=this._comments;for(i=0;i<a.length;i++){com=a[i];if(!com){continue}isLast=i===_getLast(a);if(com.cmd===JAF_DISABLE){if(!com.rules){for(j=i+1;j<a.length;j++){c=a[j];if(!c){continue}if(c.cmd===JAF_ENABLE){found=true;com.end=c.startX;if(!c.rules){a[j]=null;for(x=i+1;x<j;x++){a[x]=null}}else{c.invert=true;c.cmd=JAF_DISABLE;lastQ=c}i=j;break}else if(c.cmd.startsWith(JAF_DISABLE)){if(!c.rules){a[j]=null}else{com.end=c.startX;i--}break}else{a[j]=null}}if(!found){com.end=EOF}found=false}else{i=this._mergeScope(i)}}else if(com.cmd===JAF_DISABLE_NEXT_LINE||com.cmd===JAF_DISABLE_LINE){if(lastQ&&lastQ.end===undefined){lastQ.end=com.startX}}else if(com.cmd===JAF_ENABLE){prev=this._getPrevComment(i);prev=prev>=0?a[prev]:null;if(prev&&prev.cmd===JAF_DISABLE){if(prev.rules&&!isLast){com.cmd=JAF_DISABLE;if(com.rules){_mergeScopeRules(prev,com,true);com.invert=prev.invert}}else{this._comments.splice(i,1);i--}prev.end=com.start}}}this._dump("end check4")};Comments.prototype._check5=function(){var com,stmt,prev,obj,next,i;for(i=0;i<this._comments.length;i++){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE_NEXT_LINE){stmt=this._Ast.getNodeFromIndex(this._utils.eatWhitespace(this._data,com.start));if(stmt){com.start=stmt.start;com.end=stmt.end}else{this._comments[i]=null;continue}prev=this._getPrevComment(i);prev=prev>=0?this._comments[prev]:null;if(prev&&prev.cmd===JAF_DISABLE){if(prev.end===undefined){prev.end=com.start;next=this._getNextComment(i);obj={cmd:JAF_DISABLE,rules:prev.rules,invert:prev.invert,start:com.end+1,end:next?next.start-1:EOF};this._comments.splice(i+1,0,obj);i++}}}}this._dump("end check5")};Comments.prototype._check6=function(){var com,stmt,prev,obj,next,i;for(i=0;i<this._comments.length;i++){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE_LINE){stmt=this._Ast.getNodeFromIndex(this._utils.eatWhitespace(this._data,com.start));if(stmt){com.start=stmt.start;com.end=stmt.end}else{this._comments[i]=null;continue}prev=this._getPrevComment(i);prev=prev>=0?this._comments[prev]:null;if(prev&&prev.cmd===JAF_DISABLE){if(prev.end===undefined){prev.end=com.start;next=this._getNextComment(i);obj={cmd:JAF_DISABLE,rules:prev.rules,invert:prev.invert,start:com.end+1,end:next?next.start-1:EOF};this._comments.splice(i+1,0,obj);i++}}}}this._dump("end check6")};Comments.prototype._check7=function(){var com,prev,i;i=_getLast(this._comments);if(i>=0){com=this._comments[i];if(com.cmd===JAF_ENABLE){prev=this._getPrevComment(i);this._comments.splice(i,1);i--;prev=prev>=0?this._comments[prev]:null;if(prev&&prev.end===undefined){prev.end=com.start}}}this._dump("end check7");return i};Comments.prototype._check8=function(){var com,haveEOF=false,last,i;for(i=0;i<this._comments.length;i++){com=this._comments[i];if(com){last=com;if(com.end===EOF){if(haveEOF){this._comments[i]=null}else{haveEOF=true}}}}if(!haveEOF&&last&&last.cmd!==JAF_ENABLE&&last.end===undefined){if(this._comments.length){this._comments[this._comments.length-1].end=EOF}}this._dump("end check8")};Comments.prototype._compact=function(){var a=this._comments,i;for(i=0;i<a.length;i++){if(!a[i]){a.splice(i,1);i--}}this._dump("end compact",true)};Comments.prototype._mergeScope=function(i){var a,scope,prev,com,isEnable,isLast;a=this._comments;isLast=i===_getLast(a);com=this._comments[i];isEnable=com.cmd===JAF_ENABLE;scope=this._getPrevScope(i);if(scope<0){return i}scope=a[scope];prev=this._getPrevComment(i);prev=a[prev];if(isEnable||prev.rules){if(isEnable){if(!com.rules){prev.end=com.start;this._comments.splice(i,1);return i-1}com.cmd=JAF_DISABLE}if(com.rules){_mergeScopeRules(prev,com,isEnable);prev.end=com.start}}else{if(prev.end){return i}if(prev.cmd!==JAF_DISABLE){return i}this._comments.splice(i,1);i--}return i};function _mergeScopeRules(prev,com,isEnable){var prevRules,comRules,prevRulesLen,comRulesLen,i;prevRules=prev.rules;comRules=com.rules;prevRulesLen=prevRules?prevRules.length:0;comRulesLen=comRules?comRules.length:0;if(isEnable){if(prevRulesLen){for(i=0;i<prevRules.length;i++){if(!comRules.includes(prevRules[i])){comRules.push(prevRules[i])}}com.invert=prev.invert}else{com.invert=true}}else{if(prevRulesLen&&comRulesLen){if(!prev.invert){for(i=0;i<prevRulesLen;i++){if(!comRules.includes(prevRules[i])){comRules.push(prevRules[i])}}}else{for(i=0;i<comRulesLen;i++){var temp=[];if(!comRules.includes(prevRules[i])){temp.push(prevRules[i])}}com.rules=temp;com.invert=true}}}};Comments.prototype._getPrevComment=function(i){var i;for(--i;i>=0;i--){if(this._comments[i]){break}}return i};Comments.prototype._getPrevScope=function(i){var com,i;for(--i;i>=0;i--){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE){break}}return i};Comments.prototype._getNextComment=function(index){var o;while(++index<this._comments.length){o=this._comments[index];if(o)return o}return null};function _getLast(a){var last=-1,i;for(i=a.length-1;i>=0;i--){if(a[i]){last=i;break}}return last};Comments.prototype._getCmd=function(comment,data){var ret=null,value,cmdIndex,x,cmd,rest,rules,a,i,entry,startOfLine=-1;value=comment.value.trim();if(!value.startsWith(PREFIX)){return null}x=this._utils.getIndexToWhitespace(value,0);cmd=x>=0?value.substring(0,x):value;cmdIndex=CMDS.indexOf(cmd);if(cmdIndex<0){return null}if(cmd===JAF_GROUP){return this._getGroup(value,x)}if(cmd===JAF_DISABLE_LINE){startOfLine=_getStartOfLineIndex(data,comment.start)}ret={cmd:cmd,rules:null,start:startOfLine>=0?startOfLine:comment.end,end:undefined,startX:comment.start,endX:comment.end};rest=x>=0?value.substring(x).trim():"";if(rest.length){a=rest.split(",");for(i=0;i<a.length;i++){entry=a[i];if(entry){entry=entry.trim();if(entry){if(!rules){ret.rules=rules=[]}rules.push(entry)}}}}return ret};function _getStartOfLineIndex(data,index){while(index){if(data.charAt(index)==="\n"){return index+1}index--}};Comments.prototype._getGroup=function(value,x){var group,rules,rule,rest,t,i,j,ret,ruleCount=0,x;rest=x>=0?value.substring(x).trim():"";if(!rest.length){return null}x=rest.charAt(0)==="{"?1:0;t=this._getToken(rest,x);if(t.tok==="STRING"){group=rest.substring(x,t.next)}rest=rest.substring(t.next);i=this._expect(rest,":");if(i>=0){i=this._expect(rest,"[",i);if(i>=0){j=rest.indexOf("]",i);if(j>=0){rules=rest.substring(i,j).trim().split(",");if(rules.length){ret={cmd:JAF_GROUP,group:group,rules:[]};for(i=0;i<rules.length;i++){rule=rules[i].trim();if(rule.length){rule=rule.replace(/\"/g,"");if(!/\s/.test(rule)){if(this._isValidRuleName(rule)){ret.rules.push(rule);ruleCount++}}}}if(ruleCount){return ret}}}}}return null};Comments.prototype._expect=function(str,need,x){var t;t=this._getToken(str,x);if(t.tok===need||t.tok===t.value){return t.next}return-1};Comments.prototype._getToken=function(str,x){var c,raw,len,i,j;i=x|0;len=str.length;for(;i<len;i++){c=str[i];if(this._utils.isWhitespace(c)){continue}if(this._isGroupChar(c)){for(j=i+1;j<len;j++){c=str[j];if(this._isGroupChar(c)){continue}raw=str.substring(i,j);return{tok:"STRING",value:raw,next:j}}}else if(this._utils.isDigit(c)){for(j=i+1;j<len;j++){c=str[j];if(this._utils.isAdigit(c)){continue}raw=str.substring(i,j);return{tok:"NUMBER",value:parseInt(raw),raw:raw,next:j}}}else{return{tok:c,value:c,next:i+1}}}return null};Comments.prototype._isGroupChar=function(c){return this._utils.isAlphaNum(c)||c==="-"||c=="_"};Comments.prototype._isValidRuleName=function(rule){var c,i,len,ret=true;len=rule?rule.length:0;for(i=0;i<len;i++){c=rule.charAt(i);if(!this._isGroupChar(c)||i===0&&this._utils.isDigit(c)){ret=false;break}}return ret};Comments.prototype._dump=function(title,newLine){var show=this._msgCtx.isDebug?this._msgCtx.debug:function(){};var i,j,com,rules,s,len;len=this._comments?this._comments.length:0;show("\nComments"+(title?" ("+title+")":"")+": "+(len===0?" - empty":""));for(i=0;i<len;i++){com=this._comments[i];if(!com){show("["+i+"]");continue}s="";rules=com.rules;if(rules){s="[";for(j=0;j<rules.length;j++){if(j){s+=", "}s+=rules[j]}s+="]";s+=com.invert?":invert":""}show("["+i+"] "+com.cmd+(rules?" "+s:""));show(" ("+com.start+", "+(com.end===EOF?"EOF":com.end)+") ["+com.startX+", "+com.endX+"]")}if(newLine)show("\n")};module.exports=Comments;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ var comObj={};const PREFIX="jaf-";const JAF_DISABLE="jaf-disable";const JAF_ENABLE="jaf-enable";const JAF_DISABLE_NEXT_LINE="jaf-disable-next-line";const JAF_DISABLE_LINE="jaf-disable-line";const JAF_GROUP="jaf-group";const CMDS=[JAF_DISABLE,JAF_ENABLE,JAF_DISABLE_LINE,JAF_DISABLE_NEXT_LINE,JAF_GROUP];const EOF=Infinity;function Comments(nodeDeps,rules,msgCtx,utils,isTS){this._rules=rules;this._msgCtx=msgCtx;this._utils=utils;this._isTS=isTS};Comments.prototype.reset=function(fnAst){if(this._comments){this._comments.length=0}if(this._groups){this._groups.length=0}if(fnAst){this._Ast=fnAst;this._data=fnAst.getData();this._rawComments=fnAst.getRawComments();this._processRawComments();if(this._comments&&this._comments.length){this._rationalize()}}};Comments.prototype.isDisabled=function(node){var index,i,c,ret=null;index=this._isTS?node.range[0]:node.start;if(this._comments){for(i=0;i<this._comments.length;i++){c=this._comments[i];if(c.end!=undefined&&index>=c.start&&index<c.end){comObj.rules=c.rules;comObj.invert=c.invert;ret=comObj;break}}}return ret};Comments.prototype._processRawComments=function(){if(this._isTS){this._SetTSRawPositions()}var i,cmd,raw;raw=this._rawComments;if(raw===undefined){this._comments=null;return}for(i=0;i<raw.length;i++){cmd=this._getCmd(raw[i],this._data);if(!cmd){continue}if(cmd){if(cmd.cmd!==JAF_GROUP){if(!this._comments){this._comments=[]}this._comments.push(cmd)}else{if(!this._groups){this._groups={}}this._groups[cmd.group]=cmd.rules}}}};Comments.prototype._SetTSRawPositions=function(){var rcoms,raw,i;rcoms=this._rawComments;for(i=0;i<rcoms.length;i++){raw=rcoms[i];raw.start=raw.range[0];raw.end=raw.range[1]}};Comments.prototype._rationalize=function(){this._dump();this._check1();this._check2();this._check3();this._check4();this._check5();this._check6();this._check7();this._check8();this._compact()};Comments.prototype._check1=function(){var com,i,prev,haveEnable=false,haveDisable=false,a=this._comments;for(i=0;i<a.length;i++){com=a[i];if(com){if(!com.cmd.startsWith(JAF_ENABLE)){break}a[i]=null}}for(i=0;i<a.length;i++){com=a[i];if(!com){continue}if(com.cmd===JAF_ENABLE){haveDisable=false;if(haveEnable){if(!com.rules){a[i]=null;haveEnable=true;continue}haveEnable=false}}else if(com.cmd===JAF_DISABLE){haveEnable=false;if(haveDisable){if(!com.rules){a[i]=null;haveDisable=true;continue}}haveDisable=false}else{haveEnable=haveDisable=false}}haveDisable=false;for(i=0;i<a.length;i++){com=a[i];if(!com){continue}if(com.cmd===JAF_DISABLE){if(haveDisable){if(!prev.rules&&com.rules){a[i]=null}}else{prev=com;haveDisable=true}}else{haveDisable=false}}this._dump("end check1")};Comments.prototype._check2=function(){var a,com,i,j;a=this._comments;for(i=0;i<a.length;i++){com=a[i];if(com&&com.rules){for(j=0;j<com.rules.length;j++){if(!this._rules.isRuleEnabled(com.rules[j])){com.rules.splice(j,1);j--}}if(!com.rules.length){a.splice(i,1);i--}}}this._dump("end check2")};Comments.prototype._check3=function(){var com,i,len;len=this._comments.length;for(i=0;i<len;i++){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE_LINE){com.start=this._utils.eatWhitespace(this._data,com.start)}}this._dump("end check3")};Comments.prototype._check4=function(){var a,com,prev,lastQ,isLast,c,i,j,x,found=false;a=this._comments;for(i=0;i<a.length;i++){com=a[i];if(!com){continue}isLast=i===_getLast(a);if(com.cmd===JAF_DISABLE){if(!com.rules){for(j=i+1;j<a.length;j++){c=a[j];if(!c){continue}if(c.cmd===JAF_ENABLE){found=true;com.end=c.startX;if(!c.rules){a[j]=null;for(x=i+1;x<j;x++){a[x]=null}}else{c.invert=true;c.cmd=JAF_DISABLE;lastQ=c}i=j;break}else if(c.cmd.startsWith(JAF_DISABLE)){if(!c.rules){a[j]=null}else{com.end=c.startX;i--}break}else{a[j]=null}}if(!found){com.end=EOF}found=false}else{i=this._mergeScope(i)}}else if(com.cmd===JAF_DISABLE_NEXT_LINE||com.cmd===JAF_DISABLE_LINE){if(lastQ&&lastQ.end===undefined){lastQ.end=com.startX}}else if(com.cmd===JAF_ENABLE){prev=this._getPrevComment(i);prev=prev>=0?a[prev]:null;if(prev&&prev.cmd===JAF_DISABLE){if(prev.rules&&!isLast){com.cmd=JAF_DISABLE;if(com.rules){_mergeScopeRules(prev,com,true);com.invert=prev.invert}}else{this._comments.splice(i,1);i--}prev.end=com.start}}}this._dump("end check4")};Comments.prototype._check5=function(){var com,stmt,prev,obj,next,i;for(i=0;i<this._comments.length;i++){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE_NEXT_LINE){stmt=this._Ast.getNodeFromIndex(this._utils.eatWhitespace(this._data,com.start));if(stmt){if(this._isTS){com.start=stmt.range[0];com.end=stmt.range[1]}else{com.start=stmt.start;com.end=stmt.end}}else{this._comments[i]=null;continue}prev=this._getPrevComment(i);prev=prev>=0?this._comments[prev]:null;if(prev&&prev.cmd===JAF_DISABLE){if(prev.end===undefined){prev.end=com.start;next=this._getNextComment(i);obj={cmd:JAF_DISABLE,rules:prev.rules,invert:prev.invert,start:com.end+1,end:next?next.start-1:EOF};this._comments.splice(i+1,0,obj);i++}}}}this._dump("end check5")};Comments.prototype._check6=function(){var com,stmt,prev,obj,next,i;for(i=0;i<this._comments.length;i++){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE_LINE){stmt=this._Ast.getNodeFromIndex(this._utils.eatWhitespace(this._data,com.start));if(stmt){if(this._isTS){com.start=stmt.range[0];com.end=stmt.range[1]}else{com.start=stmt.start;com.end=stmt.end}}else{this._comments[i]=null;continue}prev=this._getPrevComment(i);prev=prev>=0?this._comments[prev]:null;if(prev&&prev.cmd===JAF_DISABLE){if(prev.end===undefined){prev.end=com.start;next=this._getNextComment(i);obj={cmd:JAF_DISABLE,rules:prev.rules,invert:prev.invert,start:com.end+1,end:next?next.start-1:EOF};this._comments.splice(i+1,0,obj);i++}}}}this._dump("end check6")};Comments.prototype._check7=function(){var com,prev,i;i=_getLast(this._comments);if(i>=0){com=this._comments[i];if(com.cmd===JAF_ENABLE){prev=this._getPrevComment(i);this._comments.splice(i,1);i--;prev=prev>=0?this._comments[prev]:null;if(prev&&prev.end===undefined){prev.end=com.start}}}this._dump("end check7");return i};Comments.prototype._check8=function(){var com,haveEOF=false,last,i;for(i=0;i<this._comments.length;i++){com=this._comments[i];if(com){last=com;if(com.end===EOF){if(haveEOF){this._comments[i]=null}else{haveEOF=true}}}}if(!haveEOF&&last&&last.cmd!==JAF_ENABLE&&last.end===undefined){if(this._comments.length){this._comments[this._comments.length-1].end=EOF}}this._dump("end check8")};Comments.prototype._compact=function(){var a=this._comments,i;for(i=0;i<a.length;i++){if(!a[i]){a.splice(i,1);i--}}this._dump("end compact",true)};Comments.prototype._mergeScope=function(i){var a,scope,prev,com,isEnable,isLast;a=this._comments;isLast=i===_getLast(a);com=this._comments[i];isEnable=com.cmd===JAF_ENABLE;scope=this._getPrevScope(i);if(scope<0){return i}scope=a[scope];prev=this._getPrevComment(i);prev=a[prev];if(isEnable||prev.rules){if(isEnable){if(!com.rules){prev.end=com.start;this._comments.splice(i,1);return i-1}com.cmd=JAF_DISABLE}if(com.rules){_mergeScopeRules(prev,com,isEnable);prev.end=com.start}}else{if(prev.end){return i}if(prev.cmd!==JAF_DISABLE){return i}this._comments.splice(i,1);i--}return i};function _mergeScopeRules(prev,com,isEnable){var prevRules,comRules,prevRulesLen,comRulesLen,i;prevRules=prev.rules;comRules=com.rules;prevRulesLen=prevRules?prevRules.length:0;comRulesLen=comRules?comRules.length:0;if(isEnable){if(prevRulesLen){for(i=0;i<prevRules.length;i++){if(!comRules.includes(prevRules[i])){comRules.push(prevRules[i])}}com.invert=prev.invert}else{com.invert=true}}else{if(prevRulesLen&&comRulesLen){if(!prev.invert){for(i=0;i<prevRulesLen;i++){if(!comRules.includes(prevRules[i])){comRules.push(prevRules[i])}}}else{for(i=0;i<comRulesLen;i++){var temp=[];if(!comRules.includes(prevRules[i])){temp.push(prevRules[i])}}com.rules=temp;com.invert=true}}}};Comments.prototype._getPrevComment=function(i){var i;for(--i;i>=0;i--){if(this._comments[i]){break}}return i};Comments.prototype._getPrevScope=function(i){var com,i;for(--i;i>=0;i--){com=this._comments[i];if(com&&com.cmd===JAF_DISABLE){break}}return i};Comments.prototype._getNextComment=function(index){var o;while(++index<this._comments.length){o=this._comments[index];if(o)return o}return null};function _getLast(a){var last=-1,i;for(i=a.length-1;i>=0;i--){if(a[i]){last=i;break}}return last};Comments.prototype._getCmd=function(comment,data){var ret=null,value,cmdIndex,x,cmd,rest,rules,a,i,entry,startOfLine=-1;value=comment.value.trim();if(!value.startsWith(PREFIX)){return null}x=this._utils.getIndexToWhitespace(value,0);cmd=x>=0?value.substring(0,x):value;cmdIndex=CMDS.indexOf(cmd);if(cmdIndex<0){return null}if(cmd===JAF_GROUP){return this._getGroup(value,x)}if(cmd===JAF_DISABLE_LINE){startOfLine=_getStartOfLineIndex(data,comment.start)}ret={cmd:cmd,rules:null,start:startOfLine>=0?startOfLine:comment.end,end:undefined,startX:comment.start,endX:comment.end};rest=x>=0?value.substring(x).trim():"";if(rest.length){a=rest.split(",");for(i=0;i<a.length;i++){entry=a[i];if(entry){entry=entry.trim();if(entry){if(!rules){ret.rules=rules=[]}rules.push(entry)}}}}return ret};function _getStartOfLineIndex(data,index){while(index){if(data.charAt(index)==="\n"){return index+1}index--}};Comments.prototype._getGroup=function(value,x){var group,rules,rule,rest,t,i,j,ret,ruleCount=0,x;rest=x>=0?value.substring(x).trim():"";if(!rest.length){return null}x=rest.charAt(0)==="{"?1:0;t=this._getToken(rest,x);if(t.tok==="STRING"){group=rest.substring(x,t.next)}rest=rest.substring(t.next);i=this._expect(rest,":");if(i>=0){i=this._expect(rest,"[",i);if(i>=0){j=rest.indexOf("]",i);if(j>=0){rules=rest.substring(i,j).trim().split(",");if(rules.length){ret={cmd:JAF_GROUP,group:group,rules:[]};for(i=0;i<rules.length;i++){rule=rules[i].trim();if(rule.length){rule=rule.replace(/\"/g,"");if(!/\s/.test(rule)){if(this._isValidRuleName(rule)){ret.rules.push(rule);ruleCount++}}}}if(ruleCount){return ret}}}}}return null};Comments.prototype._expect=function(str,need,x){var t;t=this._getToken(str,x);if(t.tok===need||t.tok===t.value){return t.next}return-1};Comments.prototype._getToken=function(str,x){var c,raw,len,i,j;i=x|0;len=str.length;for(;i<len;i++){c=str[i];if(this._utils.isWhitespace(c)){continue}if(this._isGroupChar(c)){for(j=i+1;j<len;j++){c=str[j];if(this._isGroupChar(c)){continue}raw=str.substring(i,j);return{tok:"STRING",value:raw,next:j}}}else if(this._utils.isDigit(c)){for(j=i+1;j<len;j++){c=str[j];if(this._utils.isAdigit(c)){continue}raw=str.substring(i,j);return{tok:"NUMBER",value:parseInt(raw),raw:raw,next:j}}}else{return{tok:c,value:c,next:i+1}}}return null};Comments.prototype._isGroupChar=function(c){return this._utils.isAlphaNum(c)||c==="-"||c=="_"};Comments.prototype._isValidRuleName=function(rule){var c,i,len,ret=true;len=rule?rule.length:0;for(i=0;i<len;i++){c=rule.charAt(i);if(!this._isGroupChar(c)||i===0&&this._utils.isDigit(c)){ret=false;break}}return ret};Comments.prototype._dump=function(title,newLine){var show=this._msgCtx.isDebug?this._msgCtx.debug:function(){};var i,j,com,rules,s,len;len=this._comments?this._comments.length:0;show("\nComments"+(title?" ("+title+")":"")+": "+(len===0?" - empty":""));for(i=0;i<len;i++){com=this._comments[i];if(!com){show("["+i+"]");continue}s="";rules=com.rules;if(rules){s="[";for(j=0;j<rules.length;j++){if(j){s+=", "}s+=rules[j]}s+="]";s+=com.invert?":invert":""}show("["+i+"] "+com.cmd+(rules?" "+s:""));show(" ("+com.start+", "+(com.end===EOF?"EOF":com.end)+") ["+com.startX+", "+com.endX+"]")}if(newLine)show("\n")};module.exports=Comments;
@@ -1 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
1
6
  const SCHEMA_NAME="component-schema.json";const COMPONENT_JSON="component.json";const COMP_TYPES=["composite","core","pack","reference","resource","vbcs-pattern","vbcs-template"];const SCHEMA_PATH="schema";const RULE_INIT_SCHEMA="jaf-init-schema";const JAF_RSI=0;const RE_FWDSLASHIFY=/\\/g;function ComponentSvcs(nd,metaPath,cfg,tmpDir,appCtx){this._nd=nd;this._error=appCtx.error;this._warn=appCtx.warn;this._debug=appCtx.debug;this._reporter=appCtx.reporter;this._Issue=appCtx.Issue;this._flushIssues=appCtx.flushIssues;this._getMsgId=appCtx.getMsgId;this._rules=appCtx.rules;this._compOptions=cfg.getComponentOptions();this._tempDir=tmpDir;this._schemaName=SCHEMA_NAME;this._schemaPath=nd.path.dirname(metaPath);this._schemaPath=nd.path.dirname(this._schemaPath);this._schemaPath=nd.path.join(this._schemaPath,SCHEMA_PATH,SCHEMA_NAME);this._schemaExists=nd.fs.existsSync(this._schemaPath);this._schemaChecked=true;if(!this._schemaExists&&!this._schemaMsgEmitted){this._error("Schema '"+this._schemaPath+"' not found! Component schema checking disabled.");this._schemaMsgEmitted=true}if(appCtx.debugMode){this._debug("Schema -> "+this._schemaPath)}this._zipUtils=require("./ZipUtils");this._zipUtils=new this._zipUtils(nd)};ComponentSvcs.prototype.loadZip=function(zipPath){return this._zipUtils.loadZip(zipPath)};ComponentSvcs.prototype.getZipContents=function(zipPath){return this._zipUtils.getContents(zipPath)};ComponentSvcs.prototype.extractFileFromZip=function(filePath,zipPath){return this._zipUtils.extractFileFromZip(filePath,zipPath)};ComponentSvcs.prototype.validateComponentJson=function(obj,fromLocation){var name,results,result,issue,ctx,opts,i;if(!obj.name){this._error("component definition at '"+fromLocation+"' has no 'name' property!");return false}else{if(typeof obj.name!=="string"){this._error("custom component at '"+fromLocation+"' has invalid 'name' property!");return false}}opts=this._rules.getRuleOptions(RULE_INIT_SCHEMA,JAF_RSI);if(!opts.enabled){return true}if(!this._schemaExists){return false}name=obj.name;if(!this._compOptions||this._compOptions.applySchema){results=this.validateComponentJsonWithSchema(obj);if(results){fromLocation=fromLocation.replace(/\\/g,"/");this._warn("\nSchema validation of component <"+name+"> : "+results.length+" issue"+(results.length===1?" was":"s were")+" found! \n : "+fromLocation);for(i=0;i<results.length;i++){result=results[i];issue=new this._Issue(result.msg.length?result.msg:JSON.stringify(result.error,null,4));ctx=this._makeIssueContext(fromLocation,RULE_INIT_SCHEMA);issue.msgId=this._getMsgId(ctx,RULE_INIT_SCHEMA);this._rules.getRulePack(ctx._rsi)._setCBCtx(ctx);this._reporter.addIssue(issue,ctx)}this._flushIssues()}}return true};ComponentSvcs.prototype.extractComponentJsonFromZip=function(fpath){var text,obj,ret=null;this._debug("extracting component.json from '"+fpath+"'");ret={obj:null,data:null,msg:null,error:false};text=this._zipUtils.extractFileFromZip(COMPONENT_JSON,fpath);if(typeof text==="string"){if(text.length){ret.data=text;try{ret.obj=JSON.parse(text)}catch(e){ret.msg=e.message}}}else{obj.error=true}return ret};ComponentSvcs.prototype.validateComponentJsonWithSchema=function(obj){return this._nd.schema.validateComponentJson(obj)};ComponentSvcs.prototype.loadUrl=function(url){if(!this._netUtils){this._netUtils=require("./NetUtils");this._netUtils=new this._netUtils}return this._netUtils.loadUrl(url)};ComponentSvcs.prototype.writeZipBufferToFile=function(buffer){var ret;try{this._tmpName=this._zipUtils.createTempZipFilename();ret=this._zipUtils.writeBufferToFile(buffer,this._nd.path.join(this._tempDir,this._tmpName))}catch(e){ret=e}return ret};ComponentSvcs.prototype.getLastZipFilePath=function(){return this._zipUtils.getLastFilepath()};ComponentSvcs.prototype.deleteZipFile=function(filePath){this._zipUtils.deleteFile(filePath)};ComponentSvcs.prototype.isValidType=function(type){return type?COMP_TYPES.indexOf(type)>=0:true};ComponentSvcs.prototype.getSchemaName=function(){return this._schemaName};ComponentSvcs.prototype.stripUrlQuery=function(url){return this._netUtils.stripQuery(url)};ComponentSvcs.prototype._makeIssueContext=function(fromLocation,ruleName){return{filepath:_fwdSlashify(this._nd.path.join(fromLocation,"component.json")),opts:this._rules.getRuleOptions(ruleName,JAF_RSI),rulePack:this._rules.getRulePack(JAF_RSI),_rsi:JAF_RSI,ruleName:ruleName,position:{line:0,col:0,start:0,end:0}}};function _fwdSlashify(path){return path.replace(RE_FWDSLASHIFY,"/")};module.exports=ComponentSvcs;
package/lib/Components.js CHANGED
@@ -1 +1,6 @@
1
- "use strict";const COMPONENT_JSON="component.json";const PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const DYNAMIC_FORM_ELEM="DynamicFormElement";const DYNAMIC_TABLE_ELEM="DynamicTableElement";const REGXPR=/string|number|object|array|boolean|[\|.<>]/gi;function Components(nd,runMode,compSvcs,urlBase,urls,filePaths,jetCore,msgContext,runOpts,utils){this._nd=nd;this._data={};this._path=null;this._reqAttrs=null;this._utils=utils;this._compSvcs=compSvcs;this._isAMD=runMode==="amd";this._error=msgContext.error;this._warn=msgContext.warn;this._debug=msgContext.debug;this._info=msgContext.info;this._msg=msgContext.msg;this._console=msgContext.console;this._count=0;this._isOk=true;this._runOpts=runOpts;this._init(urlBase,urls,filePaths,jetCore)};Components.prototype.isTag=function(tagName){return!!this._data[tagName]};Components.prototype.isTagAttr=function(tagName,attrName){return this.isTagProp(tagName,attrName)};Components.prototype.isTagAttrDeprecated=function(tagName,attrName){var prop,name,stats,stat,i;prop=this.getTagProp(tagName,attrName);if(prop&&prop.status){name=_deCamelCaseProp(attrName);stats=prop.status;for(i=0;i<stats.length;i++){stat=stats[i];if(stat.name===name){return{since:stat.since,description:stat.description}}}}return null};Components.prototype.isTagProp=function(tagName,propName){return!!this.getTagProp(tagName,propName)};Components.prototype.getTagProp=function(tagName,propName){var tag,props;tag=this._data[tagName];props=tag?tag[PROP_PROPS]:null;if(props){propName=_deCamelCaseProp(propName)}return props?props[propName]:false};Components.prototype.getTagPropType=function(tagName,propName){var tag,props,prop,ret;tag=this._data[tagName];props=tag?tag[PROP_PROPS]:null;if(props){propName=_deCamelCaseProp(propName);prop=props[propName];ret=prop?prop.type:undefined}return ret};Components.prototype.isTagEvent=function(tagName,eventName){var propName,o,b;o=this._data[tagName];if(o){if(eventName.startsWith("on-")){b=o.events&&o.events[eventName];if(b)return b;if(o.implements&&(o.implements.includes(DYNAMIC_FORM_ELEM)||o.implements.includes(DYNAMIC_TABLE_ELEM))){return true}if(eventName.endsWith("-changed")){if(o.props){propName=eventName.replace("-changed","").substring(3);return!!o.props[propName]}}}}return false};Components.prototype.hasTagSlotName=function(tagName,slotName){var o=this._data[tagName];return!!(o&&o.slots&&o.slots[slotName])};Components.prototype.hasTagAttrValues=function(tagName,attrName){var tag,props,prop,propName,ret=false;tag=this._data[tagName];if(tag){props=tag[PROP_PROPS];if(props){propName=_deCamelCaseProp(attrName);prop=props[propName];if(prop){ret=!!prop.enums}}}return ret};Components.prototype.isTagAttrValue=function(tagName,attrName,value){var tag,props,prop,propName,ret=false;tag=this._data[tagName];if(tag){props=tag[PROP_PROPS];if(props){propName=_deCamelCaseProp(attrName);prop=props[propName];if(prop&&prop.enums){ret=prop.enums.indexOf(value)>=0}}}return ret};Components.prototype.isTagAttrEnumDeprecated=function(tag,attr,val){var tag,props,prop,propName,stats,stat,i,ret=false;tag=this._data[tag];if(tag){props=tag[PROP_PROPS];if(props){propName=_deCamelCaseProp(attr);prop=props[propName];if(prop&&prop.enums&&prop.status){stats=prop.status;for(i=0;i<stats.length;i++){stat=stats[i];if(stat.value===val){ret={since:stat.since,description:stat.description};break}}}}}return ret};Components.prototype.isTagSupportedInTheme=function(tag,theme){var o,unsup,ret=true;o=this._data[tag];if(o){unsup=o[PROP_UNSUP_THEME];if(unsup){ret=!unsup.includes(theme)}}return ret};Components.prototype.isAttrSupportedInTheme=function(tag,attr,theme){var o,props,prop,propName,unsup,ret=true;o=this._data[tag];if(o){props=o[PROP_PROPS];if(props){propName=_deCamelCaseProp(attr);prop=props[propName];if(prop){unsup=prop[PROP_UNSUP_THEME];if(unsup){ret=!unsup.includes(theme)}}}}return ret};Components.prototype.getRequiredAttrs=function(tagName){var tag,props,attr,attrName,obj,ret=null;tagName=_removeChevrons(tagName);if(this._reqAttrs){let r=this._reqAttrs[tagName];if(r){return typeof r==="boolean"?null:r}}tag=this._data[tagName];if(tag&&tag.props){if(!this._reqAttrs){this._reqAttrs={}}if(!this._reqAttrs[tagName]){this._reqAttrs[tagName]=true}props=tag.props;for(attrName in props){attr=props[attrName];if(attr.required){if(!obj){obj=[]}obj.push(_deCamelCaseProp(attrName))}}}if(obj&&obj.length){this._reqAttrs[tagName]=obj;ret=obj}return ret};Components.prototype.getNames=function(){var name,a=[];for(name in this._data){a.push({name:name,version:this._data[name].version})}return a};Components.prototype.getCount=function(){return this._count};Components.prototype.isOk=function(){return this._isOk};Components.prototype._init=function(base,urls,filePaths,jetCore){if(this._isAMD){return}if(base){base=base.trim();if(base.charAt(base.length-1)!=="/"){base=base+"/"}}else{base=""}this._processFilePaths(filePaths);this._processUrls(base,urls);this._processJetCore(jetCore)};Components.prototype._processFilePaths=function(filePaths){var obj,compEntry,fpath,i,j;if(!filePaths){return}this._console("\nPre-processing user-declared web component metadata...");for(i=0;i<filePaths.length;i++){compEntry=filePaths[i];var dirStack=this._nd.glob.sync(compEntry);for(j=0;j<dirStack.length;j++){fpath=dirStack[j];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg="-".repeat(70)+"\n"+(this._runOpts.isDryRun?"* ":"")+"processing component path '"+fpath+"' ...";if(this._runOpts.isDryRun){console.log(msg)}else{this._debug(msg)}}if(fpath.toLowerCase().endsWith(".zip")){obj=this._compSvcs._extractComponentJsonFromZip(fpath);if(obj.obj){this.processComponentJson(obj.obj,fpath,true)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+fpath)}else if(obj.error){this._error("Failed to unzip '"+fpath+"'")}continue}if(this._isComponentJsonPath(fpath)){obj=this._readComponentJson(fpath);if(obj){if(obj.type&&obj.type==="pack"){continue}this.processComponentJson(obj,this._nd.path.dirname(fpath),true)}continue}this._recurse(fpath)}}this._debug("-".repeat(70))};Components.prototype._recurse=function(fpath){var dirs,inFile,obj,i;try{dirs=this._nd.fs.readdirSync(fpath);this._debug(" processing "+fpath+" "+dirs.length+" component dirs ...");for(i=0;i<dirs.length;i++){inFile=dirs[i];if(inFile===COMPONENT_JSON){inFile=this._nd.path.join(fpath,COMPONENT_JSON);this._debug(" processing "+inFile+"...");obj=this._readComponentJson(inFile);if(obj){if(!obj.type||obj.type==="composite"){this.processComponentJson(obj,fpath,true)}}else{return}}var curPath=this._nd.path.join(fpath,inFile);if(this._nd.fsUtils.getFileType(curPath)==="d"){this._recurse(curPath)}}}catch(e){this._error("Component check failed - "+e);this._isOk=false}};Components.prototype._processUrls=function(base,urls){var url,i;if(!urls){return}for(i=0;i<urls.length;i++){url=urls[i];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg;msg="-".repeat(70)+"\nprocessing URL '"+url+"'";if(this._runOpts.isDryRun){console.log(msg);continue}else{this._debug(msg)}}if(_isRelativeUrl(url)){url=base+url;if(_isRelativeUrl(url)){this._error("component URL incomplete - '"+url+"'");continue}}this._processUrl(url)}};Components.prototype._processUrl=function(url){var resp,obj,rc,tempFile,tmp;try{resp=this._compSvcs.loadUrl(url);if(resp.eCode==="ETIMEDOUT"){this._error("config.componentUrls - request timed-out for '"+url+"'");this._isOk=false;return}try{if(resp.type==="json"){if(resp.body){obj=JSON.parse(resp.body);if(!this.processComponentJson(obj,url,false)){this._isOk=false}}else{this._error("Server responded with "+resp.statusCode+" URL: '"+url+"'")}}else if(resp.type=="zip"){rc=this._compSvcs.writeZipBufferToFile(resp.body);if(typeof rc==="boolean"&&rc){tempFile=this._compSvcs.getLastZipFilePath();obj=this._compSvcs.extractComponentJsonFromZip(tempFile);if(obj.obj){this.processComponentJson(obj.obj,url,true)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+url)}else if(obj.error){this._error("Failed to unzip '"+url+"'")}this._compSvcs.deleteZipFile(tempFile)}else{this._error("Failed to create local temp zip file from URL '"+url+"' : rc.message");this._isOk=false}}else{tmp=typeof resp.type==="string"?resp.type:"?";this._error("Server responded with unexpected data ('"+tmp+"') : '"+url+"'");this._isOk=false}}catch(e){this._error("Invalid JSON - URL '"+url+"' : "+e);this._isOk=false}}catch(e1){this._error("URL access failed "+(e1.message.includes("ENOTFOUND")?"(NOT FOUND)":"")+" - URL '"+url+"'");this._isOk=false}};Components.prototype.processComponentJson=function(obj,fromLocation,wantDecache){var comp,props,events,event,compName;if(!this._isAMD){if(this._runOpts.isDryRun){console.log(" Would have processed '"+fromLocation+"'");return}if(obj.type&&obj.type==="pack"){return this._processJetPack(obj,fromLocation,wantDecache)}if(!this._compSvcs.validateComponentJson(obj,fromLocation)){if(wantDecache){this._nd.decache(obj)}this._isOk=false;return false}}compName=obj.pack?obj.pack+"-"+obj.name:obj.name;this._data[compName]=comp={};comp[PROP_FOLDER]=fromLocation;comp[PROP_VERSION]=obj.version;if(obj.slots){comp[PROP_SLOTS]=obj.slots}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){event=_deCamelCaseEvent(event);events[event]=true}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(wantDecache){this._nd.decache(obj)}this._count++;return true};Components.prototype._extractProps=function(propObj,propSoFar,properties,name){var prop,newProp,thisProp,soFar,obj,stats,stat,st,dep,i,j;for(prop in properties){newProp=_deCamelCaseProp(prop);soFar=(propSoFar?propSoFar+".":"")+newProp;propObj[soFar]=obj={};thisProp=properties[prop];if(thisProp.enumValues){if(Array.isArray(thisProp.enumValues)){obj.enums=thisProp.enumValues;if(thisProp.status){stats=thisProp.status;for(i=0;i<stats.length;i++){stat=stats[i];if(stat.type==="deprecated"){if(stat.since||stat.description){dep=null;if(stat.value&&stat.target==="propertyValue"){for(j=0;j<stat.value.length;j++){st=stat.value[j];if(obj.enums.indexOf(st)>=0){if(obj.enumdepr){dep=obj.enumdepr}else{obj.enumdepr=dep}dep={value:st}}}}else{dep={name:newProp}}if(dep){if(stat.since){dep.since=stat.since}if(stat.description){dep.description=stat.description}if(!obj.status){obj.status=[]}obj.status.push(dep)}};}}}}else{this._error("CCA component'"+name+"' property '"+soFar+"' has invalid 'enumValues' in component.json")}}if(thisProp.type){obj.type=thisProp.type}if(thisProp.required){obj.required=true}if(thisProp.extension&&thisProp.extension.theme&&thisProp.extension.theme.unsupportedThemes){obj[PROP_UNSUP_THEME]=thisProp.extension.theme.unsupportedThemes}if(thisProp.properties){obj.properties=true;this._extractProps(propObj,soFar,thisProp.properties,name)}}};Components.prototype._validatePropertyType=function(propType){propType=propType.replace(REGXPR,"");propType=propType.trim();return propType.length===0};Components.prototype._processJetPack=function(obj,fromLocation){var deps,dep,urlKey,depUrl,msg,i;if(this._runOpts.isDryRun||this._runOpts.isDebug){msg="processing JET Pack "+obj.name+" (version: "+obj.version+") : '"+fromLocation+"'";if(this._runOpts.isDryRun){console.log("* "+msg);return}else{this._debug(msg)}}if(!fromLocation.includes("http")){this._error("JET packs loaded via config 'components' property (file based) are currently not supported");return false}i=fromLocation.indexOf(obj.name);if(i>=0){urlKey=fromLocation.substring(0,i)}else{this._error("Cannot handle Jet Pack URL format to load dependencies : "+fromLocation)}deps=obj.dependencies;if(deps){for(dep in deps){depUrl=urlKey+dep+"/versions/"+obj.dependencies[dep]+"/content/component.json";this._debug(" processing dependency "+dep+" "+obj.dependencies[dep]);this._processUrls("",[depUrl])}}return false};Components.prototype._processJetCore=function(jetCorePath){var files,file,obj,i;if(!jetCorePath){return}this._console("-".repeat(70)+"\nPerforming schema analysis on JET Core components (dt) using '"+this._compSvcs.getSchemaName()+"'...");try{files=this._nd.fs.readdirSync(jetCorePath);this._console(" processing "+files.length+" $jetCore components...");for(i=0;i<files.length;i++){file=files[i];if(file.endsWith(".json")){file=this._nd.path.join(jetCorePath,file);try{obj=this._readComponentJson(file);if(obj){this._compSvcs.validateComponentJson(obj,file)}}catch(e){}}}}catch(e1){this._error("!!! $JetCore Component check failed - "+e1)}this._console(" processing "+(files?files.length+" ":"")+"$jetCore components completed");this._console("-".repeat(70))};Components.prototype._readComponentJson=function(inFile){var obj=null;this._debug(" loading '"+inFile+"'");obj=this._nd.jsonLoader.load(inFile,this._nd,this._error,false,this._utils);if(!obj){this._isOk=false}return obj};Components.prototype._isComponentJsonPath=function(filePath){return filePath.toLowerCase().endsWith(COMPONENT_JSON)};function _deCamelCaseProp(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()};function _deCamelCaseEvent(str){return"on-"+_deCamelCaseProp(str)};function _isRelativeUrl(url){url=url.toLowerCase();return!(url.indexOf("http://")===0||url.indexOf("https://")===0)};function _removeChevrons(tagName){if(tagName&&tagName.length){if(tagName.charAt(0)==="<"){tagName=tagName.substr(1,tagName.length-1)}}return tagName};module.exports=Components;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ "use strict";const COMPONENT_JSON="component.json";const PROP_SLOTS="slots";const PROP_PROPS="props";const PROP_EVENTS="events";const PROP_STYLECLASSES="styleClasses";const PROP_IMPLEMENTS="implements";const PROP_FOLDER="folder";const PROP_VERSION="version";const PROP_UNSUP_THEME="unsupTheme";const PROP_STATUS="status";const PROP_SUBCOMPONENT_TYPE="subcomponentType";const PROP_TYPE="type";const PROP_PACK="pack";const DEPRECATED="deprecated";const PROPERTY_VALUE="propertyValue";const PROPERTY_TYPE="propertyType";const PACK_PRIVATE="packPrivate";const DYNAMIC_FORM_ELEM="DynamicFormElement";const DYNAMIC_TABLE_ELEM="DynamicTableElement";const VB_FRAGMENT_ELEM="VbFragmentElement";const REGXPR=/string|number|object|array|boolean|[\|.<>]/gi;function Components(nd,runMode,compSvcs,urlBase,urls,filePaths,metaLib,jetCore,msgCtx,runOpts,utils){this._nd=nd;this._tagLookup={};this._styleLookup={};this._path=null;this._reqAttrs=null;this._metaLib=metaLib;this._utils=utils;this._compSvcs=compSvcs;this._isAMD=runMode==="amd";this._error=msgCtx.error;this._warn=msgCtx.warn;this._debug=msgCtx.debug;this._info=msgCtx.info;this._msg=msgCtx.msg;this._console=msgCtx.console;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._count=0;this._isOk=true;this._runOpts=runOpts;this._init(urlBase,urls,filePaths,jetCore)};Components.prototype.isTag=function(tagName){return!!this._tagLookup[tagName]};Components.prototype.isTagAttr=function(tagName,attrName){return this.isTagProp(tagName,attrName)};Components.prototype.isTagDeprecated=function(tag){var tag,stats,status,ret=null;if(tag=this._tagLookup[_removeChevrons(tag)]){if(stats=tag.status){for(status of stats){if(!status.hasOwnProperty("target")){ret=status;break}}}}return ret};Components.prototype.isTagAttrDeprecated=function(tagName,attrName){var prop,status,stats,o,ret=null;prop=this.getTagProp(tagName,attrName);if(prop&&(stats=prop.status)){ret=[];for(status of stats){if(status.type===DEPRECATED){o={type:DEPRECATED};if(status.hasOwnProperty("target")){o.target=status.target}if(status.hasOwnProperty("description")){o.description=status.description}if(status.hasOwnProperty("since")){o.since=status.since}if(status.hasOwnProperty("value")){o.value=status.value}ret.push(o)}}ret=ret.length?ret:null}return ret};Components.prototype.isTagAttrTranslatable=function(tag,attr){var prop=this.getTagProp(tag,attr);return prop&&prop.translatable};Components.prototype.isTagAttrReadOnly=function(tag,attr){var prop=this.getTagProp(tag,attr);return prop&&prop.readonly};Components.prototype.isTagProp=function(tagName,propName){return!!this.getTagProp(tagName,propName)};Components.prototype.getTagProp=function(tagName,propName){var tag,props;tag=this._tagLookup[_removeChevrons(tagName)];props=tag?tag[PROP_PROPS]:null;if(props){propName=propName.charAt(0)===":"?propName.substring(1):propName;propName=_deCamelCaseProp(propName)}return props?props[propName]:false};Components.prototype.getTagPropType=function(tagName,propName){var prop,ret;if(prop=this.getTagProp(tagName,propName)){ret=prop?prop.type:undefined}return ret};Components.prototype.getTagMetadata=function(tag){return this._tagLookup[_removeChevrons(tag)]};Components.prototype.isTagEvent=function(tagName,eventName){var propName,o,b;o=this._tagLookup[tagName];if(o){if(eventName.startsWith("on-")){b=o.events&&o.events[eventName];if(b)return b;if(o.implements&&(o.implements.includes(DYNAMIC_FORM_ELEM)||o.implements.includes(DYNAMIC_TABLE_ELEM)||o.implements.includes(VB_FRAGMENT_ELEM))){return true}if(eventName.endsWith("-changed")){if(o.props){propName=eventName.replace("-changed","").substring(3);return!!o.props[propName]}}}}return false};Components.prototype.isTagStyle=function(tag,style){if(this._tagLookup[tag]){let tags,styles,sc;if(tags=Object.keys(this._tagLookup)){for(let i=0;i<tags.length;i++){if(styles=this._tagLookup[tags[i]].styleClasses){if(sc=styles[style]){return true}}}}}return false};Components.prototype.isStyle=function(style){return!!this._styleLookup[style]};Components.prototype.getStyleMetadata=function(style){var tag,styles,sc,ret=null;if(tag=this._styleLookup[style]){if(styles=this._tagLookup[tag].styleClasses){if(sc=styles[style]){ret={tag:tag,meta:sc}}}}return ret};Components.prototype.getStyleSelector=function(style){var sm=this.getStyleMetadata(style);return sm&&sm.meta?sm.meta.styleSelector:null};Components.prototype.hasTagSlotName=function(tagName,slotName){var o=this._tagLookup[tagName];return!!(o&&o.slots&&o.slots[slotName])};Components.prototype.getPreferredSlotContent=function(tag,slotName,impls){var o,slot,prefContent=null,comps=null,content;if(this._utils.hasAnyProps(impls)){if(o=this._tagLookup[tag]){if(o.slots){if(slot=o.slots[slotName]){if(prefContent=slot.preferredContent){prefContent.forEach(impl=>{if(content=impls[impl]){if(!comps){comps=[]}comps.push(...content)}})}}}}}return prefContent||comps?{interfaces:prefContent,components:comps}:null};Components.prototype.getTagSlotMetadata=function(tag,slot){var o,ret;if(o=this._tagLookup[tag]){if(o.slots){if(slot=o.slots[slot]){ret=slot}}}return ret};Components.prototype.hasTagAttrValues=function(tagName,attrName){var prop,ret=false;if(prop=this.getTagProp(tagName,attrName)){ret=!!prop.enumValues}return ret};Components.prototype.isTagAttrValue=function(tagName,attrName,value){var prop,ret;if(prop=this.getTagProp(tagName,attrName)){if(prop&&prop.enumValues){ret=prop.enumValues.indexOf(value)>=0}}return ret};Components.prototype.isTagAttrEnumDeprecated=function(tag,attr,val){var prop,stats,status,ret=null;if(prop=this.getTagProp(tag,attr)){if(prop.status){stats=prop.status;for(status of stats){if(status.type===DEPRECATED&&status.target==="propertyValue"){if(status.value&&status.value.includes(val)){ret={type:DEPRECATED};if(status.hasOwnProperty("target")){ret.target=status.target}if(status.hasOwnProperty("description")){ret.description=status.description}if(status.hasOwnProperty("since")){ret.since=status.since}if(status.hasOwnProperty("value")){ret.value=status.value}break}}}}}return ret};Components.prototype.isTagSupportedInTheme=function(tag,theme){var o,unsup,ret=true;o=this._tagLookup[tag];if(o){unsup=o[PROP_UNSUP_THEME];if(unsup){ret=!unsup.includes(theme)}}return ret};Components.prototype.isAttrSupportedInTheme=function(tag,attr,theme){var prop,unsup,ret=true;if(prop=this.getTagProp(tag,attr)){if(unsup=prop[PROP_UNSUP_THEME]){ret=!unsup.includes(theme)}}return ret};Components.prototype.isTagPackPrivate=function(tag){var o,ret;tag=_removeChevrons(tag);if(o=this._tagLookup[tag]){ret=o[PROP_SUBCOMPONENT_TYPE]===PACK_PRIVATE}return ret};Components.prototype.getRequiredAttrs=function(tagName){var tag,props,attr,attrName,obj,ret=null;tagName=_removeChevrons(tagName);if(this._reqAttrs){let r=this._reqAttrs[tagName];if(r){return typeof r==="boolean"?null:r}}tag=this._tagLookup[tagName];if(tag&&tag.props){if(!this._reqAttrs){this._reqAttrs={}}if(!this._reqAttrs[tagName]){this._reqAttrs[tagName]=true}props=tag.props;for(attrName in props){attr=props[attrName];if(attr.required){if(!obj){obj=[]}obj.push(_deCamelCaseProp(attrName))}}}if(obj&&obj.length){this._reqAttrs[tagName]=obj;ret=obj}return ret};Components.prototype.getNames=function(){var name,a=[];for(name in this._tagLookup){a.push({name:name,version:this._tagLookup[name].version})}return a};Components.prototype.getCount=function(){return this._count};Components.prototype.isOk=function(){return this._isOk};Components.prototype._init=function(base,urls,filePaths,jetCore){if(this._isAMD){return}if(base){base=base.trim();if(base.charAt(base.length-1)!=="/"){base=base+"/"}}else{base=""}this._processFilePaths(filePaths);this._processUrls(base,urls);this._createStyleLookup();this._processJetCore(jetCore)};Components.prototype._processFilePaths=function(filePaths){var obj,compEntry,fpath,i,j;if(!filePaths){return}this._console("\nPre-processing user-declared web component metadata...");for(i=0;i<filePaths.length;i++){compEntry=filePaths[i];var dirStack=this._nd.glob.sync(compEntry);for(j=0;j<dirStack.length;j++){fpath=dirStack[j];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg="-".repeat(70)+"\n"+(this._runOpts.isDryRun?"* ":"")+"processing component path '"+fpath+"' ...";if(this._runOpts.isDryRun){console.log(msg)}else{this._debug(msg)}}if(fpath.toLowerCase().endsWith(".zip")){obj=this._compSvcs._extractComponentJsonFromZip(fpath);if(obj.obj){this.processComponentJson(obj.obj,fpath,true)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+fpath)}else if(obj.error){this._error("Failed to unzip '"+fpath+"'")}continue}if(this._isComponentJsonPath(fpath)){obj=this._readComponentJson(fpath);if(obj){if(obj.type&&obj.type==="pack"){continue}this.processComponentJson(obj,this._nd.path.dirname(fpath),true)}continue}this._recurse(fpath)}}if(this._isDebug){this._debug("-".repeat(70))}};Components.prototype._recurse=function(fpath){var dirs,inFile,obj,i;try{dirs=this._nd.fs.readdirSync(fpath);if(this._isDebug){this._debug(` processing ${fpath} ${dirs.length} component dirs ...`)}for(i=0;i<dirs.length;i++){inFile=dirs[i];if(inFile===COMPONENT_JSON){inFile=this._nd.path.join(fpath,COMPONENT_JSON);if(this._isDebug){this._debug(" processing "+inFile+"...")}obj=this._readComponentJson(inFile);if(obj){if(!obj.type||obj.type==="composite"){this.processComponentJson(obj,fpath,true)}}else{return}}var curPath=this._nd.path.join(fpath,inFile);if(this._nd.fsUtils.getFileType(curPath)==="d"){this._recurse(curPath)}}}catch(e){this._error("Component check failed - "+e);this._isOk=false}};Components.prototype._processUrls=function(base,urls){var url,i;if(!urls){return}for(i=0;i<urls.length;i++){url=urls[i];if(this._runOpts.isDryRun||this._runOpts.isDebug){let msg;msg="-".repeat(70)+"\nprocessing URL '"+url+"'";if(this._runOpts.isDryRun){console.log(msg);continue}else{this._debug(msg)}}if(_isRelativeUrl(url)){url=base+url;if(_isRelativeUrl(url)){this._error("component URL incomplete - '"+url+"'");continue}}this._processUrl(url)}};Components.prototype._processUrl=function(url){var resp,obj,rc,tempFile,tmp;try{resp=this._compSvcs.loadUrl(url);if(resp.eCode==="ETIMEDOUT"){this._error("config.componentUrls - request timed-out for '"+url+"'");this._isOk=false;return}try{if(resp.type==="json"){if(resp.body){obj=JSON.parse(resp.body);if(!this.processComponentJson(obj,url,false)){this._isOk=false}}else{this._error("Server responded with "+resp.statusCode+" URL: '"+url+"'")}}else if(resp.type=="zip"){rc=this._compSvcs.writeZipBufferToFile(resp.body);if(typeof rc==="boolean"&&rc){tempFile=this._compSvcs.getLastZipFilePath();obj=this._compSvcs.extractComponentJsonFromZip(tempFile);if(obj.obj){this.processComponentJson(obj.obj,url,true)}else if(obj.msg){this._error("Failed to parse component.json : "+obj.msg+" - "+url)}else if(obj.error){this._error("Failed to unzip '"+url+"'")}this._compSvcs.deleteZipFile(tempFile)}else{this._error("Failed to create local temp zip file from URL '"+url+"' : rc.message");this._isOk=false}}else{tmp=typeof resp.type==="string"?resp.type:"?";this._error("Server responded with unexpected data ('"+tmp+"') : '"+url+"'");this._isOk=false}}catch(e){this._error("Invalid JSON - URL '"+url+"' : "+e);this._isOk=false}}catch(e1){this._error("URL access failed "+(e1.message.includes("ENOTFOUND")?"(NOT FOUND)":"")+" - URL '"+url+"'");this._isOk=false}};Components.prototype.processComponentJson=function(obj,fromLocation){var comp,props,events,event,compName;if(!this._isAMD){if(this._runOpts.isDryRun){console.log(" Would have processed '"+fromLocation+"'");return}if(obj.type&&obj.type==="pack"){return this._processJetPack(obj,fromLocation)}if(!this._compSvcs.validateComponentJson(obj,fromLocation)){this._isOk=false;return false}}compName=obj.pack?obj.pack+"-"+obj.name:obj.name;if(this._tagLookup[compName]){this._warn(`Ignoring duplicate component '${compName}' at '${fromLocation}'`);return true}this._tagLookup[compName]=comp={};comp[PROP_FOLDER]=fromLocation;comp[PROP_VERSION]=obj.version;if(obj.slots){comp[PROP_SLOTS]=obj.slots}if(obj.properties){comp[PROP_PROPS]=props={};this._extractProps(props,null,obj.properties,obj.name)}if(obj.events){comp[PROP_EVENTS]=events={};for(event in obj.events){event=_deCamelCaseEvent(event);events[event]=true}}if(obj.implements){comp[PROP_IMPLEMENTS]=obj.implements;this._metaLib.processImplements(compName,obj.implements)}if(obj.extension&&obj.extension.theme&&obj.extension.theme.unsupportedThemes){comp[PROP_UNSUP_THEME]=obj.extension.theme.unsupportedThemes}if(obj.subcomponentType){comp[PROP_SUBCOMPONENT_TYPE]=obj.subcomponentType}if(obj.type){comp[PROP_TYPE]=obj.type}if(obj.pack){comp[PROP_PACK]=obj.pack}if(obj.status){comp[PROP_STATUS]=obj.status}if(obj.styleClasses){comp[PROP_STYLECLASSES]=this._extractStyles(obj.styleClasses)}this._count++;return true};Components.prototype._extractProps=function(propObj,propSoFar,properties,name,rdonly){var prop,newProp,thisProp,soFar,obj;for(prop in properties){newProp=_deCamelCaseProp(prop);soFar=(propSoFar?propSoFar+".":"")+newProp;propObj[soFar]=obj={};thisProp=properties[prop];if(thisProp.hasOwnProperty("enumValues")){if(Array.isArray(thisProp.enumValues)){obj.enumValues=thisProp.enumValues}else{this._error(`Web component'${name}' property '${soFar}' has invalid 'enumValues' in component.json`)}}if(thisProp.hasOwnProperty("status")){obj.status=thisProp.status}if(thisProp.hasOwnProperty("type")){obj.type=thisProp.type}if(thisProp.required){obj.required=true}if(thisProp.extension&&thisProp.extension.theme&&thisProp.extension.theme.unsupportedThemes){obj[PROP_UNSUP_THEME]=thisProp.extension.theme.unsupportedThemes}if(thisProp.hasOwnProperty("translatable")){obj.translatable=true}if(typeof thisProp.readonly==="boolean"){obj.readonly=thisProp.readOnly}else{if(rdonly){obj.readonly=true}}if(thisProp.hasOwnProperty("properties")){obj.properties=true;this._extractProps(propObj,soFar,thisProp.properties,name,obj.readonly)}}};Components.prototype._extractStyles=function(styleClasses){var so,si,obj,ret={},i,j;if(!Array.isArray(styleClasses)){return ret}for(i=0;i<styleClasses.length;i++){so=styleClasses[i];if(so.kind==="class"){ret[so.name]=this._extractStyleClass(so)}else if(so.kind==="set"&&so.styleItems&&Array.isArray(so.styleItems)){ret[so.name]=obj={kind:"set"};if(so.status){obj.status=so.status}obj.styleClasses={};for(j=0;j<so.styleItems.length;j++){si=so.styleItems[j];obj.styleClasses[si.name]=this._extractStyleClass(si)}}else if(so.kind==="template"){}}return ret};Components.prototype._extractStyleClass=function(so){var obj={};if(so.styleSelector){obj.styleSelector=so.styleSelector}if(so.status){obj.status=so.status}return obj};Components.prototype._processJetPack=function(obj,fromLocation){var deps,dep,urlKey,depUrl,msg,i;if(this._runOpts.isDryRun||this._runOpts.isDebug){msg="processing JET Pack "+obj.name+" (version: "+obj.version+") : '"+fromLocation+"'";if(this._runOpts.isDryRun){console.log("* "+msg);return}else{this._debug(msg)}}if(!fromLocation.includes("http")){this._error("JET packs loaded via config 'components' property (file based) are currently not supported");return false}i=fromLocation.indexOf(obj.name);if(i>=0){urlKey=fromLocation.substring(0,i)}else{this._error("Cannot handle Jet Pack URL format to load dependencies : "+fromLocation)}deps=obj.dependencies;if(deps){for(dep in deps){depUrl=urlKey+dep+"/versions/"+obj.dependencies[dep]+"/content/component.json";if(this._isDebug){this._debug(` processing dependency ${dep} ${obj.dependencies[dep]}`)}this._processUrls("",[depUrl])}}return false};Components.prototype._processJetCore=function(jetCorePath){var files,file,obj,i;if(!jetCorePath){return}this._console("-".repeat(70)+"\nPerforming schema analysis on JET Core components (dt) using '"+this._compSvcs.getSchemaName()+"'...");try{files=this._nd.fs.readdirSync(jetCorePath);this._console(` processing ${files.length} $jetCore components...`);for(i=0;i<files.length;i++){file=files[i];if(file.endsWith(".json")){file=this._nd.path.join(jetCorePath,file);try{obj=this._readComponentJson(file);if(obj){this._compSvcs.validateComponentJson(obj,file)}}catch(e){}}}}catch(e1){this._error("!!! $JetCore Component check failed - "+e1)}this._console(" processing "+(files?files.length+" ":"")+"$jetCore components completed");this._console("-".repeat(70))};Components.prototype._createStyleLookup=function(){var tag,o,scl,st;for(tag in this._tagLookup){o=this._tagLookup[tag];if(scl=o.styleClasses){for(st in scl){this._styleLookup[st]=tag}}}};Components.prototype._readComponentJson=function(inFile){var obj=null;if(this._isDebug){this._debug(` loading '${inFile}'`)}obj=this._nd.jsonLoader.load(inFile,this._nd,this._error,false,this._utils);if(!obj){this._isOk=false}return obj};Components.prototype._isComponentJsonPath=function(filePath){return filePath.toLowerCase().endsWith(COMPONENT_JSON)};function _deCamelCaseProp(str){return str.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()};function _deCamelCaseEvent(str){return"on-"+_deCamelCaseProp(str)};function _isRelativeUrl(url){url=url.toLowerCase();return!(url.indexOf("http://")===0||url.indexOf("https://")===0)};function _removeChevrons(tagName){if(tagName){let len=tagName.length-1;let start=tagName.charAt(0)==="<"?1:0;let end=tagName.charAt(len)===">"?len:++len;tagName=tagName.substring(start,end)}return tagName};module.exports=Components;
package/lib/Config.js CHANGED
@@ -1 +1,6 @@
1
- var nodeDeps;const Helper=require("./ConfigLib");var JET_VERSIONS;var DEFAULT_JETVER;const TYPE_BOOLEAN="boolean";const AT_INCLUDE="@include(";const QUOTE="\"";var Config=function(nd,base,iniPath,rules,groups,severity,cliGroups,cliSev,macros,msgCtx,modeCtx,utils){this._path=iniPath;this._dir=null;this._config=null;this._macros=macros;this._preBuilt=false;this._isOJET=modeCtx.isOJET;this._isCLI=modeCtx.isCLI;this._isAPI=modeCtx.isAPI;this._isAMD=modeCtx.isAMD;this._isCliMode=modeCtx.isCLI||modeCtx.isOJETCLI;this._rules=rules;this._utils=utils;this._severity=severity;this._helper=new Helper(this,nd,severity,utils,msgCtx,modeCtx);this._groups=groups;this._bErrors=false;this._console=msgCtx.console;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info;this._debug=msgCtx.debug;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;JET_VERSIONS=nd.jetver.getVersions();DEFAULT_JETVER=nd.jetver.getDefault();this._cliGroups=cliGroups;this._cliSev=cliSev;nodeDeps=nd;if(iniPath){this._init(base,iniPath)}};Config.prototype.getConfig=function(){var tmp=JSON.parse(JSON.stringify(this._config));if(tmp._sev){delete tmp._sev}return tmp};Config.prototype.getFiles=function(){return this._config.files};Config.prototype.getExclude=function(){return this._config.exclude};Config.prototype.getOptions=function(){return this._config.options};Config.prototype.getJetVer=function(){return this._config.jetVer};Config.prototype.getComponentsBaseUrl=function(){return this._config.componentsBaseUrl};Config.prototype.getComponentsBase=function(){return this._config.componentsBase};Config.prototype.getComponents=function(){return this._config.components};Config.prototype.getComponentUrls=function(){return this._config.componentUrls};Config.prototype.getComponentOptions=function(){return this._config.componentOptions};Config.prototype.getTsConfig=function(){return this._config.tsconfig};Config.prototype.getOutPath=function(){return this._config.outPath};Config.prototype.getRulePacks=function(){return this._config.rulePacks};Config.prototype.getRuleMods=function(){return this._config.ruleMods};Config.prototype.getEnable=function(){return this._config.ruleMods&&this._config.ruleMods.enable?this._config.ruleMods.enable:undefined};Config.prototype.getDisable=function(){return this._config.ruleMods&&this._config.ruleMods.disable?this._config.ruleMods.disable:undefined};Config.prototype.getRuleDescriptions=function(){return this._config.ruleDescriptions};Config.prototype.getGroups=function(){return this._config.groups};Config.prototype.setGroups=function(groups){this._config.groups=groups};Config.prototype.getDefGroups=function(){return this._config.defGroups};Config.prototype.getRunRuleNames=function(){return this._config.ruleNames};Config.prototype.isBuiltinJetRules=function(){return this._config.builtinJetRules};Config.prototype.isBuiltinCspRules=function(){return this._config.builtinCspRules};Config.prototype.isBuiltinJetWcRules=function(){return this._config.builtinJetWcRules};Config.prototype.isBuiltinJetWcOracleRules=function(){return this._config.builtinJetWcOracleRules};Config.prototype.isBuiltinSpocRules=function(){return this._config.builtinSpocRules};Config.prototype.getMessages=function(){return this._config.messages};Config.prototype.setMessages=function(msgid,state){return this._helper.setMessages(msgid,state)};Config.prototype.getFollowLinks=function(){return this._config.followLinks};Config.prototype.getFormat=function(){return this._config.format};Config.prototype.getProseFormat=function(){return this._config.proseFormat};Config.prototype.getLineFormat=function(){return this._config.lineFormat};Config.prototype.getBase=function(){return this._config.base};Config.prototype.getStylesets=function(){return this._config.stylesets};Config.prototype.getNameSpaces=function(){return this._config.nameSpaces};Config.prototype.getCommon=function(){return this._config.common||{}};Config.prototype.getSeverity=function(){return this._config.severity};Config.prototype.setSeverity=function(severity){return this._config.severity=severity};Config.prototype.getSevMap=function(){return this._config.sevMap};Config.prototype.getTheme=function(){return this._config.theme};Config.prototype.getComments=function(){return this._config.comments};Config.prototype.getEcmaVer=function(){return this._config.ecmaVer};Config.prototype.getTabs=function(){return this._config.tabs};Config.prototype.getTitle=function(){return this._config.title};Config.prototype.getRetCode=function(){var ret,o;if(this._config&&this._config.options){o=this._config.options;if(o.retCode!==undefined){ret=o.retCode}else if(o.rc!==undefined){ret=o.rc}else{ret="auto"}}else{ret="auto"}return ret};Config.prototype.isOk=function(){return!this._bErrors};Config.prototype.getUserDefs=function(){return this._config.userDefs};Config.prototype.getAppendFileList=function(){return this._helper.getAddFileList()};Config.prototype.getJetPagesOnly=function(){return this._config.jetPagesOnly};Config.prototype.getTempDir=function(){return this._config.tempDir};Config.prototype.getOrigConfig=function(){return this._origConfig};Config.prototype.get$JetCore=function(){return this._config.$JetCore};Config.prototype._init=function(base,iniPath){var i,s,val,val2,bUseDefaults=false;if(typeof iniPath==="string"){this._dir=nodeDeps.path.dirname(iniPath);bUseDefaults=this._loadConfig(iniPath);if(this._bErrors){return}}else{this._config=iniPath;this._dir=nodeDeps.process.cwd();this._preBuilt=true}this._origConfig=this._config;this._config=_cloneConfig(this._config);this._helper.setConfig(this._config);if(!this._checkProperties()){this._bErrors=true;return}if(base){this._config.base=base}if(!this._config.base){this._config.base=this._dir}if(this._config.base===this._macros.cwd){this._config.base=nodeDeps.process.cwd()}if(!bUseDefaults&&!this._isOJET){this._info("[Info]: Using "+(typeof iniPath==="string"?"config '"+iniPath+"'":"pre-built config object"),"I",true)}if(typeof this._config.builtinJetRules!==TYPE_BOOLEAN){this._config.builtinJetRules=true}if(typeof this._config.builtinCspRules!==TYPE_BOOLEAN){this._config.builtinCspRules=false}if(typeof this._config.builtinJetWcRules!==TYPE_BOOLEAN){this._config.builtinJetWcRules=false}if(typeof this._config.builtinJetWcOracleRules!==TYPE_BOOLEAN){this._config.builtinJetWcOracleRules=false}if(typeof this._config.builtinExchRules!==TYPE_BOOLEAN){this._config.builtinExchRules=false}else if(this._config.builtinExchRules){this._config.builtinJetRules=true}if(this._config.builtinSpocRules){if(typeof this._config.builtinSpocRules!==TYPE_BOOLEAN){this._error("Config entry 'builtinSpocRules' must be a boolean!");this._bErrors=true;return}if(this._config.builtinSpocRules){this._config.builtinJetRules=false;this._config.builtinJetWcRules=false;this._config.builtinJetWcOracleRules=false;this._config.builtinExchRules=false}}this._config.jetPagesOnly=!!this._config.jetPagesOnly;if(!this._config.files){this._config.files=[]}if(!this._config.options){this._config.options={}}if(this._config.jetVer){val=this._config.jetVer;if(typeof val!=="string"){this._error("Config entry 'jetVer' is not a string!");this._bErrors=true;return}val=val.trim();val2=val.split(".");for(i=0;i<val2.length;i++){s=parseInt(val2[i]);if(s===NaN){this._error(`Config entry 'jetVer' --> '${val}' is not a valid version string`);this._bErrors=true;return}val2[i]=""+s}val=val2.join(".");if(val2.length!==3||val2[2]==="0"){s=val2.length===3;val2=nodeDeps.jetver.getBestVersion(val,val2);if(!val2){s=s?`Config entry 'jetVer' --> '${val}' cannot be resolved to a supported JET version`:`Config entry 'jetVer' --> '${val}' is not a supported JET version`;this._error(s);this._bErrors=true;return}val=val2}if(!JET_VERSIONS[val]){this._error(`Config entry 'jetVer' --> '${val}' is not a supported JET version!`);this._bErrors=true;return}this._config.jetVer=val}else{this._config.jetVer=DEFAULT_JETVER}if(!this._helper.processWebComponents()){this._bErrors=true;return}if(!this._helper.processRuleSets()){this._bErrors=true;return}if(!this._helper.processRuleMods()){this._bErrors=true;return}if(!this._helper.processTsConfig()){this._bErrors=true;return}if(!this._helper.processFormat()){this._bErrors=true;return}if(!this._helper.processProseFormat()){this._bErrors=true;return}if(!this._helper.processLineFormat()){this._bErrors=true;return}if(!this._helper.processRuleDescriptions()){this._bErrors=true;return}if(!this._helper.processSevMap()){this._bErrors=true;return}if(!this._helper.processSeverity(this._cliSev)){this._bErrors=true;return}if(!this._helper.processGroups(this._cliGroups,this._groups)){this._bErrors=true;return}if(!this._helper.processDefGroups()){this._bErrors=true;return}if(!this._helper.processRuleNames()){this._bErrors=true;return}if(this._config.followLinks==null){this._config.followLinks=true}else{this._config.followLinks=!!this._config.followLinks}if(!Array.isArray(this._config.files)){this._error("Config entry 'files' is not an array!");this._bErrors=true;return}s=_validateFileList(this._config.files,this._utils);if(typeof s==="string"){this._error("'files'"+s);this._bErrors=true;return}if(this._config.exclude){if(!Array.isArray(this._config.exclude)){this._error("Config entry 'exclude' is not an array!");this._bErrors=true;return}s=_validateFileList(this._config.exclude,this._utils);if(typeof s==="string"){this._error("'exclude'"+s);this._bErrors=true;return}}else if(this._config.excludes){this._error("Config property 'excludes' found - did you mean 'exclude'?");this._bErrors=true;return}if(!this._helper.processAddFileList()){this._bErrors=true;return}if(this._config.stylesets){val=this._config.stylesets;if(!Array.isArray(val)){this._error("Config property 'stylesets' is not an array!");this._bErrors=true;return}}if(this._isAMD&&this._config.tempDir){this._error("Config entry 'tempDir' is not valid in AMD mode!");this._bErrors=true;return}if(this._config.tempDir){if(typeof this._config.tempDir!=="string"){this._error("Config property 'tempDir' is not a string!");this._bErrors=true;return}if(this._config.tempDir.startsWith(".")){this._config.tempDir=nodeDeps.path.resolve(nodeDeps.process.cwd(),this._config.tempDir)}}if(!this._helper.processMessages()){this._bErrors=true;return}if(!this._helper.processNameSpaces()){this._bErrors=true;return}if(!this._helper.processTheme()){this._bErrors=true;return}if(!this._helper.processComments()){this._bErrors=true;return}if(!this._helper.processEcmaVer()){this._bErrors=true;return}if(!this._helper.processOptions()){this._bErrors=true;return}if(!this._helper.processTitle()){this._bErrors=true;return}if(!this._helper.processRetCode()){this._bErrors=true;return}this._cleanConfigPaths()};Config.prototype._cleanConfigPaths=function(){var src,i,ftype,dir;src=this._config.base;if(src){src=nodeDeps.path.normalize(src);src=nodeDeps.path.resolve(this._dir,src);ftype=nodeDeps.fsUtils.getFileType(src);if(ftype!=="d"){this._error("Config file 'base' is not a directory - \""+src+"\"");this._bErrors=true;return}src=nodeDeps.path.join(src,"/");this._config.base=src;this._info("[Info]: Using Config base '"+src+"'","I")}src=this._config.files;if(src){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}}src=this._config.exclude;if(src){for(i=0;i<src.length;i++){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}src=this._config.components;if(src){for(i=0;i<src.length;i++){dir=nodeDeps.path.normalize(src[i]);dir=nodeDeps.path.resolve(this._config.base,dir);this._config.components[i]=dir}}src=this._config.outPath;if(src&&src!=="$noout"){src=nodeDeps.path.normalize(src);src=nodeDeps.path.resolve(this._config.base,src);this._config.outPath=src}src=this._config.rulePath;if(src){src=nodeDeps.path.normalize(src);src=nodeDeps.path.resolve(this._config.base,src);this._config.rulePath=nodeDeps.path.join(src,"/");ftype=nodeDeps.fsUtils.getFileType(this._config.rulePath);if(ftype!=="d"){this._error("'rulePath' is not a directory - \""+this._config.rulePath+"\"");this._bErrors=true;return}this._info("[Info]: Using rule path '"+this._config.rulePath+"'","I",true)}src=this._config.rulePacks;if(src){for(i=0;i<src.length;i++){dir=src[i].path;dir=nodeDeps.path.normalize(dir);src[i].path=nodeDeps.path.resolve(this._config.base,dir);if(src[i].path.endsWith(".zip")){continue}ftype=nodeDeps.fsUtils.getFileType(src[i].path);if(ftype!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true;return}}if(this._bErrors){return};}};Config.prototype._loadConfig=function(iniPath){var data,stats,bUseDefaults=false,msg;try{stats=nodeDeps.fs.statSync(iniPath);if(!stats.isFile()){this._warn("\n[Warn]: Config file '"+iniPath+"' not found. Using defaults.\n");bUseDefaults=true}else{data=nodeDeps.fs.readFileSync(iniPath,"utf8");data=nodeDeps.decomment(data);data=this._processIncludes(data,iniPath);data=this._processTokens(data);if(this._bErrors){return}if(this._isDebug){if(!data){console.log("NO CONFIG DATA")}else{var a=data.split("\n");console.log("------------- Config Raw Text...");for(var i=0;i<a.length;i++){console.log(i+1+"] "+a[i])}console.log("-".repeat(40))}}if(data){this._config=JSON.parse(nodeDeps.decomment(data))}else{this._bErrors=true}}}catch(e){this._bErrors=true;if(e.code){if(e.message.startsWith("ENOENT:")){this._warn("\nConfig file \""+iniPath+"\" not found - using defaults.\n");this._bErrors=false;bUseDefaults=true}}else if(e.toString().startsWith("SyntaxError")){msg=_convertMsgToRowCol(e.message,data,this._utils)}else{msg=e.message}if(msg){msg=msg.replace(/\r/g,"");msg=msg.replace(/ +(?= )/g,"");this._error("Config parse error");this._error("Config file '"+iniPath+"' - "+msg)}}if(this._bErrors){return}if(bUseDefaults){this._config={exclude:["./**/*-min.js","./**/*-min.css","./**/node_modules/**/*.*"],builtinJetRules:true,builtinCspRules:false,builtinJetWcRules:false,builtinJetWcOracleRules:false,followLinks:true,severity:this._severity.ALL,format:"prose",ecmaVer:this._helper.getDefaultEcmaVer(),options:{verbose:false,color:true}}}return bUseDefaults};Config.prototype._checkProperties=function(){return this._helper.checkPropNames()};function _validateFileList(aFiles,utils){var i,j,f,msg;for(i=0;i<aFiles.length;i++){f=aFiles[i];if(typeof f==="string"){continue}if(typeof f!=="object"){msg=" property entry "+(i+1)+" is not a string or an object";break}if(f.files){if(!(Array.isArray(f.files)&&utils.isArrayContentsType(f.files,"string"))){msg=" property entry "+(i+1)+" does not contain a 'files' property array, or not all elements are strings";break}}else{msg=" property entry "+(i+1)+", does not contain a 'files' property";break}if(!f.base){msg=" property entry "+(i+1)+" does not contain a 'base' property";break}for(j=0;j<f.files.length;j++){f.files[j]=nodeDeps.path.join(f.base,f.files[j])}}if(!msg){for(i=0;i<aFiles.length;i++){f=aFiles[i];if(typeof f==="object"){aFiles.splice(i,1,...f.files)}}}return msg?msg:true};function _convertMsgToRowCol(msg,data,utils){var x,n,rc;x=msg.indexOf("position");if(x<0){return msg}n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substr(0,x)+"row "+rc.row+", col "+rc.col};Config.prototype._processTokens=function(data){const TOKENS="\"tokens\"";var token,sub,start,end,json,toks,count,subst,rc,x,n;if(this._isDebug){this._debug("Performing config 'tokens' substitution...")}x=data.indexOf(TOKENS);if(x<0)return data;x+=TOKENS.length;n=this._expect(data,x,":",true);if(n<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: expected ':' after property "+TOKENS+" on line "+rc.row+" position "+rc.col+".");this._bErrors=true;return}n=this._expect(data,n,"{");if(n<0){rc=this._utils.getRowColFromIndex(data,n);this._error("Config: expected '{' after property "+TOKENS+" on line "+rc.row+".");this._bErrors=true;return}start=n;end=data.indexOf("}",start);if(end<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: "+TOKENS+" property syntax error (on/after line "+rc.row+").");this._bErrors=true;return}json=data.substring(start,end+1);try{toks=JSON.parse(json)}catch(e){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: syntax error "+TOKENS+" property (on/after line "+rc.row+").");this._bErrors=true;return}subst=0;count=0;for(token in toks){if(token.charAt(0)!=="@"){this._error("Config: token '"+token+"' : must be prefixed with '@'");this._bErrors=true;return}sub=toks[token];token=token.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");token=new RegExp(token,"g");if(this._isVerbose||this._isDebug){n=data.match(token).length;subst+=n>1?--n:0}data=data.replace(token,sub);count++}if(count){try{start=data.indexOf(TOKENS);start=this._expect(data,start+TOKENS.length,":",true);start=this._expect(data,start,"{");end=data.indexOf("}",start+1);data=data.substring(0,start)+json+data.substring(end+1);if(this._isVerbose||this._isDebug){this._info("[Info]: "+subst+" config token substitution"+(subst!==1?"s":"")+" performed with "+count+" token"+(count!==1?"s":"")+".")}}catch(e){this._error("Config: \"tokens\" substitution failed - review \"tokens\" property value");this._bErrors=true}}return data};Config.prototype._expect=function(data,x,s,bump){var ret=-1;x=this._utils.eatWhitespace(data,x);if(x>=0&&data.substr(x,s.length)===s){ret=x+(bump?s.length:0)}return ret};Config.prototype._processIncludes=function(data,filepath,chain){var a,i,line,x,path,comma;var inserts,insert,incPath;if(this._isDebug){this._debug("Checking for "+(chain?"sub ":"")+"@include. . .")}if(data.indexOf(AT_INCLUDE)<0){if(this._isDebug){this._debug("No "+(chain?"sub ":"")+"@include found")}return data}inserts=[];a=data.split("\n");for(i=0;i<a.length;i++){line=a[i];x=line.indexOf(AT_INCLUDE);if(x<0){continue}path=_extractStringFromLine(line,x+AT_INCLUDE.length,this._utils);if(!path){this._error("Config - @include syntax error"+(chain?" in '"+filepath+"'":"!"));return null}incPath=nodeDeps.path.normalize(path);incPath=nodeDeps.path.resolve(this._dir,incPath);comma=_isTrailingComma(line,x+AT_INCLUDE.length,this._utils);try{if(this._isDebug){this._debug("Reading @include -> "+incPath)}insert=nodeDeps.fs.readFileSync(incPath,"utf8")}catch(e){this._error("Config @include - "+e);return null}if(!insert){this._error("Config - @include '"+incPath+"' not found!");return null}insert=this._processIncludes(insert,incPath,true);if(insert){inserts.push(i);inserts.push(insert+(comma?",":""))}else if(insert===null){return null}}if(inserts&&inserts.length){for(i=0;i<inserts.length;i++){a[inserts[i]]=inserts[++i]}}return a.join("\n")};function _extractStringFromLine(data,start,utils){var c,xEnd,wantQuote,antiQuote;start=utils.eatWhitespace(data,start);if(start<0){return null}c=data.charAt(start);wantQuote=c===QUOTE||c==="'"?c:null;if(wantQuote){antiQuote=c===QUOTE?"'":QUOTE;start++}for(xEnd=start;xEnd<data.length;xEnd++){c=data.charAt(xEnd);if(c===")"||wantQuote&&c===wantQuote){break}else if(c==="\n"||wantQuote&&c===antiQuote||!wantQuote&&(c===QUOTE||c==="'")){xEnd=-1;break}}if(xEnd<0||xEnd>=data.length||wantQuote&&data.charAt(xEnd)!==wantQuote){return null}data=data.substring(start,xEnd).trim();return data?data:null};function _isTrailingComma(s,x,utils){var n,ret=false;n=s.indexOf(")",x);if(n<0){return false}n=utils.eatWhitespace(s,n+1);if(n>=0){ret=s.charAt(n)===","}return ret};function _cloneConfig(o){return JSON.parse(JSON.stringify(o))};module.exports=Config;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ var nodeDeps;const Helper=require("./ConfigLib");const MACROS=require("../lib/macros");const DEFAULTS=require("./defaults");var JET_VERSIONS;const TYPE_BOOLEAN="boolean";const AT_INCLUDE="@include(";const QUOTE="\"";const TSCONFIG="tsconfig.json";var Config=function(nd,base,iniPath,fnApplyMacros,rules,severity,cliGroups,cliSev,msgCtx,modeCtx,utils,cbDebug){this._path=iniPath;this._dir=null;this._config=null;this._tsCfgObj=null;this._preBuilt=false;this._isOJET=modeCtx.isOJET;this._isCLI=modeCtx.isCLI;this._isAPI=modeCtx.isAPI;this._isAMD=modeCtx.isAMD;this._isCliMode=modeCtx.isCLI||modeCtx.isOJETCLI;this._rules=rules;this._utils=utils;this._severity=severity;this._helper=new Helper(this,nd,severity,utils,msgCtx,modeCtx);this.applyMacros=fnApplyMacros;this._bErrors=false;this._console=msgCtx.console;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info;this._debug=msgCtx.debug;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;JET_VERSIONS=nd.jetver.getVersions();this._cliGroups=cliGroups;this._cliSev=cliSev;nodeDeps=nd;if(iniPath){this._init(base,iniPath,cbDebug)}};Config.prototype.getConfig=function(){var tmp=JSON.parse(JSON.stringify(this._config));if(tmp._sev){delete tmp._sev}return tmp};Config.prototype.getFiles=function(){return this._config.files};Config.prototype.getExclude=function(){return this._config.exclude};Config.prototype.getOptions=function(){return this._config.options};Config.prototype.getJetVer=function(){return this._config.jetVer};Config.prototype.getComponentsBaseUrl=function(){return this._config.componentsBaseUrl};Config.prototype.getComponentsBase=function(){return this._config.componentsBase};Config.prototype.getComponents=function(){return this._config.components};Config.prototype.getComponentUrls=function(){return this._config.componentUrls};Config.prototype.getComponentOptions=function(){return this._config.componentOptions};Config.prototype.getTypescript=function(){return this._config.typescript};Config.prototype.getTsConfig=function(){var ret;if(this._config.typescript){ret=this._config.typescript.tsconfig}return ret};Config.prototype.getTsConfigObj=function(){return this._tsCfgObj};Config.prototype.getOutPath=function(){return this._config.outPath};Config.prototype.getRulePacks=function(){return this._config.rulePacks};Config.prototype.getRuleMods=function(){return this._config.ruleMods};Config.prototype.getEnable=function(){return this._config.ruleMods&&this._config.ruleMods.enable?this._config.ruleMods.enable:undefined};Config.prototype.getDisable=function(){return this._config.ruleMods&&this._config.ruleMods.disable?this._config.ruleMods.disable:undefined};Config.prototype.getRuleDescriptions=function(){return this._config.ruleDescriptions};Config.prototype.getRulesFired=function(){return this._config.rulesFired};Config.prototype.getGroups=function(){return this._config.groups};Config.prototype.setGroups=function(groups){this._config.groups=groups};Config.prototype.getDefGroups=function(){return this._config.defGroups};Config.prototype.getRunRuleNames=function(){return this._config.ruleNames};Config.prototype.isBuiltinJetRules=function(){return this._config.builtinJetRules};Config.prototype.isBuiltinCspRules=function(){return this._config.builtinCspRules};Config.prototype.isBuiltinJetWcRules=function(){return this._config.builtinJetWcRules};Config.prototype.isBuiltinJetWcOracleRules=function(){return this._config.builtinJetWcOracleRules};Config.prototype.isBuiltinSpocRules=function(){return this._config.builtinSpocRules};Config.prototype.isBuiltinOjcMigrationRules=function(){return this._config.builtinOjcMigrationRules};Config.prototype.isBuiltinWebDriverTestRules=function(){return this._config.builtinWebDriverTestRules};Config.prototype.getMessages=function(){return this._config.messages};Config.prototype.setMessages=function(msgid,state){return this._helper.setMessages(msgid,state)};Config.prototype.getFollowLinks=function(){return this._config.followLinks};Config.prototype.getFormat=function(){return this._config.format};Config.prototype.getProseFormat=function(){return this._config.proseFormat};Config.prototype.getLineFormat=function(){return this._config.lineFormat};Config.prototype.getBase=function(){return this._config.base};Config.prototype.getStylesets=function(){return this._config.stylesets};Config.prototype.getNameSpaces=function(){return this._config.nameSpaces};Config.prototype.getCommon=function(){return this._config.common||{}};Config.prototype.getSeverity=function(){return this._config.severity};Config.prototype.setSeverity=function(severity){return this._config.severity=severity};Config.prototype.getSevMap=function(){return this._config.sevMap};Config.prototype.getTheme=function(){return this._config.theme};Config.prototype.getComments=function(){return this._config.comments};Config.prototype.getEcmaVer=function(){return this._config.ecmaVer};Config.prototype.getTabs=function(){return this._config.tabs};Config.prototype.getTitle=function(){return this._config.title};Config.prototype.getRetCode=function(){var ret,o;if(this._config&&this._config.options){o=this._config.options;if(o.retCode!==undefined){ret=o.retCode}else if(o.rc!==undefined){ret=o.rc}else{ret="auto"}}else{ret="auto"}return ret};Config.prototype.isOk=function(){return!this._bErrors};Config.prototype.getUserDefs=function(){return this._config.userDefs};Config.prototype.getAppendFileList=function(){return this._helper.getAddFileList()};Config.prototype.getJetPagesOnly=function(){return this._config.jetPagesOnly};Config.prototype.getTempDir=function(){return this._config.tempDir};Config.prototype.getOrigConfig=function(){return this._origConfig};Config.prototype.get$JetCore=function(){return this._config.$JetCore};Config.prototype._init=function(base,iniPath,cbDebug){var i,s,val,val2,bUseDefaults=false;if(typeof iniPath==="string"){this._dir=nodeDeps.path.dirname(iniPath);bUseDefaults=this._loadConfig(iniPath);if(this._bErrors){return}}else{this._config=iniPath;this._dir=nodeDeps.process.cwd();this._preBuilt=true}this._origConfig=this._config;this._config=_cloneConfig(this._config);this._helper.setConfig(this._config,this._preBuilt?null:iniPath,this._dir);if(this._config.options){this._isVerbose=!!this._config.options.verbose;this._isDebug=!!this._config.options.debug;cbDebug(this._isVerbose,this._isDebug);this._helper.setDebugStatus(this._isVerbose,this._isdebug)}if(!this._checkProperties()){this._bErrors=true;return}if(base){this._config.base=base}if(!this._config.base){this._config.base=this._dir}if(this._config.base===MACROS.cwd){this._config.base=nodeDeps.process.cwd()}if(!this._cleanBase()){return}if(!bUseDefaults&&!this._isOJET){this._info("[Info]: Analyzing "+(typeof iniPath==="string"?"config '"+iniPath+"'":"pre-built config object"),"I",true)}if(this._config.extends){if(!this._helper.processExtends(this._config)){this._bErrors=true;return}}if(typeof this._config.builtinJetRules!==TYPE_BOOLEAN){this._config.builtinJetRules=true}if(typeof this._config.builtinCspRules!==TYPE_BOOLEAN){this._config.builtinCspRules=false}if(typeof this._config.builtinJetWcRules!==TYPE_BOOLEAN){this._config.builtinJetWcRules=false}if(typeof this._config.builtinJetWcOracleRules!==TYPE_BOOLEAN){this._config.builtinJetWcOracleRules=false}if(typeof this._config.builtinWebDriverTestRules!==TYPE_BOOLEAN){this._config.builtinWebDriverTestRules=false}if(this._config.builtinSpocRules){if(typeof this._config.builtinSpocRules!==TYPE_BOOLEAN){this._error("Config entry 'builtinSpocRules' must be a boolean!");this._bErrors=true;return}if(this._config.builtinSpocRules){this._config.builtinJetRules=this._config.builtinJetWcRules=this._config.builtinJetWcOracleRules=false}}if(this._config.builtinOjcMigrationRules){if(typeof this._config.builtinOjcMigrationRules!==TYPE_BOOLEAN){this._error("Config entry 'builtinOjcMigrationRules' must be a boolean!");this._bErrors=true;return}else{this._config.builtinJetRules=this._config.builtinJetWcRules=this._config.builtinJetWcOracleRules=this._config.builtinCspRules=this._config.builtinSpocRules=false}}else{this._config.builtinOjcMigrationRules=false}this._config.jetPagesOnly=!!this._config.jetPagesOnly;if(!this._config.files){this._config.files=[]}if(!this._config.options){this._config.options={}}if(this._config.jetVer){val=this._config.jetVer;if(typeof val!=="string"){this._error("Config entry 'jetVer' is not a string!");this._bErrors=true;return}val=val.trim();val2=val.split(".");for(i=0;i<val2.length;i++){if(i===0&&val2[0].charAt(0).toLowerCase()==="v"){val2[0]=val2[0].substring(1)}s=parseInt(val2[i]);if(isNaN(s)){let part=["major","minor","patch"];this._error(`Config entry 'jetVer' --> '${val}' : '${part[i]}' value is invalid`);this._bErrors=true;return}val2[i]=""+s}val=val2.join(".");if(val2.length!==3||val2[2]==="0"){s=val2.length===3;val2=nodeDeps.jetver.getBestVersion(val,val2);if(!val2){s=s?`Config entry 'jetVer' --> '${val}' cannot be resolved to a supported JET version`:`Config entry 'jetVer' --> '${val}' is not a supported JET version`;this._error(s);this._bErrors=true;return}val=val2}if(!JET_VERSIONS[val]){this._error(`Config entry 'jetVer' --> '${val}' is not a supported JET version!`);this._bErrors=true;return}this._config.jetVer=val}else{this._config.jetVer=DEFAULTS.JETVER}if(!this._helper.processWebComponents()){this._bErrors=true;return}if(!this._helper.processRulePacks()){this._bErrors=true;return}if(!this._helper.processRuleMods()){this._bErrors=true;return}if(!this._helper.processFormat()){this._bErrors=true;return}if(!this._helper.processProseFormat()){this._bErrors=true;return}if(!this._helper.processLineFormat()){this._bErrors=true;return}if(!this._helper.processRuleDescriptions()){this._bErrors=true;return}if(!this._helper.processRulesFired()){this._bErrors=true;return}if(!this._helper.processSevMap()){this._bErrors=true;return}if(!this._helper.processSeverity(this._cliSev)){this._bErrors=true;return}if(!this._helper.processGroups(this._cliGroups)){this._bErrors=true;return}if(!this._helper.processDefGroups()){this._bErrors=true;return}if(!this._helper.processRuleNames()){this._bErrors=true;return}if(this._config.followLinks==null){this._config.followLinks=true}else{this._config.followLinks=!!this._config.followLinks}if(!Array.isArray(this._config.files)){this._error("Config entry 'files' is not an array!");this._bErrors=true;return}if(!this._helper.validateFileList(this._config.files)){this._bErrors=true;return}if(this._config.exclude){if(!Array.isArray(this._config.exclude)){this._error("Config entry 'exclude' is not an array!");this._bErrors=true;return}if(!this._helper.validateFileList(this._config.exclude)){this._bErrors=true;return}}else if(this._config.excludes){this._error("Config property 'excludes' found - did you mean 'exclude'?");this._bErrors=true;return}if(!this._helper.processAddFileList()){this._bErrors=true;return}if(this._config.stylesets){val=this._config.stylesets;if(!Array.isArray(val)){this._error("Config property 'stylesets' is not an array!");this._bErrors=true;return}}if(this._isAMD&&this._config.tempDir){this._error("Config entry 'tempDir' is not valid in AMD mode!");this._bErrors=true;return}if(this._config.tempDir){if(typeof this._config.tempDir!=="string"){this._error("Config property 'tempDir' is not a string!");this._bErrors=true;return}if(this._config.tempDir.startsWith(".")){this._config.tempDir=nodeDeps.path.resolve(nodeDeps.process.cwd(),this._config.tempDir)}}if(!this._helper.processTypeScript()){this._bErrors=true;return}if(!this._helper.processMessages()){this._bErrors=true;return}if(!this._helper.processNameSpaces()){this._bErrors=true;return}if(!this._helper.processTheme()){this._bErrors=true;return}if(!this._helper.processComments()){this._bErrors=true;return}if(!this._helper.processEcmaVer()){this._bErrors=true;return}if(!this._helper.processOptions()){this._bErrors=true;return}if(!this._helper.processTitle()){this._bErrors=true;return}if(!this._helper.processRetCode()){this._bErrors=true;return}if(!this._config.extends){this._cleanConfigPaths()}if(this._config.typescript&&(val=this._config.typescript.tsconfig)){if(!(this._tsCfgObj=this._loadTsConfig(val))){this._bErrors=true;return}}};Config.prototype.validateRetCode=function(val,cb){return this._helper.validateRetCode(val,cb)};Config.prototype._cleanConfigPaths=function(){var src,i,ftype,dir;if(!this._config.extends){this._info("[Info]: Using config base '"+this._config.base+"'","I")}src=this._config.files;if(src){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){if(!nodeDeps.path.isAbsolute(src[i])){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}}}src=this._config.exclude;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i])){src[i]=nodeDeps.path.normalize(src[i]);src[i]=nodeDeps.path.resolve(this._config.base,src[i])}}}src=this._config.components;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i])){dir=nodeDeps.path.normalize(src[i]);dir=nodeDeps.path.resolve(this._config.base,dir);this._config.components[i]=dir}}}src=this._config.outPath;if(src&&src!=="$noout"){if(!nodeDeps.path.isAbsolute(src)){src=nodeDeps.path.normalize(src);src=nodeDeps.path.resolve(this._config.base,src);this._config.outPath=src}}src=this._config.rulePacks;if(src){for(i=0;i<src.length;i++){if(!nodeDeps.path.isAbsolute(src[i].path)){dir=nodeDeps.path.normalize(src[i].path);src[i].path=nodeDeps.path.resolve(this._config.base,dir)}if(src[i].path.endsWith(".zip")){continue}ftype=nodeDeps.fsUtils.getFileType(src[i].path);if(ftype!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true;return}}}if(this._config.typescript&&this._config.typescript.tsconfig)src=this._config.typescript.tsconfig;if(src&&typeof src==="string"){if(!nodeDeps.path.isAbsolute(src)){dir=nodeDeps.path.normalize(src);dir=nodeDeps.path.resolve(this._config.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nodeDeps.path.join(dir,TSCONFIG)}this._config.typescript.tsconfig=dir}if(this._bErrors){return};};Config.prototype._cleanBase=function(){var p,ft;p=this._config.base;p=nodeDeps.path.normalize(p);p=nodeDeps.path.resolve(this._dir,p);ft=nodeDeps.fsUtils.getFileType(p);if(ft!=="d"){this._error(`Config file 'base' is not a directory - '${p}'`);this._bErrors=true;return false}p=nodeDeps.path.join(p,"/");this._config.base=p;this._info(`[Info]: Using Config base '${p}'`,"I");return true};Config.prototype._loadConfig=function(iniPath){var data,stats,bUseDefaults=false,msg;try{stats=nodeDeps.fs.statSync(iniPath);if(!stats.isFile()){this._warn("\n[Warn]: Config file '"+iniPath+"' not found. Using defaults.\n");bUseDefaults=true}else{data=nodeDeps.fs.readFileSync(iniPath,"utf8");data=nodeDeps.decomment(data);data=this.processIncludes(data,iniPath);data=this.processTokens(data);if(this._bErrors){return}if(this._isDebug){if(!data){console.log("NO CONFIG DATA")}else{var a=data.split("\n");console.log("------------- Config Raw Text...");for(var i=0;i<a.length;i++){console.log(i+1+"] "+a[i])}console.log("-".repeat(40))}}if(data){this._config=JSON.parse(nodeDeps.decomment(data))}else{this._bErrors=true}}}catch(e){this._bErrors=true;if(e.code){if(e.message.startsWith("ENOENT:")){this._warn("\nConfig file \""+iniPath+"\" not found - using defaults.\n");this._bErrors=false;bUseDefaults=true}}else if(e.toString().startsWith("SyntaxError")){msg=_convertMsgToRowCol(e.message,data,this._utils)}else{msg=e.message}if(msg){msg=msg.replace(/\r/g,"");msg=msg.replace(/ +(?= )/g,"");this._error("Config parse error");this._error("Config file '"+iniPath+"' - "+msg)}}if(this._bErrors){return}if(bUseDefaults){this._config={exclude:["./**/*-min.js","./**/*-min.css","./**/node_modules/**/*.*"],builtinJetRules:true,builtinCspRules:false,builtinJetWcRules:false,builtinJetWcOracleRules:false,builtinOjcMigrationRules:false,followLinks:true,severity:this._severity.ALL,format:"prose",ecmaVer:DEFAULTS.ECMAVER,options:{verbose:false,color:true}}}return bUseDefaults};Config.prototype._checkProperties=function(){return this._helper.checkPropNames()};Config.prototype._loadTsConfig=function(fp){return nodeDeps.jsonLoader.load(fp,nodeDeps,m=>{this._error(`Error loading tsconfig : ${m}.`);this._bErrors=true},false,this._utils)};function _convertMsgToRowCol(msg,data,utils){var x,n,rc;x=msg.indexOf("position");if(x<0){return msg}n=parseInt(msg.substr(x+8).trim());rc=utils.getRowColFromIndex(data,n);return msg.substr(0,x)+"row "+rc.row+", col "+rc.col};Config.prototype.processTokens=function(data){const TOKENS="\"tokens\"";var token,sub,start,end,json,toks,count,subst,rc,x,n;if(this._isDebug){this._debug("Performing config 'tokens' substitution...")}x=data.indexOf(TOKENS);if(x<0)return data;x+=TOKENS.length;n=this._expect(data,x,":",true);if(n<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: expected ':' after property "+TOKENS+" on line "+rc.row+" position "+rc.col+".");this._bErrors=true;return}n=this._expect(data,n,"{");if(n<0){rc=this._utils.getRowColFromIndex(data,n);this._error("Config: expected '{' after property "+TOKENS+" on line "+rc.row+".");this._bErrors=true;return}start=n;end=data.indexOf("}",start);if(end<0){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: "+TOKENS+" property syntax error (on/after line "+rc.row+").");this._bErrors=true;return}json=data.substring(start,end+1);try{toks=JSON.parse(json)}catch(e){rc=this._utils.getRowColFromIndex(data,x);this._error("Config: syntax error "+TOKENS+" property (on/after line "+rc.row+").");this._bErrors=true;return}subst=0;count=0;for(token in toks){if(token.charAt(0)!=="@"){this._error("Config: token '"+token+"' : must be prefixed with '@'");this._bErrors=true;return}sub=toks[token];token=token.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");token=new RegExp(token,"g");if(this._isVerbose||this._isDebug){n=data.match(token).length;subst+=n>1?--n:0}data=data.replace(token,sub);count++}if(count){try{start=data.indexOf(TOKENS);start=this._expect(data,start+TOKENS.length,":",true);start=this._expect(data,start,"{");end=data.indexOf("}",start+1);data=data.substring(0,start)+json+data.substring(end+1);if(this._isVerbose||this._isDebug){this._info("[Info]: "+subst+" config token substitution"+(subst!==1?"s":"")+" performed with "+count+" token"+(count!==1?"s":"")+".")}}catch(e){this._error("Config: \"tokens\" substitution failed - review \"tokens\" property value");this._bErrors=true}}return data};Config.prototype._expect=function(data,x,s,bump){var ret=-1;x=this._utils.eatWhitespace(data,x);if(x>=0&&data.substr(x,s.length)===s){ret=x+(bump?s.length:0)}return ret};Config.prototype.processIncludes=function(data,filepath,chain){var a,i,line,x,path,comma;var inserts,insert,incPath;if(this._isDebug){this._debug("Checking for "+(chain?"sub ":"")+"@include. . .")}if((i=data.indexOf(AT_INCLUDE))<0||data.charAt(i-1)==="_"){if(this._isDebug){this._debug("No "+(chain?"sub ":"")+"@include found")}return data}inserts=[];a=data.split("\n");for(i=0;i<a.length;i++){line=a[i];x=line.indexOf(AT_INCLUDE);if(x<0){continue}path=_extractStringFromLine(line,x+AT_INCLUDE.length,this._utils);if(!path){this._error("Config - @include syntax error"+(chain?" in '"+filepath+"'":"!"));return null}incPath=nodeDeps.path.normalize(path);incPath=nodeDeps.path.resolve(this._dir,incPath);comma=_isTrailingComma(line,x+AT_INCLUDE.length,this._utils);try{if(this._isDebug){this._debug("Reading @include -> "+incPath)}insert=nodeDeps.fs.readFileSync(incPath,"utf8")}catch(e){this._error("Config @include - "+e);return null}if(!insert){this._error("Config - @include '"+incPath+"' not found!");return null}insert=this.processIncludes(insert,incPath,true);if(insert){inserts.push(i);inserts.push(insert+(comma?",":""))}else if(insert===null){return null}}if(inserts&&inserts.length){for(i=0;i<inserts.length;i++){a[inserts[i]]=inserts[++i]}}return a.join("\n")};function _extractStringFromLine(data,start,utils){var c,xEnd,wantQuote,antiQuote;start=utils.eatWhitespace(data,start);if(start<0){return null}c=data.charAt(start);wantQuote=c===QUOTE||c==="'"?c:null;if(wantQuote){antiQuote=c===QUOTE?"'":QUOTE;start++}for(xEnd=start;xEnd<data.length;xEnd++){c=data.charAt(xEnd);if(c===")"||wantQuote&&c===wantQuote){break}else if(c==="\n"||wantQuote&&c===antiQuote||!wantQuote&&(c===QUOTE||c==="'")){xEnd=-1;break}}if(xEnd<0||xEnd>=data.length||wantQuote&&data.charAt(xEnd)!==wantQuote){return null}data=data.substring(start,xEnd).trim();return data?data:null};function _isTrailingComma(s,x,utils){var n,ret=false;n=s.indexOf(")",x);if(n<0){return false}n=utils.eatWhitespace(s,n+1);if(n>=0){ret=s.charAt(n)===","}return ret};function _cloneConfig(o){return JSON.parse(JSON.stringify(o))};module.exports=Config;
package/lib/ConfigLib.js CHANGED
@@ -1 +1,6 @@
1
- const COMPOSITES="jet-composites";const TYPE_STRING="string";const TYPE_BOOLEAN="boolean";const AUTO="auto";const ERRORS="errors";const UNDEF="undefined";const NUMBER="number";const TOP_PROPS=["rulePacks","ruleMods","builtinJetRules","builtinCspRules","builtinExchRules","builtinJetWcRules","builtinJetWcOracleRules","builtinSpocRules","severity","groups","defGroups","ruleNames","base","files","exclude","tsconfig","jetPagesOnly","format","proseFormat","lineFormat","outPath","tabs","messages","addFileList","title","jetVer","components","componentUrls","componentOptions","stylesets","ecmaVer","ruleDescriptions","userDefs","options","comments","nameSpaces","followLinks","tempDir","tokens","common","$JetCore","sevMap","theme","ojet","appendFileList"];const OPTIONS_PROPS=["debug","verbose","color","msgid","ruleName","retCode","rc","ojetUpdate","xts"];const THEMES=["redwood","alta","none"];const DEF_THEME="Alta";const DEF_ECMAVER=11;const DEF_COMMENTS=false;const DEF_RULE_DESCRIPT="none";const DEF_GROUPS=["all"];const DEF_RETCODE="auto";const ECMA_VER=[5,6,7,8,9,10,11];const ECMA_YEAR=[-1,2015,2016,2017,2018,2019,2020];function CfgLib(oConfig,nodeDeps,sevLib,utils,msgCtx,modeCtx){this._oConfig=oConfig;this._config=null;this._sevLib=sevLib;this._utils=utils;this._nd=nodeDeps;this._isVerbose=msgCtx.isVerbose;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info;this._modeCtx=modeCtx};CfgLib.prototype.processWebComponents=function(){var dir,o,t,i;var config=this._config;if(config.componentUrlBase){if(!typeof config.componentUrlBase===TYPE_STRING){this._error("Config entry 'componentUrlBase' must be a string!");return false}}if(config.componentUrls){if(typeof config.componentUrls===TYPE_STRING){config.componentUrls=[config.componentUrls]}else if(!Array.isArray(config.componentUrls)){this._error("Config entry 'componentUrls' must be a string or an aray of strings!");return false}for(i=0;i<this._config.componentUrls.length;i++){config.componentUrls[i]=config.componentUrls[i].trim();if(config.componentUrls[i].length===0){config.componentUrls.splice(i,1);i--}}}if(!config.components){if(this._isCLI&&!this._isOJET&&this._experimentalSet){dir=this._findCompositesDir(config.base);if(dir){config.components=[];config.components.push(this._nd.path.join(dir,COMPOSITES))}}}if(config.components){if(typeof config.components===TYPE_STRING){config.components=[config.components]}else if(!Array.isArray(config.components)){this._error("Config entry 'components' must be a string or an array of strings!");return false}for(i=0;i<config.components.length;i++){config.components[i]=config.components[i].trim();if(config.components[i].length===0){config.components.splice(i,1);i--}}}if(config.components&&config.components.length||config.componentUrls&&config.componentUrls.length){o=config.componentOptions;if(o){if(!this._utils.isObject(o)){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}t=typeof o.applySchema;if(t==="undefined"){o.applySchema=true}else if(t!=="boolean"){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}}}return true};CfgLib.prototype.processTsConfig=function(){return true};CfgLib.prototype.processRuleSets=function(){var packs,pack,i;var config=this._config;if(config.ruleSets){config.rulePacks=this._config.ruleSets}if(config.rulePacks){packs=this._config.rulePacks;if(!Array.isArray(packs)){this._error("Config entry 'rulePacks' is not an array!");return false}for(i=0;i<packs.length;i++){pack=packs[i];if(typeof pack!==TYPE_BOOLEAN){pack.enabled=true}if(!pack.path){this._error(`Config entry 'rulePacks' (entry ${i+1}) does not have a 'path' entry!`);return false}else{pack.path=pack.path.trim()}if(pack.status&&!Array.isArray(pack)){this._error(`Config entry 'rulePacks' (entry ${i+1}) 'status' property is not an array!`);return false}}}else{config.rulePacks=[]}return true};CfgLib.prototype.processRuleMods=function(){var mods,mod,val;var config=this._config;const MSG="Config 'ruleMods' sub-property '${mod}' is not an array of rule names or group names!";var b;if(config.ruleMods){mods=config.ruleMods;for(mod in mods){val=mods[mod];if(mod==="enabled"){this._error("'ruleMods' : invalid sub-property 'enabled' - did you mean 'enable'?");b=true}else if(mod==="disabled"){this._error("'ruleMods' : invalid sub-property 'disabled' - did you mean 'disable'?");b=true}if(b){return!b}if(mod==="enable"||mod==="disable"){if(!Array.isArray(val)){this._error(this._utils.format(MSG,{mod:mod}));b=true}if(!this._utils.isArrayContentsType(val,"string")){this._error(this._utils.format(MSG,{mod:mod}));b=true}}else if(!this._utils.isObject(val)){this._error(`Config 'ruleMods' sub-property '${mod}' is not an object!`);b=true}}if(!b&&mods.enable&&mods.disable){let self=this;mods.enable.forEach(function(r){if(mods.disable.includes(r)){self._error(`Config 'ruleMods': 'enable' & 'disable' conflicting entry '${r}'!`);b=true}})}}return!b};CfgLib.prototype.processFormat=function(){var config=this._config;if(config.format){if(config.format!=="json"&&config.format!=="prose"&&config.format!=="line"){this._error(`Config entry 'format' '${config.format}' not valid. Must be 'json', 'prose' or 'line'!`);return false}}return true};CfgLib.prototype.processProseFormat=function(){var config=this._config;if(config.proseFormat){if(typeof config.proseFormat==="string"){if(config.format!=="prose"){this._warn("Config entry 'proseFormat' ignored - not applicable if 'format is not 'prose'!")}}else{this._error(`Config entry 'proseFormat' '${config.proseFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processLineFormat=function(){var config=this._config;if(config.lineFormat){if(typeof config.lineFormat==="string"){if(config.format!=="line"){this._warn("Config entry 'lineFormat' ignored - not applicable if 'format is not 'line'!")}}else{this._error(`Config entry 'lineFormat' '${config.lineFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processRuleDescriptions=function(){var val,valType;var config=this._config;if(config.ruleDescriptions){val=config.ruleDescriptions;valType=typeof val;if(valType!=="string"||val!="all"&&val!=="short"&&val!=="long"&&val!=="none"){this._error(`Config entry 'ruleDescriptions' '${val}' is not valid!`);return false}}else{config.ruleDescriptions=DEF_RULE_DESCRIPT}return true};CfgLib.prototype.processSevMap=function(){var config=this._config;var set,sev,msgs,inv,val,b,error;if(!config.sevMap){return true}set=config.sevMap.sevSet;if(set){b=error=false;for(val in set){if(!this._sevLib.isValidConfigSeverity(val)){this._error(`Config entry 'sevMap' sub-property 'sevset' value '${val}' is not 'major/minor/blocker/critical/info'!`);error=true;continue}if(val==="all"){this._error("Config entry 'sevMap' sub-property 'sevset' - pseudo severity 'all' cannot be remapped!");error=true;continue}if(typeof config.sevMap.sevSet[val]!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not a string!`);error=true;continue}b=true}if(error){return false}if(b){inv={};for(val in set){inv[set[val]]=val}this._sevLib.setSevMap(config.sevMap,inv)}else{config.sevMap.sevSet=null}}msgs=config.sevMap.sevMsg;if(msgs){if(!this._utils.isObject(msgs)){this._error("Config entry 'sevMap' sub-property 'sevMsg' is not an object!");return false}b=error=false;for(val in msgs){sev=msgs[val];if(typeof sev!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${val}' is not a string!`);error=true;continue}if(!this._sevLib.isSev(sev)){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${sev}' is ${UNDEF}!`);error=true;continue}b=true}if(error){return false}if(b){this._sevLib.setSevMsg(msgs)}else{config.sevMap.sevMsg=null}}else{b=true;for(val in config.sevMap){if(val!=="sevSet"&&val!=="sevMsg"){this._error(`Config entry 'sevMap' unknown sub-property '${val}'!`);b=false}}if(!b){return false}}return true};CfgLib.prototype.processSeverity=function(cliSev){var config=this._config;var val,se,i;if(cliSev){config.severity=cliSev}if(config.severity){val=config.severity;if(typeof val==="string"){se=this._sevLib.getSevExpr(val);if(!this._sevLib.isValidConfigSeverity(val)){if(se.op&&se.sev==="all"){this._error(`Config entry 'severity' ('${val}') : 'all' cannot be used with a severity expression !`)}else if(cliSev){this._error(`command line --severity '${val}' is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}else{this._error(`Config entry 'severity' ('${val}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}return false}this._sevLib.setSevExpr(se)}else if(Array.isArray(val)&&this._utils.isArrayContentsType(val,"string")){for(i=0;i<val.length;i++){if(!this._sevLib.isValidConfigSeverity(val[i])){this._error(`Config entry 'severity' ('${val[i]}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`);return false}}}else{this._error("Config entry 'severity' is invalid!");return false}}else{config.severity=this._sevLib.ALL;this._sevLib.setSevExpr(this._sevLib.getSevExpr(this._sevLib.ALL))}return true};CfgLib.prototype.processGroups=function(cliGroups,groups){var group,i;var config=this._config;if(cliGroups){config.groups=cliGroups}if(!config.groups){config.groups=DEF_GROUPS;return true}if(!Array.isArray(config.groups)){config.groups=[config.groups]}if(config.groups.length===0){config.groups.push("all")}else{for(i=0;i<config.groups.length;i++){group=config.groups[i];if(!groups.includes(group)){if(group.startsWith("jet-")||group.startsWith("htm")){this._error(`Config 'groups' entry '${group}' is not defined!`);return false}}}}return true};CfgLib.prototype.processDefGroups=function(){var config=this._config;if(config.defGroups){if(!this._utils.isObject(config.defGroups)){this._error("Config entry 'defGroups' is not an object!");return false}}else{config.defGroups=null}return true};CfgLib.prototype.processRuleNames=function(){var config=this._config;if(config.ruleNames){if(!Array.isArray(config.ruleNames)){this._error("Config entry 'ruleNames' is not an array!");return false}}return true};CfgLib.prototype.processTheme=function(){var t,config=this._config;t=config.theme;if(t){t=t.toLowerCase();if(typeof t==="string"){if(!THEMES.includes(t)){this._error(`Invalid config theme '${t}' : must be 'Redwood' or 'Alta' (or 'none')`);return false}}else{this._error("Config entry 'theme' is not a string!");return false}config.theme=t.charAt(0).toUpperCase()+t.substring(1)}else{config.theme=DEF_THEME;if(this._isVerbose){this._info("[Info]: default theme '${DEF_THEME}' applied")}}return true};CfgLib.prototype.processComments=function(){var t,config=this._config;t=typeof config.comments;if(t===UNDEF){config.comments=DEF_COMMENTS}else if(t!=="boolean"){this._error("Invalid 'comments' property - expected a boolean");return false}return true};CfgLib.prototype.processEcmaVer=function(){var val,config=this._config;if(config.ecmaVer){val=config.ecmaVer;if(typeof val==="string"){val=parseInt(val);if(isNaN(val)){val=0}}if(typeof val===NUMBER){if(!(ECMA_VER.includes(val)||ECMA_YEAR.includes(val))){this._error(`Config 'ecmaVer: ${config.ecmaVer}' is not in the version range 5-10 or the year range 2015-2019!`);return false}}if(val>=2015){val=ECMA_YEAR.indexOf(val);config.ecmaVer=ECMA_VER[val]}else{config.ecmaVer=val}}else{config.ecmaVer=DEF_ECMAVER}return true};CfgLib.prototype.processMessages=function(){var val,config=this._config;if(config.messages){val=config.messages;if(!this._utils.isObject(val)){this._error("Config entry 'messages' is not an object!");return false}if(val.accept&&val.reject){this._error("Config entry 'messages' - 'accept' and 'reject' are mutually exclusive!");return false}if(val.accept){if(!Array.isArray(val.accept)){this._error("Config entry 'messages.accept' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.accept,"string")){this._error("Config entry 'messages.accept' property array does not contain all strings");return false}}if(val.reject){if(!Array.isArray(val.reject)){this._error("Config entry 'messages.reject' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.reject,"string")){this._error("Config entry 'messages.reject' property array does not contain all strings");return false}}}return true};CfgLib.prototype.processAddFileList=function(){var config=this._config;if(config.appendFileList){this._appendFileList=true;this._warn("Configuration property 'appendFileList' : change to 'addFileList'")}else if(config.addFileList){this._addFileList=true}return true};CfgLib.prototype.processNameSpaces=function(){var config,nsp,ns,e;config=this._config;if(!config.nameSpaces){return true}if(!Array.isArray(config.nameSpaces)){config.nameSpaces=[config.nameSpaces]}nsp=config.nameSpaces;for(let i=0;i<nsp.length;i++){ns=nsp[i];if(!ns||typeof ns!=="string"){this._error(`Config 'nameSpaces' entry "${ns}" at index ${i} is not a valid namespace`);e=true}else if(ns.startsWith("oj-")||ns.startsWith("ns-")){this._error(`Config 'nameSpaces' entry '${ns}' must not use reserved JET prefix ${ns.substring(0,3)}`);e=true}}return e?false:true};CfgLib.prototype.processOptions=function(){var prop,opts,config=this._config,isCLI=this._modeCtx.isCLI||this._modeCtx.isOJETCLI;if(config.options){opts=config.options;for(prop in opts){if(!OPTIONS_PROPS.includes(prop)){this._error(`Config - unknown 'options' sub-property '${prop}'!`);return false}else if((prop==="retCode"||prop==="rc")&&!isCLI){this._error(`"Config - 'options' property '${prop}' is valid in CLI mode only!`);return false}}}return true};CfgLib.prototype.processTitle=function(){var t,config=this._config;if(config.title){t=this._utils.getType(config.title);if(t!=="string"&&t!=="array"){this._error(`Config entry 'title has incorrect type ('${t}')`);return false}}return true};CfgLib.prototype.processRetCode=function(){var rc,prop,config=this._config;if(config.options){prop=typeof config.options.retCode!==UNDEF?"retCode":typeof config.options.rc!==UNDEF?"rc":null;if(prop){rc=config.options[prop];if(rc!==DEF_RETCODE&&rc!==ERRORS&&typeof rc!==NUMBER){this._error(`Config entry 'options.${prop}' is invalid ('${rc}')`);config.options.retCode=AUTO;return false}}}if(!prop){if(!config.options){config.options={}}config.options.retCode=DEF_RETCODE}return true};CfgLib.prototype.setMessages=function(msgid,state){var accept,reject,msgs,target,changed=false,i;var config=this._config;msgs=config.messages;state=!!state;if(!msgs){if(!state){config.messages={reject:[msgid]};changed=true}}else{reject=msgs.reject;accept=msgs.accept;target=accept||reject;i=target?target.indexOf(msgid):-1;if(state){if(!accept&&!reject){msgs.accept=accept=[]}if(reject){if(i>=0){reject.splice(i,1);changed=true;if(reject.length===0){delete msgs.reject}}}else if(accept){if(i<0){accept.push(msgid);changed=true}}}else{if(!accept&&!reject){msgs.reject=reject=[]}if(reject){if(i<0){reject.push(msgid);changed=true}}else if(accept){if(i>=0){accept.splice(i,1);if(accept.length===0){delete msgs.accept}changed=true}}}}return changed};CfgLib.prototype.getAddFileList=function(){return!!(this._addFileList||this._appendFileList)};CfgLib.prototype.checkPropNames=function(){var prop,ret=true,config=this._config;;for(prop in config){if(!TOP_PROPS.includes(prop)){if(prop.charAt(0)==="_"){delete config[prop];continue}this._error(`Config - unknown property '${prop}'!`);ret=false}}return ret};CfgLib.prototype.getDefaultEcmaVer=function(){return DEF_ECMAVER};CfgLib.prototype.setConfig=function(cfg){this._config=cfg};CfgLib.prototype._findCompositesDir=function(base){return this._nd.fsUtils.findFile(base,COMPOSITES)};module.exports=CfgLib;
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const GROUPS=require("./groups");const DEFAULTS=require("./defaults");const SemVer=require("semver");const COMPOSITES="jet-composites";const TYPE_STRING="string";const TYPE_BOOLEAN="boolean";const AUTO="auto";const ERRORS="errors";const UNDEF="undefined";const NUMBER="number";const TOP_PROPS=["rulePacks","ruleMods","builtinJetRules","builtinCspRules","builtinSpocRules","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","severity","groups","defGroups","ruleNames","base","files","exclude","typescript","jetPagesOnly","format","proseFormat","lineFormat","outPath","tabs","messages","addFileList","title","jetVer","components","componentUrls","componentOptions","stylesets","ecmaVer","ruleDescriptions","rulesFired","userDefs","options","comments","extends","extendOptions","nameSpaces","followLinks","tempDir","tokens","common","$JetCore","sevMap","theme","ojet","appendFileList"];const NOT_AMD=["addFileList","base","builtinJetWcRules","builtinJetWcOracleRules","builtinOjcMigrationRules","builtinWebDriverTestRules","components","componentOptions","componentUrls","extends","extendOptions","files","exclude","followLinks","outPath","rulePacks","tempDir","tokens","typescript"];const OPTIONS_PROPS=["debug","verbose","color","msgid","ruleName","retCode","rc","ojetUpdate","$unittest"];const THEMES=["redwood","alta","none"];const DEF_COMMENTS=false;const DEF_RULE_DESCRIPT="none";const DEF_GROUPS=["all"];const DEF_RETCODE="auto";const ECMA_VER=[5,6,7,8,9,10,11];const ECMA_YEAR=[-1,2015,2016,2017,2018,2019,2020];function CfgLib(oConfig,nodeDeps,sevLib,utils,msgCtx,modeCtx){this._oConfig=oConfig;this._config=null;this._dir=null;this._sevLib=sevLib;this._utils=utils;this._nd=nodeDeps;this._msgCtx=msgCtx;this._modeCtx=modeCtx;this._isVerbose=msgCtx.isVerbose;this._isCLI=modeCtx.isCLI||modeCtx.isOJETCLI;this._error=msgCtx.error;this._warn=msgCtx.warn;this._info=msgCtx.info};CfgLib.prototype.setDebugStatus=function(verbose,debug){this._isVerbose=this._msgCtx.isVerbose=verbose};CfgLib.prototype.processWebComponents=function(){var dir,o,t,i;var config=this._config;if(config.componentUrlBase){if(!typeof config.componentUrlBase===TYPE_STRING){this._error("Config entry 'componentUrlBase' must be a string!");return false}}if(config.componentUrls){if(typeof config.componentUrls===TYPE_STRING){config.componentUrls=[config.componentUrls]}else if(!Array.isArray(config.componentUrls)){this._error("Config entry 'componentUrls' must be a string or an aray of strings!");return false}for(i=0;i<this._config.componentUrls.length;i++){config.componentUrls[i]=config.componentUrls[i].trim();if(config.componentUrls[i].length===0){config.componentUrls.splice(i,1);i--}}}if(!config.components){if(this._isCLI&&!this._isOJET&&this._experimentalSet){dir=this._findCompositesDir(config.base);if(dir){config.components=[];config.components.push(this._nd.path.join(dir,COMPOSITES))}}}if(config.components){if(typeof config.components===TYPE_STRING){config.components=[config.components]}else if(!Array.isArray(config.components)){this._error("Config entry 'components' must be a string or an array of strings!");return false}for(i=0;i<config.components.length;i++){config.components[i]=config.components[i].trim();if(config.components[i].length===0){config.components.splice(i,1);i--}}}if(config.components&&config.components.length||config.componentUrls&&config.componentUrls.length){o=config.componentOptions;if(o){if(!this._utils.isObject(o)){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}t=typeof o.applySchema;if(t==="undefined"){o.applySchema=true}else if(t!=="boolean"){this._error("Config 'components' sub-property 'componentOptions' must be an Object!");return false}}}return true};CfgLib.prototype.processTypeScript=function(){var ts,ret=true;if(this._config.hasOwnProperty("typescript")){ts=this._config.typescript;if(!this._utils.isObject(ts)){this._error("Config 'typescript' property is not an object!");ret=false}if(ts.hasOwnProperty("compile")){if(typeof ts.compile!=="boolean"){this._error("Config 'typescript' sub-property 'compile' is not a boolean!");ret=false}}if(ts.hasOwnProperty("tsconfig")){if(typeof ts.tsconfig!=="string"){this._error("Config 'typescript' sub-property 'tsconfig' must be a directory string!");ret=false}}}return ret};CfgLib.prototype.processRulePacks=function(){var packs,pack,i;var config=this._config;if(config.rulePacks){packs=this._config.rulePacks;if(!Array.isArray(packs)){this._error("Config entry 'rulePacks' is not an array!");return false}for(i=0;i<packs.length;i++){pack=packs[i];if(typeof pack!==TYPE_BOOLEAN){pack.enabled=true}if(!pack.path){this._error(`Config entry 'rulePacks' (entry ${i+1}) does not have a 'path' entry!`);return false}else{pack.path=pack.path.trim()}if(pack.status&&!Array.isArray(pack)){this._error(`Config entry 'rulePacks' (entry ${i+1}) 'status' property is not an array!`);return false}}}else{config.rulePacks=[]}return true};CfgLib.prototype.processRuleMods=function(){var mods,mod,val;var config=this._config;const MSG="Config 'ruleMods' sub-property '${mod}' is not an array of rule names or group names!";var b;if(config.ruleMods){mods=config.ruleMods;for(mod in mods){val=mods[mod];if(mod==="enabled"){this._error("'ruleMods' : invalid sub-property 'enabled' - did you mean 'enable'?");b=true}else if(mod==="disabled"){this._error("'ruleMods' : invalid sub-property 'disabled' - did you mean 'disable'?");b=true}if(b){return!b}if(mod==="enable"||mod==="disable"){if(!Array.isArray(val)){this._error(this._utils.format(MSG,{mod:mod}));b=true}if(!this._utils.isArrayContentsType(val,"string")){this._error(this._utils.format(MSG,{mod:mod}));b=true}}else if(!this._utils.isObject(val)){this._error(`Config 'ruleMods' sub-property '${mod}' is not an object!`);b=true}}if(!b&&mods.enable&&mods.disable){let self=this;mods.enable.forEach(function(r){if(mods.disable.includes(r)){self._error(`Config 'ruleMods': 'enable' & 'disable' conflicting entry '${r}'!`);b=true}})}}return!b};CfgLib.prototype.processFormat=function(){var config=this._config;if(config.format){if(config.format!=="json"&&config.format!=="prose"&&config.format!=="line"){this._error(`Config entry 'format' '${config.format}' not valid. Must be 'json', 'prose' or 'line'!`);return false}}return true};CfgLib.prototype.processProseFormat=function(){var config=this._config;if(config.proseFormat){if(typeof config.proseFormat==="string"){if(config.format!=="prose"){this._warn("Config entry 'proseFormat' ignored - not applicable if 'format is not 'prose'!")}}else{this._error(`Config entry 'proseFormat' '${config.proseFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processLineFormat=function(){var config=this._config;if(config.lineFormat){if(typeof config.lineFormat==="string"){if(config.format!=="line"){this._warn("Config entry 'lineFormat' ignored - not applicable if 'format is not 'line'!")}}else{this._error(`Config entry 'lineFormat' '${config.lineFormat}' is not valid!`);return false}}return true};CfgLib.prototype.processRuleDescriptions=function(){var val,valType;var config=this._config;if(config.ruleDescriptions){val=config.ruleDescriptions;valType=typeof val;if(valType!=="string"||val!="all"&&val!=="short"&&val!=="long"&&val!=="none"){this._error(`Config entry 'ruleDescriptions' '${val}' is not valid!`);return false}}else{config.ruleDescriptions=DEF_RULE_DESCRIPT}return true};CfgLib.prototype.processRulesFired=function(){var config=this._config;if(config.rulesFired){if(!this._modeCtx.isAPI&&!this._modeCtx.isAMD&&(!config.format||config.format!=="json")){this._error(`Config entry 'rulesFired' - API/AMD mode required, or 'format' property set to 'json' for CLI mode!`);return false}}return true};CfgLib.prototype.processSevMap=function(){var config=this._config;var set,sev,msgs,inv,mapped,val,b,error;if(!config.sevMap){return true}set=config.sevMap.sevSet;if(set){b=error=false;for(val in set){if(!this._sevLib.isValidConfigSeverity(val)){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not 'major/minor/blocker/critical/info'!`);error=true;continue}if(val==="all"){this._error("Config entry 'sevMap' sub-property 'sevSet' - pseudo severity 'all' cannot be remapped!");error=true;continue}if(typeof set[val]!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevSet' value '${val}' is not a string!`);error=true;continue}b=true}if(error){return false}if(b){inv={};for(sev in set){mapped=set[sev];if(inv[mapped]){if(!Array.isArray(inv[mapped])){inv[mapped]=[inv[mapped]]}inv[mapped].push(sev)}else{inv[mapped]=sev}}this._sevLib.setSevMap(config.sevMap,inv)}else{config.sevMap.sevSet=null}}msgs=config.sevMap.sevMsg;if(msgs){if(!this._utils.isObject(msgs)){this._error("Config entry 'sevMap' sub-property 'sevMsg' is not an object!");return false}b=error=false;for(val in msgs){sev=msgs[val];if(typeof sev!=="string"){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${val}' is not a string!`);error=true;continue}if(!this._sevLib.isSev(sev)){this._error(`Config entry 'sevMap' sub-property 'sevMsg' : '${sev}' is ${UNDEF}!`);error=true;continue}b=true}if(error){return false}if(b){this._sevLib.setSevMsg(msgs)}else{config.sevMap.sevMsg=null}}else{b=true;for(val in config.sevMap){if(val!=="sevSet"&&val!=="sevMsg"){this._error(`Config entry 'sevMap' unknown sub-property '${val}'!`);b=false}}if(!b){return false}}return true};CfgLib.prototype.processSeverity=function(cliSev){var config=this._config;var val,se,i;if(cliSev){config.severity=cliSev}if(config.severity){val=config.severity;if(typeof val==="string"){se=this._sevLib.getSevExpr(val);if(!this._sevLib.isValidConfigSeverity(val)){if(se.op&&se.sev==="all"){this._error(`Config entry 'severity' ('${val}') : 'all' cannot be used with a severity expression !`)}else if(cliSev){this._error(`command line --severity '${val}' is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}else{this._error(`Config entry 'severity' ('${val}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`)}return false}this._sevLib.setSevExpr(se)}else if(Array.isArray(val)&&this._utils.isArrayContentsType(val,"string")){for(i=0;i<val.length;i++){if(!this._sevLib.isValidConfigSeverity(val[i])){this._error(`Config entry 'severity' ('${val[i]}') is not 'major/minor/blocker/critical/info', 'all', or a remapped severity!`);return false}}}else{this._error("Config entry 'severity' is invalid!");return false}}else{config.severity=this._sevLib.ALL;this._sevLib.setSevExpr(this._sevLib.getSevExpr(this._sevLib.ALL))}return true};CfgLib.prototype.processGroups=function(cliGroups){var group,i;var config=this._config;if(cliGroups){config.groups=cliGroups}if(!config.groups){config.groups=DEF_GROUPS;return true}if(!Array.isArray(config.groups)){config.groups=[config.groups]}if(config.groups.length===0){config.groups.push("all")}else{for(i=0;i<config.groups.length;i++){group=config.groups[i];if(!GROUPS.isGroup(group)){if(group.startsWith("jet-")||group.startsWith("htm")){this._error(`Config 'groups' entry '${group}' is not defined!`);return false}}}}return true};CfgLib.prototype.processDefGroups=function(){var config=this._config;if(config.defGroups){if(!this._utils.isObject(config.defGroups)){this._error("Config entry 'defGroups' is not an object!");return false}}else{config.defGroups=null}return true};CfgLib.prototype.processRuleNames=function(){var config=this._config;if(config.ruleNames){if(!Array.isArray(config.ruleNames)){this._error("Config entry 'ruleNames' is not an array!");return false}}return true};CfgLib.prototype.processTheme=function(){var t,config=this._config;t=config.theme;if(t){t=t.toLowerCase();if(typeof t==="string"){if(!THEMES.includes(t)){this._error(`Invalid config theme '${t}' : must be 'Redwood' or 'Alta' (or 'none')`);return false}}else{this._error("Config entry 'theme' is not a string!");return false}config.theme=t.charAt(0).toUpperCase()+t.substring(1)}else{config.theme=SemVer.gte(config.jetVer,"12.0.0")?"Redwood":DEFAULTS.THEME;if(this._isVerbose){this._info(`[Info]: Default theme '${config.theme}' applied for jetVer ${config.jetVer}`)}}return true};CfgLib.prototype.processComments=function(){var t,config=this._config;t=typeof config.comments;if(t===UNDEF){config.comments=DEF_COMMENTS}else if(t!=="boolean"){this._error("Invalid 'comments' property - expected a boolean");return false}return true};CfgLib.prototype.processEcmaVer=function(){var val,config=this._config;if(config.ecmaVer){val=config.ecmaVer;if(typeof val==="string"){val=parseInt(val);if(isNaN(val)){val=0}}if(typeof val===NUMBER){if(!(ECMA_VER.includes(val)||ECMA_YEAR.includes(val))){this._error(`Config 'ecmaVer: ${config.ecmaVer}' is not in the version range 5-10 or the year range 2015-2019!`);return false}}if(val>=2015){val=ECMA_YEAR.indexOf(val);config.ecmaVer=ECMA_VER[val]}else{config.ecmaVer=val}}else{config.ecmaVer=DEFAULTS.ECMAVER}return true};CfgLib.prototype.processMessages=function(){var val,config=this._config;if(config.messages){val=config.messages;if(!this._utils.isObject(val)){this._error("Config entry 'messages' is not an object!");return false}if(val.accept&&val.reject){this._error("Config entry 'messages' - 'accept' and 'reject' are mutually exclusive!");return false}if(val.accept){if(!Array.isArray(val.accept)){this._error("Config entry 'messages.accept' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.accept,"string")){this._error("Config entry 'messages.accept' property array does not contain all strings");return false}}if(val.reject){if(!Array.isArray(val.reject)){this._error("Config entry 'messages.reject' is not an array!");return false}else if(!this._utils.isArrayContentsType(val.reject,"string")){this._error("Config entry 'messages.reject' property array does not contain all strings");return false}}}return true};CfgLib.prototype.processAddFileList=function(){var config=this._config;if(config.appendFileList){this._appendFileList=true;this._warn("Configuration property 'appendFileList' : change to 'addFileList'")}else if(config.addFileList){this._addFileList=true}return true};CfgLib.prototype.processNameSpaces=function(){var config,nsp,ns,e;config=this._config;if(!config.nameSpaces){return true}if(!Array.isArray(config.nameSpaces)){config.nameSpaces=[config.nameSpaces]}nsp=config.nameSpaces;for(let i=0;i<nsp.length;i++){ns=nsp[i];if(!ns||typeof ns!=="string"){this._error(`Config 'nameSpaces' entry "${ns}" at index ${i} is not a valid namespace`);e=true}else if(ns.startsWith("oj-")||ns.startsWith("ns-")){this._error(`Config 'nameSpaces' entry '${ns}' must not use reserved JET prefix ${ns.substring(0,3)}`);e=true}}return e?false:true};CfgLib.prototype.processOptions=function(){var prop,opts,config=this._config,isCLI=this._modeCtx.isCLI||this._modeCtx.isOJETCLI;if(config.options){opts=config.options;for(prop in opts){if(!OPTIONS_PROPS.includes(prop)){this._error(`Config - unknown 'options' sub-property '${prop}'`);return false}else if((prop==="retCode"||prop==="rc")&&!isCLI){this._error(`Config - 'options' property '${prop}' is valid in CLI mode only`);return false}}}return true};CfgLib.prototype.processExtends=function(oCfg){if(this._config.extendOptions){if(!this._utils.isObject(this._config.extendOptions)){this._error("Config 'extendOptions' is not an object.");return false}}var extLib=new this._nd.extends(this,this._oConfig,oCfg,this._path,this._nd,this._msgCtx,this._utils);var cfg=extLib.extend();return cfg};CfgLib.prototype.processTitle=function(){var t,config=this._config;if(config.title){t=this._utils.getType(config.title);if(t!=="string"&&t!=="array"){this._error(`Config entry 'title has incorrect type ('${t}')`);return false}}return true};CfgLib.prototype.processRetCode=function(){var rc,prop,ret,config=this._config;if(config.options){prop=typeof config.options.retCode!==UNDEF?"retCode":typeof config.options.rc!==UNDEF?"rc":null;if(prop){rc=config.options[prop];ret=this.validateRetCode(rc,sev=>{this._error(`Config entry 'options.${prop}' : unknown severity '${sev}'`)});if(ret||typeof ret==="number"){config.options[prop]=ret}else{config.options[prop]=AUTO;return false}}}if(!prop){if(!config.options){config.options={}}config.options.retCode=DEF_RETCODE}return true};CfgLib.prototype.validateFileList=function(aFiles){var i,j,f,msg,ret=true;;for(i=0;i<aFiles.length;i++){f=aFiles[i];if(typeof f==="string"){continue}if(!this._utils.isObject(f)){msg=" property entry "+(i+1)+" is not a string or an object";break}if(f.files){if(!(Array.isArray(f.files)&&this._utils.isArrayContentsType(f.files,"string"))){msg=" property entry "+(i+1)+" does not contain a 'files' property array, or not all elements are strings";break}}else{msg=" property entry "+(i+1)+", does not contain a 'files' property";break}if(!f.base){msg=" property entry "+(i+1)+" does not contain a 'base' property";break}for(j=0;j<f.files.length;j++){f.files[j]=this._nd.path.join(f.base,f.files[j])}}if(!msg){for(i=0;i<aFiles.length;i++){f=aFiles[i];if(this._utils.isObject(f)){aFiles.splice(i,1,...f.files)}}}if(msg){this._error(msg);ret=false}return ret};CfgLib.prototype.validateRetCode=function(val,cb){var t,i,b;t=typeof val;if(t==="number"||t==="string"&&val===DEF_RETCODE||val===ERRORS){return val}if(t==="string"){if(!this._sevLib.isSev(val)){cb(val);return false}else{return this._sevLib.unmap(val)}}if(Array.isArray(val)){b=true;for(i=0;i<val.length;i++){if(!this._sevLib.isSev(val[i])){cb(val[i]);b=false}else{val[i]=this._sevLib.unmap(val[i])}}if(b){for(i=0;i<val.length;i++){if(Array.isArray(val[i])){let ar=[];for(i=0;i<val.length;i++){ar=ar.concat(val[i])}val=ar;break}}return val}}return false};CfgLib.prototype.setMessages=function(msgid,state){var accept,reject,msgs,target,changed=false,i;var config=this._config;msgs=config.messages;state=!!state;if(!msgs){if(!state){config.messages={reject:[msgid]};changed=true}}else{reject=msgs.reject;accept=msgs.accept;target=accept||reject;i=target?target.indexOf(msgid):-1;if(state){if(!accept&&!reject){msgs.accept=accept=[]}if(reject){if(i>=0){reject.splice(i,1);changed=true;if(reject.length===0){delete msgs.reject}}}else if(accept){if(i<0){accept.push(msgid);changed=true}}}else{if(!accept&&!reject){msgs.reject=reject=[]}if(reject){if(i<0){reject.push(msgid);changed=true}}else if(accept){if(i>=0){accept.splice(i,1);if(accept.length===0){delete msgs.accept}changed=true}}}}return changed};CfgLib.prototype.getAddFileList=function(){return!!(this._addFileList||this._appendFileList)};CfgLib.prototype.checkPropNames=function(cfg,path){var prop,ret=true,config=cfg?cfg:this._config;for(prop in config){if(!TOP_PROPS.includes(prop)){if(prop.charAt(0)==="_"){delete config[prop];continue}this._error(`Config - unknown property '${prop}' ${path?path:""}!`);ret=false}else if(this._modeCtx.isAMD&&NOT_AMD.includes(prop)){this._error(`Config - property '${prop}' is not available in AMD mode!`);ret=false}}return ret};CfgLib.prototype.setConfig=function(cfg,cfgPath,dir){this._config=cfg;this._path=cfgPath;this._dir=dir};CfgLib.prototype._findCompositesDir=function(base){return this._nd.fsUtils.findFile(base,COMPOSITES)};module.exports=CfgLib;