tutuca 0.9.20 → 0.9.21
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/dist/tutuca-cli.js +54 -20
- package/dist/tutuca-dev.js +63 -20
- package/dist/tutuca-dev.min.js +1 -1
- package/package.json +1 -1
package/dist/tutuca-cli.js
CHANGED
|
@@ -2877,32 +2877,41 @@ function defaultOnStackEnter(stack) {
|
|
|
2877
2877
|
|
|
2878
2878
|
// tools/core/lint-check.js
|
|
2879
2879
|
var ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED";
|
|
2880
|
+
var ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED";
|
|
2880
2881
|
var RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP";
|
|
2881
2882
|
var UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER";
|
|
2882
2883
|
var UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME";
|
|
2883
2884
|
var INPUT_HANDLER_NOT_IMPLEMENTED = "INPUT_HANDLER_NOT_IMPLEMENTED";
|
|
2885
|
+
var INPUT_HANDLER_NOT_REFERENCED = "INPUT_HANDLER_NOT_REFERENCED";
|
|
2884
2886
|
var INPUT_HANDLER_METHOD_NOT_IMPLEMENTED = "INPUT_HANDLER_METHOD_NOT_IMPLEMENTED";
|
|
2885
2887
|
var INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD = "INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD";
|
|
2886
2888
|
var INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER = "INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER";
|
|
2887
2889
|
var FIELD_VAL_NOT_DEFINED = "FIELD_VAL_NOT_DEFINED";
|
|
2888
2890
|
var COMPUTED_VAL_NOT_DEFINED = "COMPUTED_VAL_NOT_DEFINED";
|
|
2891
|
+
var COMPUTED_NOT_REFERENCED = "COMPUTED_NOT_REFERENCED";
|
|
2889
2892
|
var UNKNOWN_REQUEST_NAME = "UNKNOWN_REQUEST_NAME";
|
|
2890
2893
|
var UNKNOWN_COMPONENT_NAME = "UNKNOWN_COMPONENT_NAME";
|
|
2891
2894
|
var LEVEL_WARN = "warn";
|
|
2892
2895
|
var LEVEL_ERROR = "error";
|
|
2893
2896
|
var LEVEL_HINT = "hint";
|
|
2894
2897
|
function checkComponent(Comp, lx = new LintContext) {
|
|
2895
|
-
|
|
2896
|
-
|
|
2898
|
+
const referencedAlters = new Set;
|
|
2899
|
+
const referencedInputs = new Set;
|
|
2900
|
+
const referencedComputed = new Set;
|
|
2901
|
+
checkEventHandlersHaveImpls(lx, Comp, referencedInputs);
|
|
2902
|
+
checkConsistentAttrs(lx, Comp, referencedAlters, referencedComputed);
|
|
2897
2903
|
for (const name in Comp.views) {
|
|
2898
|
-
checkView(lx, Comp.views[name], Comp);
|
|
2904
|
+
checkView(lx, Comp.views[name], Comp, referencedAlters, referencedComputed);
|
|
2899
2905
|
}
|
|
2906
|
+
checkUnreferencedAlterHandlers(lx, Comp, referencedAlters);
|
|
2907
|
+
checkUnreferencedInputHandlers(lx, Comp, referencedInputs);
|
|
2908
|
+
checkUnreferencedComputed(lx, Comp, referencedComputed);
|
|
2900
2909
|
return lx;
|
|
2901
2910
|
}
|
|
2902
|
-
function checkView(lx, view, Comp) {
|
|
2911
|
+
function checkView(lx, view, Comp, referencedAlters, referencedComputed) {
|
|
2903
2912
|
checkRenderItInLoop(lx, view);
|
|
2904
2913
|
checkEventModifiers(lx, view);
|
|
2905
|
-
checkKnownHandlerNames(lx, view, Comp);
|
|
2914
|
+
checkKnownHandlerNames(lx, view, Comp, referencedAlters, referencedComputed);
|
|
2906
2915
|
}
|
|
2907
2916
|
function checkRenderItInLoop(lx, view) {
|
|
2908
2917
|
const { nodes } = view.ctx;
|
|
@@ -2954,7 +2963,7 @@ var KNOWN_HANDLER_NAMES = new Set([
|
|
|
2954
2963
|
function isKnownHandlerName(name) {
|
|
2955
2964
|
return KNOWN_HANDLER_NAMES.has(name);
|
|
2956
2965
|
}
|
|
2957
|
-
function checkKnownHandlerNames(lx, view, Comp) {
|
|
2966
|
+
function checkKnownHandlerNames(lx, view, Comp, referencedAlters, referencedComputed) {
|
|
2958
2967
|
const { computed, scope, alter, Class } = Comp;
|
|
2959
2968
|
const { prototype: proto } = Class;
|
|
2960
2969
|
const { fields } = Class.getMetaClass();
|
|
@@ -2963,12 +2972,12 @@ function checkKnownHandlerNames(lx, view, Comp) {
|
|
|
2963
2972
|
const { args } = handler.handlerCall;
|
|
2964
2973
|
for (let i = 0;i < args.length; i++) {
|
|
2965
2974
|
const arg = args[i];
|
|
2966
|
-
checkConsistentAttrVal(lx, arg, fields, proto, computed, scope, alter);
|
|
2975
|
+
checkConsistentAttrVal(lx, arg, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
2967
2976
|
}
|
|
2968
2977
|
}
|
|
2969
2978
|
}
|
|
2970
2979
|
}
|
|
2971
|
-
function checkEventHandlersHaveImpls(lx, Comp) {
|
|
2980
|
+
function checkEventHandlersHaveImpls(lx, Comp, referencedInputs) {
|
|
2972
2981
|
const { input, views, Class } = Comp;
|
|
2973
2982
|
const { prototype: proto } = Class;
|
|
2974
2983
|
for (const viewName in views) {
|
|
@@ -2978,6 +2987,7 @@ function checkEventHandlersHaveImpls(lx, Comp) {
|
|
|
2978
2987
|
const { handlerVal } = handler.handlerCall;
|
|
2979
2988
|
const hvName = handlerVal?.constructor.name;
|
|
2980
2989
|
if (hvName === "InputHandlerNameVal") {
|
|
2990
|
+
referencedInputs?.add(handlerVal.name);
|
|
2981
2991
|
if (input[handlerVal.name] === undefined) {
|
|
2982
2992
|
lx.warn(INPUT_HANDLER_NOT_IMPLEMENTED, {
|
|
2983
2993
|
name: handlerVal.name,
|
|
@@ -2993,6 +3003,7 @@ function checkEventHandlersHaveImpls(lx, Comp) {
|
|
|
2993
3003
|
}
|
|
2994
3004
|
}
|
|
2995
3005
|
} else if (hvName === "RawFieldVal") {
|
|
3006
|
+
referencedInputs?.add(handlerVal.name);
|
|
2996
3007
|
if (proto[handlerVal.name] === undefined) {
|
|
2997
3008
|
lx.warn(INPUT_HANDLER_METHOD_NOT_IMPLEMENTED, {
|
|
2998
3009
|
name: handlerVal.name,
|
|
@@ -3012,7 +3023,7 @@ function checkEventHandlersHaveImpls(lx, Comp) {
|
|
|
3012
3023
|
}
|
|
3013
3024
|
}
|
|
3014
3025
|
}
|
|
3015
|
-
function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter) {
|
|
3026
|
+
function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed) {
|
|
3016
3027
|
const valName = val?.constructor.name;
|
|
3017
3028
|
if (valName === "FieldVal" || valName === "RawFieldVal") {
|
|
3018
3029
|
const { name } = val;
|
|
@@ -3021,12 +3032,13 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter)
|
|
|
3021
3032
|
}
|
|
3022
3033
|
} else if (valName === "ComputedVal") {
|
|
3023
3034
|
const { name } = val;
|
|
3035
|
+
referencedComputed?.add(name);
|
|
3024
3036
|
if (computed[name] === undefined) {
|
|
3025
3037
|
lx.error(COMPUTED_VAL_NOT_DEFINED, { val, name });
|
|
3026
3038
|
}
|
|
3027
3039
|
} else if (valName === "SeqAccessVal") {
|
|
3028
|
-
checkConsistentAttrVal(lx, val.seqVal, fields, proto, computed, scope, alter);
|
|
3029
|
-
checkConsistentAttrVal(lx, val.keyVal, fields, proto, computed, scope, alter);
|
|
3040
|
+
checkConsistentAttrVal(lx, val.seqVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3041
|
+
checkConsistentAttrVal(lx, val.keyVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3030
3042
|
} else if (valName === "RequestVal") {
|
|
3031
3043
|
if (scope.lookupRequest(val.name) === null) {
|
|
3032
3044
|
lx.warn(UNKNOWN_REQUEST_NAME, { name: val.name });
|
|
@@ -3041,9 +3053,10 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter)
|
|
|
3041
3053
|
}
|
|
3042
3054
|
} else if (valName === "StrTplVal") {
|
|
3043
3055
|
for (const subVal of val.vals) {
|
|
3044
|
-
checkConsistentAttrVal(lx, subVal, fields, proto, computed, scope, alter);
|
|
3056
|
+
checkConsistentAttrVal(lx, subVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3045
3057
|
}
|
|
3046
3058
|
} else if (valName === "AlterHandlerNameVal") {
|
|
3059
|
+
referencedAlters?.add(val.name);
|
|
3047
3060
|
if (alter[val.name] === undefined) {
|
|
3048
3061
|
lx.warn(ALT_HANDLER_NOT_DEFINED, { name: val.name });
|
|
3049
3062
|
}
|
|
@@ -3051,7 +3064,7 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter)
|
|
|
3051
3064
|
console.log(val);
|
|
3052
3065
|
}
|
|
3053
3066
|
}
|
|
3054
|
-
function checkConsistentAttrs(lx, Comp) {
|
|
3067
|
+
function checkConsistentAttrs(lx, Comp, referencedAlters, referencedComputed) {
|
|
3055
3068
|
const { computed, scope, views, alter, Class } = Comp;
|
|
3056
3069
|
const { prototype: proto } = Class;
|
|
3057
3070
|
const { fields } = Class.getMetaClass();
|
|
@@ -3062,7 +3075,7 @@ function checkConsistentAttrs(lx, Comp) {
|
|
|
3062
3075
|
if (attrs?.constructor.name === "DynAttrs") {
|
|
3063
3076
|
for (const attr2 of attrs.items) {
|
|
3064
3077
|
if (attr2?.constructor.name === "Attr") {
|
|
3065
|
-
checkConsistentAttrVal(lx, attr2.val, fields, proto, computed, scope, alter);
|
|
3078
|
+
checkConsistentAttrVal(lx, attr2.val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3066
3079
|
}
|
|
3067
3080
|
}
|
|
3068
3081
|
}
|
|
@@ -3070,27 +3083,48 @@ function checkConsistentAttrs(lx, Comp) {
|
|
|
3070
3083
|
for (const w of wrapperAttrs) {
|
|
3071
3084
|
if (w.name === "each") {
|
|
3072
3085
|
if (w.whenVal)
|
|
3073
|
-
checkConsistentAttrVal(lx, w.whenVal, fields, proto, computed, scope, alter);
|
|
3086
|
+
checkConsistentAttrVal(lx, w.whenVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3074
3087
|
if (w.enrichWithVal)
|
|
3075
|
-
checkConsistentAttrVal(lx, w.enrichWithVal, fields, proto, computed, scope, alter);
|
|
3088
|
+
checkConsistentAttrVal(lx, w.enrichWithVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3076
3089
|
if (w.loopWithVal)
|
|
3077
|
-
checkConsistentAttrVal(lx, w.loopWithVal, fields, proto, computed, scope, alter);
|
|
3090
|
+
checkConsistentAttrVal(lx, w.loopWithVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3078
3091
|
} else if (w.name !== "scope") {
|
|
3079
|
-
checkConsistentAttrVal(lx, w.val, fields, proto, computed, scope, alter);
|
|
3092
|
+
checkConsistentAttrVal(lx, w.val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3080
3093
|
}
|
|
3081
3094
|
}
|
|
3082
3095
|
}
|
|
3083
3096
|
if (textChild) {
|
|
3084
|
-
checkConsistentAttrVal(lx, textChild, fields, proto, computed, scope, alter);
|
|
3097
|
+
checkConsistentAttrVal(lx, textChild, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3085
3098
|
}
|
|
3086
3099
|
}
|
|
3087
3100
|
for (const node of view.ctx.nodes) {
|
|
3088
3101
|
if (node.val) {
|
|
3089
|
-
checkConsistentAttrVal(lx, node.val, fields, proto, computed, scope, alter);
|
|
3102
|
+
checkConsistentAttrVal(lx, node.val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
3090
3103
|
}
|
|
3091
3104
|
}
|
|
3092
3105
|
}
|
|
3093
3106
|
}
|
|
3107
|
+
function checkUnreferencedAlterHandlers(lx, Comp, referencedAlters) {
|
|
3108
|
+
for (const name in Comp.alter) {
|
|
3109
|
+
if (!referencedAlters.has(name)) {
|
|
3110
|
+
lx.hint(ALT_HANDLER_NOT_REFERENCED, { name });
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
function checkUnreferencedInputHandlers(lx, Comp, referencedInputs) {
|
|
3115
|
+
for (const name in Comp.input) {
|
|
3116
|
+
if (!referencedInputs.has(name)) {
|
|
3117
|
+
lx.hint(INPUT_HANDLER_NOT_REFERENCED, { name });
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
function checkUnreferencedComputed(lx, Comp, referencedComputed) {
|
|
3122
|
+
for (const name in Comp.computed) {
|
|
3123
|
+
if (!referencedComputed.has(name)) {
|
|
3124
|
+
lx.hint(COMPUTED_NOT_REFERENCED, { name });
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3094
3128
|
|
|
3095
3129
|
class LintContext {
|
|
3096
3130
|
constructor() {
|
package/dist/tutuca-dev.js
CHANGED
|
@@ -7938,32 +7938,41 @@ async function compileClassesToStyleText(app, compileClasses, extraCSSClasses, C
|
|
|
7938
7938
|
}
|
|
7939
7939
|
// tools/core/lint-check.js
|
|
7940
7940
|
var ALT_HANDLER_NOT_DEFINED = "ALT_HANDLER_NOT_DEFINED";
|
|
7941
|
+
var ALT_HANDLER_NOT_REFERENCED = "ALT_HANDLER_NOT_REFERENCED";
|
|
7941
7942
|
var RENDER_IT_OUTSIDE_OF_LOOP = "RENDER_IT_OUTSIDE_OF_LOOP";
|
|
7942
7943
|
var UNKNOWN_EVENT_MODIFIER = "UNKNOWN_EVENT_MODIFIER";
|
|
7943
7944
|
var UNKNOWN_HANDLER_ARG_NAME = "UNKNOWN_HANDLER_ARG_NAME";
|
|
7944
7945
|
var INPUT_HANDLER_NOT_IMPLEMENTED = "INPUT_HANDLER_NOT_IMPLEMENTED";
|
|
7946
|
+
var INPUT_HANDLER_NOT_REFERENCED = "INPUT_HANDLER_NOT_REFERENCED";
|
|
7945
7947
|
var INPUT_HANDLER_METHOD_NOT_IMPLEMENTED = "INPUT_HANDLER_METHOD_NOT_IMPLEMENTED";
|
|
7946
7948
|
var INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD = "INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD";
|
|
7947
7949
|
var INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER = "INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER";
|
|
7948
7950
|
var FIELD_VAL_NOT_DEFINED = "FIELD_VAL_NOT_DEFINED";
|
|
7949
7951
|
var COMPUTED_VAL_NOT_DEFINED = "COMPUTED_VAL_NOT_DEFINED";
|
|
7952
|
+
var COMPUTED_NOT_REFERENCED = "COMPUTED_NOT_REFERENCED";
|
|
7950
7953
|
var UNKNOWN_REQUEST_NAME = "UNKNOWN_REQUEST_NAME";
|
|
7951
7954
|
var UNKNOWN_COMPONENT_NAME = "UNKNOWN_COMPONENT_NAME";
|
|
7952
7955
|
var LEVEL_WARN = "warn";
|
|
7953
7956
|
var LEVEL_ERROR = "error";
|
|
7954
7957
|
var LEVEL_HINT = "hint";
|
|
7955
7958
|
function checkComponent(Comp, lx = new LintContext) {
|
|
7956
|
-
|
|
7957
|
-
|
|
7959
|
+
const referencedAlters = new Set;
|
|
7960
|
+
const referencedInputs = new Set;
|
|
7961
|
+
const referencedComputed = new Set;
|
|
7962
|
+
checkEventHandlersHaveImpls(lx, Comp, referencedInputs);
|
|
7963
|
+
checkConsistentAttrs(lx, Comp, referencedAlters, referencedComputed);
|
|
7958
7964
|
for (const name in Comp.views) {
|
|
7959
|
-
checkView(lx, Comp.views[name], Comp);
|
|
7965
|
+
checkView(lx, Comp.views[name], Comp, referencedAlters, referencedComputed);
|
|
7960
7966
|
}
|
|
7967
|
+
checkUnreferencedAlterHandlers(lx, Comp, referencedAlters);
|
|
7968
|
+
checkUnreferencedInputHandlers(lx, Comp, referencedInputs);
|
|
7969
|
+
checkUnreferencedComputed(lx, Comp, referencedComputed);
|
|
7961
7970
|
return lx;
|
|
7962
7971
|
}
|
|
7963
|
-
function checkView(lx, view, Comp) {
|
|
7972
|
+
function checkView(lx, view, Comp, referencedAlters, referencedComputed) {
|
|
7964
7973
|
checkRenderItInLoop(lx, view);
|
|
7965
7974
|
checkEventModifiers(lx, view);
|
|
7966
|
-
checkKnownHandlerNames(lx, view, Comp);
|
|
7975
|
+
checkKnownHandlerNames(lx, view, Comp, referencedAlters, referencedComputed);
|
|
7967
7976
|
}
|
|
7968
7977
|
function checkRenderItInLoop(lx, view) {
|
|
7969
7978
|
const { nodes } = view.ctx;
|
|
@@ -8015,7 +8024,7 @@ var KNOWN_HANDLER_NAMES = new Set([
|
|
|
8015
8024
|
function isKnownHandlerName(name) {
|
|
8016
8025
|
return KNOWN_HANDLER_NAMES.has(name);
|
|
8017
8026
|
}
|
|
8018
|
-
function checkKnownHandlerNames(lx, view, Comp) {
|
|
8027
|
+
function checkKnownHandlerNames(lx, view, Comp, referencedAlters, referencedComputed) {
|
|
8019
8028
|
const { computed, scope, alter, Class } = Comp;
|
|
8020
8029
|
const { prototype: proto } = Class;
|
|
8021
8030
|
const { fields } = Class.getMetaClass();
|
|
@@ -8024,12 +8033,12 @@ function checkKnownHandlerNames(lx, view, Comp) {
|
|
|
8024
8033
|
const { args } = handler.handlerCall;
|
|
8025
8034
|
for (let i = 0;i < args.length; i++) {
|
|
8026
8035
|
const arg = args[i];
|
|
8027
|
-
checkConsistentAttrVal(lx, arg, fields, proto, computed, scope, alter);
|
|
8036
|
+
checkConsistentAttrVal(lx, arg, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8028
8037
|
}
|
|
8029
8038
|
}
|
|
8030
8039
|
}
|
|
8031
8040
|
}
|
|
8032
|
-
function checkEventHandlersHaveImpls(lx, Comp) {
|
|
8041
|
+
function checkEventHandlersHaveImpls(lx, Comp, referencedInputs) {
|
|
8033
8042
|
const { input, views, Class } = Comp;
|
|
8034
8043
|
const { prototype: proto } = Class;
|
|
8035
8044
|
for (const viewName in views) {
|
|
@@ -8039,6 +8048,7 @@ function checkEventHandlersHaveImpls(lx, Comp) {
|
|
|
8039
8048
|
const { handlerVal } = handler.handlerCall;
|
|
8040
8049
|
const hvName = handlerVal?.constructor.name;
|
|
8041
8050
|
if (hvName === "InputHandlerNameVal") {
|
|
8051
|
+
referencedInputs?.add(handlerVal.name);
|
|
8042
8052
|
if (input[handlerVal.name] === undefined) {
|
|
8043
8053
|
lx.warn(INPUT_HANDLER_NOT_IMPLEMENTED, {
|
|
8044
8054
|
name: handlerVal.name,
|
|
@@ -8054,6 +8064,7 @@ function checkEventHandlersHaveImpls(lx, Comp) {
|
|
|
8054
8064
|
}
|
|
8055
8065
|
}
|
|
8056
8066
|
} else if (hvName === "RawFieldVal") {
|
|
8067
|
+
referencedInputs?.add(handlerVal.name);
|
|
8057
8068
|
if (proto[handlerVal.name] === undefined) {
|
|
8058
8069
|
lx.warn(INPUT_HANDLER_METHOD_NOT_IMPLEMENTED, {
|
|
8059
8070
|
name: handlerVal.name,
|
|
@@ -8073,7 +8084,7 @@ function checkEventHandlersHaveImpls(lx, Comp) {
|
|
|
8073
8084
|
}
|
|
8074
8085
|
}
|
|
8075
8086
|
}
|
|
8076
|
-
function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter) {
|
|
8087
|
+
function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed) {
|
|
8077
8088
|
const valName = val?.constructor.name;
|
|
8078
8089
|
if (valName === "FieldVal" || valName === "RawFieldVal") {
|
|
8079
8090
|
const { name } = val;
|
|
@@ -8082,12 +8093,13 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter)
|
|
|
8082
8093
|
}
|
|
8083
8094
|
} else if (valName === "ComputedVal") {
|
|
8084
8095
|
const { name } = val;
|
|
8096
|
+
referencedComputed?.add(name);
|
|
8085
8097
|
if (computed[name] === undefined) {
|
|
8086
8098
|
lx.error(COMPUTED_VAL_NOT_DEFINED, { val, name });
|
|
8087
8099
|
}
|
|
8088
8100
|
} else if (valName === "SeqAccessVal") {
|
|
8089
|
-
checkConsistentAttrVal(lx, val.seqVal, fields, proto, computed, scope, alter);
|
|
8090
|
-
checkConsistentAttrVal(lx, val.keyVal, fields, proto, computed, scope, alter);
|
|
8101
|
+
checkConsistentAttrVal(lx, val.seqVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8102
|
+
checkConsistentAttrVal(lx, val.keyVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8091
8103
|
} else if (valName === "RequestVal") {
|
|
8092
8104
|
if (scope.lookupRequest(val.name) === null) {
|
|
8093
8105
|
lx.warn(UNKNOWN_REQUEST_NAME, { name: val.name });
|
|
@@ -8102,9 +8114,10 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter)
|
|
|
8102
8114
|
}
|
|
8103
8115
|
} else if (valName === "StrTplVal") {
|
|
8104
8116
|
for (const subVal of val.vals) {
|
|
8105
|
-
checkConsistentAttrVal(lx, subVal, fields, proto, computed, scope, alter);
|
|
8117
|
+
checkConsistentAttrVal(lx, subVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8106
8118
|
}
|
|
8107
8119
|
} else if (valName === "AlterHandlerNameVal") {
|
|
8120
|
+
referencedAlters?.add(val.name);
|
|
8108
8121
|
if (alter[val.name] === undefined) {
|
|
8109
8122
|
lx.warn(ALT_HANDLER_NOT_DEFINED, { name: val.name });
|
|
8110
8123
|
}
|
|
@@ -8112,7 +8125,7 @@ function checkConsistentAttrVal(lx, val, fields, proto, computed, scope, alter)
|
|
|
8112
8125
|
console.log(val);
|
|
8113
8126
|
}
|
|
8114
8127
|
}
|
|
8115
|
-
function checkConsistentAttrs(lx, Comp) {
|
|
8128
|
+
function checkConsistentAttrs(lx, Comp, referencedAlters, referencedComputed) {
|
|
8116
8129
|
const { computed, scope, views, alter, Class } = Comp;
|
|
8117
8130
|
const { prototype: proto } = Class;
|
|
8118
8131
|
const { fields } = Class.getMetaClass();
|
|
@@ -8123,7 +8136,7 @@ function checkConsistentAttrs(lx, Comp) {
|
|
|
8123
8136
|
if (attrs?.constructor.name === "DynAttrs") {
|
|
8124
8137
|
for (const attr2 of attrs.items) {
|
|
8125
8138
|
if (attr2?.constructor.name === "Attr") {
|
|
8126
|
-
checkConsistentAttrVal(lx, attr2.val, fields, proto, computed, scope, alter);
|
|
8139
|
+
checkConsistentAttrVal(lx, attr2.val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8127
8140
|
}
|
|
8128
8141
|
}
|
|
8129
8142
|
}
|
|
@@ -8131,27 +8144,48 @@ function checkConsistentAttrs(lx, Comp) {
|
|
|
8131
8144
|
for (const w of wrapperAttrs) {
|
|
8132
8145
|
if (w.name === "each") {
|
|
8133
8146
|
if (w.whenVal)
|
|
8134
|
-
checkConsistentAttrVal(lx, w.whenVal, fields, proto, computed, scope, alter);
|
|
8147
|
+
checkConsistentAttrVal(lx, w.whenVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8135
8148
|
if (w.enrichWithVal)
|
|
8136
|
-
checkConsistentAttrVal(lx, w.enrichWithVal, fields, proto, computed, scope, alter);
|
|
8149
|
+
checkConsistentAttrVal(lx, w.enrichWithVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8137
8150
|
if (w.loopWithVal)
|
|
8138
|
-
checkConsistentAttrVal(lx, w.loopWithVal, fields, proto, computed, scope, alter);
|
|
8151
|
+
checkConsistentAttrVal(lx, w.loopWithVal, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8139
8152
|
} else if (w.name !== "scope") {
|
|
8140
|
-
checkConsistentAttrVal(lx, w.val, fields, proto, computed, scope, alter);
|
|
8153
|
+
checkConsistentAttrVal(lx, w.val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8141
8154
|
}
|
|
8142
8155
|
}
|
|
8143
8156
|
}
|
|
8144
8157
|
if (textChild) {
|
|
8145
|
-
checkConsistentAttrVal(lx, textChild, fields, proto, computed, scope, alter);
|
|
8158
|
+
checkConsistentAttrVal(lx, textChild, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8146
8159
|
}
|
|
8147
8160
|
}
|
|
8148
8161
|
for (const node of view.ctx.nodes) {
|
|
8149
8162
|
if (node.val) {
|
|
8150
|
-
checkConsistentAttrVal(lx, node.val, fields, proto, computed, scope, alter);
|
|
8163
|
+
checkConsistentAttrVal(lx, node.val, fields, proto, computed, scope, alter, referencedAlters, referencedComputed);
|
|
8151
8164
|
}
|
|
8152
8165
|
}
|
|
8153
8166
|
}
|
|
8154
8167
|
}
|
|
8168
|
+
function checkUnreferencedAlterHandlers(lx, Comp, referencedAlters) {
|
|
8169
|
+
for (const name in Comp.alter) {
|
|
8170
|
+
if (!referencedAlters.has(name)) {
|
|
8171
|
+
lx.hint(ALT_HANDLER_NOT_REFERENCED, { name });
|
|
8172
|
+
}
|
|
8173
|
+
}
|
|
8174
|
+
}
|
|
8175
|
+
function checkUnreferencedInputHandlers(lx, Comp, referencedInputs) {
|
|
8176
|
+
for (const name in Comp.input) {
|
|
8177
|
+
if (!referencedInputs.has(name)) {
|
|
8178
|
+
lx.hint(INPUT_HANDLER_NOT_REFERENCED, { name });
|
|
8179
|
+
}
|
|
8180
|
+
}
|
|
8181
|
+
}
|
|
8182
|
+
function checkUnreferencedComputed(lx, Comp, referencedComputed) {
|
|
8183
|
+
for (const name in Comp.computed) {
|
|
8184
|
+
if (!referencedComputed.has(name)) {
|
|
8185
|
+
lx.hint(COMPUTED_NOT_REFERENCED, { name });
|
|
8186
|
+
}
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8155
8189
|
|
|
8156
8190
|
class LintContext {
|
|
8157
8191
|
constructor() {
|
|
@@ -8384,6 +8418,8 @@ function lintIdToMessage(id, info) {
|
|
|
8384
8418
|
return `Unknown handler argument '${info.name}'`;
|
|
8385
8419
|
case "INPUT_HANDLER_NOT_IMPLEMENTED":
|
|
8386
8420
|
return `Input handler '${info.name}' is not implemented`;
|
|
8421
|
+
case "INPUT_HANDLER_NOT_REFERENCED":
|
|
8422
|
+
return `Input handler '${info.name}' is defined but not referenced`;
|
|
8387
8423
|
case "INPUT_HANDLER_METHOD_NOT_IMPLEMENTED":
|
|
8388
8424
|
return `Method '.${info.name}' is not implemented`;
|
|
8389
8425
|
case "INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD":
|
|
@@ -8394,12 +8430,16 @@ function lintIdToMessage(id, info) {
|
|
|
8394
8430
|
return `Field '.${info.name}' is not defined`;
|
|
8395
8431
|
case "COMPUTED_VAL_NOT_DEFINED":
|
|
8396
8432
|
return `Computed property '$${info.name}' is not defined`;
|
|
8433
|
+
case "COMPUTED_NOT_REFERENCED":
|
|
8434
|
+
return `Computed property '$${info.name}' is defined but not referenced`;
|
|
8397
8435
|
case "UNKNOWN_REQUEST_NAME":
|
|
8398
8436
|
return `Unknown request '!${info.name}'`;
|
|
8399
8437
|
case "UNKNOWN_COMPONENT_NAME":
|
|
8400
8438
|
return `Unknown component '${info.name}'`;
|
|
8401
8439
|
case "ALT_HANDLER_NOT_DEFINED":
|
|
8402
8440
|
return `Alter handler '${info.name}' is not defined`;
|
|
8441
|
+
case "ALT_HANDLER_NOT_REFERENCED":
|
|
8442
|
+
return `Alter handler '${info.name}' is defined but not referenced`;
|
|
8403
8443
|
case "LINT_ERROR":
|
|
8404
8444
|
return info.message;
|
|
8405
8445
|
default:
|
|
@@ -8504,6 +8544,7 @@ export {
|
|
|
8504
8544
|
LEVEL_ERROR,
|
|
8505
8545
|
KList,
|
|
8506
8546
|
Set2 as ISet,
|
|
8547
|
+
INPUT_HANDLER_NOT_REFERENCED,
|
|
8507
8548
|
INPUT_HANDLER_NOT_IMPLEMENTED,
|
|
8508
8549
|
INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,
|
|
8509
8550
|
INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,
|
|
@@ -8512,5 +8553,7 @@ export {
|
|
|
8512
8553
|
FIELD_VAL_NOT_DEFINED,
|
|
8513
8554
|
Collection,
|
|
8514
8555
|
COMPUTED_VAL_NOT_DEFINED,
|
|
8556
|
+
COMPUTED_NOT_REFERENCED,
|
|
8557
|
+
ALT_HANDLER_NOT_REFERENCED,
|
|
8515
8558
|
ALT_HANDLER_NOT_DEFINED
|
|
8516
8559
|
};
|