Skip to content

Commit 8ce429d

Browse files
committed
[FIX] Unhandled CallExpression expression syntax: NewExpression
1 parent 8f50df3 commit 8ce429d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/ui5-linter/src/detectors/typeChecker/FileLinter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ export default class FileLinter {
143143
return;
144144
}
145145

146+
if (ts.isNewExpression(exprNode)) {
147+
// e.g. new Class()();
148+
// This is usually unexpected and there are currently no known deprecations of functions
149+
// returned by a class constructor.
150+
// However, the OPA Matchers are a known exception where constructors do return a function.
151+
return;
152+
}
153+
146154
if (!ts.isPropertyAccessExpression(exprNode) &&
147155
!ts.isElementAccessExpression(exprNode) &&
148156
!ts.isIdentifier(exprNode)) {

packages/ui5-linter/test/fixtures/linter/rules/NoDeprecatedApi/NoDeprecatedApi_negative.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
sap.ui.define([
22
"sap/m/upload/UploadSet",
33
"sap/ui/thirdparty/jquery",
4-
"sap/m/library"
5-
], function(UploadSet, jQuery, mobileLib) {
4+
"sap/m/library",
5+
"sap/ui/test/matchers/Ancestor"
6+
], function(UploadSet, jQuery, mobileLib, Ancestor) {
67

78
var uploadSet = new UploadSet({
89
noDataText: "No data" // OK: Property 'noDataText' is only deprecated as of 1.121
@@ -13,4 +14,9 @@ sap.ui.define([
1314
});
1415

1516
mobileLib.InputType.Text;
17+
18+
// Matchers are classes but return a function instead of an instance.
19+
// This is a special case w.r.t. AST nodes, so it should be covered.
20+
// There is no deprecated API usage in the following line.
21+
new Ancestor("my-button")(uploadSet);
1622
});

0 commit comments

Comments
 (0)