@oracle/oraclejet-audit 14.1.3 → 15.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.
- package/corePackMigrator/cli.js +6 -0
- package/corePackMigrator/corePackMigrator.js +10 -0
- package/corePackMigrator/metadata/avatarMetadata.json +40 -0
- package/corePackMigrator/metadata/buttonMetadata.json +55 -0
- package/corePackMigrator/metadata/collapsibleMetadata.json +15 -0
- package/corePackMigrator/metadata/filePickerMetadata.json +8 -0
- package/corePackMigrator/metadata/inputNumberMetadata.json +56 -0
- package/corePackMigrator/metadata/inputPasswordMetadata.json +50 -0
- package/corePackMigrator/metadata/inputTextMetadata.json +62 -0
- package/corePackMigrator/metadata/legendItemMetadata.json +8 -0
- package/corePackMigrator/metadata/legendMetadata.json +18 -0
- package/corePackMigrator/metadata/legendSectionMetadata.json +8 -0
- package/corePackMigrator/metadata/listItemLayoutMetadata.json +15 -0
- package/corePackMigrator/metadata/listviewMetadata.json +8 -0
- package/corePackMigrator/metadata/messagesMetadata.json +35 -0
- package/corePackMigrator/metadata/progressBarMetadata.json +15 -0
- package/corePackMigrator/metadata/progressCircleMetadata.json +8 -0
- package/corePackMigrator/metadata/ratingGaugeMetadata.json +78 -0
- package/corePackMigrator/metadata/selectManyMetadata.json +39 -0
- package/corePackMigrator/metadata/selectSingleMetadata.json +39 -0
- package/corePackMigrator/metadata/statusMeterGaugeMetadata.json +99 -0
- package/corePackMigrator/metadata/textAreaMetadata.json +44 -0
- package/corePackMigrator/resource/astUtils.js +6 -0
- package/corePackMigrator/resource/componentMigrator.js +6 -0
- package/corePackMigrator/resource/fileScanner.js +6 -0
- package/corePackMigrator/resource/htmlUtils.js +6 -0
- package/corePackMigrator/resource/manifest.json +102 -0
- package/corePackMigrator/resource/migrationConfig.json +21 -0
- package/corePackMigrator/templates/componentMetaData.json +119 -0
- package/corePackMigrator/templates/migrationConfig.json +17 -0
- package/corePackMigrator/utilities/logging.js +6 -0
- package/jaf-amd.js +1 -1
- package/lib/AST_Ts.js +1 -1
- package/lib/Cli.js +1 -1
- package/lib/Components.js +1 -1
- package/lib/Config.js +1 -1
- package/lib/ConfigLib.js +1 -1
- package/lib/DomUtils.js +1 -1
- package/lib/FileIndex.js +1 -1
- package/lib/FileSet.js +1 -1
- package/lib/FsUtils.js +1 -1
- package/lib/HtmlUtils.js +1 -1
- package/lib/JsonLoader.js +1 -1
- package/lib/MetaLib.js +1 -1
- package/lib/NetUtils.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/RegTypes.js +1 -1
- package/lib/Registry.js +1 -1
- package/lib/Reporter.js +1 -1
- package/lib/RulePack.js +1 -1
- package/lib/RuleSet.js +1 -1
- package/lib/Rules.js +1 -1
- package/lib/Scope.js +1 -1
- package/lib/Ts.js +1 -1
- package/lib/TsxUtils.js +1 -1
- package/lib/TsxUtils2.js +6 -0
- package/lib/Utils.js +1 -1
- package/lib/ZipUtils.js +1 -1
- package/lib/checkage.js +1 -1
- package/lib/cmdline.js +1 -1
- package/lib/defaults.js +1 -1
- package/lib/exportRules.js +1 -1
- package/lib/filetypes.js +1 -1
- package/lib/groups.js +1 -1
- package/lib/help.js +1 -1
- package/lib/jetver.js +1 -1
- package/lib/jsx.js +1 -1
- package/lib/maint.js +6 -0
- package/lib/manpage.js +1 -1
- package/lib/manual.js +1 -1
- package/lib/migrator.js +6 -0
- package/lib/msgidLoader.js +1 -1
- package/lib/ns.js +1 -1
- package/lib/outfile.js +1 -1
- package/lib/schema.js +1 -1
- package/lib/scopewalker.js +1 -1
- package/libext/expparser.js +1 -1
- package/meta/14.0.0/jetauditmeta.js +1 -1
- package/meta/14.1.0/jetauditmeta.js +1 -1
- package/meta/15.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +16 -8
- package/profiles/redwood-strict.json +2 -1
- package/rulepacks/csp/csp-html-script-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-html-unsafe-expr.js +1 -1
- package/rulepacks/csp/csp-js-script-unsafe-eval.js +1 -1
- package/rulepacks/csp/csp-js-style-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-json-unsafe-expr.js +6 -0
- package/rulepacks/csp/msgid.json +1 -1
- package/rulepacks/csp/rules.json +1 -1
- package/rulepacks/jetwc/jetwc-absolute-jetversion.js +1 -1
- package/rulepacks/jetwc/jetwc-aria-redefinition.js +1 -1
- package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +1 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +1 -1
- package/rulepacks/jetwc/jetwc-component-dependencies.js +1 -1
- package/rulepacks/jetwc/jetwc-component-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-component-foldername.js +1 -1
- package/rulepacks/jetwc/jetwc-component-location.js +1 -1
- package/rulepacks/jetwc/jetwc-component-type.js +1 -1
- package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
- package/rulepacks/jetwc/jetwc-css-pack-load-path.js +6 -0
- package/rulepacks/jetwc/jetwc-css-scoping.js +1 -1
- package/rulepacks/jetwc/jetwc-data-property-prefix.js +1 -1
- package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +1 -1
- package/rulepacks/jetwc/jetwc-disabled-property.js +1 -1
- package/rulepacks/jetwc/jetwc-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +1 -1
- package/rulepacks/jetwc/jetwc-event-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-events.js +1 -1
- package/rulepacks/jetwc/jetwc-exchange-images.js +1 -1
- package/rulepacks/jetwc/jetwc-jet-version.js +1 -1
- package/rulepacks/jetwc/jetwc-loader-file.js +1 -1
- package/rulepacks/jetwc/jetwc-markdown-link.js +1 -1
- package/rulepacks/jetwc/jetwc-method-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-methods.js +1 -1
- package/rulepacks/jetwc/jetwc-namespace.js +1 -1
- package/rulepacks/jetwc/jetwc-nested-defaults.js +1 -1
- package/rulepacks/jetwc/jetwc-nls-languages.js +1 -1
- package/rulepacks/jetwc/jetwc-nls-root.js +1 -1
- package/rulepacks/jetwc/jetwc-oj-register.js +1 -1
- package/rulepacks/jetwc/jetwc-ojcss.js +1 -1
- package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
- package/rulepacks/jetwc/jetwc-packable-components.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-pattern.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-version.js +1 -1
- package/rulepacks/jetwc/jetwc-property-changed.js +1 -1
- package/rulepacks/jetwc/jetwc-property-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-property-nesting.js +1 -1
- package/rulepacks/jetwc/jetwc-property-translatable.js +1 -1
- package/rulepacks/jetwc/jetwc-public-modules.js +1 -1
- package/rulepacks/jetwc/jetwc-reference-npm-path.js +6 -0
- package/rulepacks/jetwc/jetwc-register-css.js +1 -1
- package/rulepacks/jetwc/jetwc-register-with-promises.js +1 -1
- package/rulepacks/jetwc/jetwc-require-paths.js +1 -1
- package/rulepacks/jetwc/jetwc-required-subproperty.js +1 -1
- package/rulepacks/jetwc/jetwc-reserved-property.js +1 -1
- package/rulepacks/jetwc/jetwc-schema.js +1 -1
- package/rulepacks/jetwc/jetwc-semantic-version.js +1 -1
- package/rulepacks/jetwc/jetwc-slot-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-slots.js +1 -1
- package/rulepacks/jetwc/jetwc-standard-files.js +1 -1
- package/rulepacks/jetwc/jetwc-status-since.js +6 -0
- package/rulepacks/jetwc/jetwc-unused-events.js +1 -1
- package/rulepacks/jetwc/jetwc-unused-slots.js +1 -1
- package/rulepacks/jetwc/jetwc-vb-category.js +1 -1
- package/rulepacks/jetwc/jetwc-vb-icon.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-loader.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-version.js +1 -1
- package/rulepacks/jetwc/jetwc-version-openrange.js +1 -1
- package/rulepacks/jetwc/jetwc-writeback-required.js +1 -1
- package/rulepacks/jetwc/msgid.json +1 -1
- package/rulepacks/jetwc/rules.json +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +1 -1
- package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-componentType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-dependencies.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-events.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-helpers.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-jetVer.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodParams.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methods.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packBundle.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packContent.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-properties.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-publicModules.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slots.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-typeMappingOverrides.js +6 -0
- package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-cdn.js +1 -1
- package/rulepacks/jetwco/jetwco-description-standards.js +1 -1
- package/rulepacks/jetwco/jetwco-displayname-standards.js +1 -1
- package/rulepacks/jetwco/jetwco-exchange-version-check.js +1 -1
- package/rulepacks/jetwco/jetwco-license-info.js +1 -1
- package/rulepacks/jetwco/jetwco-prerelease-cdn.js +1 -1
- package/rulepacks/jetwco/jetwco-thirdparty-ba.js +1 -1
- package/rulepacks/jetwco/msgid.json +1 -1
- package/rulepacks/jetwco/rules.json +1 -1
- package/rules/jaf/jaf-ts-noparser.js +6 -0
- package/rules/jaf/msgid.json +1 -1
- package/rules/jaf/rules.json +1 -1
- package/rules/jet/helpers/has-slot-name.js +1 -1
- package/rules/jet/helpers/style-selector.js +1 -1
- package/rules/jet/helpers/tsx/has-slot-name.js +6 -0
- package/rules/jet/msgid.json +1 -1
- package/rules/jet/oj-acc-aria-labelledby.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-ar.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-obj.js +1 -1
- package/rules/jet/oj-css-bp-dir-flow.js +1 -1
- package/rules/jet/oj-html-attr-$unique.js +1 -1
- package/rules/jet/oj-html-attr-expr-delims.js +6 -0
- package/rules/jet/oj-html-combo-converter.js +1 -1
- package/rules/jet/oj-html-file-pick-accept.js +1 -1
- package/rules/jet/oj-html-form-bindif.js +1 -1
- package/rules/jet/oj-html-input-isodate.js +1 -1
- package/rules/jet/oj-html-invalid-doctype.js +1 -1
- package/rules/jet/oj-html-msgs-cat-text.js +1 -1
- package/rules/jet/oj-html-ojattr-deprecated.js +1 -1
- package/rules/jet/oj-html-ojattr-enum-deprecated.js +1 -1
- package/rules/jet/oj-html-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-html-ojtag-ns.js +1 -1
- package/rules/jet/oj-html-rating-gauge-track-resize.js +6 -0
- package/rules/jet/oj-html-self-close.js +1 -1
- package/rules/jet/oj-html-slot-deprecated.js +1 -1
- package/rules/jet/oj-html-slot-item-minmax.js +1 -1
- package/rules/jet/oj-html-slot-name.js +1 -1
- package/rules/jet/oj-html-slot-pref-content.js +1 -1
- package/rules/jet/oj-html-style.js +1 -1
- package/rules/jet/oj-html-stylesel.js +1 -1
- package/rules/jet/oj-html-tabbar-edge.js +6 -0
- package/rules/jet/oj-html-unsup-theme.js +1 -1
- package/rules/jet/oj-html-wctag-maintenance.js +1 -1
- package/rules/jet/oj-html-wctag-nested.js +1 -1
- package/rules/jet/oj-html-wctag-supersedes.js +6 -0
- package/rules/jet/oj-js-numconv-pattern.js +6 -0
- package/rules/jet/oj-ts-numconv-pattern.js +6 -0
- package/rules/jet/oj-tsx-5-tag-obs.js +1 -1
- package/rules/jet/oj-tsx-acc-avatar-aria-role.js +6 -0
- package/rules/jet/oj-tsx-acc-button-onclick.js +1 -1
- package/rules/jet/oj-tsx-aria-ojselector-labelledby.js +1 -1
- package/rules/jet/oj-tsx-aria-prop.js +1 -1
- package/rules/jet/oj-tsx-attr-req.js +1 -1
- package/rules/jet/oj-tsx-cca-tagname.js +1 -1
- package/rules/jet/oj-tsx-combo-converter.js +1 -1
- package/rules/jet/oj-tsx-databind-all.js +1 -1
- package/rules/jet/oj-tsx-dlg-title.js +1 -1
- package/rules/jet/oj-tsx-form-bindif.js +6 -0
- package/rules/jet/oj-tsx-form-noflex.js +6 -0
- package/rules/jet/oj-tsx-input-isodate.js +1 -1
- package/rules/jet/oj-tsx-ojattr-deprecated.js +6 -0
- package/rules/jet/oj-tsx-ojattr-enum-deprecated.js +6 -0
- package/rules/jet/oj-tsx-ojattr-value.js +1 -1
- package/rules/jet/oj-tsx-ojattr.js +1 -1
- package/rules/jet/oj-tsx-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-tsx-ojtag-ns.js +6 -0
- package/rules/jet/oj-tsx-pageopts-type.js +1 -1
- package/rules/jet/oj-tsx-picker-attrs.js +1 -1
- package/rules/jet/oj-tsx-prop-inline-definition.js +1 -1
- package/rules/jet/oj-tsx-rating-gauge-size.js +1 -1
- package/rules/jet/oj-tsx-rating-gauge-track-resize.js +6 -0
- package/rules/jet/oj-tsx-slot-deprecated.js +6 -0
- package/rules/jet/oj-tsx-slot-pref-content.js +6 -0
- package/rules/jet/oj-tsx-tabbar-edge.js +6 -0
- package/rules/jet/oj-tsx-unsup-theme.js +1 -1
- package/rules/jet/oj-tsx-wctag-maintenance.js +1 -1
- package/rules/jet/oj-tsx-wctag-nested.js +1 -1
- package/rules/jet/rules.json +1 -1
- package/schema/component-schema.json +1 -1
- package/src/JafCore.js +1 -1
- package/types/index.d.ts +6 -4
- package/rules/jet/oj-html-cspexpr.js +0 -6
package/meta/metaverlist.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"metaList":{"8.3.0":{"version":"8.3.0","date":"Monday May 04, 2020","time":"4:34pm edt"},"9.0.0":{"version":"9.0.0","date":"Friday Jun 12, 2020","time":"1:57am utc"},"9.1.0":{"version":"9.1.0","date":"Thursday Aug 06, 2020","time":"2:13am utc"},"9.2.0":{"version":"9.2.0","date":"Wednesday Oct 07, 2020","time":"5:41pm utc"},"10.0.0":{"version":"10.0.0","date":"Thursday Jan 07, 2021","time":"9:20pm utc"},"10.1.0":{"version":"10.1.0","date":"Saturday Apr 17, 2021","time":"4:01pm utc"},"11.0.0":{"version":"11.0.0","date":"Friday Jul 02, 2021","time":"3:02am utc"},"11.1.0":{"version":"11.1.0","date":"Thursday Sep 30, 2021","time":"9:33pm utc"},"12.0.0":{"version":"12.0.0","date":"Friday Feb 04, 2022","time":"2:29am utc"},"12.1.0":{"version":"12.1.0","date":"Saturday Apr 09, 2022","time":"7:54am utc"},"13.0.0":{"version":"13.0.4","date":"Thursday Sep 22, 2022","time":"3:14am utc"},"13.1.0":{"version":"13.1.0","date":"Sunday Oct 02, 2022","time":"3:37am utc"},"14.0.0":{"version":"14.0.0","date":"
|
|
1
|
+
{"metaList":{"8.3.0":{"version":"8.3.0","date":"Monday May 04, 2020","time":"4:34pm edt"},"9.0.0":{"version":"9.0.0","date":"Friday Jun 12, 2020","time":"1:57am utc"},"9.1.0":{"version":"9.1.0","date":"Thursday Aug 06, 2020","time":"2:13am utc"},"9.2.0":{"version":"9.2.0","date":"Wednesday Oct 07, 2020","time":"5:41pm utc"},"10.0.0":{"version":"10.0.0","date":"Thursday Jan 07, 2021","time":"9:20pm utc"},"10.1.0":{"version":"10.1.0","date":"Saturday Apr 17, 2021","time":"4:01pm utc"},"11.0.0":{"version":"11.0.0","date":"Friday Jul 02, 2021","time":"3:02am utc"},"11.1.0":{"version":"11.1.0","date":"Thursday Sep 30, 2021","time":"9:33pm utc"},"12.0.0":{"version":"12.0.0","date":"Friday Feb 04, 2022","time":"2:29am utc"},"12.1.0":{"version":"12.1.0","date":"Saturday Apr 09, 2022","time":"7:54am utc"},"13.0.0":{"version":"13.0.4","date":"Thursday Sep 22, 2022","time":"3:14am utc"},"13.1.0":{"version":"13.1.0","date":"Sunday Oct 02, 2022","time":"3:37am utc"},"14.0.0":{"version":"14.0.0","date":"Tuesday Jan 03, 2023","time":"8:54pm utc"},"14.1.0":{"version":"14.1.0","date":"Thursday Apr 06, 2023","time":"7:55pm utc"},"15.0.0":{"version":"15.0.0","date":"Saturday Jul 08, 2023","time":"0:04am utc"}}}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oracle/oraclejet-audit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "JET AUDIT FRAMEWORK",
|
|
5
5
|
"main": "jaf.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"jafconfig.json",
|
|
8
8
|
"*.js",
|
|
9
|
+
"corePackMigrator",
|
|
9
10
|
"html",
|
|
10
11
|
"lib",
|
|
11
12
|
"libext",
|
|
@@ -26,9 +27,9 @@
|
|
|
26
27
|
"build": "node ./build/build.js",
|
|
27
28
|
"metadel": "node ./build/metadel.js",
|
|
28
29
|
"buildmeta": "node ./build/metabuild.js --show",
|
|
29
|
-
"test-oj-sample":"node ./tests/scripts/testCaseAudit oj-sample base",
|
|
30
|
-
"test-spectra":"node ./tests/scripts/testCaseAudit spectra-components base",
|
|
31
|
-
"test-cx-common":"node ./tests/scripts/testCaseAudit cx-common base"
|
|
30
|
+
"test-oj-sample": "node ./tests/scripts/testCaseAudit oj-sample base",
|
|
31
|
+
"test-spectra": "node ./tests/scripts/testCaseAudit spectra-components base",
|
|
32
|
+
"test-cx-common": "node ./tests/scripts/testCaseAudit cx-common base"
|
|
32
33
|
},
|
|
33
34
|
"bin": {
|
|
34
35
|
"ojaf": "./jaf.js"
|
|
@@ -43,32 +44,39 @@
|
|
|
43
44
|
"lint"
|
|
44
45
|
],
|
|
45
46
|
"Jaf": {
|
|
46
|
-
"version": "
|
|
47
|
+
"version": "7.0.1"
|
|
47
48
|
},
|
|
48
49
|
"license": "UPL-1.0",
|
|
49
50
|
"dependencies": {
|
|
51
|
+
"@babel/generator": "^7.19.5",
|
|
52
|
+
"@babel/parser": "^7.19.4",
|
|
50
53
|
"@typescript-eslint/typescript-estree": "5.36.1",
|
|
51
54
|
"adm-zip": "0.4.16",
|
|
52
55
|
"ajv": "8.10.0",
|
|
53
56
|
"ajv-formats": "2.1.1",
|
|
57
|
+
"ast-traverse": "^0.1.1",
|
|
58
|
+
"astring": "^1.8.3",
|
|
54
59
|
"css-tree": "1.0.0-alpha.39",
|
|
55
60
|
"decache": "4.6.0",
|
|
56
61
|
"es-abstract": "1.20.5",
|
|
57
|
-
"espree": "9.
|
|
62
|
+
"espree": "9.5.2",
|
|
58
63
|
"glob": "7.1.6",
|
|
59
|
-
"htmlparser2": "
|
|
64
|
+
"htmlparser2": "8.0.1",
|
|
65
|
+
"line-column": "^1.0.2",
|
|
60
66
|
"markdown-it": "12.2.0",
|
|
61
67
|
"md5": "2.3.0",
|
|
62
68
|
"mock-http-server": "1.4.2",
|
|
63
69
|
"parserlib": "1.1.1",
|
|
70
|
+
"readline-sync": "^1.4.10",
|
|
64
71
|
"really-relaxed-json": "0.2.24",
|
|
65
72
|
"semver": "6.3.0",
|
|
66
73
|
"strip-json-comments": "2.0.1",
|
|
67
74
|
"sync-request": "6.1.0",
|
|
68
75
|
"tmp": "0.0.33",
|
|
69
|
-
"typescript": "4.
|
|
76
|
+
"typescript": "4.8.4"
|
|
70
77
|
},
|
|
71
78
|
"devDependencies": {
|
|
79
|
+
"@babel/traverse": "^7.19.6",
|
|
72
80
|
"chai": "~4.3.7",
|
|
73
81
|
"mocha": "^7.2.0"
|
|
74
82
|
}
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"JET-5111":"blocker", //oj-html-no-pageopts-type
|
|
26
26
|
"JET-6065":"blocker", //oj-css-var-override
|
|
27
27
|
"JET-6066":"blocker", //oj-css-var-override
|
|
28
|
-
"JET-0520":"blocker"
|
|
28
|
+
"JET-0520":"blocker", //oj-html-rating-gauge-size
|
|
29
|
+
"JET-0525":"blocker" //oj-html-rating-gauge-track-resize
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const RULE_NAME="csp-html-script-unsafe-inline";const LONG_DESCRIPT="CSP-1020:<br>"+"Inline script blocks are considered to be CSP violation. The general solution is to use hashes or a nonce to allow inline scripts to run."+"<p>CSP-1021:<br>"+"The execution of a JS event handler from inline HTML markup is a CSP violation. e.g. onclick onload onmouseover onsubmit, etc.<p>"+"The general solution is to use <b>addEventListener()</b>. e.g.<p>"+" <b><button id=\"btn\" <b>onclick='doSomething()'></b><p>"+"can be replaced with<p>"+" document.getElementById(\"btn\")<b>.addEventListener('click', doSomething)</b>";const SHORT_DESCRIPT=LONG_DESCRIPT;const TYPE="type";const MIME_TEXT_HTML="text/html";const NONCE="nonce";const SRC="src";function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(
|
|
6
|
+
const RULE_NAME="csp-html-script-unsafe-inline";const LONG_DESCRIPT="CSP-1020:<br>"+"Inline script blocks are considered to be CSP violation. The general solution is to use hashes or a nonce to allow inline scripts to run."+"<p>CSP-1021:<br>"+"The execution of a JS event handler from inline HTML markup is a CSP violation. e.g. onclick onload onmouseover onsubmit, etc.<p>"+"The general solution is to use <b>addEventListener()</b>. e.g.<p>"+" <b><button id=\"btn\" <b>onclick='doSomething()'></b><p>"+"can be replaced with<p>"+" document.getElementById(\"btn\")<b>.addEventListener('click', doSomething)</b>";const SHORT_DESCRIPT=LONG_DESCRIPT;const TYPE="type";const MIME_TEXT_HTML="text/html";const NONCE="nonce";const SRC="src";function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{"script":_fnScript,"tag":_fnElem}};function _fnScript(context){var o,a,issue;o=context.tagNode.attribs;for(a in o){if(a===SRC||a===NONCE||a===TYPE&&o[a]===MIME_TEXT_HTML){return}}issue=new context.Issue("inline <script> 'nonce' attribute required - CSP violation");issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)};function _fnElem(context,elem){var node,attribs,attrib,issue,attrPos;node=context.node;if(!node||!node.attribs){return}attribs=node.attribs;for(attrib in attribs){if(!attrib.startsWith(":")&&attrib.startsWith("on")&&!attrib.startsWith("on-")){if(context.utils.DomUtils.isCommonEventAttr(attrib)){issue=new context.Issue("inline event handler '"+attrib+"' - CSP violation");attrPos=context.utils.DomUtils.getAttrPosition(context.data,context.node,attrib);issue.setPosition(attrPos.row,attrPos.col,attrPos.start,attrPos.end);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}}}};module.exports={getName,getDescription,getShortDescription,register};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const RULE_NAME="csp-html-unsafe-expr";const LONG_DESCRIPT="Attribute contains an expression that violates the Content Security Policy, and is not supported. Execution of the attribute's expression will be blocked.";const SHORT_DESCRIPT="Expressions of this format are unsupported if the content_security_policy does not have an exception for unsafe eval";function Rule(){};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return SHORT_DESCRIPT};Rule.prototype.getDescription=function(){return LONG_DESCRIPT};Rule.prototype.register=function(regCtx){if(regCtx.runMode==="api"&®Ctx.VsCodeExtHint){if(this._exprEval){regCtx.decache(this._exprEval)}}this._exprEval=require("../../libext/expparser");this._exprEval=new this._exprEval;return{"attrexpr":this._onAttrExpr}};Rule.prototype._onAttrExpr=function(ruleCtx,attrName,attrValue){var p,issue,msg;attrValue=attrValue.trim();if(attrName.charAt(0)===":"){attrName=attrName.substring(1)}attrValue=attrValue.substring(2,attrValue.length-2);try{p=this._exprEval.parse(attrValue)}catch(e){msg=_cleanUp(e.message);issue=new ruleCtx.Issue(`Attribute '${attrName}' contains an expression that may not be compatible with all Content Security policies: ${msg}`);ruleCtx.reporter.addIssue(issue,ruleCtx)}};function _cleanUp(msg){msg=msg.replace("character","attribute value position");return msg}module.exports=Rule;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const RULE_NAME="csp-js-script-unsafe-eval";const LONG_DESCRIPT="CSP-1000:<br>Dynamically evaluated code is a security risk. "+"<b>eval()</b> executes the code it is passed with the privileges of the caller. If you run eval() with a string "+"that could be compromised by a malicious party, you may end up running malicious code on a user machine "+"with the permissions of your webpage/extension.<p>"+"CSP-1001:<br>A dynamically evaluated \"Function\" poses a security risk by allowing arbitrary JS execution "+"that can contain untrusted data. Strings passed to Function() may be constructed from user-provided or compromised "+"data. The data could thus contain arbitrary code supplied by an attacker, and used to inject content into the DOM.<p>"+"CSP-1002:<br>Using a string as the first argument to functions such as <b>setTimeout/setInterval</b> poses a security risk "+"by allowing arbitrary JS execution of untrusted data. Variants of the API that take a function as the first argument are permitted. "+"Where possible, remove the argument's delimiting quotes in calls such as<p>"+" <b>setTimeout(STRING, delay)</b><p>"+"and wrap the content in a function e.g.<p>"+" <b>(setTimeout(function() { CODE }, delay) )</b><p>"+"When this is not possible, the code can be wrapped in a function and served in a .js file.";const SHORT_DESCRIPT=LONG_DESCRIPT;const FUNC_EXPR="FunctionExpression";const ARROW_FUNC_EXPR="ArrowFunctionExpression";const IDENTIFIER="Identifier";const LITERAL="Literal";const BLOCK_STMT="BlockStatement";const CALL_EXPR="CallExpression";function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{CallExpression:_fn,NewExpression:_fn}};function _fn(context,node){_checkEval(context,node);_checkFunction(context,node);_checkTimer(context,node)};function _checkEval(context,node){var callee,obj,issue;if(node.callee){callee=node.callee;obj=callee.property?callee.property:callee;if(obj.name==="eval"){if(!callee.object){issue=new context.Issue("eval() found - CSP violation");issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}}}};function _checkFunction(context,node){var obj,issue;if(node.callee){obj=node.callee.property?node.callee.property:node.callee;if(obj.type===IDENTIFIER&&obj.name==="Function"){issue=new context.Issue("Use of Function() - CSP violation");issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}}};function _checkTimer(context,node){var obj,funcName,issue;if(node.callee){obj=node.callee.property?node.callee.property:node.callee;funcName=obj.name;if(funcName==="setTimeout"||funcName==="setInterval"){issue=_checkTimerFuncs(context,node,funcName);if(issue){issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context)}}}};function _checkTimerFuncs(context,node,funcName){var obj,callee,args,arg,issue;callee=node.callee;obj=callee.property?callee.property:callee;if(obj.type===IDENTIFIER){if(node.arguments){args=node.arguments;if(args.length>=1){arg=args[0];if(arg.type!==FUNC_EXPR&&arg.type!==ARROW_FUNC_EXPR){if(arg.type!==CALL_EXPR&&arg.type!="NewExpression"){if(arg.type===LITERAL||_isIdentAString(node,arg.name)){issue=new context.Issue(
|
|
6
|
+
const RULE_NAME="csp-js-script-unsafe-eval";const LONG_DESCRIPT="CSP-1000:<br>Dynamically evaluated code is a security risk. "+"<b>eval()</b> executes the code it is passed with the privileges of the caller. If you run eval() with a string "+"that could be compromised by a malicious party, you may end up running malicious code on a user machine "+"with the permissions of your webpage/extension.<p>"+"CSP-1001:<br>A dynamically evaluated \"Function\" poses a security risk by allowing arbitrary JS execution "+"that can contain untrusted data. Strings passed to Function() may be constructed from user-provided or compromised "+"data. The data could thus contain arbitrary code supplied by an attacker, and used to inject content into the DOM.<p>"+"CSP-1002:<br>Using a string as the first argument to functions such as <b>setTimeout/setInterval</b> poses a security risk "+"by allowing arbitrary JS execution of untrusted data. Variants of the API that take a function as the first argument are permitted. "+"Where possible, remove the argument's delimiting quotes in calls such as<p>"+" <b>setTimeout(STRING, delay)</b><p>"+"and wrap the content in a function e.g.<p>"+" <b>(setTimeout(function() { CODE }, delay) )</b><p>"+"When this is not possible, the code can be wrapped in a function and served in a .js file.";const SHORT_DESCRIPT=LONG_DESCRIPT;const FUNC_EXPR="FunctionExpression";const ARROW_FUNC_EXPR="ArrowFunctionExpression";const IDENTIFIER="Identifier";const LITERAL="Literal";const BLOCK_STMT="BlockStatement";const CALL_EXPR="CallExpression";function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{CallExpression:_fn,NewExpression:_fn}};function _fn(context,node){_checkEval(context,node);_checkFunction(context,node);_checkTimer(context,node)};function _checkEval(context,node){var callee,obj,issue;if(node.callee){callee=node.callee;obj=callee.property?callee.property:callee;if(obj.name==="eval"){if(!callee.object){issue=new context.Issue("eval() found - CSP violation");issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}}}};function _checkFunction(context,node){var obj,issue;if(node.callee){obj=node.callee.property?node.callee.property:node.callee;if(obj.type===IDENTIFIER&&obj.name==="Function"){issue=new context.Issue("Use of Function() - CSP violation");issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}}};function _checkTimer(context,node){var obj,funcName,issue;if(node.callee){obj=node.callee.property?node.callee.property:node.callee;funcName=obj.name;if(funcName==="setTimeout"||funcName==="setInterval"){issue=_checkTimerFuncs(context,node,funcName);if(issue){issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context)}}}};function _checkTimerFuncs(context,node,funcName){var obj,callee,args,arg,issue;callee=node.callee;obj=callee.property?callee.property:callee;if(obj.type===IDENTIFIER){if(node.arguments){args=node.arguments;if(args.length>=1){arg=args[0];if(arg.type!==FUNC_EXPR&&arg.type!==ARROW_FUNC_EXPR){if(arg.type!==CALL_EXPR&&arg.type!="NewExpression"){if(arg.type===LITERAL||_isIdentAString(node,arg.name)){issue=new context.Issue(`function ${funcName}() - first argument CSP violation`)}}}}}}return issue};function _isIdentAString(node,ident){var n,decls,decl,i,j,s;node=node.parent;while(node){if(!node){break}if(node.type!==BLOCK_STMT){if(node.type!=="Program"){node=node.parent;continue}for(i=0;i<node.body.length;i++){n=node.body[i];if(n.type==="FunctionDeclaration"){if(n.id&&n.id.type===IDENTIFIER&&n.id.name===ident){return false}}}}if(node.body){for(i=0;i<node.body.length;i++){n=node.body[i];if(n.type==="VariableDeclaration"){decls=n.declarations;if(decls&&decls.length){for(j=0;j<decls.length;j++){decl=decls[j];if(decl.type==="VariableDeclarator"){if(decl.id&&decl.id.type===IDENTIFIER&&decl.id.name===ident){if(decl.init){if(decl.init.type===LITERAL){s=decl.init.raw.charAt(0);if(s==="\""||s==="'"){return true}}}return false}}}}}}}node=node.parent}return false};module.exports={getName,getDescription,getShortDescription,register};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const RULE_NAME="csp-js-style-unsafe-inline";const LONG_DESCRIPT="Styles applied in JavaScript by setting the style attribute directly using setAttribute() are a CSP violation. "+"Style properties that are set directly on an element's style property permit safe style manipulation in JavaScript. e.g. in place of<p>"+" elem<b>.setAttribute</b>('style', 'background-color : red;')<p>"+"use<p>"+" elem<b>.style</b>.backgroundColor = 'red';";const SHORT_DESCRIPT=LONG_DESCRIPT;function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(
|
|
6
|
+
const RULE_NAME="csp-js-style-unsafe-inline";const LONG_DESCRIPT="Styles applied in JavaScript by setting the style attribute directly using setAttribute() are a CSP violation. "+"Style properties that are set directly on an element's style property permit safe style manipulation in JavaScript. e.g. in place of<p>"+" elem<b>.setAttribute</b>('style', 'background-color : red;')<p>"+"use<p>"+" elem<b>.style</b>.backgroundColor = 'red';";const SHORT_DESCRIPT=LONG_DESCRIPT;function getName(){return RULE_NAME};function getShortDescription(){return SHORT_DESCRIPT};function getDescription(){return LONG_DESCRIPT};function register(){return{CallExpression:_fnCall}};function _fnCall(context,node){var callee,meth,args,arg,issue;callee=node.callee;if(callee.property&&callee.property.type==="Identifier"){meth=callee.property.name;if(meth==="setAttribute"||meth==="attr"){args=node.arguments;if(meth==="attr"&&args.length<2){return}arg=args[0];if(arg.type==="Literal"&&arg.value==="style"){if(meth==="setAttribute"||_isKO(node)){issue=new context.Issue("setAttribute('style') - CSP violation");context.reporter.addIssue(issue,context)}}}}};function _isKO(node){var callee=node.callee;var o=callee.object;return o&&o.callee&&o.callee.type==="Identifier"&&o.callee.name==="$"}module.exports={getName,getDescription,getShortDescription,register};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2023, 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 RULE_NAME="csp-json-unsafe-expr";const LONG_DESCRIPT="A JSON member value contains an expression that violates the Content Security Policy, and is not supported. Execution of the expression will be blocked.";const SHORT_DESCRIPT=LONG_DESCRIPT;const CHARACTER="character";const VB_ASSET_TOKEN_MATCHER=/\@{2}(?<tokenRef>[A-Z\d\-\$]*)@{2}/gmi;function Rule(){};Rule.prototype.getName=function(){return RULE_NAME};Rule.prototype.getShortDescription=function(){return SHORT_DESCRIPT};Rule.prototype.getDescription=function(){return LONG_DESCRIPT};Rule.prototype.register=function(regCtx){if(regCtx.runMode==="api"&®Ctx.VsCodeExtHint){if(this._exprEval){regCtx.decache(this._exprEval)}}this._exprEval=require("../../libext/expparser");this._exprEval=new this._exprEval;return{"json":this._onJson}};Rule.prototype._onJson=function(ruleCtx,ast){if(!ast){_onSyntaxError(ruleCtx);return false}this._walk(ruleCtx,ast)};Rule.prototype._walk=function(ruleCtx,ast,members){members=members||ast.members;members.forEach(member=>{let subMems;if(member.value.type==="string"&&_isExpr(member.value.value)){this._checkExpr(ruleCtx,member)}else if(member.value.type==="array"){this._checkArrayExpr(ruleCtx,ast,member)}if(subMems=member.value.members){this._walk(ruleCtx,ast,subMems)};})};Rule.prototype._checkArrayExpr=function(ruleCtx,ast,member){var arrayMems,mem,i;if(arrayMems=member.value.members){for(i=0;i<arrayMems.length;i++){if(mem=arrayMems[i]){if(mem.type==="Object"&&mem.members){this._walk(ruleCtx,ast,mem.members)}}}}};Rule.prototype._checkExpr=function(ruleCtx,member){var value,issue,p;value=member.value.value.trim();value=value.substring(2,value.length-2).trim();value=value.replace(VB_ASSET_TOKEN_MATCHER,"$<tokenRef>");try{p=this._exprEval.parse(value)}catch(e){let o=_cleanUp(e.message,member);issue=new ruleCtx.Issue(`Member '${member.name}' contains an expression that may not be compatible with all Content Security policies: "${o.msg}"`);if(o.pos>=0){let pos=member.value.pos;issue.setPosition(pos.line,pos.col+o.pos+3,pos.start+o.pos+3,pos.end+o.pos+3)}else{issue.setPosition(member.value.pos)}ruleCtx.reporter.addIssue(issue,ruleCtx)}};function _cleanUp(msg,member){var pos=-1,x;if((x=msg.indexOf(CHARACTER))>=0){let posChars=msg.substring(x+CHARACTER.length+1);pos=parseInt(posChars);if(!isNaN(pos)){msg=msg.replace(CHARACTER,"column");msg=msg.replace(posChars,""+(pos+member.value.pos.col+3))}}return{msg:msg,pos:pos}};function _onSyntaxError(ruleCtx){if(ruleCtx.suppData){if(!ruleCtx.rulePack.isRuleEnabled("oj-json-syntax","JET")){let issue=new ruleCtx.Issue(ruleCtx.suppData.msg);issue.setPosition(ruleCtx.suppData.line,ruleCtx.suppData.col,ruleCtx.suppData.position,ruleCtx.suppData.position+3);issue.setMsgKey(RULE_NAME+"_1");issue.setSeverity("critical");ruleCtx.reporter.addIssue(issue,ruleCtx)}}};function _isExpr(s){s=s.trimStart();return s.startsWith("[[")||s.startsWith("{{")};module.exports=Rule;
|
package/rulepacks/csp/msgid.json
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
{"csp-js-script-unsafe-eval_1":"1000","csp-js-script-unsafe-eval_2":"1001","csp-js-script-unsafe-eval_3":"1002","csp-js-style-unsafe-inline":"1010","csp-html-script-unsafe-inline_1":"1020","csp-html-script-unsafe-inline_2":"1021","csp-html-style-unsafe-inline_1":"1030","csp-html-style-unsafe-inline_2":"1031","csp-html-unsafe-expr":"1040","csp-ts-script-unsafe-eval_1":"1100","csp-ts-script-unsafe-eval_2":"1101","csp-ts-script-unsafe-eval_3":"1102","csp-ts-style-unsafe-inline":"1110"}
|
|
6
|
+
{"csp-js-script-unsafe-eval_1":"1000","csp-js-script-unsafe-eval_2":"1001","csp-js-script-unsafe-eval_3":"1002","csp-js-style-unsafe-inline":"1010","csp-html-script-unsafe-inline_1":"1020","csp-html-script-unsafe-inline_2":"1021","csp-html-style-unsafe-inline_1":"1030","csp-html-style-unsafe-inline_2":"1031","csp-html-unsafe-expr":"1040","csp-json-unsafe-expr":"1045","csp-json-unsafe-expr_1":"1046","csp-ts-script-unsafe-eval_1":"1100","csp-ts-script-unsafe-eval_2":"1101","csp-ts-script-unsafe-eval_3":"1102","csp-ts-style-unsafe-inline":"1110"}
|
package/rulepacks/csp/rules.json
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
{"title":"CSP Builtin Rulepack","version":"1.
|
|
6
|
+
{"title":"CSP Builtin Rulepack","version":"1.2.0","prefix":"CSP","rules":{"csp-js-script-unsafe-eval":{"severity":"major","filetype":"js","group":["jet-js","jet-html","jet-csp"],"status":"production"},"csp-ts-script-unsafe-eval":{"severity":"major","filetype":["ts","tsx"],"group":["jet-ts","jet-tsx","jet-csp"],"amd":false,"status":"production"},"csp-html-script-unsafe-inline":{"severity":"major","filetype":"html","group":["jet-html","jet-csp"],"status":"production"},"csp-html-style-unsafe-inline":{"severity":"major","filetype":"html","group":["jet-html","jet-csp"],"status":"production"},"csp-js-style-unsafe-inline":{"severity":"major","filetype":"js","group":["jet-js","jet-html","jet-csp"],"status":"production"},"csp-ts-style-unsafe-inline":{"severity":"major","filetype":["ts","tsx"],"group":["jet-js","jet-tsx","jet-csp"],"amd":false,"status":"production"},"csp-html-unsafe-expr":{"severity":"blocker","filetype":"html","group":["jet-html","jet-csp"],"status":"production"},"csp-json-unsafe-expr":{"severity":"blocker","filetype":"json","group":["jet-csp"],"status":"production"}}}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-absolute-jetversion"};ruleDef.prototype.getShortDescription=function(){return"Verify support for some range of JET versions"};ruleDef.prototype.getDescription=function(){return"This rule checks that a component has not be hard-wired to a specific version of JET - e.g. specifies some form of range at least"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);if(context.suppData.obj.jetVersion){this._versionCheck(context,fullName,meta.jetVersion)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo&&componentInfo.jetVersion){this._versionCheck(context,componentInfo.fullName,componentInfo.jetVersion)}};ruleDef.prototype._versionCheck=function(context,fullName,version){if(context.utils.semVerUtils.isValid(version)){const issue=new context.Issue(`Component ${fullName} is hardwired to a specific JET version (${version}), not a range`);context.reporter.addIssue(issue,context)}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-aria-redefinition"};ruleDef.prototype.getShortDescription=function(){return"Ensure that the component does not re-define any WAI-ARIA properties"};ruleDef.prototype.getDescription=function(){return"This rule checks that a component has not overridden or tries to introduce (any custom) WAI-ARIA attributes"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkProps(context,fullName,meta.properties)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkProps(context,componentInfo.fullName,componentInfo.properties)}};ruleDef.prototype._checkProps=function(context,fullName,properties){let issue;if(properties){const ariaDetect=/^aria[A-Z\-].*$/;Object.keys(properties).forEach(propName=>{if(ariaDetect.test(propName)){issue=new context.Issue(`Component ${fullName} defines a WAI-ARIA property ${propName} which is not allowed`);context.reporter.addIssue(issue,context)}})}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require(
|
|
6
|
+
const path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const componentFinder=require("../jetwc-lib/jetwcutils-componentFinder");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const preCompiler=require("../jetwc-lib/jetwcutils-preCompiler");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-bootstrap"};ruleDef.prototype.getShortDescription=function(){return"Bootstrap processing for the JETWC rulset"};ruleDef.prototype.getDescription=function(){return"This rule is for internal use by the ruleset and should not be disabled"};ruleDef.prototype.register=function(context){this.componentRoots=context.config.components;this.auditBase=context.config.base;this.typeScriptCompile=context.config.typescript&&context.config.typescript.compile;return{startupRP:this._getAllVisibleComponents,closedownRP:this._reportDiagnostics}};ruleDef.prototype._getAllVisibleComponents=function(context){const{msgLib}=context.utils;msgLib.info(`builtinJetWcRules (${context.rulePack.getPackInfo().prefix}): ${context.rulePack.getPackInfo().version}`);const projectPathInfo=Utils.getKeyPathInfoForRulepack(context,this.auditBase);const componentRootFolder=context.rulePack.getRuleOptions().componentRoot||projectPathInfo.componentRootFolder;let precompileCache;if(this.typeScriptCompile&&projectPathInfo.tsSource){precompileCache=preCompiler.getPrecompileCacheIfNeeded(context,this.auditBase,projectPathInfo.tsSource,projectPathInfo.componentRootFolder)}const masterComponentList=componentFinder.findAllComponents(context,projectPathInfo,this.componentRoots,precompileCache);if(masterComponentList&&masterComponentList.length>0){const allComponentsMap=masterComponentList.reduce((wmap,component)=>{if(!projectPathInfo.isBuiltOutput||projectPathInfo.isBuiltOutput&&!wmap.has(component.fullName)){wmap.set(component.fullName,component)}return wmap},new Map);const referenceComponents=new Map;const componentPaths=new Map;allComponentsMap.forEach(component=>{component.language=Utils.detectComponentSourceType(context,component.rootFolder,component.vcomponent);switch(component.type){case"reference":referenceComponents.set(component.fullName,component.ba);break;case"composite":case"resource":if(component.local){if(component.dependencies){Object.values(component.dependencies).forEach(dependency=>{if(allComponentsMap.has(dependency.name)){const proxyPaths=allComponentsMap.get(dependency.name).requirePaths;proxyPaths.forEach(path=>{component.requirePaths.add(path)})}else{msgLib.debug(`JETWC: missing dependency lookup for ${dependency.name} when resolving requirePaths`)}})}componentPaths.set(component.rootFolder,component.fullName)}break}});context.rulePack.setExtension({rulepackVersion:context.rulePack.getPackInfo().version,bootStrap:true,platform:Utils.isWindows?"Windows":"Unix-like",precompiled:this.typeScriptCompile,componentHome:`/${componentRootFolder}/`,auditBuildOutput:projectPathInfo.isBuiltOutput,discoveredPaths:projectPathInfo,componentRoots:this.componentRoots,allReferenceComponents:referenceComponents,allComponents:allComponentsMap,auditableComponentPaths:componentPaths,allAuditableFilePaths:new Map})}else{msgLib.error(`No components have been discovered from the JAF configuration for the ${context.rulePack.getPackInfo().prefix} ruleset to process. You will need to configure the "components" array to point at your component root folder`);Utils.disableRulePack(context)}};ruleDef.prototype._reportDiagnostics=function(context){const msgLib=context.utils.msgLib;const opts=context.rulePack.getRuleOptions();const diagnostics=context.rulePack.getExtension();if(opts.debug){msgLib.msg("The custom component specific audits discovered the following components:");diagnostics.allComponents.forEach(component=>{msgLib.msg(` ${component.fullName}`)})}if(!opts.testMode){let foundVMMapping=0;let candidateLocal=0;if(diagnostics&&diagnostics.allComponents&&diagnostics.allComponents.length>0){diagnostics.allComponents.forEach(component=>{if(component.local&&component.type==="composite"){candidateLocal++;if(component.viewModel&&component.viewModel.resolved){foundVMMapping++}}});if(foundVMMapping!==candidateLocal){msgLib.error(`Error: Audit was only able to map ${foundVMMapping} out of ${candidateLocal} components to their viewModels. Some audits will be unable to operate.`)}}}if(opts.debug&&opts.diagnosticFile&&diagnostics){msgLib.msg(`Writing JETWC diagnostics to ${opts.diagnosticFile}.json`);const dFile=Utils.toJAFPath(path.join(path.resolve("."),opts.diagnosticFile+".json"));context.utils.fsUtils.writeJsonSync(diagnostics,dFile,{spaces:2,replacer:Utils.diagnosticReplacer})}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require(
|
|
6
|
+
const path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const helperProp=require("../../rules/jet/helpers/bp-checkPropType");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-compjson-bp-ar"};ruleDef.prototype.getShortDescription=function(){return"Web component component.json metadata should follow best practices and avoid plain 'array' type properties"};ruleDef.prototype.getDescription=function(){return"For best practices, web components should avoid use of unqualified property type 'array', and provide a more complete definition of the API using a closure type definition"};ruleDef.prototype.register=function(context){if(context.rulePack.isRuleEnabled("oj-cca-compjson-bp-ar","JET")){return false}else{return{compjson:this._doAudit,Program:this._doVComponentAudit}}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkProps(context,fullName,meta.properties)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkProps(context,componentInfo.fullName,componentInfo.properties)}};ruleDef.prototype._checkProps=function(context,fullName,properties){if(properties){const arrayProps=helperProp(properties,"a");if(arrayProps){for(let i=0;i<arrayProps.length;i++){const checkProperty=arrayProps[i];const checkPropertyType=Utils.getPropertyAttributeFromPath(context,fullName,checkProperty,"type");if(checkPropertyType.toLowerCase()==="array"){if(!Utils.shouldIgnoreCheck(context,"jetwc-compjson-bp-ar",fullName,"properties",checkProperty)){const issue=new context.Issue(`property '${checkProperty}' is defined with unqualified type 'array'. Provide a more complete API definition using a closure type definition.`);context.reporter.addIssue(issue,context)}}}}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const helperProp=require("../../rules/jet/helpers/bp-checkPropType");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-compjson-bp-obj"};ruleDef.prototype.getShortDescription=function(){return"Web component component.json metadata should follow best practices and avoid 'object' type properties"};ruleDef.prototype.getDescription=function(){return"For best practices, web components should avoid use of the property type 'object' without sub-properties, and provide a more complete definition of the API either using sub-properties or using a closure type definition"};ruleDef.prototype.register=function(context){if(context.rulePack.isRuleEnabled("oj-cca-compjson-bp-obj","JET")){return false}else{return{compjson:this._doAudit,Program:this._doVComponentAudit}}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkProps(context,fullName,meta.properties)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkProps(context,componentInfo.fullName,componentInfo.properties)}};ruleDef.prototype._checkProps=function(context,fullName,properties){if(properties){const objectProps=helperProp(properties,"o");if(objectProps){for(let i=0;i<objectProps.length;i++){const checkProperty=objectProps[i];if(!this._hasSub_properties(properties,checkProperty)){if(!Utils.shouldIgnoreCheck(context,"jetwc-compjson-bp-obj",fullName,"properties",checkProperty)){const issue=new context.Issue(`property '${checkProperty}' of type 'object' has no sub-properties. Provide a more complete API definition using sub-properties or a closure type definition`);context.reporter.addIssue(issue,context)}}}}}};ruleDef.prototype._hasSub_properties=function(props,prop){var subprop,a,i;if(!prop.includes(".")){return!!props[prop].properties}a=prop.split(".");for(i=0;i<a.length;i++){subprop=props[a[i]];if(subprop&&subprop.properties){if(a.length-1===i){return true}props=subprop.properties;continue}break}return false};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-component-dependencies"};ruleDef.prototype.getShortDescription=function(){return"Validate the stated dependencies for a component"};ruleDef.prototype.getDescription=function(){return"This rule checks that any dependencies defined for a component actually exist in the context of the project and are correct"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty("allComponents")){const componentMetadata=context.suppData.obj;const componentType=Utils.getComponentType(componentMetadata);if(componentMetadata){let issue;if(componentMetadata.dependencies){Object.keys(componentMetadata.dependencies).forEach(dependency=>{const dependentVersion=componentMetadata.dependencies[dependency];if(componentType==="pack"){if(!context.utils.semVerUtils.isValid(dependentVersion)){issue=new context.Issue(`Pack dependency '${dependency}':'${componentMetadata.dependencies[dependency]}' in ${componentMetadata.name} must be an absolute semver version not a range`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}}else{if(!context.utils.semVerUtils.isValidRange(dependentVersion)){issue=new context.Issue(`Component dependency '${dependency}':'${componentMetadata.dependencies[dependency]}' in ${componentMetadata.name} is not a valid semver or semver range`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}else{if(componentMetadata.type&&componentMetadata.type==="demo"&&context.utils.semVerUtils.isValid(dependentVersion)){issue=new context.Issue(`Demo component ${componentMetadata.name} depends on an absolute version of '${dependency}':'${componentMetadata.dependencies[dependency]}', range support is preferred for demos`);issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context,"info")}}}if(!issue){this._validateDependency(context,componentMetadata.name,dependency,componentMetadata.dependencies[dependency])}})}}}else{Utils.reportMissingBootstrapInfo(context,"allComponents")}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){if(componentInfo.dependencies){componentInfo.dependencies.forEach(dependency=>{this._validateDependency(context,componentInfo.fullName,dependency.name,dependency.range)})}}};ruleDef.prototype._validateDependency=function(context,fullName,dependencyName,dependencyVersion){const allVisibleComponents=context.rulePack.getExtension().allComponents;if(!allVisibleComponents.has(dependencyName)){issue=new context.Issue(`Component dependency '${dependencyName}':'${dependencyVersion}' in '${fullName}' has no match in the project`);issue.setMsgKey(context.ruleName+"_4");context.reporter.addIssue(issue,context)}else{const availableVersion=allVisibleComponents.get(dependencyName).version;if(!context.utils.semVerUtils.satisfiesRange(availableVersion,dependencyVersion)){issue=new context.Issue(`Component dependency '${dependencyName}' in '${fullName}' exists in the project but the versions are mismatched. Requested:'${dependencyVersion}', version available in project: '${availableVersion}'`);issue.setMsgKey(context.ruleName+"_5");context.reporter.addIssue(issue,context)}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-component-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component has display name defined"};ruleDef.prototype.getDescription=function(){return"This rule checks that the component has a display name supplied to make the user experience in Visual Builder and Exchange as useful as possible"};ruleDef.prototype.register=function(context){if(context.rulePack.isRuleEnabled("oj-cca-compjson-bp-dsplyname","JET")){return false}else{return{compjson:this._doAudit,Program:this._doVComponentAudit}}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){this._checkDisplayName(context,context.suppData.obj)}};ruleDef.prototype._checkDisplayName=function(context,meta){let issue;if(!meta.hasOwnProperty("displayName")||meta.displayName===undefined||meta.displayName.length===0){issue=new context.Issue(`displayName for component should be defined`);context.reporter.addIssue(issue,context)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDisplayName(context,componentInfo)}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require(
|
|
6
|
+
const path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-component-foldername"};ruleDef.prototype.getShortDescription=function(){return"Ensure components are defined in the correctly named folder"};ruleDef.prototype.getDescription=function(){return"This rule applies to both singleton and JET Pack components and verifies that they are correctly named in the folder structure based on their type"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty("auditBuildOutput")){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentName=meta.name;const componentVersion=meta.version;const pathSegments=context.filepath.split("/");const componentFolder=pathSegments[pathSegments.length-2];const componentParentFolder=pathSegments[pathSegments.length-3];let expectedFolder;const processingBuilt=context.rulePack.getExtension().auditBuildOutput;if(!processingBuilt||meta.pack){expectedFolder=componentName}else{expectedFolder=componentVersion}if(componentFolder!==expectedFolder){issue=new context.Issue(`${processingBuilt?"For built output ":""}Component '${fullName}' should be defined in a folder called '${processingBuilt?componentName+path.sep:""}${expectedFolder}' not '${processingBuilt?componentParentFolder+path.sep:""}${componentFolder}' for referencing to work correctly`);context.reporter.addIssue(issue,context)}}}else{Utils.reportMissingBootstrapInfo(context,"auditBuildOutput")}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){const fullName=componentInfo.fullName;let expectedPath=componentInfo.pack?componentInfo.name:componentInfo.fullName;const pathSegments=context.filepath.split("/");const componentFolder=pathSegments[pathSegments.length-2];const parentFolder=pathSegments[pathSegments.length-3];if(componentFolder!==expectedPath){issue=new context.Issue(`Component '${fullName}' should be defined in a folder called '${expectedPath}' not '${componentFolder}' for referencing to work correctly`);context.reporter.addIssue(issue,context)}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require(
|
|
6
|
+
const path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-component-location"};ruleDef.prototype.getShortDescription=function(){return"Ensure components are defined in the correct folder structure"};ruleDef.prototype.getDescription=function(){return"This rule applies to both singleton and JET Pack components and verifies that they are correctly placed in the folder structure based on their naming"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty("auditBuildOutput")){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentParentPack=meta.pack;const componentName=meta.name;const fullName=Utils.getComponentFullName(meta);const pathSegments=context.filepath.split("/");const componentRoot=context.rulePack.getExtension().componentHome;const sepStrip=/\//g;const parentFolder=pathSegments[pathSegments.length-3];const grandParentFolder=pathSegments[pathSegments.length-4];let expectedParent;let expectedGrandParent;const processingBuilt=context.rulePack.getExtension().auditBuildOutput;if(processingBuilt){if(componentParentPack){expectedParent=Utils.componentInfo(context,componentParentPack).version;expectedGrandParent=componentParentPack}else{expectedParent=componentName;expectedGrandParent=componentRoot.replace(sepStrip,"")}}else{if(componentParentPack){expectedParent=componentParentPack;expectedGrandParent=componentRoot.replace(sepStrip,"")}else{expectedParent=componentRoot.replace(sepStrip,"")}}if(parentFolder!==expectedParent){if(!processingBuilt){issue=new context.Issue(`Component '${fullName}' should be defined in a folder which is a child of '${expectedParent}'`);issue.setMsgKey(context.ruleName+"_1")}else{issue=new context.Issue(`Built component '${fullName}' should be present in a folder which is a child of '${expectedGrandParent}${path.sep}${expectedParent}'`);issue.setMsgKey(context.ruleName+"_3")}}if(!issue){if(expectedGrandParent&&grandParentFolder!==expectedGrandParent){issue=new context.Issue(`Parent folder for ${processingBuilt?"built":""} component '${fullName}' should be present in a folder called '${expectedGrandParent}'`);issue.setMsgKey(context.ruleName+"_2")}}if(issue){context.reporter.addIssue(issue,context)}}}else{Utils.reportMissingBootstrapInfo(context,"auditBuildOutput")}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-component-type"};ruleDef.prototype.getShortDescription=function(){return"Check component has an explicit type defined"};ruleDef.prototype.getDescription=function(){return"This rule checks that the component explicitly defines a type attribute rather than relying on the original fallback behavior and assuming composite"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;if(!meta.hasOwnProperty("type")){issue=new context.Issue(`type for component should be explicitly defined rather than assuming the default`);context.reporter.addIssue(issue,context)}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-css-oj-complete"};ruleDef.prototype.getShortDescription=function(){return"Verify that a component CSS implementation includes the standard definition for hiding itself before it is fully initialized"};ruleDef.prototype.getDescription=function(){return"All custom components should include a selector definition for the component tag that ensures that it is hidden until the oj-complete marker class is applied. This is managed through the use of the :not(.oj-complete) pseudo-class setting the visibility to hidden"};ruleDef.prototype.register=function(context){return{startaudit:this._ruleSetup,"css-selector":this._detectNotSelector,endaudit:this._reportUnmatchedComponents}};ruleDef.prototype._ruleSetup=function(context){this.validOjCompleteSelectors=new Set};ruleDef.prototype._detectNotSelector=function(context,selector){if(selector.type==="Selector"&&selector.children.length===2&&selector.children[0].type==="TypeSelector"&&selector.children[1].type==="PseudoClassSelector"&&selector.children[1].name==="not"){const selectorComponentName=selector.children[0].name;const componentInfo=Utils.componentInfo(context,selectorComponentName);if(componentInfo&&selector.children[1].children.length>0&&selector.children[1].children[0].type==="SelectorList"&&selector.children[1].children[0].children.length>0&&selector.children[1].children[0].children[0].type==="Selector"&&selector.children[1].children[0].children[0].children.length>0&&selector.children[1].children[0].children[0].children[0].type==="ClassSelector"&&selector.children[1].children[0].children[0].children[0].name==="oj-complete"){this.validOjCompleteSelectors.add(selectorComponentName)}}};ruleDef.prototype._reportUnmatchedComponents=function(context){let allComponents;if(context.rulePack.getExtension()){allComponents=context.rulePack.getExtension().allComponents}if(allComponents){for(const[componentName,componentDef]of allComponents.entries()){if(componentDef.local&&componentDef.type==="composite"){const fullName=componentDef.fullName;if(!this.validOjCompleteSelectors.has(fullName)){if(!Utils.shouldIgnoreCheck(context,this.getName(),fullName)){const issue=new context.Issue(`Component '${fullName}' does not have a defined CSS sector for :not(.oj-complete)`);context.reporter.addIssue(issue,context)}}}}}};module.exports=ruleDef;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2023, 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 path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-css-pack-load-path"};ruleDef.prototype.getShortDescription=function(){return"Checks that the canonical pack path is used when loading a css file from a component in a pack"};ruleDef.prototype.getDescription=function(){return"Components in a JET Pack should always use the canonical path for that pack when using the css! or ojcss! plugins rather than relative (./) addressing"};ruleDef.prototype.register=function(context){return{CallExpression:this._doAudit,ImportDeclaration:this._doAuditImport}};ruleDef.prototype._doAuditImport=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));if(withinComponent){if(node.importKind==="value"&&node.source&&node.source.type===NT.LITERAL&&this._matchRelativeReference(node.source.value)){this._packMemberCheck(context,withinComponent)}}};ruleDef.prototype._doAudit=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));if(withinComponent&&(node.callee.name==="define"||node.callee.name==="require")){if(node.arguments[0].type===NT.ARRAY_EXPR&&node.arguments[0].elements.length>0){node.arguments[0].elements.forEach(arg=>{this._checkRequireTarget(context,withinComponent,arg)})}else if(node.arguments[0].type===NT.LITERAL){this._checkRequireTarget(context,withinComponent,node.arguments[0])}}};ruleDef.prototype._checkRequireTarget=function(context,withinComponent,node){const NT=context.utils.AstUtils.getNodeTypes();if(node.type===NT.LITERAL&&this._matchRelativeReference(node.value)){this._packMemberCheck(context,withinComponent)}};ruleDef.prototype._matchRelativeReference=function(importString){const cssImportMatcher=/^(?:css!|ojcss!)\.\//;return cssImportMatcher.test(importString)};ruleDef.prototype._packMemberCheck=function(context,withinComponent){if(withinComponent){const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(componentInfo?.pack){const issue=new context.Issue(`Component ${componentInfo.fullName} should import css files using the canonical pack path e.g "${componentInfo.pack}/${componentInfo.name}/" rather than a relative path "./" to enable correct minification`);context.reporter.addIssue(issue,context)}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const path=require("path");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-css-scoping"};ruleDef.prototype.getShortDescription=function(){return"Verify that any styles defined by a component are correctly scoped"};ruleDef.prototype.getDescription=function(){return"Any style defined by a custom component should be scoped to only operate in the context of that component so as not to bleed through to the rest of the page and cause unexpected side effects"};ruleDef.prototype.register=function(context){return{"css-rule":this._doAudit,"css-atrule":this._doAudit}};ruleDef.prototype._doAudit=function(context,cssRule,indentifier){const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));if(withinComponent){const componentInfo=Utils.componentInfo(context,withinComponent);const ruleOptions=context.rulePack.getRuleOptions();let validPrefixes=[];let packContext;if(componentInfo.type==="resource"){packContext=componentInfo.pack;if(packContext){const packInfo=Utils.componentInfo(context,packContext);const packJson=path.join(packInfo.rootFolder,"component.json");const packDef=context.utils.fsUtils.readJsonSync(packJson);validPrefixes=validPrefixes.concat(Object.keys(packDef.dependencies))}}else{validPrefixes.push(withinComponent)}let relaxedForPack=false;if(componentInfo.pack&&ruleOptions&&ruleOptions.customOpts&&ruleOptions.customOpts.allowPackScoping){validPrefixes.push(componentInfo.pack);relaxedForPack=true}let globalIgnore=["html","body","oj-color-invert","from","to"];if(ruleOptions&&ruleOptions.customOpts&&ruleOptions.customOpts.ignoreScopes&&Array.isArray(ruleOptions.customOpts.ignoreScopes)){globalIgnore=globalIgnore.concat(ruleOptions.customOpts.ignoreScopes)}let ruleSelectorName,ruleSelectorType;if(cssRule.type==="Atrule"){ruleSelectorType=cssRule.type;if(cssRule.prelude.children[0]&&cssRule.prelude.children[0].name){ruleSelectorName=cssRule.prelude.children[0].name}}else{for(let i=0;i<cssRule.prelude.children[0].children.length;i++){const selector=cssRule.prelude.children[0].children[i];if(selector.type==="TypeSelector"&&!globalIgnore.includes(selector.name)){ruleSelectorType=selector.type;ruleSelectorName=selector.name;break}else if(selector.type==="ClassSelector"&&!globalIgnore.includes(selector.name)){ruleSelectorType=selector.type;ruleSelectorName=selector.name;break}}}let errorMessage;let validScopes=`by the custom component tag name: ${withinComponent}`;if(ruleSelectorName&&ruleSelectorType){if(ruleSelectorType==="TypeSelector"){if(!validPrefixes.includes(ruleSelectorName)){if(packContext){validScopes=`by the tag name of one of the custom elements in the pack: ${packContext}`}errorMessage=`CSS Type selector ${ruleSelectorName} must be scoped ${validScopes}`}}else if(ruleSelectorType==="ClassSelector"||ruleSelectorType==="Atrule"){if(packContext){validPrefixes.push(packContext);validScopes=`by the one of the tag names of one of the custom elements in the pack: ${packContext}`}const matchingPrefixes=validPrefixes.filter(prefix=>ruleSelectorName.startsWith(prefix));if(matchingPrefixes.length===0){errorMessage=`Error in class selector naming for class: ${ruleSelectorName}. CSS Class selectors used by custom components must be scoped ${validScopes}${relaxedForPack?" or the pack name itself":""}`}}}if(errorMessage){if(!Utils.shouldIgnoreCheck(context,this.getName(),withinComponent)){const issue=new context.Issue(errorMessage);context.reporter.addIssue(issue,context)}}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-data-property-prefix"};ruleDef.prototype.getShortDescription=function(){return"Ensure that the component does not define properties with a data* prefix"};ruleDef.prototype.getDescription=function(){return"This rule checks that a component has not defined any property that once translated to an attribute becomes a data-* attribute. This involves checking the property name of top level properties only for the prefix of data followed by an uppercase letter. The property name data on its own is OK"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkProps(context,fullName,meta.properties)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkProps(context,componentInfo.fullName,componentInfo.properties)}};ruleDef.prototype._checkProps=function(context,fullName,properties){let issue;if(properties){const dataDetect=/^data[A-Z\-].*$/;Object.keys(properties).forEach(propName=>{if(dataDetect.test(propName)){issue=new context.Issue(`Component ${fullName} defines a data prefixed property ${propName} which is not allowed`);context.reporter.addIssue(issue,context)}})}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-deprecated-lifecycle"};ruleDef.prototype.getShortDescription=function(){return"Checks for deprecated component lifecycle definitions"};ruleDef.prototype.getDescription=function(){return"This rule ensures that the component does not still declare deprecated lifecycle methods such as attached"};ruleDef.prototype.register=function(context){return{FunctionExpression:Utils.setupFileMethodMapping.bind(Utils),ArrowFunctionExpression:Utils.setupFileMethodMapping.bind(Utils),CallExpression:Utils.deriveViewModels.bind(Utils),MethodDefinition:Utils.setupFileMethodMappingFromMethodDefintion.bind(Utils),closedownRP:this._doAudit}};ruleDef.prototype._doAudit=function(context){let issue;if(context.rulePack.getExtension()){context.rulePack.getExtension().allComponents.forEach(compInfo=>{const vmMethods=Utils.getVMMethodsForLocalComposite(context,compInfo);if(vmMethods&&(vmMethods.has("attached")||vmMethods.has("detached")||vmMethods.has("initialize")||vmMethods.has("dispose"))){let reportSource=compInfo.fullName;if(compInfo.viewModel.resolved&&!compInfo.viewModel.skip){reportSource=compInfo.viewModel.path}issue=new context.Issue(`Component '${compInfo.fullName}' still defines one or more of the following deprecated lifecycle methods: attached(), detached(), dispose(), initialize()`);issue.setReportedFilePath(reportSource);context.reporter.addIssue(issue,context)}})}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-disabled-property"};ruleDef.prototype.getShortDescription=function(){return"Check component does not use the problematic disabled property"};ruleDef.prototype.getDescription=function(){return"This rule checks that a component does not define a property called disabled which can cause issues with IE"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){if(meta.properties&&meta.properties.hasOwnProperty("disabled")){var deprecated=false;if(meta.properties.disabled.hasOwnProperty("status")){var statusArray=meta.properties.disabled.status;statusArray.forEach(status=>{if(status.hasOwnProperty("type")){if(status.type==="deprecated"){deprecated=true}}})}if(!deprecated){issue=new context.Issue(`Component ${fullName} defines a property called 'disabled' this can cause problems with Internet Explorer and we recommend 'disable' as a replacement property name`);context.reporter.addIssue(issue,context)}}}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component display name will work with Visual Builder"};ruleDef.prototype.getDescription=function(){return"This rule checks both the length and the number of words of the display name - configurable"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);this._checkDisplayNames(context,fullName,componentType,meta.displayName,meta.properties,meta.events,meta.slots)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDisplayNames(context,componentInfo.fullName,componentInfo.type,componentInfo.displayName,componentInfo.properties,componentInfo.events,componentInfo.slots)}};ruleDef.prototype._checkDisplayNames=function(context,fullName,componentType,displayName,properties,events,slots){const ruleOptions=context.rulePack.getRuleOptions();let limits;let elimits;let plimits;let slimits;switch(componentType){case"composite":elimits=ruleOptions.limits.event;plimits=ruleOptions.limits.property;slimits=ruleOptions.limits.slot;case"vbcs-pattern":limits=ruleOptions.limits.component;break;case"vbcs-template":limits=ruleOptions.limits.template;break}if(limits&&displayName){if(displayName.length>limits.length){this._lengthError(context,fullName,componentType,limits.length)}if(displayName.split(" ").length>limits.words){this._wordCountError(context,fullName,componentType,limits.words)}}if(plimits&&properties){this.checkByAttributeType(context,fullName,componentType,plimits,properties,"properties","property")}if(elimits&&events){this.checkByAttributeType(context,fullName,componentType,elimits,events,"events","event")}if(slimits&&slots){this.checkByAttributeType(context,fullName,componentType,slimits,slots,"slots","slot")}};ruleDef.prototype._lengthError=function(context,component,type,limit,scope){issue=new context.Issue(`displayName property for Component ${component}${scope?" ("+scope+")":""} exceeds the defined length limit of ${limit} for a ${type}`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)};ruleDef.prototype._wordCountError=function(context,component,type,limit,scope){issue=new context.Issue(`displayName property for Component ${component}${scope?" ("+scope+")":""} exceeds the defined word count of ${limit} for a ${type}`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)};ruleDef.prototype.checkByAttributeType=function(context,fullName,componentType,limits,meta,attributeType,typeName){Object.keys(meta).forEach(cName=>{const cDN=meta[cName].displayName;if(cDN){if(cDN.length>limits.length){this._lengthError(context,fullName,componentType+" "+typeName,limits.length,attributeType+"=>"+cName)}if(cDN.split(" ").length>limits.words){this._wordCountError(context,fullName,componentType+" "+typeName,limits.words,attributeType+"=>"+cName)}}})};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-dynamic-slot-context"};ruleDef.prototype.getShortDescription=function(){return"Check properties have valid dynamicSlotDef values"};ruleDef.prototype.getDescription=function(){return"Ensures that any property that defines itself as a dynamic slot discriminant using the dynamicSlotDef attribute is using a valid context defined within the dynamicSlots set for the component"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="composite"){if(meta.properties){Object.keys(meta.properties).forEach(propName=>{let issueNoticed=false;const prop=meta.properties[propName];if(prop.hasOwnProperty("dynamicSlotDef")){if(meta.dynamicSlots){if(!meta.dynamicSlots.hasOwnProperty(prop.dynamicSlotDef)){issueNoticed=true}}else{issueNoticed=true}}if(issueNoticed){const issue=new context.Issue(`Component ${fullName} property ${propName} references an invalid dynamic-slot`);context.reporter.addIssue(issue,context)}})}}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-event-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component has display name defined for events"};ruleDef.prototype.getDescription=function(){return"This rule checks that events have a display name supplied to make the user experience in Visual Builder as useful as possible"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkEvents(context,meta.events)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkEvents(context,componentInfo.events)}};ruleDef.prototype._checkEvents=function(context,events){let issue;if(events){Object.keys(events).forEach(eventName=>{if(!events[eventName].displayName){issue=new context.Issue(`displayName for event '${eventName}' should be defined`);context.reporter.addIssue(issue,context)}})}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require(
|
|
6
|
+
const path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-events"};ruleDef.prototype.getShortDescription=function(){return"Checks that any events raised are declared"};ruleDef.prototype.getDescription=function(){return"This rule ensures that all events omitted from a component are declared in the metadata"};ruleDef.prototype.register=function(context){return{CallExpression:this._doAudit}};ruleDef.prototype._doAudit=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();let issue;if(node.callee.type===NT.MEMBER_EXPR&&node.callee.property.type===NT.IDENTIFIER&&node.callee.property.name==="dispatchEvent"){if(node.arguments[0].type===NT.CALL_EXPR||node.arguments[0].type===NT.NEW_EXPR){if(node.arguments[0].callee.name==="CustomEvent"){const eventNameNode=node.arguments[0].arguments[0];if(eventNameNode.type===NT.LITERAL){const eventName=eventNameNode.value;const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));const componentInfo=Utils.componentInfo(context,withinComponent);if(withinComponent&&componentInfo.type==="composite"){if(!componentInfo.events||!componentInfo.events.hasOwnProperty(eventName)){issue=new context.Issue(`Event '${eventName}' raised for component ${withinComponent} has not been declared in the component metadata`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}}else{issue=new context.Issue(`Custom event '${eventName}' raised by code outside of a web component and so cannot be verified against any component API`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}}}}}};module.exports=ruleDef;
|