Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing autofix for methods related to jQuery.sap.* (Utils) #529

Open
13 tasks
flovogt opened this issue Feb 11, 2025 · 1 comment
Open
13 tasks

Missing autofix for methods related to jQuery.sap.* (Utils) #529

flovogt opened this issue Feb 11, 2025 · 1 comment
Labels
autofix An issue related to the autofix capabilities enhancement New feature or request

Comments

@flovogt
Copy link
Member

flovogt commented Feb 11, 2025

Missing autofix for methods related to jQuery.sap.* (Utils)

Methods related to jQuery.sap.* (Utils) are deprecated. Therefore an autofix should be offered by UI5 linter.

Deprecated APIs:

  • jQuery.sap.equal
  • jQuery.sap.each
  • jQuery.sap.forIn
  • jQuery.isPlainObject
  • jQuery.sap.parseJS
  • jQuery.sap.extend
  • jQuery.sap.now
  • jQuery.sap.properties
  • jQuery.sap.uid
  • jQuery.sap.Version
  • jQuery.sap.syncStyleClass
  • jQuery.sap.setObject
  • jQuery.sap.getObject

Deprecated Usage

var areBothObjectsEqual = jQuery.sap.equal({a:1, b:2}, {a:1, b:2});
jQuery.sap.each({name: "me", age: 32}, function(sKey, oValue) 
  console.log("key: " + sKey + ", value: " + oValue);
});
jQuery.sap.forIn({name: "you", age: 42}, function(sKey, oValue) 
  console.log("key: " + sKey + ", value: " + oValue);
});
var isObjectPlainObject = jQuery.isPlainObject({});
var parsedJS = jQuery.sap.parseJS("{name: 'me'}");
var clone = jQuery.sap.extend(true, {}, {name: "me"});
var timestampsnumber = jQuery.sap.now();
var props = jQuery.sap.properties({ url: sap.ui.require.toUrl(sap.ui.require.toUrl("testdata/test.properties"))});
var myUid = jQuery.sap.uid();
var v = jQuery.sap.Version("3.6.2");
var v2 = new jQuery.sap.Version("3.6.2");
myDialog = jQuery.sap.syncStyleClass("sapUiSizeCompact", this.getView(), myDialog);
jQuery.sap.setObject("name.lastname", "Miller", { name: { firstname: "me" }});
var myFirstName = jQuery.sap.getObject("name.firstname", 0, { name: { firstname: "me" }});

Recommended Usage

sap.ui.define([
  "sap/base/util/deepEqual",
  "sap/base/util/each",
  "sap/base/util/isPlainObject",
  "sap/base/util/JSTokenizer",
  "sap/base/util/merge",
  "sap/base/util/now",
  "sap/base/util/Properties",
  "sap/base/util/uid",
  "sap/base/util/Version",
  "sap/ui/core/syncStyleClass",
  "sap/base/util/ObjectPath"
], (deepEqual, each, isPlainObject, JSTokenizer, merge, now, Properties, uid, Version, syncStyleClass, ObjectPath) => {
  var areBothObjectsEqual = deepEqual({a:1, b:2}, {a:1, b:2});
  each({name: "me", age: 32}, function(sKey, oValue) 
    console.log("key: " + sKey + ", value: " + oValue);
  });
  each({name: "you", age: 42}, function(sKey, oValue) 
    console.log("key: " + sKey + ", value: " + oValue);
  });
  var isObjectPlainObject = isPlainObject({});
  var parsedJS = JSTokenizer.parseJS("{name: 'me'}");
  var clone = merge({}, {name: "me"});
  var timestampsnumber = now();
  var props = Properties.create({ url: sap.ui.require.toUrl(sap.ui.require.toUrl("testdata/test.properties"))});
  var myUid = uid();
  var v = Version("3.6.2");
  var v2 = new Version("3.6.2");
  myDialog = syncStyleClass("sapUiSizeCompact", this.getView(), myDialog);
  ObjectPath.set("name.lastname", "Miller", { name: { firstname: "me" }});
  // in case object path used in `ObjectPath.get` does not exist, ObjectPath.create("name.firstname", myObject) has to be called before
  var myFirstName = ObjectPath.get("name.firstname", 0, { name: { firstname: "me" }});
});

Note for jQuery.sap.extend: Without enforcing a deep copy while using true as first parameter a shallow copy is created. This is not supported by sap/base/util/merge. For shallow copies browser native Object.assign() might be used but null and undefined values are ignored.

@flovogt flovogt added enhancement New feature or request autofix An issue related to the autofix capabilities labels Feb 11, 2025
@flovogt
Copy link
Member Author

flovogt commented Feb 11, 2025

Will be implemented in CPOUI5FOUNDATION-990.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autofix An issue related to the autofix capabilities enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant