From a1c0a07b6f28a1c66ebbc606f28fe82a7730cb57 Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Mon, 8 Apr 2024 15:18:02 +0200 Subject: [PATCH] refactor: eslint error fixes --- .../src/my/lib/sample/base/BaseController.js | 10 +-- .../src/my/lib/sample/base/Component.js | 64 +++++++-------- .../src/my/lib/sample/base/library.js | 5 +- .../src/my/lib/sample/categories/Component.js | 2 +- .../categories/controller/App.controller.js | 2 +- .../controller/Detail.controller.js | 45 +++++------ .../categories/controller/List.controller.js | 20 +++-- .../categories/localService/mockserver.js | 68 ++++++++-------- .../sample/categories/test/initMockServer.js | 25 +++--- .../src/my/lib/sample/products/Component.js | 20 ++--- .../products/controller/App.controller.js | 2 +- .../products/controller/Detail.controller.js | 77 +++++++++--------- .../products/controller/List.controller.js | 40 +++++----- .../products/localService/mockserver.js | 68 ++++++++-------- .../sample/products/test/initMockServer.js | 25 +++--- demo/RootComponent/webapp/Component.js | 26 ++++--- .../webapp/controller/App.controller.js | 28 +++---- .../webapp/controller/Home.controller.js | 6 +- .../webapp/localService/mockserver.js | 78 ++++++++++--------- .../webapp/test/initMockServer.js | 25 +++--- .../webapp/test/integration/AllJourneys.js | 2 +- .../test/integration/NavigationJourney.js | 6 +- .../test/integration/arrangements/Startup.js | 20 ++--- .../webapp/test/integration/opaTests.qunit.js | 4 +- .../webapp/test/integration/pages/App.js | 20 ++--- .../webapp/test/integration/pages/Home.js | 14 ++-- .../webapp/test/testsuite.qunit.js | 9 ++- .../webapp/test/unit/AllTests.js | 2 +- .../webapp/test/unit/base/BaseController.js | 7 +- .../webapp/test/unit/unitTests.qunit.js | 4 +- .../src/my/lib/sample/suppliers/Component.js | 2 +- .../suppliers/controller/App.controller.js | 2 +- .../suppliers/controller/Detail.controller.js | 44 +++++------ .../suppliers/controller/List.controller.js | 12 +-- .../suppliers/localService/mockserver.js | 68 ++++++++-------- .../sample/suppliers/test/initMockServer.js | 25 +++--- demo/eslint.config.mjs | 21 ++++- demo/package.json | 4 +- 38 files changed, 462 insertions(+), 440 deletions(-) diff --git a/demo/BaseComponent/src/my/lib/sample/base/BaseController.js b/demo/BaseComponent/src/my/lib/sample/base/BaseController.js index 54aeed3c3..c51f26219 100644 --- a/demo/BaseComponent/src/my/lib/sample/base/BaseController.js +++ b/demo/BaseComponent/src/my/lib/sample/base/BaseController.js @@ -1,15 +1,15 @@ sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/base/Log" -], function(Controller, Log) { +], (Controller, Log) => { "use strict"; return Controller.extend("my.lib.sample.base.BaseController", { - onInit: function() { - Log.info(this.getView().getControllerName(), "onInit"); + base64StringToImage(picture) { + return picture ? `data:image/bmp;base64,${ picture}` : null; }, - base64StringToImage: function(picture) { - return picture ? "data:image/bmp;base64," + picture : null; + onInit() { + Log.info(this.getView().getControllerName(), "onInit"); } }); }); diff --git a/demo/BaseComponent/src/my/lib/sample/base/Component.js b/demo/BaseComponent/src/my/lib/sample/base/Component.js index 3754ad06b..a2e909c9f 100644 --- a/demo/BaseComponent/src/my/lib/sample/base/Component.js +++ b/demo/BaseComponent/src/my/lib/sample/base/Component.js @@ -1,14 +1,14 @@ sap.ui.define([ "sap/ui/core/UIComponent", "sap/base/util/deepClone" -], function(UIComponent, deepClone) { +], (UIComponent, deepClone) => { "use strict"; return UIComponent.extend("my.lib.sample.base.Component", { - init: function() { - UIComponent.prototype.init.apply(this, arguments); + init(...args) { + UIComponent.prototype.init.apply(this, args); - var oRouter = this.getRouter(); + const oRouter = this.getRouter(); oRouter.getViews().attachCreated(this._processEventMappingOnTargetCreated, this); oRouter.initialize(); }, @@ -32,55 +32,57 @@ sap.ui.define([ * @param {object} oEvent The event object which is provided by the 'created' event from * router's target cache */ - _processEventMappingOnTargetCreated: function(oEvent) { + _processEventMappingOnTargetCreated(oEvent) { if (!this.eventMappings) { return; } - var sType = oEvent.getParameter("type"); - var oObject = oEvent.getParameter("object"); - var oOptions = oEvent.getParameter("options"); - var that = this; - var aEvents; - - function processComponentTargetInfo(oComponentTargetInfo, oEvent) { - Object.keys(oComponentTargetInfo).forEach(function(sTargetName) { - var oInfo = oComponentTargetInfo[sTargetName]; + const sType = oEvent.getParameter("type"), + oObject = oEvent.getParameter("object"), + oOptions = oEvent.getParameter("options"), + that = this, + processComponentTargetInfo = (oComponentTargetInfo, oEv) => { + Object.keys(oComponentTargetInfo).forEach((sTargetName) => { + const oInfo = oComponentTargetInfo[sTargetName]; if (oInfo.parameters) { - Object.keys(oInfo.parameters).forEach(function(sName) { - var sParamName = oInfo.parameters[sName]; - var sEventValue = oEvent.getParameter(sParamName); + Object.keys(oInfo.parameters).forEach((sName) => { + const sParamName = oInfo.parameters[sName], + sEventValue = oEv.getParameter(sParamName); - // expand the parameter mapping with the parameter value from - // the event + /* + * Expand the parameter mapping with the parameter value from + * the event + */ oInfo.parameters[sName] = sEventValue; }); } if (oInfo.componentTargetInfo) { - processComponentTargetInfo(oInfo.componentTargetInfo, oEvent); + processComponentTargetInfo(oInfo.componentTargetInfo, oEv); } }); - } + }; if (sType === "Component") { - aEvents = this.eventMappings[oOptions.usage]; + const aEvents = this.eventMappings[oOptions.usage]; if (Array.isArray(aEvents)) { - aEvents.forEach(function(oEventMapping) { - oObject.attachEvent(oEventMapping.name, function(oEvent) { - var oComponentTargetInfo; - if (oEventMapping.route) { // route information defined, call 'navTo' + aEvents.forEach((oEventMapping) => { + oObject.attachEvent(oEventMapping.name, (oEv) => { + let oComponentTargetInfo = {}; + if (oEventMapping.route) { // Route information defined, call 'navTo' if (oEventMapping.componentTargetInfo) { - // if there's information for component target defined, replace the - // event parameter mapping with the value from the event object + /* + * If there's information for component target defined, replace the + * event parameter mapping with the value from the event object + */ oComponentTargetInfo = deepClone(oEventMapping.componentTargetInfo); - processComponentTargetInfo(oComponentTargetInfo, oEvent); + processComponentTargetInfo(oComponentTargetInfo, oEv); } that.getRouter().navTo(oEventMapping.route, {}, oComponentTargetInfo); - } else if (oEventMapping.forward) { // event should be forwarded with the same parameters - that.fireEvent(oEventMapping.forward, oEvent.getParameters()); + } else if (oEventMapping.forward) { // Event should be forwarded with the same parameters + that.fireEvent(oEventMapping.forward, oEv.getParameters()); } }); }); diff --git a/demo/BaseComponent/src/my/lib/sample/base/library.js b/demo/BaseComponent/src/my/lib/sample/base/library.js index 9cd766b15..bcfbff448 100644 --- a/demo/BaseComponent/src/my/lib/sample/base/library.js +++ b/demo/BaseComponent/src/my/lib/sample/base/library.js @@ -1,15 +1,16 @@ -sap.ui.define(function() { +sap.ui.define(() => { "use strict"; sap.ui.getCore().initLibrary({ name : "my.lib.sample.base", + // eslint-disable-next-line no-template-curly-in-string version : "${version}", noLibraryCSS: true, dependencies : [ "sap.ui.core" ], controls : [ ], types : [ ] }); - + // eslint-disable-next-line no-undef return my.lib.sample.base; }); diff --git a/demo/CategoriesComponent/src/my/lib/sample/categories/Component.js b/demo/CategoriesComponent/src/my/lib/sample/categories/Component.js index 4f342131b..670113795 100644 --- a/demo/CategoriesComponent/src/my/lib/sample/categories/Component.js +++ b/demo/CategoriesComponent/src/my/lib/sample/categories/Component.js @@ -1,4 +1,4 @@ -sap.ui.define(["my/lib/sample/base/Component"], function(Component) { +sap.ui.define(["my/lib/sample/base/Component"], (Component) => { "use strict"; return Component.extend("my.lib.sample.categories.Component", { diff --git a/demo/CategoriesComponent/src/my/lib/sample/categories/controller/App.controller.js b/demo/CategoriesComponent/src/my/lib/sample/categories/controller/App.controller.js index 768b02bc1..d46d11e3f 100644 --- a/demo/CategoriesComponent/src/my/lib/sample/categories/controller/App.controller.js +++ b/demo/CategoriesComponent/src/my/lib/sample/categories/controller/App.controller.js @@ -1,4 +1,4 @@ -sap.ui.define(["my/lib/sample/base/BaseController"], function(BaseController) { +sap.ui.define(["my/lib/sample/base/BaseController"], (BaseController) => { "use strict"; return BaseController.extend("my.lib.sample.categories.controller.App", { diff --git a/demo/CategoriesComponent/src/my/lib/sample/categories/controller/Detail.controller.js b/demo/CategoriesComponent/src/my/lib/sample/categories/controller/Detail.controller.js index 84ae4b5f6..383a141a6 100644 --- a/demo/CategoriesComponent/src/my/lib/sample/categories/controller/Detail.controller.js +++ b/demo/CategoriesComponent/src/my/lib/sample/categories/controller/Detail.controller.js @@ -1,42 +1,43 @@ sap.ui.define([ "my/lib/sample/base/BaseController", "sap/base/Log" -], function(BaseController, Log) { +], (BaseController, Log) => { "use strict"; return BaseController.extend("my.lib.sample.categories.controller.Detail", { - onInit: function() { - BaseController.prototype.onInit.apply(this, arguments); + onInit(...args) { + BaseController.prototype.onInit.apply(this, args); this.getOwnerComponent().getRouter().getRoute("detailRoute").attachMatched(this._onMatched, this); }, - _onMatched: function(oEvent) { + _onMatched(oEvent) { Log.info(this.getView().getControllerName(), "_onMatched"); - var oArgs = oEvent.getParameter("arguments"); + const oArgs = oEvent.getParameter("arguments"); this.getOwnerComponent().getModel().metadataLoaded().then(this._bindData.bind(this, oArgs.id)); }, - _bindData: function(id) { + _bindData(id) { Log.info(this.getView().getControllerName(), "_bindData"); - var sObjectPath = this.getOwnerComponent().getModel().createKey("Categories", { CategoryID: id }); + const sObjectPath = this.getOwnerComponent().getModel().createKey("Categories", { CategoryID: id }), + that = this; this.getView().bindElement({ - path: "/" + sObjectPath, + path: "/"+ sObjectPath, events: { - change: function() { - Log.info(this.getView().getControllerName(), "_bindData change"); - this.getView().setBusy(false); - }.bind(this), - dataRequested: function() { - Log.info(this.getView().getControllerName(), "_bindData dataRequested"); - this.getView().setBusy(true); - }.bind(this), - dataReceived: function() { - Log.info(this.getView().getControllerName(), "_bindData dataReceived"); - this.getView().setBusy(false); - if (this.getView().getBindingContext() === null) { - this.getOwnerComponent().getRouter().getTargets().display("notFound"); + change() { + Log.info(that.getView().getControllerName(), "_bindData change"); + that.getView().setBusy(false); + }, + dataRequested() { + Log.info(that.getView().getControllerName(), "_bindData dataRequested"); + that.getView().setBusy(true); + }, + dataReceived() { + Log.info(that.getView().getControllerName(), "_bindData dataReceived"); + that.getView().setBusy(false); + if (that.getView().getBindingContext() === null) { + that.getOwnerComponent().getRouter().getTargets().display("notFound"); } - }.bind(this) + } } }); } diff --git a/demo/CategoriesComponent/src/my/lib/sample/categories/controller/List.controller.js b/demo/CategoriesComponent/src/my/lib/sample/categories/controller/List.controller.js index 023125282..e922effa0 100644 --- a/demo/CategoriesComponent/src/my/lib/sample/categories/controller/List.controller.js +++ b/demo/CategoriesComponent/src/my/lib/sample/categories/controller/List.controller.js @@ -1,18 +1,20 @@ sap.ui.define([ "my/lib/sample/base/BaseController", "sap/base/Log" -], function(Controller, Log) { +], (Controller, Log) => { "use strict"; return Controller.extend("my.lib.sample.categories.controller.List", { - onPressListItem: function(oEvent) { + onPressListItem(oEvent) { Log.info(this.getView().getControllerName(), "onPressListItem"); - var oBindingContext = oEvent.getSource().getBindingContext(); + const oBindingContext = oEvent.getSource().getBindingContext(); - // navigate to the detail page. Because the products component is - // integrated in the detail page, it's also needed to provide route - // information for the deeply nested products component + /* + * Navigate to the detail page. Because the products component is + * integrated in the detail page, it's also needed to provide route + * information for the deeply nested products component + */ this.getOwnerComponent() .getRouter() .navTo("detailRoute", { @@ -21,8 +23,10 @@ sap.ui.define([ productsTarget: { route: "listRoute", parameters: { - // encode the path because it could contain "/" which - // isn't allowed to use as pattern parameter directly + /* + * Encode the path because it could contain "/" which + * isn't allowed to use as pattern parameter directly + */ basepath: encodeURIComponent(oBindingContext.getPath()) } } diff --git a/demo/CategoriesComponent/src/my/lib/sample/categories/localService/mockserver.js b/demo/CategoriesComponent/src/my/lib/sample/categories/localService/mockserver.js index 8930b4b82..b197ccc65 100644 --- a/demo/CategoriesComponent/src/my/lib/sample/categories/localService/mockserver.js +++ b/demo/CategoriesComponent/src/my/lib/sample/categories/localService/mockserver.js @@ -3,14 +3,16 @@ sap.ui.define([ "sap/ui/model/json/JSONModel", "sap/base/Log", "sap/base/util/UriParameters" -], function (MockServer, JSONModel, Log, UriParameters) { +], (MockServer, JSONModel, Log, UriParameters) => { "use strict"; - var oMockServer, - _sAppPath = "my/lib/sample/categories/", - _sJsonFilesPath = _sAppPath + "localService/mockdata"; - var oMockServerInterface = { + // eslint-disable-next-line init-declarations + let oMockServer; + + const sAppPath = "my/lib/sample/categories/", + sJsonFilesPath = `${sAppPath }localService/mockdata`, + oMockServerInterface = { /** * Initializes the mock server asynchronously. @@ -20,23 +22,23 @@ sap.ui.define([ * @param {object} [oOptionsParameter] init parameters for the mockserver * @returns{Promise} a promise that is resolved when the mock server has been started */ - init : function (oOptionsParameter) { - var oOptions = oOptionsParameter || {}; + init (oOptionsParameter) { + const oOptions = oOptionsParameter || {}; - return new Promise(function(fnResolve, fnReject) { - var sManifestUrl = sap.ui.require.toUrl(_sAppPath + "manifest.json"), + return new Promise((fnResolve, fnReject) => { + const sManifestUrl = sap.ui.require.toUrl(`${sAppPath }manifest.json`), oManifestModel = new JSONModel(sManifestUrl); - oManifestModel.attachRequestCompleted(function () { - var oUriParameters = new UriParameters(window.location.href), - // parse manifest for local metadata URI - sJsonFilesUrl = sap.ui.require.toUrl(_sJsonFilesPath), + oManifestModel.attachRequestCompleted(() => { + const oUriParameters = new UriParameters(window.location.href), + // Parse manifest for local metadata URI + sJsonFilesUrl = sap.ui.require.toUrl(sJsonFilesPath), oMainDataSource = oManifestModel.getProperty("/sap.app/dataSources/mainService"), - sMetadataUrl = sap.ui.require.toUrl(_sAppPath + oMainDataSource.settings.localUri), - // ensure there is a trailing slash - sMockServerUrl = /.*\/$/.test(oMainDataSource.uri) ? oMainDataSource.uri : oMainDataSource.uri + "/"; + sMetadataUrl = sap.ui.require.toUrl(sAppPath + oMainDataSource.settings.localUri), + // Ensure there is a trailing slash + sMockServerUrl = /.*\/$/u.test(oMainDataSource.uri) ? oMainDataSource.uri : `${oMainDataSource.uri }/`; - // create a mock server instance or stop the existing one to reinitialize + // Create a mock server instance or stop the existing one to reinitialize if (!oMockServer) { oMockServer = new MockServer({ rootUri: sMockServerUrl @@ -45,48 +47,48 @@ sap.ui.define([ oMockServer.stop(); } - // configure mock server with the given options or a default delay of 0.5s + // Configure mock server with the given options or a default delay of 0.5s MockServer.config({ autoRespond : true, autoRespondAfter : (oOptions.delay || oUriParameters.get("serverDelay") || 500) }); - // simulate all requests using mock data + // Simulate all requests using mock data oMockServer.simulate(sMetadataUrl, { sMockdataBaseUrl : sJsonFilesUrl, bGenerateMissingMockData : true }); - var aRequests = oMockServer.getRequests(); + const aRequests = oMockServer.getRequests(), - // compose an error response for each request - var fnResponse = function (iErrCode, sMessage, aRequest) { - aRequest.response = function(oXhr){ + // Compose an error response for each request + fnResponse = (iErrCode, sMessage, aRequest) => { + aRequest.response = (oXhr) => { oXhr.respond(iErrCode, {"Content-Type": "text/plain;charset=utf-8"}, sMessage); }; }; - // simulate metadata errors + // Simulate metadata errors if (oOptions.metadataError || oUriParameters.get("metadataError")) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { if (aEntry.path.toString().indexOf("$metadata") > -1) { fnResponse(500, "metadata Error", aEntry); } }); } - // simulate request errors - var sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), + // Simulate request errors + const sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), iErrorCode = sErrorParam === "badRequest" ? 400 : 500; if (sErrorParam) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { fnResponse(iErrorCode, sErrorParam, aEntry); }); } - // custom mock behaviour may be added here + // Custom mock behaviour may be added here - // set requests and start the server + // Set requests and start the server oMockServer.setRequests(aRequests); oMockServer.start(); @@ -94,8 +96,8 @@ sap.ui.define([ fnResolve(); }); - oManifestModel.attachRequestFailed(function () { - var sError = "Failed to load application manifest"; + oManifestModel.attachRequestFailed(() => { + const sError = "Failed to load application manifest"; Log.error(sError); fnReject(new Error(sError)); @@ -107,7 +109,7 @@ sap.ui.define([ * @public returns the mockserver of the app, should be used in integration tests * @returns {sap.ui.core.util.MockServer} the mockserver instance */ - getMockServer : function () { + getMockServer () { return oMockServer; } }; diff --git a/demo/CategoriesComponent/src/my/lib/sample/categories/test/initMockServer.js b/demo/CategoriesComponent/src/my/lib/sample/categories/test/initMockServer.js index 27f6aea54..036aac215 100644 --- a/demo/CategoriesComponent/src/my/lib/sample/categories/test/initMockServer.js +++ b/demo/CategoriesComponent/src/my/lib/sample/categories/test/initMockServer.js @@ -1,25 +1,20 @@ sap.ui.define([ "../localService/mockserver" -], function (mockserver) { +], (mockserver) => { "use strict"; - var aMockservers = []; + const aMockservers = []; - // initialize the mock server + // Initialize the mock server aMockservers.push(mockserver.init()); - Promise.all(aMockservers).catch(function (oError) { - var fnShowErrorMessage = function () { - return new Promise(function (resolve, reject) { - sap.ui.require(["sap/m/MessageBox"], function (MessageBox) { - MessageBox.error(oError.message); - resolve(); - }, reject); - }); - } - return sap.ui.getCore().loadLibrary("sap.m", { async: true }).then(fnShowErrorMessage); - }).finally(function () { - // initialize the embedded component on the HTML page + Promise.all(aMockservers).catch(async (oError) => { + await sap.ui.getCore().loadLibrary("sap.m", { async: true }); + sap.ui.require(["sap/m/MessageBox"], (MessageBox) => { + MessageBox.error(oError.message); + }); + }).finally(() => { + // Initialize the embedded component on the HTML page sap.ui.require(["sap/ui/core/ComponentSupport"]); }); }); \ No newline at end of file diff --git a/demo/ProductsComponent/src/my/lib/sample/products/Component.js b/demo/ProductsComponent/src/my/lib/sample/products/Component.js index 13e7579f9..68e4f7d0b 100644 --- a/demo/ProductsComponent/src/my/lib/sample/products/Component.js +++ b/demo/ProductsComponent/src/my/lib/sample/products/Component.js @@ -1,7 +1,7 @@ sap.ui.define([ "my/lib/sample/base/Component", "sap/ui/core/Component" -], function(BaseComponent, Component) { +], (BaseComponent, Component) => { "use strict"; return BaseComponent.extend("my.lib.sample.products.Component", { metadata: { @@ -10,17 +10,19 @@ sap.ui.define([ "sap.ui.core.IAsyncContentCreation" ] }, - init: function() { - BaseComponent.prototype.init.apply(this, arguments); + init(...args) { + BaseComponent.prototype.init.apply(this, args); - var oParentComponent = Component.getOwnerComponentFor(this); + const oParentComponent = Component.getOwnerComponentFor(this); - // if this component runs standalone instead of embedded to another component, - // it should handle the navigation to detail page by itself. It attaches to - // its own "toProduct" event and navigates to the detail page + /* + * If this component runs standalone instead of embedded to another component, + * it should handle the navigation to detail page by itself. It attaches to + * its own "toProduct" event and navigates to the detail page + */ if (!oParentComponent) { - this.attachEvent("toProduct", function(oEvent) { - var sProductID = oEvent.getParameter("productID"); + this.attachEvent("toProduct", (oEvent) => { + const sProductID = oEvent.getParameter("productID"); this.getRouter().navTo("detailRoute", { id: sProductID }); diff --git a/demo/ProductsComponent/src/my/lib/sample/products/controller/App.controller.js b/demo/ProductsComponent/src/my/lib/sample/products/controller/App.controller.js index ef54c96d1..debe3803d 100644 --- a/demo/ProductsComponent/src/my/lib/sample/products/controller/App.controller.js +++ b/demo/ProductsComponent/src/my/lib/sample/products/controller/App.controller.js @@ -1,4 +1,4 @@ -sap.ui.define(["sap/ui/core/mvc/Controller"], function(Controller) { +sap.ui.define(["sap/ui/core/mvc/Controller"], (Controller) => { "use strict"; return Controller.extend("my.lib.sample.products.controller.App", { }); diff --git a/demo/ProductsComponent/src/my/lib/sample/products/controller/Detail.controller.js b/demo/ProductsComponent/src/my/lib/sample/products/controller/Detail.controller.js index a8370dc16..b60dd3319 100644 --- a/demo/ProductsComponent/src/my/lib/sample/products/controller/Detail.controller.js +++ b/demo/ProductsComponent/src/my/lib/sample/products/controller/Detail.controller.js @@ -1,80 +1,81 @@ sap.ui.define([ "my/lib/sample/base/BaseController", "sap/base/Log" -], function(BaseController, Log) { +], (BaseController, Log) => { "use strict"; return BaseController.extend("my.lib.sample.products.controller.Detail", { - onInit: function() { - BaseController.prototype.onInit.apply(this, arguments); + onInit(...args) { + BaseController.prototype.onInit.apply(this, args); this.getOwnerComponent().getRouter().getRoute("detailRoute").attachPatternMatched(this._onMatched, this); }, - _onMatched: function(oEvent) { + _onMatched(oEvent) { Log.info(this.getView().getControllerName(), "_onMatched"); - var oArgs = oEvent.getParameter("arguments"); + const oArgs = oEvent.getParameter("arguments"); this.getOwnerComponent().getModel().metadataLoaded().then(this._bindData.bind(this, oArgs.id)); }, - _bindData: function(id) { + _bindData(id) { Log.info(this.getView().getControllerName(), "_bindData"); - var sObjectPath = this.getOwnerComponent().getModel().createKey("Products", { ProductID: id }); + const sObjectPath = this.getOwnerComponent().getModel().createKey("Products", { ProductID: id }), + that = this; this.getView().bindElement({ - path: "/" + sObjectPath, + path: "/"+ sObjectPath, parameters: { expand: "Supplier,Category" }, events: { - change: function() { - Log.info(this.getView().getControllerName(), "_bindData change"); - this.getView().setBusy(false); - }.bind(this), - dataRequested: function() { - Log.info(this.getView().getControllerName(), "_bindData dataRequested"); - this.getView().setBusy(true); - }.bind(this), - dataReceived: function() { - Log.info(this.getView().getControllerName(), "_bindData dataReceived"); - this.getView().setBusy(false); - if (this.getView().getBindingContext() === null) { - this.getOwnerComponent().getRouter().getTargets().display("notFound"); + change() { + Log.info(that.getView().getControllerName(), "_bindData change"); + that.getView().setBusy(false); + }, + dataRequested() { + Log.info(that.getView().getControllerName(), "_bindData dataRequested"); + that.getView().setBusy(true); + }, + dataReceived() { + Log.info(that.getView().getControllerName(), "_bindData dataReceived"); + that.getView().setBusy(false); + if (that.getView().getBindingContext() === null) { + that.getOwnerComponent().getRouter().getTargets().display("notFound"); } - }.bind(this) + } } }); }, - onPressSupplier: function(oEvent) { - Log.info(this.getView().getControllerName(), "onPressSupplier " + oEvent.getSource().getBindingContext().getObject().SupplierID); + onPressSupplier(oEvent) { + Log.info(this.getView().getControllerName(), `onPressSupplier ${ oEvent.getSource().getBindingContext().getObject().SupplierID}`); - var oOwnerComponent = this.getOwnerComponent(); - var oModel = oOwnerComponent.getModel(); - var oBindingContext = oEvent.getSource().getBindingContext(); - var sSupplierID = oBindingContext.getProperty("SupplierID"); + const oOwnerComponent = this.getOwnerComponent(), + oModel = oOwnerComponent.getModel(), + oBindingContext = oEvent.getSource().getBindingContext(), + sSupplierID = oBindingContext.getProperty("SupplierID"); oOwnerComponent.fireEvent("toSupplier", { supplierID: sSupplierID, - supplierKey: encodeURIComponent("/" + oModel.createKey("Suppliers", { + supplierKey: encodeURIComponent(`/${ oModel.createKey("Suppliers", { SupplierID: sSupplierID - })) + })}`) }); }, - onPressCategory: function(oEvent) { - Log.info(this.getView().getControllerName(), "onPressCategory " + oEvent.getSource().getBindingContext().getObject().CategoryID); + onPressCategory(oEvent) { + Log.info(this.getView().getControllerName(), `onPressCategory ${ oEvent.getSource().getBindingContext().getObject().CategoryID}`); - var oOwnerComponent = this.getOwnerComponent(); - var oModel = oOwnerComponent.getModel(); - var oBindingContext = oEvent.getSource().getBindingContext(); - var sCategoryID = oBindingContext.getProperty("CategoryID"); + const oOwnerComponent = this.getOwnerComponent(), + oModel = oOwnerComponent.getModel(), + oBindingContext = oEvent.getSource().getBindingContext(), + sCategoryID = oBindingContext.getProperty("CategoryID"); oOwnerComponent.fireEvent("toCategory", { categoryID: sCategoryID, - categoryKey: encodeURIComponent("/" + oModel.createKey("Categories", { + categoryKey: encodeURIComponent(`/${ oModel.createKey("Categories", { CategoryID: sCategoryID - })) + })}`) }); } }); diff --git a/demo/ProductsComponent/src/my/lib/sample/products/controller/List.controller.js b/demo/ProductsComponent/src/my/lib/sample/products/controller/List.controller.js index 6b32b137a..2744fd73c 100644 --- a/demo/ProductsComponent/src/my/lib/sample/products/controller/List.controller.js +++ b/demo/ProductsComponent/src/my/lib/sample/products/controller/List.controller.js @@ -4,21 +4,21 @@ sap.ui.define([ "sap/m/Text", "sap/base/Log", "sap/ui/model/type/Currency" -], function(BaseController, ColumnListItem, Text, Log, Currency) { +], (BaseController, ColumnListItem, Text, Log, Currency) => { "use strict"; return BaseController.extend("my.lib.sample.products.controller.List", { - onInit: function() { - BaseController.prototype.onInit.apply(this, arguments); + onInit(...args) { + BaseController.prototype.onInit.apply(this, args); this.getOwnerComponent().getRouter().getRoute("listRoute").attachMatched(this._onMatched, this); }, - _onMatched: function(oEvent) { - var oArgs = oEvent.getParameter("arguments"); - var sPath = decodeURIComponent(oArgs.basepath || "") + "/Products"; - var oTable = this.getView().byId("table"); - var that = this; + _onMatched(oEvent) { + const oArgs = oEvent.getParameter("arguments"), + sPath = `${decodeURIComponent(oArgs.basepath || "") }/Products`, + oTable = this.getView().byId("table"), + that = this; oTable.bindItems({ path: sPath, @@ -47,20 +47,22 @@ sap.ui.define([ }); }, - onPressListItem: function(oEvent) { + onPressListItem(oEvent) { Log.info(this.getView().getControllerName(), "onPressListItem"); - var sProductID = oEvent.getSource().getBindingContext().getProperty("ProductID"); + const sProductID = oEvent.getSource().getBindingContext().getProperty("ProductID"); - // inform the parent component about the navigation to the detail page - // - // the navigation isn't done within this component because when this component is embedded - // in suppliers/categories component, it should trigger the navigation within the root - // component. - // - // simply always inform the parent component that a navigation to the detail page is needed. - // In the deeply nested use case, the direct parent component forwards this event to the root - // component and a navigation is then triggered from the root component + /* + * Inform the parent component about the navigation to the detail page + * + * the navigation isn't done within this component because when this component is embedded + * in suppliers/categories component, it should trigger the navigation within the root + * component. + * + * simply always inform the parent component that a navigation to the detail page is needed. + * In the deeply nested use case, the direct parent component forwards this event to the root + * component and a navigation is then triggered from the root component + */ this.getOwnerComponent().fireEvent("toProduct", { productID: sProductID }); diff --git a/demo/ProductsComponent/src/my/lib/sample/products/localService/mockserver.js b/demo/ProductsComponent/src/my/lib/sample/products/localService/mockserver.js index 3d10f77cc..1e81508fd 100644 --- a/demo/ProductsComponent/src/my/lib/sample/products/localService/mockserver.js +++ b/demo/ProductsComponent/src/my/lib/sample/products/localService/mockserver.js @@ -3,14 +3,16 @@ sap.ui.define([ "sap/ui/model/json/JSONModel", "sap/base/Log", "sap/base/util/UriParameters" -], function (MockServer, JSONModel, Log, UriParameters) { +], (MockServer, JSONModel, Log, UriParameters) => { "use strict"; - var oMockServer, - _sAppPath = "my/lib/sample/products/", - _sJsonFilesPath = _sAppPath + "localService/mockdata"; - var oMockServerInterface = { + // eslint-disable-next-line init-declarations + let oMockServer; + + const sAppPath = "my/lib/sample/products/", + sJsonFilesPath = `${sAppPath }localService/mockdata`, + oMockServerInterface = { /** * Initializes the mock server asynchronously. @@ -20,23 +22,23 @@ sap.ui.define([ * @param {object} [oOptionsParameter] init parameters for the mockserver * @returns{Promise} a promise that is resolved when the mock server has been started */ - init : function (oOptionsParameter) { - var oOptions = oOptionsParameter || {}; + init (oOptionsParameter) { + const oOptions = oOptionsParameter || {}; - return new Promise(function(fnResolve, fnReject) { - var sManifestUrl = sap.ui.require.toUrl(_sAppPath + "manifest.json"), + return new Promise((fnResolve, fnReject) => { + const sManifestUrl = sap.ui.require.toUrl(`${sAppPath }manifest.json`), oManifestModel = new JSONModel(sManifestUrl); - oManifestModel.attachRequestCompleted(function () { - var oUriParameters = new UriParameters(window.location.href), - // parse manifest for local metadata URI - sJsonFilesUrl = sap.ui.require.toUrl(_sJsonFilesPath), + oManifestModel.attachRequestCompleted(() => { + const oUriParameters = new UriParameters(window.location.href), + // Parse manifest for local metadata URI + sJsonFilesUrl = sap.ui.require.toUrl(sJsonFilesPath), oMainDataSource = oManifestModel.getProperty("/sap.app/dataSources/mainService"), - sMetadataUrl = sap.ui.require.toUrl(_sAppPath + oMainDataSource.settings.localUri), - // ensure there is a trailing slash - sMockServerUrl = /.*\/$/.test(oMainDataSource.uri) ? oMainDataSource.uri : oMainDataSource.uri + "/"; + sMetadataUrl = sap.ui.require.toUrl(sAppPath + oMainDataSource.settings.localUri), + // Ensure there is a trailing slash + sMockServerUrl = /.*\/$/u.test(oMainDataSource.uri) ? oMainDataSource.uri : `${oMainDataSource.uri }/`; - // create a mock server instance or stop the existing one to reinitialize + // Create a mock server instance or stop the existing one to reinitialize if (!oMockServer) { oMockServer = new MockServer({ rootUri: sMockServerUrl @@ -45,48 +47,48 @@ sap.ui.define([ oMockServer.stop(); } - // configure mock server with the given options or a default delay of 0.5s + // Configure mock server with the given options or a default delay of 0.5s MockServer.config({ autoRespond : true, autoRespondAfter : (oOptions.delay || oUriParameters.get("serverDelay") || 500) }); - // simulate all requests using mock data + // Simulate all requests using mock data oMockServer.simulate(sMetadataUrl, { sMockdataBaseUrl : sJsonFilesUrl, bGenerateMissingMockData : true }); - var aRequests = oMockServer.getRequests(); + const aRequests = oMockServer.getRequests(), - // compose an error response for each request - var fnResponse = function (iErrCode, sMessage, aRequest) { - aRequest.response = function(oXhr){ + // Compose an error response for each request + fnResponse = (iErrCode, sMessage, aRequest) => { + aRequest.response = (oXhr) => { oXhr.respond(iErrCode, {"Content-Type": "text/plain;charset=utf-8"}, sMessage); }; }; - // simulate metadata errors + // Simulate metadata errors if (oOptions.metadataError || oUriParameters.get("metadataError")) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { if (aEntry.path.toString().indexOf("$metadata") > -1) { fnResponse(500, "metadata Error", aEntry); } }); } - // simulate request errors - var sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), + // Simulate request errors + const sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), iErrorCode = sErrorParam === "badRequest" ? 400 : 500; if (sErrorParam) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { fnResponse(iErrorCode, sErrorParam, aEntry); }); } - // custom mock behaviour may be added here + // Custom mock behaviour may be added here - // set requests and start the server + // Set requests and start the server oMockServer.setRequests(aRequests); oMockServer.start(); @@ -94,8 +96,8 @@ sap.ui.define([ fnResolve(); }); - oManifestModel.attachRequestFailed(function () { - var sError = "Failed to load application manifest"; + oManifestModel.attachRequestFailed(() => { + const sError = "Failed to load application manifest"; Log.error(sError); fnReject(new Error(sError)); @@ -107,7 +109,7 @@ sap.ui.define([ * @public returns the mockserver of the app, should be used in integration tests * @returns {sap.ui.core.util.MockServer} the mockserver instance */ - getMockServer : function () { + getMockServer () { return oMockServer; } }; diff --git a/demo/ProductsComponent/src/my/lib/sample/products/test/initMockServer.js b/demo/ProductsComponent/src/my/lib/sample/products/test/initMockServer.js index 27f6aea54..036aac215 100644 --- a/demo/ProductsComponent/src/my/lib/sample/products/test/initMockServer.js +++ b/demo/ProductsComponent/src/my/lib/sample/products/test/initMockServer.js @@ -1,25 +1,20 @@ sap.ui.define([ "../localService/mockserver" -], function (mockserver) { +], (mockserver) => { "use strict"; - var aMockservers = []; + const aMockservers = []; - // initialize the mock server + // Initialize the mock server aMockservers.push(mockserver.init()); - Promise.all(aMockservers).catch(function (oError) { - var fnShowErrorMessage = function () { - return new Promise(function (resolve, reject) { - sap.ui.require(["sap/m/MessageBox"], function (MessageBox) { - MessageBox.error(oError.message); - resolve(); - }, reject); - }); - } - return sap.ui.getCore().loadLibrary("sap.m", { async: true }).then(fnShowErrorMessage); - }).finally(function () { - // initialize the embedded component on the HTML page + Promise.all(aMockservers).catch(async (oError) => { + await sap.ui.getCore().loadLibrary("sap.m", { async: true }); + sap.ui.require(["sap/m/MessageBox"], (MessageBox) => { + MessageBox.error(oError.message); + }); + }).finally(() => { + // Initialize the embedded component on the HTML page sap.ui.require(["sap/ui/core/ComponentSupport"]); }); }); \ No newline at end of file diff --git a/demo/RootComponent/webapp/Component.js b/demo/RootComponent/webapp/Component.js index 40c7baa97..fab00f5d3 100644 --- a/demo/RootComponent/webapp/Component.js +++ b/demo/RootComponent/webapp/Component.js @@ -1,6 +1,6 @@ sap.ui.define([ "my/lib/sample/base/Component" -], function(Component) { +], (Component) => { "use strict"; return Component.extend("my.lib.sample.root.Component", { @@ -10,13 +10,15 @@ sap.ui.define([ "sap.ui.core.IAsyncContentCreation" ] }, - // define the events which are fired from the reuse components - // - // this component registers handler to those events and navigates - // to the other reuse components - // - // see the implementation in Component for processing the event - // mapping + /* + * Define the events which are fired from the reuse components + * + * this component registers handler to those events and navigates + * to the other reuse components + * + * see the implementation in Component for processing the event + * mapping + */ eventMappings: { suppliersComponent: [{ name: "toProduct", @@ -93,10 +95,10 @@ sap.ui.define([ } }] }, - init: function() { - // call the init function of the parent - Component.prototype.init.apply(this, arguments); - } + init(...args) { + // Call the init function of the parent + Component.prototype.init.apply(this, args); + }, }); } ); diff --git a/demo/RootComponent/webapp/controller/App.controller.js b/demo/RootComponent/webapp/controller/App.controller.js index ee97927ff..3e0e94c9c 100644 --- a/demo/RootComponent/webapp/controller/App.controller.js +++ b/demo/RootComponent/webapp/controller/App.controller.js @@ -2,45 +2,45 @@ sap.ui.define([ "my/lib/sample/base/BaseController", "sap/base/Log", "sap/ui/model/json/JSONModel" -], function(Controller, Log, JSONModel){ +], (Controller, Log, JSONModel) =>{ "use strict"; return Controller.extend("my.lib.sample.root.controller.App", { - onInit: function(){ + onInit(){ Log.info(this.getView().getControllerName(), "onInit"); this.getOwnerComponent().getRouter().attachRouteMatched(this._onRouteMatched, this); this.getOwnerComponent().getRouter().attachBypassed(this._onBypassed, this); - var oTitlesModel = new JSONModel(); + const oTitlesModel = new JSONModel(); this.getView().setModel(oTitlesModel, "titleModel"); - this.getOwnerComponent().getRouter().attachTitleChanged(function (oEvent) { + this.getOwnerComponent().getRouter().attachTitleChanged((oEvent) => { oTitlesModel.setData(oEvent.getParameters()); }); }, - _onRouteMatched: function(oEvent) { + _onRouteMatched(oEvent) { Log.info(this.getView().getControllerName(), "_onRouteMatched"); - var oConfig = oEvent.getParameter("config"); + const oConfig = oEvent.getParameter("config"); - // select the corresponding item in the left menu + // Select the corresponding item in the left menu this.setSelectedMenuItem(oConfig.name); }, - setSelectedMenuItem: function(sKey) { + setSelectedMenuItem(sKey) { this.byId("navigationList").setSelectedKey(sKey); }, - _onBypassed: function(oEvent) { - var sHash = oEvent.getParameter("hash"); + _onBypassed(oEvent) { + const sHash = oEvent.getParameter("hash"); Log.info( this.getView().getControllerName(), - "_onBypassed Hash=" + sHash + `_onBypassed Hash=${ sHash}` ); }, - onItemSelect: function(oEvent) { - var sKey = oEvent.getParameter("item").getKey(); - Log.info(this.getView().getControllerName(), "onItemSelect Key=" + sKey); + onItemSelect(oEvent) { + const sKey = oEvent.getParameter("item").getKey(); + Log.info(this.getView().getControllerName(), `onItemSelect Key=${ sKey}`); this.getOwnerComponent().getRouter().navTo(sKey); } diff --git a/demo/RootComponent/webapp/controller/Home.controller.js b/demo/RootComponent/webapp/controller/Home.controller.js index cedbb7df0..e632234c4 100644 --- a/demo/RootComponent/webapp/controller/Home.controller.js +++ b/demo/RootComponent/webapp/controller/Home.controller.js @@ -2,14 +2,14 @@ sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/base/Log", "sap/ui/model/json/JSONModel" -], function(Controller, Log, JSONModel) { +], (Controller, Log, JSONModel) => { "use strict"; return Controller.extend("my.lib.sample.root.controller.Home", { - onInit: function() { + onInit() { Log.info(this.getView().getControllerName(), "onInit"); // HTML string bound to the formatted text control - var oModel = new JSONModel({ + const oModel = new JSONModel({ HTML: "

We are now in the Home View of the Root component. By clicking on the other three items (Suppliers, Categories and Products) in the left menu, further components will be loaded and nested into the Root component.

" + "

Each nested component is consisted with 2 Views: List and Detail Views. In the Detail View of the nested component Products, there are controls which lead to a navigation into one of the other nested components. For example, the category or the supplier link in the Detail View of the Products component navigates to the Detail View of the Categories component or the Suppliers component.

" + "

Furthermore, the Detail View of the Categories or Suppliers component integrates the Products component to show a list of products under a certain category or supplier. Clicking on an item in the product list, a navigation is done to the Detail View of the Products component.

" + diff --git a/demo/RootComponent/webapp/localService/mockserver.js b/demo/RootComponent/webapp/localService/mockserver.js index 8c6ba4c85..d2dd8e886 100644 --- a/demo/RootComponent/webapp/localService/mockserver.js +++ b/demo/RootComponent/webapp/localService/mockserver.js @@ -3,14 +3,16 @@ sap.ui.define([ "sap/ui/model/json/JSONModel", "sap/base/Log", "sap/base/util/UriParameters" -], function (MockServer, JSONModel, Log, UriParameters) { +], (MockServer, JSONModel, Log, UriParameters) => { "use strict"; - var oMockServer, - _sAppPath = "my/lib/sample/root/", - _sJsonFilesPath = _sAppPath + "localService/mockdata"; - var oMockServerInterface = { + // eslint-disable-next-line init-declarations + let oMockServer; + + const sAppPath = "my/lib/sample/root/", + sJsonFilesPath = `${sAppPath }localService/mockdata`, + oMockServerInterface = { /** * Initializes the mock server asynchronously. @@ -20,23 +22,23 @@ sap.ui.define([ * @param {object} [oOptionsParameter] init parameters for the mockserver * @returns{Promise} a promise that is resolved when the mock server has been started */ - init: function (oOptionsParameter) { - var oOptions = oOptionsParameter || {}; + init (oOptionsParameter) { + const oOptions = oOptionsParameter || {}; - return new Promise(function (fnResolve, fnReject) { - var sManifestUrl = sap.ui.require.toUrl(_sAppPath + "manifest.json"), + return new Promise((fnResolve, fnReject) => { + const sManifestUrl = sap.ui.require.toUrl(`${sAppPath }manifest.json`), oManifestModel = new JSONModel(sManifestUrl); - oManifestModel.attachRequestCompleted(function () { - var oUriParameters = new UriParameters(window.location.href), - // parse manifest for local metadata URI - sJsonFilesUrl = sap.ui.require.toUrl(_sJsonFilesPath), + oManifestModel.attachRequestCompleted(() => { + const oUriParameters = new UriParameters(window.location.href), + // Parse manifest for local metadata URI + sJsonFilesUrl = sap.ui.require.toUrl(sJsonFilesPath), oMainDataSource = oManifestModel.getProperty("/sap.app/dataSources/mainService"), - sMetadataUrl = sap.ui.require.toUrl(_sAppPath + oMainDataSource.settings.localUri), - // ensure there is a trailing slash - sMockServerUrl = /.*\/$/.test(oMainDataSource.uri) ? oMainDataSource.uri : oMainDataSource.uri + "/"; + sMetadataUrl = sap.ui.require.toUrl(sAppPath + oMainDataSource.settings.localUri), + // Ensure there is a trailing slash + sMockServerUrl = /.*\/$/u.test(oMainDataSource.uri) ? oMainDataSource.uri : `${oMainDataSource.uri }/`; - // create a mock server instance or stop the existing one to reinitialize + // Create a mock server instance or stop the existing one to reinitialize if (!oMockServer) { oMockServer = new MockServer({ rootUri: sMockServerUrl @@ -45,48 +47,48 @@ sap.ui.define([ oMockServer.stop(); } - // configure mock server with the given options or a default delay of 0.5s + // Configure mock server with the given options or a default delay of 0.5s MockServer.config({ - autoRespond: true, - autoRespondAfter: (oOptions.delay || oUriParameters.get("serverDelay") || 500) + autoRespond : true, + autoRespondAfter : (oOptions.delay || oUriParameters.get("serverDelay") || 500) }); - // simulate all requests using mock data + // Simulate all requests using mock data oMockServer.simulate(sMetadataUrl, { - sMockdataBaseUrl: sJsonFilesUrl, - bGenerateMissingMockData: true + sMockdataBaseUrl : sJsonFilesUrl, + bGenerateMissingMockData : true }); - var aRequests = oMockServer.getRequests(); + const aRequests = oMockServer.getRequests(), - // compose an error response for each request - var fnResponse = function (iErrCode, sMessage, aRequest) { - aRequest.response = function (oXhr) { - oXhr.respond(iErrCode, { "Content-Type": "text/plain;charset=utf-8" }, sMessage); + // Compose an error response for each request + fnResponse = (iErrCode, sMessage, aRequest) => { + aRequest.response = (oXhr) => { + oXhr.respond(iErrCode, {"Content-Type": "text/plain;charset=utf-8"}, sMessage); }; }; - // simulate metadata errors + // Simulate metadata errors if (oOptions.metadataError || oUriParameters.get("metadataError")) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { if (aEntry.path.toString().indexOf("$metadata") > -1) { fnResponse(500, "metadata Error", aEntry); } }); } - // simulate request errors - var sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), + // Simulate request errors + const sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), iErrorCode = sErrorParam === "badRequest" ? 400 : 500; if (sErrorParam) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { fnResponse(iErrorCode, sErrorParam, aEntry); }); } - // custom mock behaviour may be added here + // Custom mock behaviour may be added here - // set requests and start the server + // Set requests and start the server oMockServer.setRequests(aRequests); oMockServer.start(); @@ -94,8 +96,8 @@ sap.ui.define([ fnResolve(); }); - oManifestModel.attachRequestFailed(function () { - var sError = "Failed to load application manifest"; + oManifestModel.attachRequestFailed(() => { + const sError = "Failed to load application manifest"; Log.error(sError); fnReject(new Error(sError)); @@ -107,7 +109,7 @@ sap.ui.define([ * @public returns the mockserver of the app, should be used in integration tests * @returns {sap.ui.core.util.MockServer} the mockserver instance */ - getMockServer: function () { + getMockServer () { return oMockServer; } }; diff --git a/demo/RootComponent/webapp/test/initMockServer.js b/demo/RootComponent/webapp/test/initMockServer.js index 27f6aea54..036aac215 100644 --- a/demo/RootComponent/webapp/test/initMockServer.js +++ b/demo/RootComponent/webapp/test/initMockServer.js @@ -1,25 +1,20 @@ sap.ui.define([ "../localService/mockserver" -], function (mockserver) { +], (mockserver) => { "use strict"; - var aMockservers = []; + const aMockservers = []; - // initialize the mock server + // Initialize the mock server aMockservers.push(mockserver.init()); - Promise.all(aMockservers).catch(function (oError) { - var fnShowErrorMessage = function () { - return new Promise(function (resolve, reject) { - sap.ui.require(["sap/m/MessageBox"], function (MessageBox) { - MessageBox.error(oError.message); - resolve(); - }, reject); - }); - } - return sap.ui.getCore().loadLibrary("sap.m", { async: true }).then(fnShowErrorMessage); - }).finally(function () { - // initialize the embedded component on the HTML page + Promise.all(aMockservers).catch(async (oError) => { + await sap.ui.getCore().loadLibrary("sap.m", { async: true }); + sap.ui.require(["sap/m/MessageBox"], (MessageBox) => { + MessageBox.error(oError.message); + }); + }).finally(() => { + // Initialize the embedded component on the HTML page sap.ui.require(["sap/ui/core/ComponentSupport"]); }); }); \ No newline at end of file diff --git a/demo/RootComponent/webapp/test/integration/AllJourneys.js b/demo/RootComponent/webapp/test/integration/AllJourneys.js index 1211f97e3..97032202b 100644 --- a/demo/RootComponent/webapp/test/integration/AllJourneys.js +++ b/demo/RootComponent/webapp/test/integration/AllJourneys.js @@ -2,7 +2,7 @@ sap.ui.define([ "sap/ui/test/Opa5", "./arrangements/Startup", "./NavigationJourney" -], function (Opa5, Startup) { +], (Opa5, Startup) => { "use strict"; Opa5.extendConfig({ arrangements: new Startup(), diff --git a/demo/RootComponent/webapp/test/integration/NavigationJourney.js b/demo/RootComponent/webapp/test/integration/NavigationJourney.js index 3657a7de7..906547770 100644 --- a/demo/RootComponent/webapp/test/integration/NavigationJourney.js +++ b/demo/RootComponent/webapp/test/integration/NavigationJourney.js @@ -4,12 +4,12 @@ sap.ui.define([ "sap/ui/test/opaQunit", "./pages/App", "./pages/Home" -], function (opaTest) { +], (opaTest) => { "use strict"; QUnit.module("Navigation Journey"); - opaTest("Should navigate to the different pages", function (Given, When, Then) { + opaTest("Should navigate to the different pages", (Given, When, Then) => { // Arrangements Given.iStartMyApp(); @@ -33,7 +33,7 @@ sap.ui.define([ Then.iTeardownMyApp(); }); - opaTest("Should navigate to unknown site", function (Given, When, Then) { + opaTest("Should navigate to unknown site", (Given, When, Then) => { // Arrangements Given.iStartMyApp({hash: "coool"}); diff --git a/demo/RootComponent/webapp/test/integration/arrangements/Startup.js b/demo/RootComponent/webapp/test/integration/arrangements/Startup.js index 0667c0f14..d95732a89 100644 --- a/demo/RootComponent/webapp/test/integration/arrangements/Startup.js +++ b/demo/RootComponent/webapp/test/integration/arrangements/Startup.js @@ -2,7 +2,7 @@ sap.ui.define([ "sap/ui/test/Opa5", "my/lib/sample/root/localService/mockserver", "sap/ui/model/odata/v2/ODataModel" -], function(Opa5, mockserver, ODataModel) { +], (Opa5, mockserver, ODataModel) => { "use strict"; return Opa5.extend("my.lib.sample.root.test.integration.arrangements.Startup", { @@ -14,20 +14,20 @@ sap.ui.define([ * @param {string} [oOptionsParameter.hash] The in-app hash can also be passed separately for better readability in tests * @param {boolean} [oOptionsParameter.autoWait=true] Automatically wait for pending requests while the application is starting up */ - iStartMyApp : function (oOptionsParameter) { - var oOptions = oOptionsParameter || {}; + iStartMyApp (oOptionsParameter) { + const oOptions = oOptionsParameter || {}; this._clearSharedData(); - // start the app with a minimal delay to make tests fast but still async to discover basic timing issues - oOptions.delay = oOptions.delay || 1; + // Start the app with a minimal delay to make tests fast but still async to discover basic timing issues + oOptions.delay ||= 1; - // configure mock server with the current options - var oMockServerInitialized = mockserver.init(oOptions); + // Configure mock server with the current options + const oMockServerInitialized = mockserver.init(oOptions); this.iWaitForPromise(oMockServerInitialized); - // start the app UI component + // Start the app UI component this.iStartMyUIComponent({ componentConfig: { name: "my.lib.sample.root", @@ -37,8 +37,8 @@ sap.ui.define([ autoWait: oOptions.autoWait }); }, - _clearSharedData: function () { - // clear shared metadata in ODataModel to allow tests for loading the metadata + _clearSharedData () { + // Clear shared metadata in ODataModel to allow tests for loading the metadata ODataModel.mSharedData = { server: {}, service: {}, meta: {} }; } }); diff --git a/demo/RootComponent/webapp/test/integration/opaTests.qunit.js b/demo/RootComponent/webapp/test/integration/opaTests.qunit.js index 17470c294..b99ab4ef0 100644 --- a/demo/RootComponent/webapp/test/integration/opaTests.qunit.js +++ b/demo/RootComponent/webapp/test/integration/opaTests.qunit.js @@ -3,12 +3,12 @@ QUnit.config.autostart = false; -sap.ui.getCore().attachInit(function() { +sap.ui.getCore().attachInit(() => { "use strict"; sap.ui.require([ "my/lib/sample/root/test/integration/AllJourneys" - ], function() { + ], () => { QUnit.start(); }); }); \ No newline at end of file diff --git a/demo/RootComponent/webapp/test/integration/pages/App.js b/demo/RootComponent/webapp/test/integration/pages/App.js index 9fd26141f..1634d1442 100644 --- a/demo/RootComponent/webapp/test/integration/pages/App.js +++ b/demo/RootComponent/webapp/test/integration/pages/App.js @@ -1,38 +1,38 @@ sap.ui.define([ "sap/ui/test/Opa5", "sap/ui/test/actions/Press" -], function(Opa5, Press) { +], (Opa5, Press) => { "use strict"; - var sViewName = "App"; + const sViewName = "App"; Opa5.createPageObjects({ onTheAppPage : { viewName: sViewName, actions : { - iClickOnItem : function (sId) { + iClickOnItem (sId) { return this.waitFor({ id: sId, actions: new Press({}), - success: function () { - Opa5.assert.ok(true, "The control with id '" + sId + "' was pressed."); + success () { + Opa5.assert.ok(true, `The control with id '${ sId }' was pressed.`); } }); } }, assertions : { - iShouldSeeToolPageContentDisplayed: function(sTitle){ + iShouldSeeToolPageContentDisplayed(sTitle){ return this.waitFor({ id : "toolPage", - check: function(oToolPage){ + check(oToolPage){ return sTitle === oToolPage.getHeader().getContent()[1].getText(); }, - success : function () { - Opa5.assert.ok(true, "The toolpage with title '" + sTitle + "' is displayed."); + success () { + Opa5.assert.ok(true, `The toolpage with title '${ sTitle }' is displayed.`); }, - errorMessage : "The toolpage with title '" + sTitle + "' is not displayed." + errorMessage : `The toolpage with title '${ sTitle }' is not displayed.` }); } } diff --git a/demo/RootComponent/webapp/test/integration/pages/Home.js b/demo/RootComponent/webapp/test/integration/pages/Home.js index a9b85b589..3aa4f22b2 100644 --- a/demo/RootComponent/webapp/test/integration/pages/Home.js +++ b/demo/RootComponent/webapp/test/integration/pages/Home.js @@ -1,10 +1,10 @@ sap.ui.define([ "sap/ui/test/Opa5" -], function(Opa5) { +], (Opa5) => { "use strict"; - var sViewName = "Home", - sPageId = "homePage"; + const sPageId = "homePage", + sViewName = "Home"; Opa5.createPageObjects({ onTheHomePage : { @@ -14,13 +14,13 @@ sap.ui.define([ assertions : { - iShouldSeeTheScreen : function () { + iShouldSeeTheScreen () { return this.waitFor({ id : sPageId, - success : function () { - Opa5.assert.ok(true, "The page with id '" + sPageId + "' is displayed."); + success () { + Opa5.assert.ok(true, `The page with id '${ sPageId }' is displayed.`); }, - errorMessage : "The page with id '" + sPageId + "' can not be found." + errorMessage : `The page with id '${ sPageId }' can not be found.` }); } diff --git a/demo/RootComponent/webapp/test/testsuite.qunit.js b/demo/RootComponent/webapp/test/testsuite.qunit.js index c88b87f02..b11ee3e75 100644 --- a/demo/RootComponent/webapp/test/testsuite.qunit.js +++ b/demo/RootComponent/webapp/test/testsuite.qunit.js @@ -1,11 +1,12 @@ -window.suite = function () { +/* eslint-disable no-undef, new-cap */ +window.suite = () => { "use strict"; - var oSuite = new parent.jsUnitTestSuite(), + const oSuite = new parent.jsUnitTestSuite(), sContextPath = location.pathname.substring(0, location.pathname.lastIndexOf("/") + 1); - oSuite.addTestPage(sContextPath + "unit/unitTests.qunit.html"); - oSuite.addTestPage(sContextPath + "integration/opaTests.qunit.html"); + oSuite.addTestPage(`${sContextPath }unit/unitTests.qunit.html`); + oSuite.addTestPage(`${sContextPath }integration/opaTests.qunit.html`); return oSuite; }; \ No newline at end of file diff --git a/demo/RootComponent/webapp/test/unit/AllTests.js b/demo/RootComponent/webapp/test/unit/AllTests.js index 238385ffa..f7f35e34b 100644 --- a/demo/RootComponent/webapp/test/unit/AllTests.js +++ b/demo/RootComponent/webapp/test/unit/AllTests.js @@ -1,5 +1,5 @@ sap.ui.define([ "./base/BaseController", -], function() { +], () => { "use strict"; }); \ No newline at end of file diff --git a/demo/RootComponent/webapp/test/unit/base/BaseController.js b/demo/RootComponent/webapp/test/unit/base/BaseController.js index 185b98188..7e766770f 100644 --- a/demo/RootComponent/webapp/test/unit/base/BaseController.js +++ b/demo/RootComponent/webapp/test/unit/base/BaseController.js @@ -1,14 +1,15 @@ /*global QUnit*/ +/* eslint-disable no-undefined */ sap.ui.define([ "my/lib/sample/base/BaseController" -], function(BaseController) { +], (BaseController) => { "use strict"; QUnit.module("Base Controller"); - QUnit.test("I should test the image formatter", function (assert) { - var oBaseController = new BaseController(); + QUnit.test("I should test the image formatter", (assert) => { + const oBaseController = new BaseController(); assert.strictEqual(oBaseController.base64StringToImage("335463536"), "data:image/bmp;base64,335463536" , "The base64 string is formatted to a valid HTML image string"); assert.strictEqual(oBaseController.base64StringToImage(null), null, "The base64 string is formatted to 'null' because given value is 'null'"); assert.strictEqual(oBaseController.base64StringToImage(undefined), null, "The base64 string is formatted to 'undefined' because given value is 'null'"); diff --git a/demo/RootComponent/webapp/test/unit/unitTests.qunit.js b/demo/RootComponent/webapp/test/unit/unitTests.qunit.js index b27a31c50..35f794d9e 100644 --- a/demo/RootComponent/webapp/test/unit/unitTests.qunit.js +++ b/demo/RootComponent/webapp/test/unit/unitTests.qunit.js @@ -1,12 +1,12 @@ /* global QUnit */ QUnit.config.autostart = false; -sap.ui.getCore().attachInit(function () { +sap.ui.getCore().attachInit(() => { "use strict"; sap.ui.require([ "my/lib/sample/root/test/unit/AllTests" - ], function () { + ], () => { QUnit.start(); }); }); \ No newline at end of file diff --git a/demo/SuppliersComponent/src/my/lib/sample/suppliers/Component.js b/demo/SuppliersComponent/src/my/lib/sample/suppliers/Component.js index b1fbe0fa6..b52336f07 100644 --- a/demo/SuppliersComponent/src/my/lib/sample/suppliers/Component.js +++ b/demo/SuppliersComponent/src/my/lib/sample/suppliers/Component.js @@ -1,4 +1,4 @@ -sap.ui.define(["my/lib/sample/base/Component"], function(Component) { +sap.ui.define(["my/lib/sample/base/Component"], (Component) => { "use strict"; return Component.extend("my.lib.sample.suppliers.Component", { diff --git a/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/App.controller.js b/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/App.controller.js index a586732e2..99db2839c 100644 --- a/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/App.controller.js +++ b/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/App.controller.js @@ -1,4 +1,4 @@ -sap.ui.define(["my/lib/sample/base/BaseController"], function(Controller) { +sap.ui.define(["my/lib/sample/base/BaseController"], (Controller) => { "use strict"; return Controller.extend("my.lib.sample.suppliers.controller.App", { }); diff --git a/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/Detail.controller.js b/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/Detail.controller.js index f7603b7b3..0c2ea5fd9 100644 --- a/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/Detail.controller.js +++ b/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/Detail.controller.js @@ -1,46 +1,46 @@ sap.ui.define([ "sap/ui/core/mvc/Controller", "sap/base/Log" -], function(Controller, Log) { +], (Controller, Log) => { "use strict"; return Controller.extend("my.lib.sample.suppliers.controller.Detail", { - onInit: function() { + onInit() { this.getOwnerComponent().getRouter().getRoute("detailRoute").attachMatched(this._onMatched, this); }, - _onMatched: function(oEvent) { + _onMatched(oEvent) { Log.info(this.getView().getControllerName(), "_onMatched"); - var oArgs = oEvent.getParameter("arguments"); + const oArgs = oEvent.getParameter("arguments"); this.getOwnerComponent().getModel().metadataLoaded().then(this._bindData.bind(this, oArgs.id)); }, - _bindData: function(id) { + _bindData(id) { Log.info(this.getView().getControllerName(), "_bindData"); - var sObjectPath = this.getOwnerComponent().getModel().createKey("Suppliers", { SupplierID: id }); + const sObjectPath = this.getOwnerComponent().getModel().createKey("Suppliers", { SupplierID: id }), + that = this; this.getView().bindElement({ - path: "/" + sObjectPath, + path: "/"+ sObjectPath, events: { - change: function() { - Log.info(this.getView().getControllerName(), "_bindData change"); - this.getView().setBusy(false); - }.bind(this), - dataRequested: function() { - Log.info(this.getView().getControllerName(), "_bindData dataRequested"); - this.getView().setBusy(true); - }.bind(this), - dataReceived: function() { - Log.info(this.getView().getControllerName(), "_bindData dataReceived" - ); - this.getView().setBusy(false); - if (this.getView().getBindingContext() === null) { - this.getOwnerComponent().getRouter().getTargets().display("notFound"); + change() { + Log.info(that.getView().getControllerName(), "_bindData change"); + that.getView().setBusy(false); + }, + dataRequested() { + Log.info(that.getView().getControllerName(), "_bindData dataRequested"); + that.getView().setBusy(true); + }, + dataReceived() { + Log.info(that.getView().getControllerName(), "_bindData dataReceived"); + that.getView().setBusy(false); + if (that.getView().getBindingContext() === null) { + that.getOwnerComponent().getRouter().getTargets().display("notFound"); } - }.bind(this) + } } }); } diff --git a/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/List.controller.js b/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/List.controller.js index 60a49a98c..6515661db 100644 --- a/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/List.controller.js +++ b/demo/SuppliersComponent/src/my/lib/sample/suppliers/controller/List.controller.js @@ -1,13 +1,13 @@ sap.ui.define([ "my/lib/sample/base/BaseController", "sap/base/Log" -], function(Controller, Log) { +], (Controller, Log) => { "use strict"; return Controller.extend("my.lib.sample.suppliers.controller.List", { - onPressListItem: function(oEvent) { + onPressListItem(oEvent) { Log.info(this.getView().getControllerName(), "onPressListItem"); - var oBindingContext = oEvent.getSource().getBindingContext(); + const oBindingContext = oEvent.getSource().getBindingContext(); this.getOwnerComponent() .getRouter() @@ -17,8 +17,10 @@ sap.ui.define([ productsTarget: { route: "listRoute", parameters: { - // encode the path because it could contain "/" which - // isn't allowed to use as pattern parameter directly + /* + * Encode the path because it could contain "/" which + * isn't allowed to use as pattern parameter directly + */ basepath: encodeURIComponent(oBindingContext.getPath()) } } diff --git a/demo/SuppliersComponent/src/my/lib/sample/suppliers/localService/mockserver.js b/demo/SuppliersComponent/src/my/lib/sample/suppliers/localService/mockserver.js index 020e84243..ed07163db 100644 --- a/demo/SuppliersComponent/src/my/lib/sample/suppliers/localService/mockserver.js +++ b/demo/SuppliersComponent/src/my/lib/sample/suppliers/localService/mockserver.js @@ -3,14 +3,16 @@ sap.ui.define([ "sap/ui/model/json/JSONModel", "sap/base/Log", "sap/base/util/UriParameters" -], function (MockServer, JSONModel, Log, UriParameters) { +], (MockServer, JSONModel, Log, UriParameters) => { "use strict"; - var oMockServer, - _sAppPath = "my/lib/sample/suppliers/", - _sJsonFilesPath = _sAppPath + "localService/mockdata"; - var oMockServerInterface = { + // eslint-disable-next-line init-declarations + let oMockServer; + + const sAppPath = "my/lib/sample/suppliers/", + sJsonFilesPath = `${sAppPath }localService/mockdata`, + oMockServerInterface = { /** * Initializes the mock server asynchronously. @@ -20,23 +22,23 @@ sap.ui.define([ * @param {object} [oOptionsParameter] init parameters for the mockserver * @returns{Promise} a promise that is resolved when the mock server has been started */ - init : function (oOptionsParameter) { - var oOptions = oOptionsParameter || {}; + init (oOptionsParameter) { + const oOptions = oOptionsParameter || {}; - return new Promise(function(fnResolve, fnReject) { - var sManifestUrl = sap.ui.require.toUrl(_sAppPath + "manifest.json"), + return new Promise((fnResolve, fnReject) => { + const sManifestUrl = sap.ui.require.toUrl(`${sAppPath }manifest.json`), oManifestModel = new JSONModel(sManifestUrl); - oManifestModel.attachRequestCompleted(function () { - var oUriParameters = new UriParameters(window.location.href), - // parse manifest for local metadata URI - sJsonFilesUrl = sap.ui.require.toUrl(_sJsonFilesPath), + oManifestModel.attachRequestCompleted(() => { + const oUriParameters = new UriParameters(window.location.href), + // Parse manifest for local metadata URI + sJsonFilesUrl = sap.ui.require.toUrl(sJsonFilesPath), oMainDataSource = oManifestModel.getProperty("/sap.app/dataSources/mainService"), - sMetadataUrl = sap.ui.require.toUrl(_sAppPath + oMainDataSource.settings.localUri), - // ensure there is a trailing slash - sMockServerUrl = /.*\/$/.test(oMainDataSource.uri) ? oMainDataSource.uri : oMainDataSource.uri + "/"; + sMetadataUrl = sap.ui.require.toUrl(sAppPath + oMainDataSource.settings.localUri), + // Ensure there is a trailing slash + sMockServerUrl = /.*\/$/u.test(oMainDataSource.uri) ? oMainDataSource.uri : `${oMainDataSource.uri }/`; - // create a mock server instance or stop the existing one to reinitialize + // Create a mock server instance or stop the existing one to reinitialize if (!oMockServer) { oMockServer = new MockServer({ rootUri: sMockServerUrl @@ -45,48 +47,48 @@ sap.ui.define([ oMockServer.stop(); } - // configure mock server with the given options or a default delay of 0.5s + // Configure mock server with the given options or a default delay of 0.5s MockServer.config({ autoRespond : true, autoRespondAfter : (oOptions.delay || oUriParameters.get("serverDelay") || 500) }); - // simulate all requests using mock data + // Simulate all requests using mock data oMockServer.simulate(sMetadataUrl, { sMockdataBaseUrl : sJsonFilesUrl, bGenerateMissingMockData : true }); - var aRequests = oMockServer.getRequests(); + const aRequests = oMockServer.getRequests(), - // compose an error response for each request - var fnResponse = function (iErrCode, sMessage, aRequest) { - aRequest.response = function(oXhr){ + // Compose an error response for each request + fnResponse = (iErrCode, sMessage, aRequest) => { + aRequest.response = (oXhr) => { oXhr.respond(iErrCode, {"Content-Type": "text/plain;charset=utf-8"}, sMessage); }; }; - // simulate metadata errors + // Simulate metadata errors if (oOptions.metadataError || oUriParameters.get("metadataError")) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { if (aEntry.path.toString().indexOf("$metadata") > -1) { fnResponse(500, "metadata Error", aEntry); } }); } - // simulate request errors - var sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), + // Simulate request errors + const sErrorParam = oOptions.errorType || oUriParameters.get("errorType"), iErrorCode = sErrorParam === "badRequest" ? 400 : 500; if (sErrorParam) { - aRequests.forEach(function (aEntry) { + aRequests.forEach((aEntry) => { fnResponse(iErrorCode, sErrorParam, aEntry); }); } - // custom mock behaviour may be added here + // Custom mock behaviour may be added here - // set requests and start the server + // Set requests and start the server oMockServer.setRequests(aRequests); oMockServer.start(); @@ -94,8 +96,8 @@ sap.ui.define([ fnResolve(); }); - oManifestModel.attachRequestFailed(function () { - var sError = "Failed to load application manifest"; + oManifestModel.attachRequestFailed(() => { + const sError = "Failed to load application manifest"; Log.error(sError); fnReject(new Error(sError)); @@ -107,7 +109,7 @@ sap.ui.define([ * @public returns the mockserver of the app, should be used in integration tests * @returns {sap.ui.core.util.MockServer} the mockserver instance */ - getMockServer : function () { + getMockServer () { return oMockServer; } }; diff --git a/demo/SuppliersComponent/src/my/lib/sample/suppliers/test/initMockServer.js b/demo/SuppliersComponent/src/my/lib/sample/suppliers/test/initMockServer.js index 27f6aea54..036aac215 100644 --- a/demo/SuppliersComponent/src/my/lib/sample/suppliers/test/initMockServer.js +++ b/demo/SuppliersComponent/src/my/lib/sample/suppliers/test/initMockServer.js @@ -1,25 +1,20 @@ sap.ui.define([ "../localService/mockserver" -], function (mockserver) { +], (mockserver) => { "use strict"; - var aMockservers = []; + const aMockservers = []; - // initialize the mock server + // Initialize the mock server aMockservers.push(mockserver.init()); - Promise.all(aMockservers).catch(function (oError) { - var fnShowErrorMessage = function () { - return new Promise(function (resolve, reject) { - sap.ui.require(["sap/m/MessageBox"], function (MessageBox) { - MessageBox.error(oError.message); - resolve(); - }, reject); - }); - } - return sap.ui.getCore().loadLibrary("sap.m", { async: true }).then(fnShowErrorMessage); - }).finally(function () { - // initialize the embedded component on the HTML page + Promise.all(aMockservers).catch(async (oError) => { + await sap.ui.getCore().loadLibrary("sap.m", { async: true }); + sap.ui.require(["sap/m/MessageBox"], (MessageBox) => { + MessageBox.error(oError.message); + }); + }).finally(() => { + // Initialize the embedded component on the HTML page sap.ui.require(["sap/ui/core/ComponentSupport"]); }); }); \ No newline at end of file diff --git a/demo/eslint.config.mjs b/demo/eslint.config.mjs index 9448000e1..c7475d9ef 100644 --- a/demo/eslint.config.mjs +++ b/demo/eslint.config.mjs @@ -7,8 +7,25 @@ export default [ languageOptions: { globals: { jQuery: true, - sap: true - } + sap: true, + window: true + }, + sourceType: "script" + }, + rules: { + "no-negated-condition": "off", + "no-magic-numbers": "off", + "no-ternary": "off", + "no-underscore-dangle": ["error", { "allowAfterThis": true }], + "one-var": ["off"], + "max-lines-per-function": ["error", 300], + "max-params": ["error", 5], + "max-statements": ["error", 16], + "prefer-template": ["off"], + "sort-keys": "off", + "sort-vars": "off", + "line-comment-position": "off", + "no-inline-comments": "off" } } ] diff --git a/demo/package.json b/demo/package.json index f685a1489..f96f93482 100644 --- a/demo/package.json +++ b/demo/package.json @@ -5,8 +5,7 @@ "description": "ui5-nested-component-scenario demo", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "lint": "npm run lint --workspaces --if-present", - "lint:fix": "npm run lint:fix --workspaces --if-present" + "lint": "npm run lint --workspaces --if-present" }, "workspaces": [ "BaseComponent", @@ -15,7 +14,6 @@ "SuppliersComponent", "RootComponent" ], - "author": "Jiawei Cao, Florian Vogt", "license": "Apache-2.0" }