
UI5 linter is the tool of choice to check your UI5 project for using best practices and replacement of deprecated UI5 APIs. Last year, we focused on the detection capabilities of UI5 linter. In early 2025, we started on an actual migration functionality to be offered by UI5 linter, a.k.a "Autofix". Right from the beginning, our goal was to provide a similar developer experience as offered by the famous ESLint project. With UI5 linter v1.12.0, we are happy to announce the initial version of an autofix feature. You can directly use the "--fix" argument to let UI5 linter apply fixes to your code automatically.
In our initial autofix version, UI5 linter can replace the deprecated usage of UI5 globals with our recommended way of importing the respective module and using the local name in your code.
Let’s try it out! In our application we have used the deprecated global notation when creating an sap.ui.model.json.JSONModel instance:
sap.ui.define([
"sap/ui/core/mvc/Controller"
], (Controller) => {
"use strict";
return Controller.extend("ui5.app.controller.Home", {
onInit() {
this.getView().setModel(new sap.ui.model.json.JSONModel({
achievement: "UI5 linter Autofix has landed"
}));
}
});
});
Now, let’s execute UI5 linter to see whether it detects the deprecated usage of the JSON model. Simply call "ui5lint" in a shell of your choice.
> ui5lint
UI5 linter report:
/ui5-app/webapp/controller/Home.controller.js
8:41 error Access of global variable 'sap' (sap.ui.model.json.JSONModel) no-globals
1 problems (1 errors, 0 warnings)
Run 'ui5lint --fix' to resolve all auto-fixable problems
Note: Run 'ui5lint --details' to get more information on the findings
Got it! UI5 linter has found the issue. We could fix the issue on our own or we can let UI5 linter do the job for us by executing "ui5lint --fix".
> ui5lint --fix
UI5 linter report:
0 problems (0 errors, 0 warnings)
Yay! UI5 linter says it was able to fix my code. Let’s see whether UI5 linter is right:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel"
], (Controller, JSONModel) => {
"use strict";
return Controller.extend("ui5.app.controller.Home", {
onInit() {
this.getView().setModel(new JSONModel({
achievement: "UI5 linter Autofix has landed"
}));
}
});
});
There are plenty of other deprecation types waiting to be fixed automatically by UI5 linter, and our team puts a huge focus on giving you an update here soon. See our roadmap https://github.com/SAP/ui5-linter/issues/323 to get an overview of our planned upcoming features.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
17 | |
16 | |
12 | |
12 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 |