fix(validator): add expression keywords list

This commit is contained in:
Bowen Tan 2022-07-08 15:37:48 +08:00
parent 5f8da1bc0e
commit 158c462a95
2 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { get, has } from 'lodash';
import { ExpressionKeywords } from '@sunmao-ui/shared';
import { ComponentId, ModuleId } from '../../AppModel/IAppModel';
import {
PropertiesValidatorRule,
@ -104,8 +105,11 @@ class ExpressionValidatorRule implements PropertiesValidatorRule {
} else if (dependencyNames.includes(id)) {
// case 4: id is from dependency
// do nothing
} else if (ExpressionKeywords.includes(id)) {
// case 5: id is from expression keywords
// do nothing
} else {
// case 5: id doesn't exist
// case 6: id doesn't exist
results.push({
message: `Cannot find '${id}' in store or window.`,
componentId: component.id,

View File

@ -4,5 +4,14 @@ export const EXPRESSION = {
};
export const LIST_ITEM_EXP = '$listItem';
export const LIST_ITEM_INDEX_EXP = '$i';
export const SLOT_PROPS_EXP = '$slot';
export const GLOBAL_UTIL_METHOD_ID = '$utils';
export const GLOBAL_MODULE_ID = '$module';
export const ExpressionKeywords = [
LIST_ITEM_EXP,
LIST_ITEM_INDEX_EXP,
SLOT_PROPS_EXP,
GLOBAL_UTIL_METHOD_ID,
GLOBAL_MODULE_ID,
];