ui5lint --fix should not add AMD dependency on `instanceof` usages
@flovogt is already working on this.
Since Aug 10, 2026.
- Dominant language
- TypeScript
- Stars
- 79
- Forks
- 13
- Avg merge
- 19h 34m
- Merged PRs (30d)
- 9
Description
Is your feature request related to a problem? Please describe.
Currently, the UI5 linter replaces identified usages of globals with AMD dependencies. In most cases this is the expected behavior. However, when checking whether an object belongs to a UI5 class (e.g. obj instanceof sap.m.Button) it might be desirable to avoid this dependency, either for performance reason, or because the check is a mere probing and must not lead to a dependency. In addition to the impact on the performance or adding an unwanted dependency, this might lead to a dependency cycle which might make successful loading of the module even impossible.
Describe the solution you'd like
Instead of adding an AMD dependency, use sap/ui/base/Object#isObjectA().
Enhances behavior: If there is already another dependency to the class used in instanceof (after applying all the other fixes to the module), keep the instanceof and make use of the dependency.
Describe alternatives you've considered
n/a
Additional context
Sample:
| Input to UI5 linter | sap.ui.define([], () => {
...
const isButton = ctrl instanceof sap.m.Button;
...
};
|
sap.ui.define([], () => {
...
const ctrl = new sap.m.Button();
...
const isButton = ctrl instanceof sap.m.Button;
...
}; |
|---|---|---|
| Current --fix result | sap.ui.define(["sap/m/Button"], (Button) => {
...
const isButton = ctrl instanceof Button;
...
}; |
sap.ui.define(["sap/m/Button"], (Button) => {
...
const ctrl = new Button();
...
const isButton = ctrl instanceof Button;
...
}; |
| Proposed --fix result | sap.ui.define(["sap/ui/base/Object"], (BaseObject) => {
...
const isButton = BaseObject.isObjectA(ctrl, "sap.m.Button");
...
}; |
sap.ui.define(["sap/m/Button"], (Button) => {
...
const ctrl = new Button();
...
const isButton = ctrl instanceof Button;
...
}; |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.