add custom component name validate

Signed-off-by: yangbo <1442420648@qq.com>
Change-Id: Ib196c2c7daabb7a0c855dad0546b3670ebd8eec3
This commit is contained in:
yangbo
2021-10-29 17:23:44 +08:00
parent a8b94fb58f
commit f16c72f9e8
2 changed files with 11 additions and 5 deletions
+2 -2
View File
@@ -30,8 +30,8 @@ function preProcess(source: string): string {
if (/\.ets$/.test(this.resourcePath)) {
const result: ReplaceResult = sourceReplace(source, this.resourcePath);
const newContent: string = result.content;
const log: LogInfo[] = result.log;
log.concat(validateUISyntax(source, newContent, this.resourcePath, this.resourceQuery));
const log: LogInfo[] = result.log.concat(validateUISyntax(source, newContent,
this.resourcePath, this.resourceQuery));
if (log.length) {
emitLogInfo(this, log);
}
+9 -3
View File
@@ -189,7 +189,8 @@ function validateEntryCount(result: DecoratorResult, fileQuery: string,
if (result.entryCount !== 1 && fileQuery === '?entry') {
log.push({
type: LogType.ERROR,
message: `A page must have one and only one '@Entry' decorator with a struct.`,
message: `A page configured in 'config.json' must have one and only one '@Entry' `
+ `decorator with a struct.`,
fileName: fileName
});
}
@@ -266,8 +267,13 @@ function checkDecorators(node: ts.MissingDeclaration | ts.ExportAssignment, resu
addLog(LogType.WARN, message, component.pos, log, sourceFile);
}
if (BUILDIN_STYLE_NAMES.has(componentName)) {
const message: string =
`The struct '${componentName}' cannot have the same name as the built-in attribute '${componentName}'.`;
const message: string = `The struct '${componentName}' cannot have the same name ` +
`as the built-in attribute '${componentName}'.`;
addLog(LogType.ERROR, message, component.pos, log, sourceFile);
}
if (INNER_COMPONENT_NAMES.has(componentName)) {
const message: string = `The struct '${componentName}' cannot have the same name ` +
`as the built-in component '${componentName}'.`;
addLog(LogType.ERROR, message, component.pos, log, sourceFile);
}
}