Skip to content

Commit e117736

Browse files
committed
[FEATURE] Migrate to ECMAScript 2022 syntax
1 parent 0021bb8 commit e117736

File tree

18 files changed

+233
-232
lines changed

18 files changed

+233
-232
lines changed

.eslintrc.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"env": {
3-
"browser": true
3+
"browser": true,
4+
"es2022": "true"
45
},
6+
"extends": "eslint:recommended",
57
"globals": {
68
"sap": true,
79
"jQuery": true
810
},
911
"rules": {
10-
"block-scoped-var": 1,
1112
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
1213
"consistent-this": 2,
1314
"no-div-regex": 2,
1415
"no-floating-decimal": 2,
1516
"no-self-compare": 2,
1617
"no-mixed-spaces-and-tabs": [2, true],
1718
"no-nested-ternary": 2,
18-
"no-unused-vars": [2, {"vars":"all", "args":"none"}],
1919
"radix": 2,
2020
"keyword-spacing": 2,
2121
"space-unary-ops": 2,
@@ -49,6 +49,9 @@
4949
"comma-spacing": 0,
5050
"no-multi-spaces": 0,
5151
"no-shadow": 0,
52-
"no-irregular-whitespace": 0
52+
"no-irregular-whitespace": 0,
53+
"no-var": 2,
54+
"no-const-assign": 2,
55+
"prefer-const": 2
5356
}
5457
}

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = function(config) {
22
"use strict";
33

4-
var chromeFlags = [
4+
const chromeFlags = [
55
"--window-size=1280,1024"
66
];
77

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openui5-sample-app",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Sample of an OpenUI5 app",
55
"private": true,
66
"engines": {

ui5.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
specVersion: '2.0'
1+
specVersion: '3.0'
22
metadata:
33
name: openui5-sample-app
44
type: application

webapp/Component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sap.ui.define(["sap/ui/core/UIComponent", "sap/ui/core/ComponentSupport"], function(UIComponent) {
1+
sap.ui.define(["sap/ui/core/UIComponent", "sap/ui/core/ComponentSupport"], (UIComponent) => {
22
"use strict";
33
return UIComponent.extend("sap.ui.demo.todo.Component", {
44
metadata: {

webapp/controller/App.controller.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ sap.ui.define([
44
"sap/ui/model/Filter",
55
"sap/ui/model/FilterOperator",
66
"sap/ui/model/json/JSONModel"
7-
], function(Device, Controller, Filter, FilterOperator, JSONModel) {
7+
], (Device, Controller, Filter, FilterOperator, JSONModel) => {
88
"use strict";
99

1010
return Controller.extend("sap.ui.demo.todo.controller.App", {
1111

12-
onInit: function() {
12+
onInit() {
1313
this.aSearchFilters = [];
1414
this.aTabFilters = [];
1515

@@ -22,9 +22,9 @@ sap.ui.define([
2222
/**
2323
* Adds a new todo item to the bottom of the list.
2424
*/
25-
addTodo: function() {
26-
var oModel = this.getView().getModel();
27-
var aTodos = oModel.getProperty("/todos").map(function (oTodo) { return Object.assign({}, oTodo); });
25+
addTodo() {
26+
const oModel = this.getView().getModel();
27+
const aTodos = oModel.getProperty("/todos").map((oTodo) => Object.assign({}, oTodo));
2828

2929
aTodos.push({
3030
title: oModel.getProperty("/newTodo"),
@@ -38,13 +38,13 @@ sap.ui.define([
3838
/**
3939
* Removes all completed items from the todo list.
4040
*/
41-
clearCompleted: function() {
42-
var oModel = this.getView().getModel();
43-
var aTodos = oModel.getProperty("/todos").map(function (oTodo) { return Object.assign({}, oTodo); });
41+
clearCompleted() {
42+
const oModel = this.getView().getModel();
43+
const aTodos = oModel.getProperty("/todos").map((oTodo) => Object.assign({}, oTodo));
4444

45-
var i = aTodos.length;
45+
let i = aTodos.length;
4646
while (i--) {
47-
var oTodo = aTodos[i];
47+
const oTodo = aTodos[i];
4848
if (oTodo.completed) {
4949
aTodos.splice(i, 1);
5050
}
@@ -56,13 +56,11 @@ sap.ui.define([
5656
/**
5757
* Updates the number of items not yet completed
5858
*/
59-
updateItemsLeftCount: function() {
60-
var oModel = this.getView().getModel();
61-
var aTodos = oModel.getProperty("/todos") || [];
59+
updateItemsLeftCount() {
60+
const oModel = this.getView().getModel();
61+
const aTodos = oModel.getProperty("/todos") || [];
6262

63-
var iItemsLeft = aTodos.filter(function(oTodo) {
64-
return oTodo.completed !== true;
65-
}).length;
63+
const iItemsLeft = aTodos.filter((oTodo) => oTodo.completed !== true).length;
6664

6765
oModel.setProperty("/itemsLeftCount", iItemsLeft);
6866
},
@@ -71,8 +69,8 @@ sap.ui.define([
7169
* Trigger search for specific items. The removal of items is disable as long as the search is used.
7270
* @param {sap.ui.base.Event} oEvent Input changed event
7371
*/
74-
onSearch: function(oEvent) {
75-
var oModel = this.getView().getModel();
72+
onSearch(oEvent) {
73+
const oModel = this.getView().getModel();
7674

7775
// First reset current filters
7876
this.aSearchFilters = [];
@@ -81,7 +79,7 @@ sap.ui.define([
8179
this.sSearchQuery = oEvent.getSource().getValue();
8280
if (this.sSearchQuery && this.sSearchQuery.length > 0) {
8381
oModel.setProperty("/itemsRemovable", false);
84-
var filter = new Filter("title", FilterOperator.Contains, this.sSearchQuery);
82+
const filter = new Filter("title", FilterOperator.Contains, this.sSearchQuery);
8583
this.aSearchFilters.push(filter);
8684
} else {
8785
oModel.setProperty("/itemsRemovable", true);
@@ -90,7 +88,7 @@ sap.ui.define([
9088
this._applyListFilters();
9189
},
9290

93-
onFilter: function(oEvent) {
91+
onFilter(oEvent) {
9492
// First reset current filters
9593
this.aTabFilters = [];
9694

@@ -113,13 +111,13 @@ sap.ui.define([
113111
this._applyListFilters();
114112
},
115113

116-
_applyListFilters: function() {
117-
var oList = this.byId("todoList");
118-
var oBinding = oList.getBinding("items");
114+
_applyListFilters() {
115+
const oList = this.byId("todoList");
116+
const oBinding = oList.getBinding("items");
119117

120118
oBinding.filter(this.aSearchFilters.concat(this.aTabFilters), "todos");
121119

122-
var sI18nKey;
120+
let sI18nKey;
123121
if (this.sFilterKey && this.sFilterKey !== "all") {
124122
if (this.sFilterKey === "active") {
125123
sI18nKey = "ACTIVE_ITEMS";
@@ -134,9 +132,9 @@ sap.ui.define([
134132
sI18nKey = "ITEMS_CONTAINING";
135133
}
136134

137-
var sFilterText;
135+
let sFilterText;
138136
if (sI18nKey) {
139-
var oResourceBundle = this.getView().getModel("i18n").getResourceBundle();
137+
const oResourceBundle = this.getView().getModel("i18n").getResourceBundle();
140138
sFilterText = oResourceBundle.getText(sI18nKey, [this.sSearchQuery]);
141139
}
142140

webapp/test/integration/AllJourneys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sap.ui.define([
44
"sap/ui/demo/todo/test/integration/TodoListJourney",
55
"sap/ui/demo/todo/test/integration/SearchJourney",
66
"sap/ui/demo/todo/test/integration/FilterJourney"
7-
], function(Opa5, Startup) {
7+
], (Opa5, Startup) => {
88
"use strict";
99

1010
Opa5.extendConfig({

webapp/test/integration/FilterJourney.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
sap.ui.define([
44
"sap/ui/test/opaQunit",
55
"sap/ui/demo/todo/test/integration/pages/App"
6-
], function (opaTest) {
6+
], (opaTest) => {
77
"use strict";
88

99
QUnit.module("Filter");
1010

11-
opaTest("should show correct items when filtering for 'Active' items", function (Given, When, Then) {
11+
opaTest("should show correct items when filtering for 'Active' items", (Given, When, Then) => {
1212

1313
// Arrangements
1414
Given.iStartMyApp();
@@ -23,7 +23,7 @@ sap.ui.define([
2323
Then.iTeardownMyApp();
2424
});
2525

26-
opaTest("should show correct items when filtering for 'Completed' items", function (Given, When, Then) {
26+
opaTest("should show correct items when filtering for 'Completed' items", (Given, When, Then) => {
2727

2828
// Arrangements
2929
Given.iStartMyApp();
@@ -38,7 +38,7 @@ sap.ui.define([
3838
Then.iTeardownMyApp();
3939
});
4040

41-
opaTest("should show correct items when filtering for 'Completed' items and switch back to 'All'", function (Given, When, Then) {
41+
opaTest("should show correct items when filtering for 'Completed' items and switch back to 'All'", (Given, When, Then) => {
4242

4343
// Arrangements
4444
Given.iStartMyApp();

webapp/test/integration/SearchJourney.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sap.ui.define([
44
"sap/ui/Device",
55
"sap/ui/test/opaQunit",
66
"sap/ui/demo/todo/test/integration/pages/App"
7-
], function (Device, opaTest) {
7+
], (Device, opaTest) => {
88
"use strict";
99

1010
QUnit.module("Search");
@@ -14,7 +14,7 @@ sap.ui.define([
1414
return;
1515
}
1616

17-
opaTest("should show correct item count after search (1)", function (Given, When, Then) {
17+
opaTest("should show correct item count after search (1)", (Given, When, Then) => {
1818

1919
// Arrangements
2020
Given.iStartMyApp();
@@ -29,7 +29,7 @@ sap.ui.define([
2929
Then.iTeardownMyApp();
3030
});
3131

32-
opaTest("should show correct item count after search (0)", function (Given, When, Then) {
32+
opaTest("should show correct item count after search (0)", (Given, When, Then) => {
3333

3434
// Arrangements
3535
Given.iStartMyApp();
@@ -44,7 +44,7 @@ sap.ui.define([
4444
Then.iTeardownMyApp();
4545
});
4646

47-
opaTest("should show correct item count after search and clearing the search", function (Given, When, Then) {
47+
opaTest("should show correct item count after search and clearing the search", (Given, When, Then) => {
4848

4949
// Arrangements
5050
Given.iStartMyApp();
@@ -60,7 +60,7 @@ sap.ui.define([
6060
Then.iTeardownMyApp();
6161
});
6262

63-
opaTest("should show correct item count after search and active items filter", function (Given, When, Then) {
63+
opaTest("should show correct item count after search and active items filter", (Given, When, Then) => {
6464

6565
// Arrangements
6666
Given.iStartMyApp();
@@ -76,7 +76,7 @@ sap.ui.define([
7676
Then.iTeardownMyApp();
7777
});
7878

79-
opaTest("should show correct item count after search and completed items filter", function (Given, When, Then) {
79+
opaTest("should show correct item count after search and completed items filter", (Given, When, Then) => {
8080

8181
// Arrangements
8282
Given.iStartMyApp();
@@ -92,7 +92,7 @@ sap.ui.define([
9292
Then.iTeardownMyApp();
9393
});
9494

95-
opaTest("should show correct item count after search and all items filter", function (Given, When, Then) {
95+
opaTest("should show correct item count after search and all items filter", (Given, When, Then) => {
9696

9797
// Arrangements
9898
Given.iStartMyApp();

0 commit comments

Comments
 (0)