@komaci/static-analyzer 256.0.1 → 260.0.401
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.
- package/build/shared.d.ts +1 -0
- package/build/shared.js +28 -9
- package/build/staticAnalyzer.js +5 -0
- package/package.json +5 -5
package/build/shared.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare const LLSRange: {
|
|
|
35
35
|
* @param rootAst the Abstract Syntax Tree for the component
|
|
36
36
|
* @param moduleMetadata metadata about the given component
|
|
37
37
|
* @param moduleContext contextual details about the component, like module level variables, etc
|
|
38
|
+
* @param onlyValidateWireUsedGetters optional parameter to only validate getters used in wire configurations (usedInPriming: true)
|
|
38
39
|
* @returns diagnostics for the getters
|
|
39
40
|
*/
|
|
40
41
|
export declare function analyzeSrcForInvalidGetterFunctions(adgIndex: number, rootAst: t.File, moduleMetadata: ModuleMetadata, moduleContext: ModuleContext): GetterDiagnosticsContext;
|
package/build/shared.js
CHANGED
|
@@ -89,6 +89,7 @@ exports.LLSRange = {
|
|
|
89
89
|
* @param rootAst the Abstract Syntax Tree for the component
|
|
90
90
|
* @param moduleMetadata metadata about the given component
|
|
91
91
|
* @param moduleContext contextual details about the component, like module level variables, etc
|
|
92
|
+
* @param onlyValidateWireUsedGetters optional parameter to only validate getters used in wire configurations (usedInPriming: true)
|
|
92
93
|
* @returns diagnostics for the getters
|
|
93
94
|
*/
|
|
94
95
|
function analyzeSrcForInvalidGetterFunctions(adgIndex, rootAst, moduleMetadata, moduleContext) {
|
|
@@ -98,17 +99,35 @@ function analyzeSrcForInvalidGetterFunctions(adgIndex, rootAst, moduleMetadata,
|
|
|
98
99
|
(0, common_shared_1.setGetterPropertyTypeBeforeProcessing)(getters, adgIndex, moduleMetadata);
|
|
99
100
|
const adg = moduleMetadata.adgs.get(adgIndex);
|
|
100
101
|
if (getters.length > 0 && adg) {
|
|
102
|
+
const usedByPrimingFunctions = new Set();
|
|
103
|
+
const usedByTemplates = new Set();
|
|
104
|
+
adg.functions.forEach((func) => {
|
|
105
|
+
if (func.type === common_shared_1.FunctionTypes.PRIMING_FUNCTION) {
|
|
106
|
+
func.requiredProperties.forEach((prop) => usedByPrimingFunctions.add(prop));
|
|
107
|
+
}
|
|
108
|
+
if (func.type === common_shared_1.FunctionTypes.TEMPLATE_STRING) {
|
|
109
|
+
func.requiredProperties.forEach((prop) => usedByTemplates.add(prop));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
101
112
|
getters.forEach((getterFunc, index) => {
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
(0,
|
|
113
|
+
const getterName = (0, common_shared_1.getClassMethodName)(getterFunc);
|
|
114
|
+
const property = adg.properties.get(getterName);
|
|
115
|
+
const usedByPrimingFunction = usedByPrimingFunctions.has(getterName);
|
|
116
|
+
const usedInTemplate = usedByTemplates.has(getterName);
|
|
117
|
+
const usedInPriming = typeof property !== 'undefined' ? property.usedInPriming : false;
|
|
118
|
+
// Only validate getters that are used by priming or the template
|
|
119
|
+
if (usedInPriming || usedByPrimingFunction || usedInTemplate) {
|
|
120
|
+
const res = (0, validateGetter_1.validateGetter)(getterFunc, adgIndex, moduleMetadata, moduleContext, true);
|
|
121
|
+
const getterDiagnostics = res;
|
|
122
|
+
//Same thing as passing false into validate getter and getting a boolean back. If there are no diagnostics its valid.
|
|
123
|
+
if (getterDiagnostics.length == 0) {
|
|
124
|
+
const validGetter = generateValidGetterContext(getterFunc, adgIndex, moduleMetadata, index);
|
|
125
|
+
validGetters.push(validGetter);
|
|
126
|
+
const name = (0, common_shared_1.getClassMethodName)(getterFunc);
|
|
127
|
+
(0, common_shared_1.updatePropertyUsage)(name, validGetter.memberUsage, adg.properties, common_shared_1.PropertyTypes.GETTER);
|
|
128
|
+
}
|
|
129
|
+
diagnostics.push(...getterDiagnostics);
|
|
110
130
|
}
|
|
111
|
-
diagnostics.push(...getterDiagnostics);
|
|
112
131
|
});
|
|
113
132
|
}
|
|
114
133
|
return {
|
package/build/staticAnalyzer.js
CHANGED
|
@@ -101,6 +101,9 @@ class StaticAnalyzer {
|
|
|
101
101
|
astContext: (0, common_shared_1.getAstContextObject)(rootAst),
|
|
102
102
|
isExternal: (0, common_shared_1.isExternalModule)(input.namespace),
|
|
103
103
|
};
|
|
104
|
+
if (templateKomaciDoc !== undefined) {
|
|
105
|
+
(0, common_shared_1.addTemplateUsageForAdg)(templateKomaciDoc, adgIndex, moduleMetadata);
|
|
106
|
+
}
|
|
104
107
|
const { getterFunctionDiagnostics, validGetters } = (0, shared_1.analyzeSrcForInvalidGetterFunctions)(adgIndex, rootAst, moduleMetadata, moduleContext);
|
|
105
108
|
const { templateDiagnostics, validTemplates } = (0, shared_1.analyzeSrcForTemplateStringDiagnostics)(adgIndex, rootAst, moduleMetadata, moduleContext);
|
|
106
109
|
const getterAndTemplateDiagnostics = [
|
|
@@ -638,6 +641,7 @@ class StaticAnalyzer {
|
|
|
638
641
|
name: input.name,
|
|
639
642
|
type: 'platform',
|
|
640
643
|
namespaceMapping: {},
|
|
644
|
+
npmModuleMapping: {},
|
|
641
645
|
files: [{ fileName: input.fileName, source: input.sourceFile }],
|
|
642
646
|
enableKomaci: true,
|
|
643
647
|
});
|
|
@@ -655,6 +659,7 @@ class StaticAnalyzer {
|
|
|
655
659
|
name: input.name,
|
|
656
660
|
type: 'platform',
|
|
657
661
|
namespaceMapping: {},
|
|
662
|
+
npmModuleMapping: {},
|
|
658
663
|
files: fileEntries,
|
|
659
664
|
enableKomaci: true,
|
|
660
665
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@komaci/static-analyzer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "260.0.401",
|
|
4
4
|
"description": "Komaci Diagnostics API",
|
|
5
5
|
"homepage": "https://komaci.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/types": "^7.9.0",
|
|
32
|
-
"@komaci/common-shared": "
|
|
32
|
+
"@komaci/common-shared": "258.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@komaci/types": "
|
|
35
|
+
"@komaci/types": "258.0.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@lwc/metadata": "
|
|
39
|
-
"@lwc/sfdc-compiler-utils": "
|
|
38
|
+
"@lwc/metadata": "^12.0.0",
|
|
39
|
+
"@lwc/sfdc-compiler-utils": "^12.0.0"
|
|
40
40
|
}
|
|
41
41
|
}
|