@komaci/static-analyzer 242.1.7 → 242.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -60,12 +60,8 @@ function checkRenderFunctionReturnValues(returnStmt, moduleMetadata) {
|
|
|
60
60
|
else if (returnStmt.argument &&
|
|
61
61
|
returnStmt.argument.type == 'ConditionalExpression') {
|
|
62
62
|
const conditionalExpr = returnStmt.argument;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const consequenceTemplateImport = moduleMetadata.importsByName.get(consequence.name);
|
|
66
|
-
const alternateTemplateImport = moduleMetadata.importsByName.get(alternate.name);
|
|
67
|
-
if (!consequenceTemplateImport.templateKomaciDoc &&
|
|
68
|
-
!alternateTemplateImport.templateKomaciDoc) {
|
|
63
|
+
const isValidCondtional = validateConditionalExpression(conditionalExpr, moduleMetadata, returnStmt);
|
|
64
|
+
if (!isValidCondtional) {
|
|
69
65
|
if (returnStmt.loc) {
|
|
70
66
|
return (0, rules_1.getPrimingDiagnostic)(rules_1.diagnosticMessages.NO_RENDER_FUNCTION_RETURN_STATEMENT_NOT_RETURNING_IMPORTED_TEMPLATE, shared_1.LLSRange.fromBabelSourceLocation(returnStmt.loc), []);
|
|
71
67
|
}
|
|
@@ -79,4 +75,55 @@ function checkRenderFunctionReturnValues(returnStmt, moduleMetadata) {
|
|
|
79
75
|
return undefined;
|
|
80
76
|
}
|
|
81
77
|
exports.checkRenderFunctionReturnValues = checkRenderFunctionReturnValues;
|
|
78
|
+
/**
|
|
79
|
+
* A recursive function that will validate conditionals and nested conditionals.
|
|
80
|
+
* @param conditionalExpr the root conditional expression
|
|
81
|
+
* @param moduleMetadata the module metadata
|
|
82
|
+
* @param returnStmt the return statement node
|
|
83
|
+
* @returns true or false if the conditonal is valid.
|
|
84
|
+
*/
|
|
85
|
+
function validateConditionalExpression(conditionalExpr, moduleMetadata, returnStmt) {
|
|
86
|
+
const consequence = conditionalExpr.consequent;
|
|
87
|
+
const alternate = conditionalExpr.alternate;
|
|
88
|
+
//checking the consequent condition
|
|
89
|
+
if (consequence.type === 'ConditionalExpression') {
|
|
90
|
+
const isValid = validateConditionalExpression(consequence, moduleMetadata, returnStmt);
|
|
91
|
+
if (!isValid) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (consequence.type === 'Identifier') {
|
|
97
|
+
const consequenceTemplateImport = moduleMetadata.importsByName.get(consequence.name);
|
|
98
|
+
if (!consequenceTemplateImport.templateKomaciDoc) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
//the consequent was not an identifier or another conditional.
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//Checking the alternate condition
|
|
108
|
+
if (alternate.type === 'ConditionalExpression') {
|
|
109
|
+
const isValid = validateConditionalExpression(alternate, moduleMetadata, returnStmt);
|
|
110
|
+
if (!isValid) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (alternate.type === 'Identifier') {
|
|
116
|
+
const alternateTemplateImport = moduleMetadata.importsByName.get(alternate.name);
|
|
117
|
+
if (!alternateTemplateImport.templateKomaciDoc) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
//the alternate was not an identifier or another conditional.
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//the condtional will return a valid template.
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
82
129
|
//# sourceMappingURL=returnStatementInvariantFunctions.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@komaci/static-analyzer",
|
|
3
|
-
"version": "242.1.
|
|
3
|
+
"version": "242.1.9",
|
|
4
4
|
"description": "Komaci Diagnostics API",
|
|
5
5
|
"homepage": "https://komaci.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"!**/RULES.todo.md"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@komaci/common-shared": "242.1.
|
|
31
|
+
"@komaci/common-shared": "242.1.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/types": "^7.9.0",
|
|
35
|
-
"@komaci/types": "242.1.
|
|
35
|
+
"@komaci/types": "242.1.9"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@lwc/metadata": "2.22.0-0",
|