/*
 * Copyright (c) 2018, 2025, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
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;