fix-js-globals
Fix JavaScript Global Access (no-globals)
Fixes no-globals errors in JavaScript files that the UI5 linter detects but cannot auto-fix. Run npx @ui5/linter --details to get replacement suggestions and documentation links.
Key Rules — Read Before Applying Any Fix
-
jQuery/$ globals — preserve jQuery API calls: When fixing jQuery/$ globals, ONLY add the
sap/ui/thirdparty/jquerydependency and replace$withjQuery. Do NOT replace standard jQuery API calls (jQuery.each,jQuery.extend,jQuery.proxy,jQuery.isEmptyObject, etc.) with native JavaScript equivalents. These are standard jQuery methods, not deprecated SAP APIs. -
Case 9/10 — fix ALL globals in a single pass: When converting a file from
jQuery.sap.declare/requiretosap.ui.define(Case 9 or 10), you MUST also fix ALL other global-access patterns inside the file body in the same pass. There is no second pass — everything must be handled at once. Read the "Apply ALL Applicable Cases in a Single Pass" section below. -
Dead code — delete, don't import: If a global assignment stores a value that is never read anywhere else in the file (e.g.,
this.BarColor = sap.ui.core.BarColorwherethis.BarColornever appears again), delete the entire statement. Do NOT add an import for it. -
No intermediate forms for byId in controllers:
sap.ui.getCore().byId("prefix--id")orjQuery("#prefix--id").control(0)inside a controller →this.byId("id")directly. Never leave it asElement.getElementById("prefix--id"). After replacing, remove unusedElementorjQueryimports. -
merge, not deepExtend:
jQuery.sap.extend(true, ...)→merge()fromsap/base/util/merge. The modulesap/base/util/deepExtenddoes NOT exist.