!3956 增加Span使用通用属性不生效告警提示

Merge pull request !3956 from zhouyan/spantip
This commit is contained in:
openharmony_ci 2024-11-22 02:59:19 +00:00 committed by Gitee
commit f632f7310c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 15 additions and 1 deletions

View File

@ -603,3 +603,4 @@ export const ARKTS_MODULE_PREFIX: string = '@arkts';
export const ARKTS_MODULE_NAME: string = 'arkts';
export const COLD_RELOAD_MODE: string = 'coldReload';
export const INTEGRATED_HSP: string = 'integratedHsp';
export const SpanComponents: string[] = ['Span'];

View File

@ -137,7 +137,8 @@ import {
NAVIGATION,
CREATE_ROUTER_COMPONENT_COLLECT,
NAV_PATH_STACK,
IS_USER_CREATE_STACK
IS_USER_CREATE_STACK,
SpanComponents
} from './pre_define';
import {
INNER_COMPONENT_NAMES,
@ -2147,6 +2148,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode:
}
while (temp && ts.isCallExpression(temp) && temp.expression) {
let flag: boolean = false;
validatePropertyAccessExpressionOnSpanComponent(temp.expression, identifierNode, log);
if (temp.expression && (validatePropertyAccessExpressionWithCustomBuilder(temp.expression) ||
validateIdentifierWithCustomBuilder(temp.expression))) {
let propertyName: string = '';
@ -2595,6 +2597,17 @@ function validateIdentifierWithCustomBuilder(node: ts.Node): boolean {
return ts.isIdentifier(node) && CUSTOM_BUILDER_PROPERTIES.has(node.escapedText.toString());
}
function validatePropertyAccessExpressionOnSpanComponent(node: ts.Node, identifierNode: ts.Identifier, log: LogInfo[]): void {
if (SpanComponents.includes(identifierNode.escapedText.toString()) && ts.isPropertyAccessExpression(node) && node.name &&
ts.isIdentifier(node.name) && BUILDIN_STYLE_NAMES.has(node.name.escapedText.toString())) {
log.push({
type: LogType.WARN,
message: `Property '${node.name.escapedText.toString()}' does not take effect on '${identifierNode.escapedText.toString()}'.`,
pos: node.getStart()
});
}
}
function createArrowFunctionForDollar($$varExp: ts.Expression): ts.ArrowFunction {
return ts.factory.createArrowFunction(
undefined, undefined,