Skip to content

Commit

Permalink
fix: JSON "parse" improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Apr 16, 2024
1 parent dfa8aa9 commit 64b1f71
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/linter/ui5Types/SourceFileLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ export default class SourceFileLinter {

if (!hasAsyncInterface && manifestJson?.manifest) {
// https://sapui5.hana.ondemand.com/sdk/#/topic/676b636446c94eada183b1218a824717
if (manifestJson?.["sap.ui5"]?.rootView?.async === true &&
manifestJson?.["sap.ui5"]?.routing?.config?.async === true
if (manifestJson?.manifest?.value["\"sap.ui5\""]?.value.rootView?.value.async?.value === true &&
manifestJson?.manifest?.value["\"sap.ui5\""]?.value.routing?.value.config?.value.async?.value === true
) {
return;
}
Expand All @@ -519,19 +519,33 @@ export default class SourceFileLinter {
}

const key = prop.name.getText();
if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) {
if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) {
properties[key] = { value: true, node: prop.initializer };
} else if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) {
properties[key] = { value: false, node: prop.initializer };
} else if (prop.initializer.kind === ts.SyntaxKind.NullKeyword) {
properties[key] = { value: null, node: prop.initializer };
} if (ts.isObjectLiteralExpression(prop.initializer) && prop.initializer.properties) {
} else if (ts.isObjectLiteralExpression(prop.initializer) && prop.initializer.properties) {
properties[key] = { value: this.extractPropsRecursive(prop.initializer), node: prop.initializer };
} else if (ts.isArrayLiteralExpression(prop.initializer)) {
const resolvedValue = prop.initializer.elements.map((elem) => {
if (!ts.isObjectLiteralExpression(elem)) {
return;
}

return this.extractPropsRecursive(elem)
}).filter(($) => $);

properties[key] = { value: resolvedValue, node: prop.initializer };
} else if (
(ts.isIdentifier(prop.initializer) ||
ts.isNumericLiteral(prop.initializer) ||
ts.isStringLiteral(prop.initializer))

&& prop.initializer.text) {
&& prop.initializer.getText()) {
properties[key] = { value: prop.initializer.getText(), node: prop.initializer };
} else {
throw new Error("Unhandled property assignment");
}
});
return properties;
Expand Down

0 comments on commit 64b1f71

Please sign in to comment.