Skip to content

Commit

Permalink
fix: Include only Lib's init() method into the analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Mar 18, 2024
1 parent a3affb6 commit 2483808
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/detectors/typeChecker/FileLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export default class FileLinter {
!ts.isIdentifier(nodeExp.expression) ||
nodeExp?.expression?.text !== settings.callExpressionPropName) {
// Didn't match Instance.call(), so we're not interested anymore of analyzing it.
return "zzzz";
return;
}

let fnArgumentNode;
Expand All @@ -245,7 +245,7 @@ export default class FileLinter {
fnArgumentNode = node.arguments.find((arg: ts.Expression) =>
arg.kind === ts.SyntaxKind.Identifier && arg.getText() === settings.fnArgument);
}
return fnArgumentNode;
return fnArgumentNode || null;
}

checkLibInitCall(node: ts.CallExpression) {
Expand All @@ -267,9 +267,9 @@ export default class FileLinter {

let libVersion;

if (!fnArg) {
if (fnArg === null) { // The method is init, but nor argument has been found
libVersion = node;
} else {
} else if (fnArg) {
const apiKeyProp = (fnArg as ts.ObjectLiteralExpression)
.properties?.find((prop: ts.ObjectLiteralElementLike) => {
return ts.isPropertyAssignment(prop) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ sap.ui.define([
apiVersion: 2
});

// Should ignore
Library.anotherLibMethod({
// Should be ignored
Library.load({
apiVersion: 23
})

Expand Down
4 changes: 2 additions & 2 deletions test/lib/linter/snapshots/linter.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 33,
line: 38,
message: 'Call to deprecated function \'initLibrary\' of class \'Core\'',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
Expand All @@ -948,7 +948,7 @@ Generated by [AVA](https://avajs.dev).
{
column: 2,
fatal: undefined,
line: 33,
line: 38,
message: 'Call to deprecated function \'getCore\' (sap.ui.getCore)',
messageDetails: 'Deprecated test message',
ruleId: 'ui5-linter-no-deprecated-api',
Expand Down
Binary file modified test/lib/linter/snapshots/linter.ts.snap
Binary file not shown.

0 comments on commit 2483808

Please sign in to comment.