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

fix: Unhandled CallExpression expression syntax: CallExpression #255

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/linter/ui5Types/SourceFileLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ export default class SourceFileLinter {

if (!ts.isPropertyAccessExpression(exprNode) &&
!ts.isElementAccessExpression(exprNode) &&
!ts.isIdentifier(exprNode)) {
!ts.isIdentifier(exprNode) &&
!ts.isCallExpression(exprNode)) {
// TODO: Transform into coverage message if it's really ok not to handle this
throw new Error(`Unhandled CallExpression expression syntax: ${ts.SyntaxKind[exprNode.kind]}`);
}
Expand All @@ -229,7 +230,7 @@ export default class SourceFileLinter {
reportNode = exprNode.name;
} else if (ts.isElementAccessExpression(exprNode)) {
reportNode = exprNode.argumentExpression;
} else { // Identifier
} else { // Identifier / CallExpression
reportNode = exprNode;
}

Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/linter/general/Class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import BaseObject from "sap/ui/base/Object";

class Foo extends BaseObject {
constructor() {
super();
}
}
3 changes: 3 additions & 0 deletions test/fixtures/linter/general/FunctionCall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import values from "sap/base/util/values";
const getValues = () => values;
getValues()({foo: "bar"}); // Special case: CallExpression on a CallExpression
3 changes: 3 additions & 0 deletions test/fixtures/linter/rules/NoDeprecatedApi/NoDeprecatedApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ sap.ui.define([

includes([1], 1); // Function "includes" is deprecated

const getIncludesFunction = () => includes;
getIncludesFunction()([1], 1); // Function "includes" is deprecated

Configuration.getCompatibilityVersion("sapMDialogWithPadding"); // Method "getCompatibilityVersion" is deprecated
Configuration["getCompatibilityVersion"]("sapMDialogWithPadding"); // Method "getCompatibilityVersion" is deprecated

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sap.ui.define([
"sap/ui/core/BarColor", // BarColor is defined in sap/ui/core/library
"sap/m/ListSeparators", // ListSeparators is defined in sap/m/library
"sap/ui/core/CSSSize" // TODO detect: CSSSize is defined in sap/ui/core/library
"sap/ui/core/CSSSize" // CSSSize is defined in sap/ui/core/library
], function() {

});
27 changes: 18 additions & 9 deletions test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Generated by [AVA](https://avajs.dev).
[
{
coverageInfo: [],
errorCount: 18,
errorCount: 19,
fatalErrorCount: 0,
filePath: 'NoDeprecatedApi.js',
messages: [
Expand Down Expand Up @@ -164,10 +164,19 @@ Generated by [AVA](https://avajs.dev).
ruleId: 'ui5-linter-no-deprecated-api',
severity: 2,
},
{
column: 2,
fatal: undefined,
line: 27,
message: 'Call to deprecated function \'getIncludesFunction()\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
severity: 2,
},
{
column: 16,
fatal: undefined,
line: 26,
line: 29,
message: 'Call to deprecated function \'getCompatibilityVersion\' of class \'Configuration\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
Expand All @@ -176,7 +185,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 16,
fatal: undefined,
line: 27,
line: 30,
message: 'Call to deprecated function \'getCompatibilityVersion\' of class \'Configuration\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
Expand All @@ -185,7 +194,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 29,
line: 32,
message: 'Access of deprecated property \'webview\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-property',
Expand All @@ -194,7 +203,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 30,
line: 33,
message: 'Access of deprecated property \'webview\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-property',
Expand All @@ -203,7 +212,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 32,
line: 35,
message: 'Access of deprecated property \'AnimationMode\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-property',
Expand All @@ -212,7 +221,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 34,
line: 37,
message: 'Access of deprecated property \'MessageType\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-property',
Expand All @@ -221,7 +230,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 36,
line: 39,
message: 'Access of deprecated property \'Date\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-property',
Expand All @@ -230,7 +239,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 20,
fatal: undefined,
line: 39,
line: 42,
message: 'Call to deprecated function \'storeInnerAppState\' of class \'NavigationHandler\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
Expand Down
Binary file modified test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.snap
Binary file not shown.
30 changes: 30 additions & 0 deletions test/lib/linter/snapshots/linter.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ The actual snapshot is saved in `linter.ts.snap`.

Generated by [AVA](https://avajs.dev).

## General: Class.js

> Snapshot 1

[
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'Class.js',
messages: [],
warningCount: 0,
},
]

## General: Coverage.js

> Snapshot 1
Expand Down Expand Up @@ -92,6 +107,21 @@ Generated by [AVA](https://avajs.dev).
},
]

## General: FunctionCall.js

> Snapshot 1

[
{
coverageInfo: [],
errorCount: 0,
fatalErrorCount: 0,
filePath: 'FunctionCall.js',
messages: [],
warningCount: 0,
},
]

## General: JSDoc.js

> Snapshot 1
Expand Down
Binary file modified test/lib/linter/snapshots/linter.ts.snap
Binary file not shown.