@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
|
@@ -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-exchange-images"};ruleDef.prototype.getShortDescription=function(){return"Validates the existence of images specified for Exchange in the component metadata"};ruleDef.prototype.getDescription=function(){return"This audit checks for the declaration of cover image or screen shot information in a component definition and ensures that the specified files actually exist within the packaged component. Such missing images would prevent the component from being shared via the Exchange"};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);this._checkImages(context,fullName,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkImages(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkImages=function(context,fullName,componentMeta){if(!Utils.shouldIgnoreCheck(context,"jetwc-exchange-images",fullName)){const compInfo=context.rulePack.getExtension().allComponents.get(fullName);if(componentMeta.extension&&componentMeta.extension.catalog&&compInfo){const componentRoot=compInfo.rootFolder;if(componentMeta.extension.catalog.coverImage&&componentMeta.extension.catalog.coverImage.length>0){this._verfiyImage(context,componentRoot,componentMeta.extension.catalog.coverImage,"Cover Image",fullName)}if(componentMeta.extension.catalog.screenshots&&Object.keys(componentMeta.extension.catalog.screenshots).length>0){Object.keys(componentMeta.extension.catalog.screenshots).forEach(screenShot=>{this._verfiyImage(context,componentRoot,componentMeta.extension.catalog.screenshots[screenShot],"Screenshot",fullName)})}}}};ruleDef.prototype._verfiyImage=function(context,componentRoot,imageFile,use,componentName){let issue;if(!context.utils.fsUtils.fileExists(path.join(componentRoot,imageFile))){issue=new context.Issue(`Image file used for Exchange does not exist or is outside of the component distribution: Image ${imageFile} used as ${use} for component ${componentName}`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}else{const pathSegs=imageFile.split("/");if(pathSegs[0]!=="extension"){issue=new context.Issue(`Images used for Exchange should ideally be located in the /extension folder: Image ${imageFile} used as ${use} for component ${componentName}`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context,"info")}}};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-jet-version"};ruleDef.prototype.getShortDescription=function(){return"Verify the JET version range of a component "};ruleDef.prototype.getDescription=function(){return"This rule is configured with your required JET version range for a set of components to make sure that they are all consistent"};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(meta.jetVersion&&fullName){this._checkVersion(context,fullName,meta.jetVersion)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo&&componentInfo.jetVersion){this._checkVersion(context,componentInfo.fullName,componentInfo.jetVersion)}};ruleDef.prototype._checkVersion=function(context,fullName,version){let issue;const ruleOptions=context.rulePack.getRuleOptions();let targetJetVersion;if(ruleOptions.hasOwnProperty("jetVersion")){targetJetVersion=ruleOptions.jetVersion}else{targetJetVersion=context.utils.jafLib.getConfig().getJetVer()}if(ruleOptions.hasOwnProperty("versionMatch")){switch(ruleOptions.versionMatch){case"absolute":if(targetJetVersion!==version){issue=new context.Issue(`Component ${fullName} does not support the expected JET version range ${targetJetVersion} (found ${version})`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}break;case"upperLimit":if(!context.utils.semVerUtils.satisfiesRange(targetJetVersion,version)){issue=new context.Issue(`Component ${fullName} does not support the required version of JET ${targetJetVersion} (supported range found ${version})`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}break}}};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-loader-file"};ruleDef.prototype.getShortDescription=function(){return"Checks for the existence of the loader.js / ts"};ruleDef.prototype.getDescription=function(){return"This rule ensures that standard loader entry point is available for composites. This looks for a file called loader.js or loader.ts in the same folder as the components component.json file and then checks that the information matches, e.g. the loader registers the correct tag name for the component."};ruleDef.prototype.register=function(context){return{compjson:this._doAuditPhysical,CallExpression:this._doAuditMapping}};ruleDef.prototype._doAuditPhysical=function(context){const componentMetadata=context.suppData.obj;if(componentMetadata){let issue;const fullName=Utils.getComponentFullName(componentMetadata);const componentType=Utils.getComponentType(componentMetadata);if(componentType==="composite"){const testLoader=Utils.toJAFPath(path.join(path.dirname(context.filepath),"loader."));if(!context.utils.fsUtils.fileExistsSync(testLoader+"js")&&!context.utils.fsUtils.fileExistsSync(testLoader+"ts")){issue=new context.Issue(`Required loader script for ${fullName} is not present`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}}}};ruleDef.prototype._doAuditMapping=function(context,node){if(this._isCompositeLoader(context)){const candidateTag=this._getLoaderTag(context,node);if(candidateTag){if(candidateTag==="?"){issue=new context.Issue(`Web Component tag registration does not pass a literal for the tag name and so cannot be verified`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context,"info")}else{const checkFormat=/^[a-zA_Z]\w*-.*$/;if(!candidateTag.match(checkFormat)){issue=new context.Issue(`Tag ${candidateTag} used in Web Component registration does not conform to HTML custom element syntax rules. It must begin with a letter and have at least one hyphen`);issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context)}else{const componentDefFile=Utils.toJAFPath(path.join(path.dirname(context.filepath),"component.json"));if(context.utils.fsUtils.fileExistsSync(componentDefFile)){const componentDef=context.utils.fsUtils.readJsonSync(componentDefFile);const expectedTag=componentDef.pack?`${componentDef.pack}-${componentDef.name}`:componentDef.name;if(expectedTag!==candidateTag){issue=new context.Issue(`Tag '${candidateTag}' does not match the full name of the associated component '${expectedTag}'`);issue.setMsgKey(context.ruleName+"_4");context.reporter.addIssue(issue,context)}}}}}}};ruleDef.prototype._getLoaderTag=function(context,node){let tagName;const registerInfo=Utils.getLoaderRegisterInfo(context,node);if(registerInfo){tagName=registerInfo.tag}return tagName};ruleDef.prototype._isCompositeLoader=function(context){let loaderFound=false;if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty("allComponents")){const fileName=context.filepath;const withinComponent=Utils.matchComponentPath(context,path.dirname(fileName));const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(withinComponent&&componentInfo&&componentInfo.type==="composite"){const targetLoaderExt=componentInfo.language==="tsx"?".ts":`.${componentInfo.language}`;if(path.basename(fileName,targetLoaderExt)==="loader"){loaderFound=true}}}else{Utils.reportMissingBootstrapInfo(context,"allComponents")}return loaderFound};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 ruleDef=function(){};ruleDef.prototype.getName=function(){return
|
|
6
|
+
const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-markdown-link"};ruleDef.prototype.getShortDescription=function(){return"Validates any links in markdown documents"};ruleDef.prototype.getDescription=function(){return"This rule flags any links used in markdown based documents such as README.md or CHANGELOG.md which are not in the correct markdown format. It also allows verification of any servers against include or exclude globs so that links can be sanitised if required"};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,"md-link":this._doAudit}};ruleDef.prototype._auditPrep=function(context){let allowList=context.rulePack.getRuleOption("allow");let disallowList=context.rulePack.getRuleOption("disallow");this.urlMatchExpressions=[];this.allowMatching=true;let processList=allowList;if(!processList){processList=disallowList;this.allowMatching=false}if(processList){processList.forEach(pattern=>{this.urlMatchExpressions.push(new RegExp(pattern,"i"))})}};ruleDef.prototype._doAudit=function(context,linkObj){let issue;let matchCount=0;this.urlMatchExpressions.forEach(urlRegex=>{if(urlRegex.test(linkObj.link)){matchCount++}});if(this.allowMatching&&matchCount===0){issue=new context.Issue(`Hyperlink '${linkObj.link}' does not match an allowed link pattern`);issue.setMsgKey(context.ruleName+"_2");issue.setSeverity("blocker")}else if(!this.allowMatching&&matchCount>0){issue=new context.Issue(`Hyperlink '${linkObj.link}' matches a disallowed link pattern`);issue.setMsgKey(context.ruleName+"_2");issue.setSeverity("blocker")}if(!issue&&!linkObj.text){issue=new context.Issue(`Hyperlink '${linkObj.link}' is missing an associated label in the markdown`);issue.setMsgKey(context.ruleName+"_1")}if(issue){issue.setPosition(linkObj.pos);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-method-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component has display name defined for methods"};ruleDef.prototype.getDescription=function(){return"This rule checks that methods 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._checkMethods(context,meta.methods)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkMethods(context,componentInfo.methods)}};ruleDef.prototype._checkMethods=function(context,methods){let issue;if(methods){Object.keys(methods).forEach(methodName=>{if(!methods[methodName].displayName&&!["setProperty","getProperty","setProperties"].includes(methodName)){issue=new context.Issue(`displayName for method '${methodName}' 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 Utils=require(
|
|
6
|
+
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-methods"};ruleDef.prototype.getShortDescription=function(){return"Checks for the existence of declared methods"};ruleDef.prototype.getDescription=function(){return"This rule ensures that any methods declared in the component.json actually have an implementation in the associated viewModel"};ruleDef.prototype.register=function(context){return{FunctionExpression:Utils.setupFileMethodMapping.bind(Utils),ArrowFunctionExpression:Utils.setupFileMethodMapping.bind(Utils),MethodDefinition:Utils.setupFileMethodMappingFromMethodDefintion.bind(Utils),CallExpression:Utils.deriveViewModels.bind(Utils),closedownRP:this._doAudit}};ruleDef.prototype._doAudit=function(context){let issue;if(context.rulePack.getExtension()){context.rulePack.getExtension().allComponents.forEach(compInfo=>{if(compInfo.methods){let reportSource=compInfo.fullName;if(compInfo.viewModel.resolved&&!compInfo.viewModel.skip){reportSource=compInfo.viewModel.path}const vmMethods=Utils.getVMMethodsForLocalComposite(context,compInfo);if(vmMethods){Object.keys(compInfo.methods).forEach(methodName=>{const methodMeta=compInfo.methods[methodName];const testName=methodMeta.internalName?methodMeta.internalName:methodName;if(!vmMethods.has(testName)){issue=new context.Issue(`Component '${compInfo.fullName}' declares a API method '${methodName}' which does not have an implementation in its viewModel file`);issue.setMsgKey(context.ruleName+"_1");issue.setReportedFilePath(reportSource);context.reporter.addIssue(issue,context)}else{const implementedParamCount=vmMethods.get(testName).parameters;const declaredParamCount=methodMeta.params?methodMeta.params.length:0;if(implementedParamCount!==declaredParamCount){issue=new context.Issue(`The implementation of Component '${compInfo.fullName}' API method '${testName}' does not match the declared API. The parameter lists differ in length`);issue.setMsgKey(context.ruleName+"_2");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 TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-namespace"};ruleDef.prototype.getShortDescription=function(){return"Verify components are within your registered namespace"};ruleDef.prototype.getDescription=function(){return"This rule is configured with your namespace(s) in the audit configuration file and will match the naming of your component to those namespaces"};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);this._checkNamespace(context,fullName)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkNamespace(context,componentInfo.fullName)}};ruleDef.prototype._checkNamespace=function(context,fullName){let issue;if(context.rulePack.getRuleOptions().namespaces.filter(ns=>fullName.startsWith(ns)).length===0){issue=new context.Issue(`Component ${fullName} is not in an assigned namespace`);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-nested-defaults"};ruleDef.prototype.getShortDescription=function(){return"Checks for incorrect definition of default values"};ruleDef.prototype.getDescription=function(){return"This rule checks that for complex properties (those with sub-properties) we do not have conflicting default values set e.g. a default on both a parent and a child."};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"&&meta.properties){const expandedProperties=[];this._propertyDrill(context,meta,expandedProperties);expandedProperties.forEach(prop=>{if(prop.defaultCount>1){issue=new context.Issue(`Component ${fullName}, nested property ${prop.propertyPath} has multiple defaults defined at different levels`);context.reporter.addIssue(issue,context)}})}}};ruleDef.prototype._propertyDrill=function(context,metadata,accumulator,parentInfo){const levelPath=parentInfo?parentInfo.propertyPath+".":"";const defaultCount=parentInfo?parentInfo.defaultCount:0;const propKeys=Object.keys(metadata.properties);propKeys.forEach(propertyName=>{const propertyMeta=metadata.properties[propertyName];let runningDefault=defaultCount;if(propertyMeta.hasOwnProperty("value")){runningDefault++}const propertyInfo={propertyPath:levelPath+propertyName,defaultCount:runningDefault};if(propertyMeta.hasOwnProperty("properties")){this._propertyDrill(context,propertyMeta,accumulator,propertyInfo)}accumulator.push(propertyInfo)})};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-nls-languages"};ruleDef.prototype.getShortDescription=function(){return"Ensures that the correct language bundles are supplied"};ruleDef.prototype.getDescription=function(){return"This rule ensures that a string bundle both declares and implements locale overrides for each required language"};ruleDef.prototype.register=function(context){return{CallExpression:this._doAudit,TSExportAssignment:this._doAudit}};ruleDef.prototype._doAudit=function(context,node){let issue;const NT=context.utils.AstUtils.getNodeTypes();if(context.filepath.includes("/resources/nls/")){const dirPath=path.dirname(context.filepath);const bundleName=path.basename(context.filepath);const pathSegs=dirPath.split("/").reverse();const ruleOptions=context.rulePack.getRuleOptions();if(pathSegs[0]==="nls"){const withinComponent=Utils.matchComponentPath(context,dirPath);if(withinComponent){let langProps;if(node.callee&&node.callee.type===NT.IDENTIFIER&&node.callee.name==="define"&&node.arguments&&node.arguments.length>0&&node.arguments[0].type===NT.OBJ_EXPR){langProps=node.arguments[0].properties}else if(node.type===NT.EXPORT_ASSIGNMENT&&node.expression&&node.expression.type===NT.OBJ_EXPR){langProps=node.expression.properties}if(langProps){const languagesSupported=langProps.reduce((langs,langEntry)=>{if(langEntry.type===NT.PROPERTY&&langEntry.key.type===NT.LITERAL){if(langEntry.value.type===NT.LITERAL){langs.push({locale:langEntry.key.value,verified:false,enabled:langEntry.value.value})}else if(langEntry.value.type===NT.OBJ_EXPR){langs.push({locale:langEntry.key.value,verified:true})}}return langs},[]);const nlsFiles=context.utils.fsUtils.readDir(dirPath);const expectedLocales=ruleOptions.locales.reduce((locs,locale)=>{if(locale.includes("|")){const alternatives=locale.split("|");locs.push({locale:alternatives[0].toLowerCase(),alt:alternatives[1].toLowerCase(),found:false,configured:locale})}else{locs.push({locale:locale.toLowerCase(),alt:locale.toLowerCase(),found:false,configured:locale})}return locs},[]);expectedLocales.push({locale:"root",alt:"root",found:false,configured:"Root Bundle"});languagesSupported.forEach(lang=>{if(lang.verified){issue=new context.Issue(`Component '${withinComponent}' - the recommended pattern for string bundles is for each locale to be defined in its own file in a locale specific subdirectory under /resources/nls/`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context,"info")}else{if(!lang.enabled){issue=new context.Issue(`Component '${withinComponent}' - locale support declared for '${lang.locale}', but is currently disabled`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context,"info")}else{let bundleFound=false;const localeFolder=nlsFiles.filter(nlsChild=>{let found=false;if(!nlsChild.isFile){found=this._localeMatch(nlsChild.name,lang.locale,ruleOptions.strict)}return found});if(localeFolder.length===1){const localeSpecificFile=localeFolder[0].files.filter(localeChild=>localeChild.isFile&&localeChild.name===bundleName);if(localeSpecificFile.length===1){bundleFound=true;expectedLocales.forEach(localeRec=>{if(this._localeMatch(localeRec.locale,lang.locale,ruleOptions.strict)||this._localeMatch(localeRec.alt,lang.locale,ruleOptions.strict)){localeRec.found=true}})}}if(!bundleFound){issue=new context.Issue(`Component '${withinComponent}' - locale support declared for '${lang.locale}', but the expected file: '/resources/nls/${lang.locale}/${bundleName}' is missing`);issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context)}}}});if(!issue){expectedLocales.forEach(localeRec=>{if(!localeRec.found){issue=new context.Issue(`Component '${withinComponent}' - required locale support not provided for '${localeRec.configured}'`);issue.setMsgKey(context.ruleName+"_4");context.reporter.addIssue(issue,context)}})}}}}}};ruleDef.prototype._localeMatch=function(test,against,strict){let l1,l2;if(strict){l1=test;l2=against}else{l1=test.toLowerCase().replace("_","-");l2=against.toLowerCase().replace("_","-")}return l1===l2};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-nls-root"};ruleDef.prototype.getShortDescription=function(){return"Checks for the existence of translations in the expected place"};ruleDef.prototype.getDescription=function(){return"This rule ensures that standards are being followed regarding the use of translation bundles"};ruleDef.prototype.register=function(context){return{CallExpression:this._doAudit,TSImportEqualsDeclaration:this._doAuditImportRequire}};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=>{if(arg.value){this._checkRequireTarget(context,withinComponent,arg.value)}})}else if(node.arguments[0].type===NT.LITERAL&&node.arguments[0].value){this._checkRequireTarget(context,withinComponent,node.arguments[0].value)}}};ruleDef.prototype._doAuditImportRequire=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));if(withinComponent){if(node.moduleReference&&node.moduleReference.type===NT.EXTERN_MOD_REF&&node.moduleReference.expression){const sourcePath=node.moduleReference.expression.value;this._checkRequireTarget(context,withinComponent,sourcePath)}}};ruleDef.prototype._checkRequireTarget=function(context,withinComponent,sourcePath){if(sourcePath&&sourcePath.startsWith("ojL10n!")){let bundleStdLocation=false;const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);const expectedFolderStart=sourcePath.indexOf("/resources/nls/");if(expectedFolderStart>0){const depathed=sourcePath.substring(7).split("/");const resourcesOffset=depathed.indexOf("resources");const nlsOffset=depathed.indexOf("nls");if(nlsOffset===resourcesOffset+1){const requireRoot=depathed.slice(0,nlsOffset-1).join("/");if(componentInfo.requirePaths.has(requireRoot)){bundleStdLocation=true}}}if(!bundleStdLocation){issue=new context.Issue(`String bundle for component ${componentInfo.fullName} is either not in the recommended location of /resources/nls/ relative to the source component or is defined with an unsupported path. Found: ${sourcePath}`);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-oj-register"};ruleDef.prototype.getShortDescription=function(){return"Checks for usage of the deprecated oj.Register() syntax"};ruleDef.prototype.getDescription=function(){return"This rule ensures that components have been upgraded to remove references to the deprecated oj.Register() syntax"};ruleDef.prototype.register=function(context){return{CallExpression:this._doAudit}};ruleDef.prototype._doAudit=function(context,node){if(path.basename(context.filepath,".js")==="loader"||path.basename(context.filepath,".ts")==="loader"){const registerInfo=Utils.getLoaderRegisterInfo(context,node);if(registerInfo&®isterInfo.oldStyle){issue=new context.Issue(`Loader for Web Component registration uses deprecated oj.Register syntax`);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-ojcss"};ruleDef.prototype.getShortDescription=function(){return"Checks that the requirejs css! plugin is not used"};ruleDef.prototype.getDescription=function(){return"Teams should be using ojcss! in preference to css!"};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&&node.source.value.startsWith("css!")){const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);const issue=new context.Issue(`Component ${componentInfo.fullName} uses the requireJS css! plugin. The ojcss! plugin should be used instead`);context.reporter.addIssue(issue,context)}}};ruleDef.prototype._doAudit=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();let issue;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&&node.value.startsWith("css!")){const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(componentInfo){issue=new context.Issue(`Component ${componentInfo.fullName} uses the requireJS css! plugin. The ojcss! plugin should be used instead`);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-pack-children"};ruleDef.prototype.getShortDescription=function(){return"Ensure that all of the stated children of a pack are actually present and that we do not have any obvious orphans"};ruleDef.prototype.getDescription=function(){return"This rule inspects the physical structure of a pack and ensures that the declared child components are indeed present. We also check for un-registered children"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const componentMetadata=context.suppData.obj;if(componentMetadata){let issue;let emptyMembership=false;if(componentMetadata.type&&componentMetadata.type==="pack"){const packName=componentMetadata.name;const packRoot=path.dirname(context.filepath);if(componentMetadata.dependencies){const packMembers=Object.keys(componentMetadata.dependencies);if(packMembers.length>0){const packFileStructure=context.utils.fsUtils.readDir(packRoot);packMembers.forEach(fullName=>{if(!fullName.startsWith(packName)){issue=new context.Issue(`All members of the '${packName}' Pack should be named with the pack name prefix`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}if(!issue){const componentDir=fullName.slice(packName.length+1);const componentFolder=packFileStructure.filter(fileObj=>fileObj.name===componentDir&&!fileObj.file);if(componentFolder.length!==1){issue=new context.Issue(`Pack ${packName} dependency '${fullName}' should be defined in a folder called '${componentDir}' for referencing to work correctly`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}}});packFileStructure.map(child=>{if(!child.isFile){const matchesDeclaration=packMembers.filter(childComponent=>childComponent===`${packName}-${child.name}`);if(matchesDeclaration.length===0){const folderName=path.join(packRoot,child.name);const matchesComponent=Utils.matchComponentPath(context,folderName);if(matchesComponent){issue=new context.Issue(`Pack ${packName} seems to have a child component '${child.name}' that is not included in the dependencies of the pack`);issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context,"major")}}}})}else{emptyMembership=true}}else{emptyMembership=true}if(emptyMembership){let vcomponentsPresent=false;const allVisibleComponents=context.rulePack.getExtension().allComponents;allVisibleComponents.forEach(componentInfo=>{if(componentInfo.pack&&componentInfo.pack===packName&&componentInfo.vcomponent){vcomponentsPresent=true}});if(!vcomponentsPresent){issue=new context.Issue(`Pack '${componentMetadata.name}' has no defined members`);issue.setMsgKey(context.ruleName+"_4");context.reporter.addIssue(issue,context,"major")}}}}};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-packable-components"};ruleDef.prototype.getShortDescription=function(){return"Validate that components that are, or are not, defined as part of a pack"};ruleDef.prototype.getDescription=function(){return"This rule checks the type of a component and detects, in the case that it is part of a pack, if this should be the case (or not)"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const componentMetadata=context.suppData.obj;if(componentMetadata){let issue;const componentType=Utils.getComponentType(componentMetadata);const componentPack=componentMetadata.pack;switch(componentType){case"pack":case"reference":case"vbcs-template":if(componentPack){issue=new context.Issue(`Component '${componentMetadata.name}' (type: ${componentType}), should be defined as a singleton component, not as a member of a pack`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}break;case"resource":if(!componentPack){issue=new context.Issue(`Component '${componentMetadata.name}' (type: ${componentType}), should be defined as a member of a pack, not a singleton`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context)}break;case"demo":if(componentPack){issue=new context.Issue(`Component '${componentMetadata.name}', we advise that demo components are not included in a pack`);issue.setMsgKey(context.ruleName+"_3");context.reporter.addIssue(issue,context,"minor")}break}}};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-prerelease-dependencies"};ruleDef.prototype.getShortDescription=function(){return"Issue an info audit for any components that have pre-release dependencies"};ruleDef.prototype.getDescription=function(){return"This rule can be applied before production to ensure that all components depend, in turn, on release ready versions"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const componentMetadata=context.suppData.obj;const fullName=Utils.getComponentFullName(componentMetadata);if(componentMetadata.dependencies){const dependencyNames=Object.keys(componentMetadata.dependencies);dependencyNames.forEach(dependency=>{this._checkDependency(context,fullName,dependency,componentMetadata.dependencies[dependency])})}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo&&componentInfo.dependencies){componentInfo.dependencies.forEach(dependency=>{this._checkDependency(context,componentInfo.fullName,dependency.name,dependency.range)})}};ruleDef.prototype._checkDependency=function(context,fullName,dependency,version){const depRangeMin=context.utils.semVerUtils.minVersion(version);if(depRangeMin.prerelease.length>0){issue=new context.Issue(`Component dependency ${dependency} for ${fullName} has a pre-release version number`);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-prerelease-pattern"};ruleDef.prototype.getShortDescription=function(){return"Checks pattern of any pre-release version number"};ruleDef.prototype.getDescription=function(){return"This rule ensures that if a component has a pre-release version number it is one that conforms to one of the recommended patterns, e.g. -alpha|beta|rc.1 (keyword, incremented), -1 (incremented numerical), or -20190412T060000 (timestamp)"};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);this._checkPrereleasePattern(context,fullName,meta.version)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkPrereleasePattern(context,componentInfo.fullName,componentInfo.version)}};ruleDef.prototype._checkPrereleasePattern=function(context,fullName,version){const prereleases=context.utils.semVerUtils.prerelease(version);if(prereleases&&prereleases.length>0){const patterns=[/^alpha|beta|rc$/i,/^\d*$/,/^20\d{6}T\d*$/];if(!(patterns[0].test(prereleases[0])||patterns[1].test(prereleases[0])||patterns[2].test(prereleases[0]))){issue=new context.Issue(`Component ${fullName} has a pre-release version number that does not use a recommended pattern`);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-prerelease-version"};ruleDef.prototype.getShortDescription=function(){return"Issue an info audit for any components that are flagged with a pre-release version"};ruleDef.prototype.getDescription=function(){return"This rule can be applied before production to ensure that all components have correct release-worthy versions and are not still flagged as pre-releases"};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);this._checkForPrerelease(context,fullName,meta.version)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkForPrerelease(context,componentInfo.fullName,componentInfo.version)}};ruleDef.prototype._checkForPrerelease=function(context,fullName,version){const prereleases=context.utils.semVerUtils.prerelease(version);if(prereleases&&prereleases.length>0){issue=new context.Issue(`Component ${fullName} has a pre-release version number (${version})`);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-property-changed"};ruleDef.prototype.getShortDescription=function(){return"Checks for the existence of a propertyChanged function"};ruleDef.prototype.getDescription=function(){return"This rule ensures that any component that has properties also provides a propertyChanged lifecycle listener to handle async updates to those properties"};ruleDef.prototype.register=function(context){return{FunctionExpression:Utils.setupFileMethodMapping.bind(Utils),ArrowFunctionExpression:Utils.setupFileMethodMapping.bind(Utils),MethodDefinition:Utils.setupFileMethodMappingFromMethodDefintion.bind(Utils),CallExpression:Utils.deriveViewModels.bind(Utils),closedownRP:this._doAudit}};ruleDef.prototype._doAudit=function(context){let issue;if(context.rulePack.getExtension()){context.rulePack.getExtension().allComponents.forEach(compInfo=>{if(compInfo.viewModel&&compInfo.viewModel.resolved){if(!Utils.shouldIgnoreCheck(context,"jetwc-property-changed",compInfo.fullName)){if(compInfo.properties){const vmMethods=Utils.getVMMethodsForLocalComposite(context,compInfo);if(vmMethods&&!vmMethods.has("propertyChanged")){let reportSource=compInfo.fullName;if(compInfo.viewModel.resolved&&!compInfo.viewModel.skip){reportSource=compInfo.viewModel.path}issue=new context.Issue(`Component '${compInfo.fullName}' supports properties but does not provide a 'propertyChanged()' lifecycle method to react to async changes to those properties`);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 helperPos=require("../../rules/jet/helpers/json-propname-pos");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-property-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component properties have a display name defined"};ruleDef.prototype.getDescription=function(){return"This rule checks that any component properties and sub-properties have a display name supplied to make the user experience in Visual Builder 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._checkDisplayNames(context,Utils.getComponentFullName(context.suppData.obj),context.suppData.obj)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkDisplayNames(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkDisplayNames=function(context,componentName,componentInfo){let issue;const propertyList=Utils.flattenComponentProperties(componentInfo,"displayName");propertyList.forEach(prop=>{if(!prop.value){issue=new context.Issue(`displayName for property '${prop.key}' 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 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-property-nesting"};ruleDef.prototype.getShortDescription=function(){return"Checks for correct property nesting depth"};ruleDef.prototype.getDescription=function(){return"This rule determines the depth at which we are are happy to see nested properties. The default depth is 3, e.g. parent-child-grandchild. Setting to 1 would catch any use of subProperties"};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);const maxDepth=context.rulePack.getRuleOptions().depth?context.rulePack.getRuleOptions().depth:1;if(componentType==="composite"&&meta.properties){this._propertyDrill(context,fullName,meta,0,maxDepth)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo&&componentInfo.properties){const maxDepth=context.rulePack.getRuleOptions().depth?context.rulePack.getRuleOptions().depth:1;this._propertyDrill(context,componentInfo.fullName,componentInfo,0,maxDepth)}};ruleDef.prototype._propertyDrill=function(context,fullName,metadata,depth,maxDepth,recursion){depth++;const propKeys=Object.keys(metadata.properties);const propDepthCount=new Map;propKeys.forEach(propertyName=>{const checkProperty=metadata.properties[propertyName];if(checkProperty.hasOwnProperty("properties")){propDepthCount.set(propertyName,this._propertyDrill(context,fullName,checkProperty,depth,maxDepth,true))}else{propDepthCount.set(propertyName,depth)}if(!recursion&&propDepthCount.get(propertyName)>maxDepth){issue=new context.Issue(`Property '${propertyName}' in component ${fullName} exceeds the defined maximum level of property nesting. Max: ${maxDepth}, encountered: ${propDepthCount.get(propertyName)}`);context.reporter.addIssue(issue,context)}});let maxChild=depth;propDepthCount.forEach(depth=>{if(depth>maxChild){maxChild=depth}});return maxChild};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 helperPos=require("../../rules/jet/helpers/json-propname-pos");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-property-translatable"};ruleDef.prototype.getShortDescription=function(){return"Verify that properties with a given name have the translatable flag set "};ruleDef.prototype.getDescription=function(){return"To promote consistency amongst a set of components this audit will verify that properties or sub-properties with a given name e.g. pageTitle have the translatable flag set. This flag is primarily used in Visual Builder to guide users to set these properties to resource bundle references rather than hardcoded strings"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){this._checkForTranslatable(context,Utils.getComponentFullName(context.suppData.obj),context.suppData.obj)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkForTranslatable(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkForTranslatable=function(context,componentName,componentInfo){let issue;const customOpts=context.rulePack.getRuleOptions().customOpts;if(customOpts.translatableProperties&&Array.isArray(customOpts.translatableProperties)&&customOpts.translatableProperties.length>0){let matchExpressions;if(customOpts.expressionMatch){matchExpressions=[];customOpts.translatableProperties.forEach(expString=>{matchExpressions.push(new RegExp(expString,"i"))})}const propertyList=Utils.flattenComponentProperties(componentInfo,"translatable",this._propertyFilter);propertyList.forEach(prop=>{let needsTranslatableFlagSet=false;let matchKey=prop.key;if(matchKey.includes(".")){matchKey=matchKey.split(".").reverse()[0]}if(!matchExpressions&&customOpts.translatableProperties.includes(matchKey)&&!prop.value){needsTranslatableFlagSet=true}else if(matchExpressions?.length>0){matchExpressions.forEach(matchExpression=>{if(matchKey.match(matchExpression)&&!prop.value){needsTranslatableFlagSet=true}})}if(needsTranslatableFlagSet){issue=new context.Issue(`translatable flag should be set for property '${prop.key}'`);context.reporter.addIssue(issue,context)}})}};ruleDef.prototype._propertyFilter=function(propertyName,propertyMetadata){if(propertyMetadata.type==="string"&&!propertyMetadata.enumValues){return true}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 path=require("path");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-public-modules"};ruleDef.prototype.getShortDescription=function(){return"Ensure the publicModules definition in a resource component is valid"};ruleDef.prototype.getDescription=function(){return"This rule checks that any classes listed in publicModules are correctly specified and exist"};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);const componentRoot=path.dirname(context.filepath);if(componentType==="resource"&&meta.publicModules){meta.publicModules.forEach(modulePath=>{let checkPath=Utils.toJAFPath(path.join(componentRoot,modulePath));if(path.extname(modulePath)!==""){issue=new context.Issue(`Resource component ${fullName} publicModule references should not include file extension`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}else{if(!context.utils.fsUtils.fileExistsSync(checkPath+".js")){if(!context.utils.fsUtils.fileExistsSync(checkPath+".ts")){issue=new context.Issue(`Resource component ${fullName} publicModule reference '${modulePath}' does not exist as a JS or TS file`);issue.setMsgKey(context.ruleName+"_2");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 Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const path=require("path");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-reference-npm-path"};ruleDef.prototype.getShortDescription=function(){return"Ensures that reference components have an NPM path defined"};ruleDef.prototype.getDescription=function(){return"In order to be usable in local deployment mode, reference components must have npm path mappings defined as well as cdn path mappings"};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==="reference"||componentType==="mono-pack"&&meta.package){if(!meta.paths?.npm?.debug&&!meta.paths?.npm?.min){if(!Utils.shouldIgnoreCheck(context,"jetwc-reference-npm-path",fullName)){issue=new context.Issue(`Component ${fullName} (${componentType} component) ${componentType==="mono-pack"?"is marked as an NPM package and so ":""}must define npm path(s) to allow local installation`);issue.setMsgKey(context.ruleName);if(!meta.paths?.cdn){issue.setSeverity("blocker")}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-register-css"};ruleDef.prototype.getShortDescription=function(){return"Checks for usage of the deprecated registration of CSS files "};ruleDef.prototype.getDescription=function(){return"This rule ensures that components have been upgraded to remove any passing of CSS information to the register() API"};ruleDef.prototype.register=function(context){return{CallExpression:this._doAudit}};ruleDef.prototype._doAudit=function(context,node){if(path.basename(context.filepath,".js")==="loader"||path.basename(context.filepath,".ts")==="loader"){const registerInfo=Utils.getLoaderRegisterInfo(context,node);if(registerInfo&®isterInfo.registerCSS){issue=new context.Issue(`Loader for Web Component passes CSS information to the registration call. This is deprecated and the CSS! directive in the loader imports should be used instead`);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-register-with-promises"};ruleDef.prototype.getShortDescription=function(){return"Checks for usage of the deprecated promise syntax for registration"};ruleDef.prototype.getDescription=function(){return"This rule ensures that components have been upgraded to remove references to the deprecated oj.Register() syntax"};ruleDef.prototype.register=function(context){return{CallExpression:this._doAudit}};ruleDef.prototype._doAudit=function(context,node){if(path.basename(context.filepath,".js")==="loader"||path.basename(context.filepath,".ts")==="loader"){const registerInfo=Utils.getLoaderRegisterInfo(context,node);if(registerInfo&®isterInfo.usesPromises){issue=new context.Issue(`Loader for Web Component registration uses deprecated promise syntax in Register function`);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-require-paths"};ruleDef.prototype.getShortDescription=function(){return"Checks that any import paths used are valid"};ruleDef.prototype.getDescription=function(){return"This rule ensures that all path references (define, require or import) use paths that are valid in the context of the component. This list of valid paths will be constructed based on the declared and implicit dependencies of the component, combined with the standardPaths configuration property of the jetwc-require-paths rule which you can add to if needs be. The path \".\" is always valid. The path .. should not be used outside of the boundary of a given component, use the pack root instead."};ruleDef.prototype.register=function(context){return{CallExpression:this._doAuditRequireStyle,ImportDeclaration:this._doAuditImport,TSImportEqualsDeclaration:this._doAuditImportRequire}};ruleDef.prototype._doAuditRequireStyle=function(context,node){const ruleOptions=context.rulePack.getRuleOptions();const NT=context.utils.AstUtils.getNodeTypes();let issue;if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty("allComponents")){const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(withinComponent&&node.callee.type===NT.IDENTIFIER&&(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=>{if(arg.value){this._verifyPath(context,arg.value,componentInfo,node.callee.name)}})}else if(node.arguments[0].type===NT.LITERAL&&node.arguments[0].value){this._verifyPath(context,node.arguments[0].value,componentInfo,node.callee.name)}}}else{Utils.reportMissingBootstrapInfo(context,"allComponents")}};ruleDef.prototype._doAuditImport=function(context,node){if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty("allComponents")){const NT=context.utils.AstUtils.getNodeTypes();const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(componentInfo){if(node.source&&node.source.type===NT.LITERAL){const sourcePath=node.source.value;this._verifyPath(context,sourcePath,componentInfo,"import")}}}else{Utils.reportMissingBootstrapInfo(context,"allComponents")}};ruleDef.prototype._doAuditImportRequire=function(context,node){const NT=context.utils.AstUtils.getNodeTypes();if(context.rulePack.getExtension()&&context.rulePack.getExtension().hasOwnProperty("allComponents")){const withinComponent=Utils.matchComponentPath(context,path.dirname(context.filepath));const componentInfo=context.rulePack.getExtension().allComponents.get(withinComponent);if(componentInfo){if(node.moduleReference&&node.moduleReference.type===NT.EXTERN_MOD_REF&&node.moduleReference.expression){const sourcePath=node.moduleReference.expression.value;this._verifyPath(context,sourcePath,componentInfo,"importRequire")}}}else{Utils.reportMissingBootstrapInfo(context,"allComponents")}};ruleDef.prototype._verifyPath=function(context,pathToCheck,componentInfo,importType){if(pathToCheck&&typeof pathToCheck==="string"){let pathVerified=false;const allValidPaths=context.rulePack.getRuleOptions().standardPaths.slice(0);if(componentInfo.requirePaths){componentInfo.requirePaths.forEach(depPath=>{allValidPaths.push(depPath)})}let targetPath=pathToCheck;const pluginPos=targetPath.indexOf("!");if(pluginPos>=0){targetPath=targetPath.substring(pluginPos+1)}const targetPathParts=targetPath.split("/");if(targetPathParts[0]!==".."){if(allValidPaths.includes(targetPathParts[0])){pathVerified=true}else{if(targetPathParts[1]){const packCompPath=targetPathParts[0]+"/"+targetPathParts[1];if(allValidPaths.includes(packCompPath)){pathVerified=true}}}}else{let walkBackDepth=0;let examineSegment="..";while(examineSegment===".."){examineSegment=targetPathParts.shift();if(examineSegment===".."){walkBackDepth++}}const compRootPathParts=componentInfo.rootFolder.split("/");const importingFileParts=context.filepath.split("/");for(let i=walkBackDepth;i>=0;i--){importingFileParts.pop()}if(importingFileParts.length>=compRootPathParts.length){if(importingFileParts.slice(0,compRootPathParts.length).join("/")===componentInfo.rootFolder){pathVerified=true}}}if(!pathVerified){let sourceInfo;switch(importType){case"import":sourceInfo="Import";break;case"importRequire":sourceInfo="Import via require()";break;case"define":sourceInfo="Import via define()";break;case"require":sourceInfo="Import via require()";break};issue=new context.Issue(`${sourceInfo} for component ${componentInfo.fullName} is not based on a valid path in that component context. Valid paths would be [${allValidPaths.join(",")}] encountered: '${pathToCheck}'`);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-required-subproperty"};ruleDef.prototype.getShortDescription=function(){return"Checks for the required attribute setting on component sub-properties"};ruleDef.prototype.getDescription=function(){return"This rule checks that for complex properties (those with sub-properties) we do not have have a situation where the sub-property is defined as required. As a best practice, any required inputs to a component should really be top level properties."};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"&&meta.properties){const expandedProperties=[];this._propertyDrill(context,meta,expandedProperties);expandedProperties.forEach(prop=>{if(prop.defaultCount>0){issue=new context.Issue(`Component ${fullName}, nested property ${prop.propertyPath} has the required attribute set. Best practice dictates that only top-level properties should be marked as required.`);context.reporter.addIssue(issue,context)}})}}};ruleDef.prototype._propertyDrill=function(context,metadata,accumulator,parentInfo){const levelPath=parentInfo?parentInfo.propertyPath+".":"";const defaultCount=parentInfo?parentInfo.defaultCount:0;const propKeys=Object.keys(metadata.properties);propKeys.forEach(propertyName=>{const propertyMeta=metadata.properties[propertyName];if(!this._shouldIgnore(propertyMeta)){let runningCount=defaultCount;if(propertyMeta.hasOwnProperty("required")&&propertyMeta.required&&parentInfo){runningCount++}const propertyInfo={propertyPath:levelPath+propertyName,defaultCount:runningCount};if(propertyMeta.hasOwnProperty("properties")){this._propertyDrill(context,propertyMeta,accumulator,propertyInfo)}accumulator.push(propertyInfo)}})};ruleDef.prototype._shouldIgnore=function(metadataNode){if(metadataNode&&metadataNode.extension&&metadataNode.extension.audit&&metadataNode.extension.audit.ignore&&Array.isArray(metadataNode.extension.audit.ignore)&&metadataNode.extension.audit.ignore.includes(this.getName())){return true}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-reserved-property"};ruleDef.prototype.getShortDescription=function(){return"Check component does not a reserved word as a property name"};ruleDef.prototype.getDescription=function(){return"This rule checks that a component does not define a property that is on the list of reserved values e.g. slot, key, ref, children etc."};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._checkForReservedPropertyNames(context,fullName,meta)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo&&componentInfo.properties){this._checkForReservedPropertyNames(context,componentInfo.fullName,componentInfo)}};ruleDef.prototype._checkForReservedPropertyNames=function(context,fullName,componentMeta){if(componentMeta&&componentMeta.properties){const reservedProperties=context.rulePack.getRuleOptions().reserved;reservedProperties.forEach(reserved=>{if(componentMeta.properties.hasOwnProperty(reserved)){const issue=new context.Issue(`Component ${fullName} defines a property which uses a reserved name: '${reserved}'. You must select a different name for this property`);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-schema"};ruleDef.prototype.getShortDescription=function(){return"Validate component json definition against the schema"};ruleDef.prototype.getDescription=function(){return"This rule checks verifies the component.json file included by or generated from the component against the schema supplied for this purpose"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context,obj){let issue;if(context.suppData.obj){const jsonToValidate=obj.obj.component?obj.obj.component:obj.obj;const schemaErrors=context.utils.metaLib.applySchema(jsonToValidate);if(schemaErrors){schemaErrors.forEach(error=>{issue=new context.Issue(`component.json schema violation: ${this._formatViolation(error)}`);context.reporter.addIssue(issue,context)})}}};ruleDef.prototype._doVComponentAudit=function(context){const customOpts=context.rulePack.getRuleOptions().customOpts;let lenient=false;if(customOpts){lenient=customOpts.ignoreAdditionalProperties}const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo&&componentInfo.compiledMetadata){const jsonToValidate=context.utils.fsUtils.readJsonSync(componentInfo.compiledMetadata);const schemaErrors=context.utils.metaLib.applySchema(jsonToValidate);if(schemaErrors){const encounteredErrors=new Set;schemaErrors.forEach(report=>{const skip=lenient&&report.error&&report.error.keyword==="additionalProperties";if(!skip){const formattedError=this._formatViolation(report);if(!encounteredErrors.has(formattedError)){encounteredErrors.add(formattedError);issue=new context.Issue(`Generated component.json has schema violation: ${formattedError}`);context.reporter.addIssue(issue,context)}}})}}};ruleDef.prototype._formatViolation=function(report){let formattedMsg;switch(report.error.keyword){case"required":const jsonErrorPath=report.error.dataPath?report.error.dataPath:report.error.instancePath;const formattedPath=this._transformViolationDataPath(jsonErrorPath);formattedMsg=`${formattedPath} ${report.msg}`;break;default:formattedMsg=report.msg}return formattedMsg};ruleDef.prototype._transformViolationDataPath=function(dataPath){let formatted=dataPath;;const parser=/\.(\w*)\['(\w*)'\]/g;const segparser=/\.(\w*)\['(\w*)'\]/;const instancePathParser=/\/(\w*)\/(\w*)/g;const instancePathSegParser=/\/(\w*)\/(\w*)/;let segments=dataPath.match(parser);let deconstructed;if(segments!==null){deconstructed=segments.map(seg=>{subParts=seg.match(segparser);return{segment:subParts[0],type:subParts[1],context:subParts[2]}})}else{segments=dataPath.match(instancePathParser);deconstructed=segments.map(seg=>{subParts=seg.match(instancePathSegParser);return{segment:subParts[0],type:subParts[1],context:subParts[2]}})}if(deconstructed&&deconstructed.length>0){if(deconstructed[0].type==="properties"){formatted=`Property ${deconstructed[0].context}`;if(deconstructed.length>1){for(let i=1;i<deconstructed.length;i++){if(deconstructed[i].type==="properties"){formatted+=`.${deconstructed[i].context}`}else{formatted+=` ${deconstructed[i].type}:${deconstructed[i].context}`}}}}}return formatted};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-semantic-version"};ruleDef.prototype.getShortDescription=function(){return"Verify the component has a valid Semver"};ruleDef.prototype.getDescription=function(){return"This rule ensures that a valid semantic version has been used for this component"};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 componentVersionValid=context.utils.semVerUtils.isValid(meta.version);if(!componentVersionValid||meta.version.toLowerCase().startsWith("v")){issue=new context.Issue(`Component ${fullName} has version number which is not in strict semantic versioning format (${meta.version})`);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-slot-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component has display name defined for slots"};ruleDef.prototype.getDescription=function(){return"This rule checks that slots 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._checkSlots(context,meta.slots)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkSlots(context,componentInfo.slots)}};ruleDef.prototype._checkSlots=function(context,slots){let issue;if(slots){Object.keys(slots).forEach(slotName=>{if(!slots[slotName].displayName){issue=new context.Issue(`displayName for ${slotName===""?"default slot":"slot '"+slotName+"'"} 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-slots"};ruleDef.prototype.getShortDescription=function(){return"Verify slots are declared"};ruleDef.prototype.getDescription=function(){return"This rule checks that any slots used are declared in the metadata"};ruleDef.prototype.register=function(context){return{"<oj-bind-slot>":this._doAudit}};ruleDef.prototype._doAudit=function(context){let issue;const componentName=Utils.matchComponentPath(context,path.dirname(context.filepath));if(componentName){const slotName=context.tagNode.attribs.name;if(!slotName||!context.utils.DomUtils.isExpression(slotName)){const componentSlots=Utils.componentInfo(context,componentName).slots;if(!componentSlots||slotName&&!componentSlots.hasOwnProperty(slotName)||!slotName&&!componentSlots.hasOwnProperty("")){issue=new context.Issue(`Slot '${slotName?slotName:"default"}' for component ${componentName} has not been declared in the component metadata`);issue.setMsgKey(context.ruleName+"_1");context.reporter.addIssue(issue,context)}else{const slotDetail=componentSlots[slotName?slotName:""];if(slotDetail.data){issue=new context.Issue(`Slot '${slotName?slotName:"default"}' for component ${componentName} has been declared with a data attribute in the component metadata. The data attribute only applies for template slots`);issue.setMsgKey(context.ruleName+"_2");context.reporter.addIssue(issue,context,"minor")}}}}};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-standard-files"};ruleDef.prototype.getShortDescription=function(){return"Checks for the existence of standard informational files"};ruleDef.prototype.getDescription=function(){return"This rule ensures that standard files such as readmes are included"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){const componentMetadata=context.suppData.obj;if(componentMetadata){const fullName=Utils.getComponentFullName(componentMetadata);this._checkForStandardFiles(context,fullName,componentMetadata.version,componentMetadata.type)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkForStandardFiles(context,componentInfo.fullName,componentInfo.version,"composite")}};ruleDef.prototype._checkForStandardFiles=function(context,fullName,version,componentType){const componentFiles=context.utils.fsUtils.readDir(Utils.getDirectoryName(context.filepath));const checkForFiles=context.rulePack.getRuleOptions().files;checkForFiles.forEach(requiredFile=>{let exclusion=false;switch(requiredFile.toLowerCase()){case"changelog.md":case"changelog.txt":case"changes.txt":if(componentType&&componentType==="reference"){exclusion=true}else{if(version&&context.utils.semVerUtils.gt("1.0.1",version)){exclusion=true}}break}if(!exclusion){let hits=componentFiles.filter(compFile=>compFile.name===requiredFile&&compFile.isFile);if(hits.length===0){const issue=new context.Issue(`Required supporting file ${requiredFile} is not present for component ${fullName}`);context.reporter.addIssue(issue,context)}}})};module.exports=ruleDef;
|