!73 增加自定义组件名称校验

Merge pull request !73 from yangbo_404/yangbo_1029
This commit is contained in:
openharmony_ci
2021-10-29 10:16:10 +00:00
committed by Gitee
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);
}
}