# UI5 Linter - Complete Autofix Reference **Source**: [https://github.com/UI5/linter/blob/main/docs/Scope-of-Autofix.md](https://github.com/UI5/linter/blob/main/docs/Scope-of-Autofix.md) **Last Updated**: 2025-11-21 **UI5 Linter Version**: 1.20.5 --- ## Overview The UI5 Linter's autofix feature (`--fix` flag) can automatically correct certain categories of issues. However, the documentation explicitly states: **"This list is not exhaustive; there are more APIs that are currently not replaced automatically."** This reference provides comprehensive coverage of what can and cannot be automatically fixed. --- ## Using Autofix ### Basic Usage ```bash # Apply fixes to all files ui5lint --fix # Fix specific files ui5lint --fix "webapp/**/*.js" # Preview fixes without applying (dry-run mode) UI5LINT_FIX_DRY_RUN=true ui5lint --fix ``` ### Dry-Run Mode Before applying fixes, preview changes using the environment variable: ```bash UI5LINT_FIX_DRY_RUN=true ui5lint --fix ``` This shows what would be changed without modifying any files. --- ## Rules with Autofix Support ### 1. no-globals ✅ **What It Fixes**: Replaces UI5 global references with corresponding module imports. **Example**: ```javascript // Before: function onInit() { const core = sap.ui.getCore(); const control = core.byId("myControl"); } // After: import Core from "sap/ui/core/Core"; function onInit() { const core = Core; const control = core.byId("myControl"); } ``` **Limitations**: - ❌ Cannot fix assignments to global variables - ❌ Cannot handle `delete` expressions on globals - ❌ Third-party module access via globals (like `jQuery`) not handled --- ### 2. no-deprecated-api ✅ (Partial) **What It Fixes**: Multiple categories of deprecated API usage. #### Category A: Configuration Facade Replacements **Core.getConfiguration() Methods**: Replaces deprecated `Core.getConfiguration()` method calls with modern equivalents. ```javascript // Before: import Core from "sap/ui/core/Core"; const config = Core.getConfiguration(); const language = config.getLanguage(); // After: import Localization from "sap/base/i18n/Localization"; const language = Localization.getLanguage(); ``` **Supported Configuration Methods** (Partial List): - `getLanguage()` → `sap/base/i18n/Localization.getLanguage()` - `getAnimationMode()` → `sap/ui/core/AnimationMode.getAnimationMode()` - `getTimezone()` → `sap/base/i18n/Localization.getTimezone()` **Not Supported** (~20 methods, see Issue #620): - `getAnimation()` - `getAppCacheBuster()` - `getCompatibilityVersion()` - `getFormatSettings()` (requires complex manual replacement) - `getDebug()`, `getInspect()`, `getOriginInfo()` (no alternatives) - Many others... --- #### Category B: Core Facade Replacements **Core API Methods**: ```javascript // Before: import Core from "sap/ui/core/Core"; Core.loadLibrary("sap.m", {async: true}); // After: import Lib from "sap/ui/core/Lib"; Lib.load({name: "sap.m"}); ``` **Supported Core Methods** (Partial List): - `loadLibrary()` → `sap/ui/core/Lib.load()` (with `async: true` only) - `byId()` → `sap/ui/core/Element.getElementById()` - `getLibraryResourceBundle()` → `sap/ui/core/Lib.getResourceBundleFor()` **Not Supported** (~30+ methods, see Issue #619): **Template & Rendering** (discarded concepts): - `getTemplate()` - `createRenderManager()` - `getRenderManager()` **Event Handlers** (different APIs): - `attachLocalizationChanged()` - Event attachment methods discontinued **Error Management** (only on ManagedObject): - Format/parse/validation error methods **Model Operations** (only on ManagedObject): - `getModel()`, `setModel()`, `hasModel()` **Component/Application** (no replacements): - `getApplication()` - `getRootComponent()` - `getLoadedLibraries()` - `createUIArea()`, `getUIArea()` **Other** (discarded or no alternatives): - `applyChanges()` - `isLocked()`, `lock()`, `unlock()` - `registerPlugin()` - `setRoot()`, `setThemeRoot()` --- #### Category C: Button Event Handler Migration **tap → press Event**: ```javascript // Before: new Button({ tap: function() { console.log("Tapped"); } }); // After: new Button({ press: function() { console.log("Pressed"); } }); ``` **XML Views**: ```xml