From 3f2a11cc46beb292eebe367363a77f843e9fb7f1 Mon Sep 17 00:00:00 2001 From: sniperc96 Date: Sun, 7 Sep 2025 18:48:11 +0800 Subject: [PATCH] fix bug of entry Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICX085 Signed-off-by: sniperc96 --- ets2panda/linter/rule-config.json | 3 +- ets2panda/linter/src/lib/CookBookMsg.ts | 4 +- ets2panda/linter/src/lib/FaultAttrs.ts | 3 +- ets2panda/linter/src/lib/FaultDesc.ts | 3 +- ets2panda/linter/src/lib/Problems.ts | 3 +- ets2panda/linter/src/lib/TypeScriptLinter.ts | 84 +-- .../linter/src/lib/autofixes/Autofixer.ts | 212 ++++--- .../src/lib/utils/consts/ArkuiConstants.ts | 2 + .../linter/test/main/entry_componentv1_1.ets | 38 ++ .../main/entry_componentv1_1.ets.args.json | 21 + .../main/entry_componentv1_1.ets.arkts2.json | 198 +++++++ .../main/entry_componentv1_1.ets.autofix.json | 363 ++++++++++++ .../test/main/entry_componentv1_1.ets.json | 17 + .../main/entry_componentv1_1.ets.migrate.ets | 48 ++ .../main/entry_componentv1_1.ets.migrate.json | 48 ++ .../linter/test/main/entry_componentv1_2.ets | 56 ++ .../main/entry_componentv1_2.ets.args.json | 21 + .../main/entry_componentv1_2.ets.arkts2.json | 268 +++++++++ .../main/entry_componentv1_2.ets.autofix.json | 543 ++++++++++++++++++ .../test/main/entry_componentv1_2.ets.json | 17 + .../main/entry_componentv1_2.ets.migrate.ets | 62 ++ .../main/entry_componentv1_2.ets.migrate.json | 17 + .../linter/test/main/entry_componentv2_1.ets | 14 +- .../main/entry_componentv2_1.ets.arkts2.json | 98 +++- .../main/entry_componentv2_1.ets.autofix.json | 223 +++++-- .../main/entry_componentv2_1.ets.migrate.ets | 14 +- .../linter/test/main/entry_componentv2_2.ets | 2 +- .../main/entry_componentv2_2.ets.arkts2.json | 12 +- .../main/entry_componentv2_2.ets.autofix.json | 30 +- .../main/entry_componentv2_2.ets.migrate.ets | 2 +- .../main/ui_modules/common_ts_ets_api.d.ts | 5 + 31 files changed, 2218 insertions(+), 213 deletions(-) create mode 100644 ets2panda/linter/test/main/entry_componentv1_1.ets create mode 100644 ets2panda/linter/test/main/entry_componentv1_1.ets.args.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_1.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_1.ets.autofix.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_1.ets.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.ets create mode 100644 ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_2.ets create mode 100644 ets2panda/linter/test/main/entry_componentv1_2.ets.args.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_2.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_2.ets.autofix.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_2.ets.json create mode 100644 ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.ets create mode 100644 ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.json diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index 0174894363..6d799da52a 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -121,7 +121,8 @@ "arkui-persistent-prop-serialization", "arkui-persistent-props-serialization", "arkui-persistencev2-connect-serialization", - "arkui-entry-invalid-params" + "arkui-entry-invalid-params", + "arkui-entry-invalid-localstorage" ], "builtin": [ "arkts-builtin-thisArgs", diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 0c004df48d..403fe20db6 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -425,7 +425,9 @@ cookBookTag[392] = cookBookTag[393] = 'When calling the "globalConnect" and "connect" methods, the parameter list of the methods needs to include "toJson" and "fromJson" (arkui-persistencev2-connect-serialization)'; cookBookTag[394] = - 'The "@ComponentV2" decorator cannot be used together with the "@Entry" decorator that has "storage" or "useSharedStorage" parameters (arkui-entry-invalid-params)' + 'The "@Entry" decorator that has "storage" or "useSharedStorage" parameters cannot be used together with the "@ComponentV2" decorator (arkui-entry-invalid-params)'; +cookBookTag[395] = + 'The "@Entry" decorator that has a "LocalStorage" type parameter cannot be used together with the "@ComponentV2" decorator (arkui-entry-invalid-localstorage)'; cookBookTag[399] = 'ArkUI deprecated api check (arkui-no-deprecated-api)'; cookBookTag[400] = 'ArkUI sdk common deprecated api check (arkui-sdk-common-deprecated-api)'; cookBookTag[401] = 'ArkUI sdk common whitelist api check (arkui-sdk-common-whitelist-api)'; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index 383491da21..a549c0e701 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -296,7 +296,8 @@ faultsAttrs[FaultID.PromiseVoidNeedResolveArg] = new FaultAttributes(382); faultsAttrs[FaultID.PersistentPropNeedImplementMethod] = new FaultAttributes(391); faultsAttrs[FaultID.PersistentPropsNeedImplementMethod] = new FaultAttributes(392); faultsAttrs[FaultID.PersistenceV2ConnectNeedAddParam] = new FaultAttributes(393); -faultsAttrs[FaultID.EntryHasInvalidParams] = new FaultAttributes(394); +faultsAttrs[FaultID.EntryHasInvalidParamsWithV2] = new FaultAttributes(394); +faultsAttrs[FaultID.EntryHasInvalidLocalStorageWithV2] = new FaultAttributes(395); faultsAttrs[FaultID.NoDeprecatedApi] = new FaultAttributes(399); faultsAttrs[FaultID.SdkCommonApiDeprecated] = new FaultAttributes(400); faultsAttrs[FaultID.SdkCommonApiWhiteList] = new FaultAttributes(401); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 59ab653299..5663736e47 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -300,5 +300,6 @@ faultDesc[FaultID.OptionalTupleType] = 'No optional tuple type'; faultDesc[FaultID.LargeNumericLiteral] = 'Numeric literal exceeds allowed range'; faultDesc[FaultID.InstanceOfFunction] = 'instanceof with function type'; faultDesc[FaultID.unfixedTuple] = 'No unfixed tuple'; -faultDesc[FaultID.EntryHasInvalidParams] = 'Entry has invalid parameters'; faultDesc[FaultID.SuperInStaticContext] = '"super" in static context'; +faultDesc[FaultID.EntryHasInvalidParamsWithV2] = 'Entry has invalid parameters'; +faultDesc[FaultID.EntryHasInvalidLocalStorageWithV2] = 'Entry has invalid LocalStorage'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index ddf7244972..55e2c3d20f 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -300,7 +300,8 @@ export enum FaultID { InstanceOfFunction, unfixedTuple, SuperInStaticContext, - EntryHasInvalidParams, + EntryHasInvalidParamsWithV2, + EntryHasInvalidLocalStorageWithV2, // this should always be last enum LAST_ID } diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index b3309fb4e0..cc227158ea 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -7756,7 +7756,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleDecorator(node: ts.Node): void { this.handleExtendDecorator(node); - this.handleEntryDecorator(node); + this.handleEntryDecorator(node as ts.Decorator); this.handleProvideDecorator(node); this.handleLocalBuilderDecorator(node); @@ -8563,12 +8563,17 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private handleEntryDecorator(node: ts.Node): void { + private handleEntryDecorator(node: ts.Decorator): void { if (!this.options.arkts2) { return; } - if (!ts.isDecorator(node)) { + const decoratorName = TsUtils.getDecoratorName(node); + if (decoratorName !== ENTRY_DECORATOR_NAME) { + return; + } + + if (!ts.isCallExpression(node.expression)) { return; } @@ -8586,27 +8591,25 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression)) { - if (node.expression.expression.escapedText !== ENTRY_DECORATOR_NAME || node.expression.arguments.length !== 1) { + const arg = node.expression.arguments?.[0]; + if (!arg) { + return; + } + + if (ts.isObjectLiteralExpression(arg)) { + const hasStorage = arg.properties.some((property) => { + return ( + ts.isPropertyAssignment(property) && + property.name.getText() === ENTRY_STORAGE && + !ts.isStringLiteral(property.initializer) + ); + }); + if (!hasStorage) { return; } - const arg = node.expression.arguments[0]; - if (ts.isObjectLiteralExpression(arg)) { - const properties = arg.properties; - if (properties.length !== 1) { - return; - } - if (!ts.isPropertyAssignment(properties[0])) { - return; - } - const property = properties[0]; - if (ts.isStringLiteral(property.initializer)) { - return; - } - } - const autofix = this.autofixer?.fixEntryDecorator(node); - this.incrementCounters(node, FaultID.EntryAnnotation, autofix); } + const autofix = this.autofixer?.fixEntryDecorator(node, arg); + this.incrementCounters(node, FaultID.EntryAnnotation, autofix); } private handleStructPropertyDecl(propDecl: ts.PropertyDeclaration): void { @@ -15718,28 +15721,29 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } let entryDecorator: ts.Decorator | undefined; - const hasEntry = decorators.some((decorator) => { + let hasEntry: boolean = false; + let hasComponentV2: boolean = false; + decorators.forEach((decorator) => { if (TsUtils.getDecoratorName(decorator) === ENTRY_DECORATOR_NAME) { entryDecorator = decorator; - return true; + hasEntry = true; + } + if (TsUtils.getDecoratorName(decorator) === COMPONENTV2_DECORATOR_NAME) { + hasComponentV2 = true; } - return false; - }); - const hasComponentV2 = decorators.some((decorator) => { - return TsUtils.getDecoratorName(decorator) === COMPONENTV2_DECORATOR_NAME; }); - + if (!hasEntry || !hasComponentV2 || !entryDecorator) { return; } - const entryDecoratorHasInvalidParams = TypeScriptLinter.checkEntryDecoratorHasInvalidParams(entryDecorator); - if (!entryDecoratorHasInvalidParams) { - return; + if (TypeScriptLinter.checkEntryDecoratorHasInvalidParams(entryDecorator)) { + const autofix = this.autofixer?.fixEntryDecoratorHasInvalidParams(entryDecorator); + this.incrementCounters(entryDecorator, FaultID.EntryHasInvalidParamsWithV2, autofix); + } else if (TypeScriptLinter.checkEntryDecoratorHasInvaildLocalStorage(entryDecorator)) { + const autofix = this.autofixer?.fixEntryDecoratorHasInvaildLocalStorage(entryDecorator); + this.incrementCounters(entryDecorator, FaultID.EntryHasInvalidLocalStorageWithV2, autofix); } - - const autofix = this.autofixer?.fixEntryAndComponentV2(entryDecorator); - this.incrementCounters(entryDecorator, FaultID.EntryHasInvalidParams, autofix); } private static checkEntryDecoratorHasInvalidParams(entryDecorator: ts.Decorator): boolean { @@ -15749,7 +15753,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const arg = callExpr.arguments?.[0]; - if (!ts.isObjectLiteralExpression(arg)) { + if (!arg || !ts.isObjectLiteralExpression(arg)) { return false; } @@ -15760,4 +15764,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return hasInvalidParams; } + + private static checkEntryDecoratorHasInvaildLocalStorage(entryDecorator: ts.Decorator): boolean { + const callExpr = entryDecorator.expression; + if (!ts.isCallExpression(callExpr)) { + return false; + } + + const arg = callExpr.arguments?.[0]; + return arg && !ts.isObjectLiteralExpression(arg); + } } diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 374e9466d4..4f351b0223 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -47,7 +47,10 @@ import { USE_STATIC_STATEMENT, UI_CONTEXT, GET_FOCUSED_UI_CONTEXT, - GET_CONTEXT + GET_CONTEXT, + GET_SHARED, + GET_SHARED_CAPITALIZED, + COMMON_TS_ETS_API_D_TS } from '../utils/consts/ArkuiConstants'; import { ES_VALUE } from '../utils/consts/ESObject'; import type { IncrementDecrementNodeInfo } from '../utils/consts/InteropAPI'; @@ -2962,95 +2965,149 @@ export class Autofixer { return [{ start: funcDecl.getStart(), end: funcDecl.getEnd(), replacementText: text }]; } - fixEntryDecorator(entryDecorator: ts.Decorator): Autofix[] | undefined { + fixEntryDecorator(entryDecorator: ts.Decorator, arg: ts.Expression): Autofix[] | undefined { if (!ts.isCallExpression(entryDecorator.expression)) { return undefined; } - const args = entryDecorator.expression.arguments; - if (args.length !== 1) { - return undefined; + if (ts.isObjectLiteralExpression(arg)) { + return this.fixLiteralForEntry(entryDecorator, arg); } + return this.fixObjectForEntry(entryDecorator, arg); + } - const arg = args[0]; - let getLocalStorageStmt: ts.VariableStatement | undefined; + fixLiteralForEntry(decorator: ts.Decorator, objectLiteral: ts.ObjectLiteralExpression): Autofix[] | undefined { + const hasDeprecatedGetShared = objectLiteral.properties.some((property) => { + return ts.isPropertyAssignment(property) && this.checkIsDeprecatedGetShared(property.initializer); + }); + if (hasDeprecatedGetShared) { + const properties = objectLiteral.properties.filter((property) => { + return ( + ts.isPropertyAssignment(property) && + property.name.getText() !== ENTRY_USE_SHARED_STORAGE && + property.name.getText() !== ENTRY_STORAGE + ); + }); + return this.fixDeprecatedGetSharedForEntry(properties, decorator); + } - if (ts.isIdentifier(arg) || ts.isNewExpression(arg) || ts.isCallExpression(arg)) { - getLocalStorageStmt = Autofixer.createGetLocalStorageLambdaStatement(arg); - } else if (ts.isObjectLiteralExpression(arg)) { - getLocalStorageStmt = Autofixer.processEntryAnnotationObjectLiteralExpression(arg); + let storageExpr: ts.Expression | undefined; + const newProperties = objectLiteral.properties.map((property) => { + if (ts.isPropertyAssignment(property) && property.name.getText() === ENTRY_STORAGE) { + storageExpr = property.initializer; + return ts.factory.createPropertyAssignment( + property.name, + ts.factory.createStringLiteral(GET_LOCAL_STORAGE_FUNC_NAME) + ); + } + return property; + }); + + if (!storageExpr) { + return undefined; } - if (getLocalStorageStmt !== undefined) { - let text = this.printer.printNode(ts.EmitHint.Unspecified, getLocalStorageStmt, entryDecorator.getSourceFile()); - const fixedEntryDecorator = Autofixer.createFixedEntryDecorator(); - const fixedEntryDecoratorText = this.printer.printNode( - ts.EmitHint.Unspecified, - fixedEntryDecorator, - entryDecorator.getSourceFile() - ); - text = text + this.getNewLine() + fixedEntryDecoratorText; - return [{ start: entryDecorator.getStart(), end: entryDecorator.getEnd(), replacementText: text }]; + const getLocalStorageStmt = Autofixer.createLocalStorageStmt(storageExpr); + const newEntryDecorator = ts.factory.createDecorator( + ts.factory.createCallExpression(ts.factory.createIdentifier(ENTRY_DECORATOR_NAME), undefined, [ + ts.factory.createObjectLiteralExpression(newProperties, false) + ]) + ); + + const stmtText = this.printer.printNode(ts.EmitHint.Unspecified, getLocalStorageStmt, decorator.getSourceFile()); + const decoratorText = this.printer.printNode(ts.EmitHint.Unspecified, newEntryDecorator, decorator.getSourceFile()); + const text = stmtText + this.getNewLine() + decoratorText; + return [{ start: decorator.getStart(), end: decorator.getEnd(), replacementText: text }]; + } + + fixObjectForEntry(decorator: ts.Decorator, storageExpr: ts.Expression): Autofix[] { + if (this.checkIsDeprecatedGetShared(storageExpr)) { + return this.fixDeprecatedGetSharedForEntry([], decorator); } - return undefined; + + const getLocalStorageStmt = Autofixer.createLocalStorageStmt(storageExpr); + const newEntryDecorator = ts.factory.createDecorator( + ts.factory.createCallExpression(ts.factory.createIdentifier(ENTRY_DECORATOR_NAME), undefined, [ + ts.factory.createObjectLiteralExpression( + [ + ts.factory.createPropertyAssignment( + ts.factory.createIdentifier(ENTRY_STORAGE), + ts.factory.createStringLiteral(GET_LOCAL_STORAGE_FUNC_NAME) + ) + ], + false + ) + ]) + ); + const stmtText = this.printer.printNode(ts.EmitHint.Unspecified, getLocalStorageStmt, decorator.getSourceFile()); + const decoratorText = this.printer.printNode(ts.EmitHint.Unspecified, newEntryDecorator, decorator.getSourceFile()); + const text = stmtText + this.getNewLine() + decoratorText; + return [{ start: decorator.getStart(), end: decorator.getEnd(), replacementText: text }]; } - private static createFixedEntryDecorator(): ts.Decorator { - const storageProperty = ts.factory.createPropertyAssignment( - ts.factory.createIdentifier(ENTRY_STORAGE), - ts.factory.createStringLiteral(GET_LOCAL_STORAGE_FUNC_NAME) + fixDeprecatedGetSharedForEntry(properties: ts.ObjectLiteralElementLike[], decorator: ts.Decorator): Autofix[] { + const newProperties = properties.filter((property) => { + return ts.isPropertyAssignment(property); + }); + const newEntryDecorator = ts.factory.createDecorator( + ts.factory.createCallExpression(ts.factory.createIdentifier(ENTRY_DECORATOR_NAME), undefined, [ + ts.factory.createObjectLiteralExpression( + [ + ts.factory.createPropertyAssignment( + ts.factory.createIdentifier(ENTRY_USE_SHARED_STORAGE), + ts.factory.createTrue() + ), + ...newProperties + ], + false + ) + ]) ); - const objectLiteralExpr = ts.factory.createObjectLiteralExpression([storageProperty], false); - const callExpr = ts.factory.createCallExpression(ts.factory.createIdentifier(ENTRY_DECORATOR_NAME), undefined, [ - objectLiteralExpr - ]); - return ts.factory.createDecorator(callExpr); + const text = this.printer.printNode(ts.EmitHint.Unspecified, newEntryDecorator, decorator.getSourceFile()); + return [{ start: decorator.getStart(), end: decorator.getEnd(), replacementText: text }]; } - private static processEntryAnnotationObjectLiteralExpression( - expression: ts.ObjectLiteralExpression - ): ts.VariableStatement | undefined { - const objectProperties = expression.properties; - if (objectProperties.length !== 1) { - return undefined; + private checkIsDeprecatedGetShared(expr: ts.Expression): boolean { + if (!ts.isCallExpression(expr) || !ts.isPropertyAccessExpression(expr.expression)) { + return false; } - const objectProperty = objectProperties[0]; - if (!ts.isPropertyAssignment(objectProperty)) { - return undefined; + + if (expr.expression.name.getText() !== GET_SHARED && expr.expression.name.getText() !== GET_SHARED_CAPITALIZED) { + return false; } - if (ts.isIdentifier(objectProperty.name)) { - if (objectProperty.name.escapedText !== ENTRY_STORAGE) { - return undefined; - } - const properityInitializer = objectProperty.initializer; - if ( - ts.isIdentifier(properityInitializer) || - ts.isNewExpression(properityInitializer) || - ts.isCallExpression(properityInitializer) || - ts.isPropertyAccessExpression(properityInitializer) - ) { - return Autofixer.createGetLocalStorageLambdaStatement(properityInitializer); - } + + const symbol = this.typeChecker.getSymbolAtLocation(expr.expression.name); + const decl = TsUtils.getDeclaration(symbol); + if (!decl) { + return false; } - return undefined; + + const fileName = path.basename(decl.getSourceFile().fileName); + return fileName === COMMON_TS_ETS_API_D_TS; } - private static createGetLocalStorageLambdaStatement(expression: ts.Expression): ts.VariableStatement { - const variable = ts.factory.createVariableDeclaration( - ts.factory.createIdentifier(GET_LOCAL_STORAGE_FUNC_NAME), - undefined, + private static createLocalStorageStmt(storageExpr: ts.Expression): ts.VariableStatement { + return ts.factory.createVariableStatement( undefined, - ts.factory.createArrowFunction( - undefined, - undefined, - [], - ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(LOCAL_STORAGE_TYPE_NAME), undefined), - ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - expression + ts.factory.createVariableDeclarationList( + [ + ts.factory.createVariableDeclaration( + ts.factory.createIdentifier(GET_LOCAL_STORAGE_FUNC_NAME), + undefined, + undefined, + ts.factory.createArrowFunction( + undefined, + undefined, + [], + ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(LOCAL_STORAGE_TYPE_NAME), undefined), + ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + storageExpr + ) + ) + ], + ts.NodeFlags.Const ) ); - const declarationList = ts.factory.createVariableDeclarationList([variable], ts.NodeFlags.Const); - return ts.factory.createVariableStatement(undefined, declarationList); } fixProvideDecorator(provideDecorator: ts.Decorator): Autofix[] | undefined { @@ -5478,7 +5535,7 @@ export class Autofixer { ]; } - fixEntryAndComponentV2(entryDecorator: ts.Decorator): Autofix[] | undefined { + fixEntryDecoratorHasInvalidParams(entryDecorator: ts.Decorator): Autofix[] | undefined { const callExpr = entryDecorator.expression; if (!ts.isCallExpression(callExpr)) { return undefined; @@ -5494,8 +5551,21 @@ export class Autofixer { return name !== ENTRY_STORAGE && name !== ENTRY_USE_SHARED_STORAGE; }); - const newArg = ts.factory.createObjectLiteralExpression(newProperties, false); - const text = this.printer.printNode(ts.EmitHint.Unspecified, newArg, entryDecorator.getSourceFile()); - return [{ start: arg.getStart(), end: arg.getEnd(), replacementText: text }]; + const newDecorator = + newProperties.length === 0 ? + ts.factory.createDecorator(ts.factory.createIdentifier(ENTRY_DECORATOR_NAME)) : + ts.factory.createDecorator( + ts.factory.createCallExpression(ts.factory.createIdentifier(ENTRY_DECORATOR_NAME), undefined, [ + ts.factory.createObjectLiteralExpression(newProperties, false) + ]) + ); + const text = this.printer.printNode(ts.EmitHint.Unspecified, newDecorator, entryDecorator.getSourceFile()); + return [{ start: entryDecorator.getStart(), end: entryDecorator.getEnd(), replacementText: text }]; + } + + fixEntryDecoratorHasInvaildLocalStorage(entryDecorator: ts.Decorator): Autofix[] { + const newDecorator = ts.factory.createDecorator(ts.factory.createIdentifier(ENTRY_DECORATOR_NAME)); + const text = this.printer.printNode(ts.EmitHint.Unspecified, newDecorator, entryDecorator.getSourceFile()); + return [{ start: entryDecorator.getStart(), end: entryDecorator.getEnd(), replacementText: text }]; } } diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts index b16394a134..f986e8d42d 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts @@ -164,6 +164,8 @@ export const ENTRY_STORAGE = 'storage'; export const ENTRY_USE_SHARED_STORAGE = 'useSharedStorage'; export const LOCAL_STORAGE_TYPE_NAME = 'LocalStorage'; export const GET_LOCAL_STORAGE_FUNC_NAME = '__get_local_storage__'; +export const GET_SHARED = 'getShared'; +export const GET_SHARED_CAPITALIZED = 'GetShared'; export const COMPONENTV2_DECORATOR_NAME = 'ComponentV2'; diff --git a/ets2panda/linter/test/main/entry_componentv1_1.ets b/ets2panda/linter/test/main/entry_componentv1_1.ets new file mode 100644 index 0000000000..a84e7fc242 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_1.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry({ storage: new LocalStorage(), useSharedStorage: true }) +@Component +struct MyPage1 { + build() { + Text("Hello World") + } +} + +@Entry({ storage: new LocalStorage(), routeName: '' }) +@Component +struct MyPage2 { + build() { + Text("Hello World") + } +} + +@Entry({ storage: new LocalStorage(), useSharedStorage: true, routeName: '' }) +@Component +struct MyPage3 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_1.ets.args.json b/ets2panda/linter/test/main/entry_componentv1_1.ets.args.json new file mode 100644 index 0000000000..ee0734c0fc --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_1.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_1.ets.arkts2.json b/ets2panda/linter/test/main/entry_componentv1_1.ets.arkts2.json new file mode 100644 index 0000000000..ec799cbda4 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_1.ets.arkts2.json @@ -0,0 +1,198 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 64, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 23, + "endLine": 16, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 55, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 79, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 23, + "endLine": 32, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 23, + "endLine": 16, + "endColumn": 35, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 2, + "endLine": 24, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 35, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 2, + "endLine": 25, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 5, + "endLine": 28, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 23, + "endLine": 32, + "endColumn": 35, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 2, + "endLine": 33, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_1.ets.autofix.json b/ets2panda/linter/test/main/entry_componentv1_1.ets.autofix.json new file mode 100644 index 0000000000..73733f673c --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_1.ets.autofix.json @@ -0,0 +1,363 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 64, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 605, + "end": 668, + "replacementText": "const __get_local_storage__ = (): LocalStorage => new LocalStorage();\n@Entry({ storage: \"__get_local_storage__\", useSharedStorage: true })", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 64 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 23, + "endLine": 16, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 55, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 740, + "end": 794, + "replacementText": "const __get_local_storage__ = (): LocalStorage => new LocalStorage();\n@Entry({ storage: \"__get_local_storage__\", routeName: '' })", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 55 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 79, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 866, + "end": 944, + "replacementText": "const __get_local_storage__ = (): LocalStorage => new LocalStorage();\n@Entry({ storage: \"__get_local_storage__\", useSharedStorage: true, routeName: '' })", + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 79 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 23, + "endLine": 32, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 23, + "endLine": 16, + "endColumn": 35, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 2, + "endLine": 24, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 35, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 2, + "endLine": 25, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 5, + "endLine": 28, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 23, + "endLine": 32, + "endColumn": 35, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 2, + "endLine": 33, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_1.ets.json b/ets2panda/linter/test/main/entry_componentv1_1.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_1.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.ets b/ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.ets new file mode 100644 index 0000000000..8342832409 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + Entry, + LocalStorage, + Component, + Text, +} from '@kit.ArkUI'; + +const __get_local_storage__ = (): LocalStorage => new LocalStorage(); +@Entry({ storage: "__get_local_storage__", useSharedStorage: true }) +@Component +struct MyPage1 { + build() { + Text("Hello World") + } +} + +const __get_local_storage__ = (): LocalStorage => new LocalStorage(); +@Entry({ storage: "__get_local_storage__", routeName: '' }) +@Component +struct MyPage2 { + build() { + Text("Hello World") + } +} + +const __get_local_storage__ = (): LocalStorage => new LocalStorage(); +@Entry({ storage: "__get_local_storage__", useSharedStorage: true, routeName: '' }) +@Component +struct MyPage3 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.json b/ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.json new file mode 100644 index 0000000000..6e9ab3d9d7 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_1.ets.migrate.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 23, + "column": 55, + "endLine": 23, + "endColumn": 67, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 55, + "endLine": 32, + "endColumn": 67, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 55, + "endLine": 41, + "endColumn": 67, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_2.ets b/ets2panda/linter/test/main/entry_componentv1_2.ets new file mode 100644 index 0000000000..37869b9a86 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_2.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LocalStorage } from './ui_modules/common_ts_ets_api'; + +@Entry(LocalStorage.getShared()) +@Component +struct MyPage1 { + build() { + Text("Hello World") + } +} + +@Entry({ storage: LocalStorage.getShared() }) +@Component +struct MyPage2 { + build() { + Text("Hello World") + } +} + +@Entry({ storage: LocalStorage.getShared(), useSharedStorage: true }) +@Component +struct MyPage3 { + build() { + Text("Hello World") + } +} + +@Entry({ storage: LocalStorage.getShared(), routeName: '' }) +@Component +struct MyPage4 { + build() { + Text("Hello World") + } +} + +@Entry({ storage: LocalStorage.getShared(), useSharedStorage: true, routeName: '' }) +@Component +struct MyPage5 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_2.ets.args.json b/ets2panda/linter/test/main/entry_componentv1_2.ets.args.json new file mode 100644 index 0000000000..ee0734c0fc --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_2.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_2.ets.arkts2.json b/ets2panda/linter/test/main/entry_componentv1_2.ets.arkts2.json new file mode 100644 index 0000000000..cbc5c71305 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_2.ets.arkts2.json @@ -0,0 +1,268 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 33, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 21, + "endLine": 18, + "endColumn": 30, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 46, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 32, + "endLine": 26, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 1, + "endLine": 34, + "endColumn": 70, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 32, + "endLine": 34, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 1, + "endLine": 42, + "endColumn": 61, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 32, + "endLine": 42, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 1, + "endLine": 50, + "endColumn": 85, + "problem": "EntryAnnotation", + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 32, + "endLine": 50, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 2, + "endLine": 26, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 2, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 5, + "endLine": 30, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 2, + "endLine": 34, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 2, + "endLine": 35, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 2, + "endLine": 42, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 2, + "endLine": 43, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 2, + "endLine": 50, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 2, + "endLine": 51, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_2.ets.autofix.json b/ets2panda/linter/test/main/entry_componentv1_2.ets.autofix.json new file mode 100644 index 0000000000..82a891ddbc --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_2.ets.autofix.json @@ -0,0 +1,543 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 33, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 669, + "end": 701, + "replacementText": "@Entry({ useSharedStorage: true })", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 21, + "endLine": 18, + "endColumn": 30, + "problem": "NoDeprecatedApi", + "autofix": [ + { + "start": 676, + "end": 698, + "replacementText": "UIContext.getFocusedUIContext()?.getSharedLocalStorage", + "line": 18, + "column": 21, + "endLine": 18, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 46, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 773, + "end": 818, + "replacementText": "@Entry({ useSharedStorage: true })", + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 46 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 32, + "endLine": 26, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "autofix": [ + { + "start": 791, + "end": 813, + "replacementText": "UIContext.getFocusedUIContext()?.getSharedLocalStorage", + "line": 26, + "column": 32, + "endLine": 26, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 1, + "endLine": 34, + "endColumn": 70, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 890, + "end": 959, + "replacementText": "@Entry({ useSharedStorage: true })", + "line": 34, + "column": 1, + "endLine": 34, + "endColumn": 70 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 32, + "endLine": 34, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "autofix": [ + { + "start": 908, + "end": 930, + "replacementText": "UIContext.getFocusedUIContext()?.getSharedLocalStorage", + "line": 34, + "column": 32, + "endLine": 34, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 1, + "endLine": 42, + "endColumn": 61, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 1031, + "end": 1091, + "replacementText": "@Entry({ useSharedStorage: true, routeName: '' })", + "line": 42, + "column": 1, + "endLine": 42, + "endColumn": 61 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 32, + "endLine": 42, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "autofix": [ + { + "start": 1049, + "end": 1071, + "replacementText": "UIContext.getFocusedUIContext()?.getSharedLocalStorage", + "line": 42, + "column": 32, + "endLine": 42, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 1, + "endLine": 50, + "endColumn": 85, + "problem": "EntryAnnotation", + "autofix": [ + { + "start": 1163, + "end": 1247, + "replacementText": "@Entry({ useSharedStorage: true, routeName: '' })", + "line": 50, + "column": 1, + "endLine": 50, + "endColumn": 85 + } + ], + "suggest": "", + "rule": "The \"@Entry\" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 32, + "endLine": 50, + "endColumn": 41, + "problem": "NoDeprecatedApi", + "autofix": [ + { + "start": 1181, + "end": 1203, + "replacementText": "UIContext.getFocusedUIContext()?.getSharedLocalStorage", + "line": 50, + "column": 32, + "endLine": 50, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"getShared\" is deprecated (arkui-deprecated-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 2, + "endLine": 26, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 2, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 5, + "endLine": 30, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 2, + "endLine": 34, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 2, + "endLine": 35, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 2, + "endLine": 42, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 2, + "endLine": 43, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 2, + "endLine": 50, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 2, + "endLine": 51, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n Component,\n Text,\n} from '@kit.ArkUI';", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_2.ets.json b/ets2panda/linter/test/main/entry_componentv1_2.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_2.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.ets b/ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.ets new file mode 100644 index 0000000000..b9573575e0 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + Entry, + Component, + Text, +} from '@kit.ArkUI'; + +import { LocalStorage } from './ui_modules/common_ts_ets_api'; + +@Entry({ useSharedStorage: true }) +@Component +struct MyPage1 { + build() { + Text("Hello World") + } +} + +@Entry({ useSharedStorage: true }) +@Component +struct MyPage2 { + build() { + Text("Hello World") + } +} + +@Entry({ useSharedStorage: true }) +@Component +struct MyPage3 { + build() { + Text("Hello World") + } +} + +@Entry({ useSharedStorage: true, routeName: '' }) +@Component +struct MyPage4 { + build() { + Text("Hello World") + } +} + +@Entry({ useSharedStorage: true, routeName: '' }) +@Component +struct MyPage5 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.json b/ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv1_2.ets.migrate.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets b/ets2panda/linter/test/main/entry_componentv2_1.ets index ac140a9514..e639341b9f 100644 --- a/ets2panda/linter/test/main/entry_componentv2_1.ets +++ b/ets2panda/linter/test/main/entry_componentv2_1.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -@Entry({ storage: new LocalStorage() }) +@Entry(new LocalStorage()) @ComponentV2 struct MyPage1 { build() { @@ -21,7 +21,7 @@ struct MyPage1 { } } -@Entry({ useSharedStorage: true }) +@Entry({ storage: new LocalStorage() }) @ComponentV2 struct MyPage2 { build() { @@ -29,10 +29,18 @@ struct MyPage2 { } } -@Entry({ storage: new LocalStorage(), useSharedStorage: true }) +@Entry({ useSharedStorage: true }) @ComponentV2 struct MyPage3 { build() { Text("Hello World") } +} + +@Entry({ storage: new LocalStorage(), useSharedStorage: true }) +@ComponentV2 +struct MyPage4 { + build() { + Text("Hello World") + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets.arkts2.json b/ets2panda/linter/test/main/entry_componentv2_1.ets.arkts2.json index 6e46e3a973..d207f501a7 100644 --- a/ets2panda/linter/test/main/entry_componentv2_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/entry_componentv2_1.ets.arkts2.json @@ -18,17 +18,17 @@ "line": 16, "column": 1, "endLine": 16, - "endColumn": 40, - "problem": "EntryHasInvalidParams", + "endColumn": 27, + "problem": "EntryHasInvalidLocalStorageWithV2", "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has a \"LocalStorage\" type parameter cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-localstorage)", "severity": "ERROR" }, { "line": 16, - "column": 23, + "column": 12, "endLine": 16, - "endColumn": 35, + "endColumn": 24, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", @@ -38,26 +38,46 @@ "line": 24, "column": 1, "endLine": 24, + "endColumn": 40, + "problem": "EntryHasInvalidParamsWithV2", + "suggest": "", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, "endColumn": 35, - "problem": "EntryHasInvalidParams", + "problem": "DynamicCtorCall", "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { "line": 32, "column": 1, "endLine": 32, + "endColumn": 35, + "problem": "EntryHasInvalidParamsWithV2", + "suggest": "", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 1, + "endLine": 40, "endColumn": 64, - "problem": "EntryHasInvalidParams", + "problem": "EntryHasInvalidParamsWithV2", "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { - "line": 32, + "line": 40, "column": 23, - "endLine": 32, + "endLine": 40, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -76,9 +96,9 @@ }, { "line": 16, - "column": 23, + "column": 12, "endLine": 16, - "endColumn": 35, + "endColumn": 24, "problem": "UIInterfaceImport", "suggest": "", "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", @@ -114,6 +134,16 @@ "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 35, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, { "line": 25, "column": 2, @@ -145,9 +175,39 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, + "column": 2, + "endLine": 33, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 2, + "endLine": 40, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, "column": 23, - "endLine": 32, + "endLine": 40, "endColumn": 35, "problem": "UIInterfaceImport", "suggest": "", @@ -155,9 +215,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 41, "column": 2, - "endLine": 33, + "endLine": 41, "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", @@ -165,9 +225,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json b/ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json index bb47a5be22..381194a69f 100644 --- a/ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json +++ b/ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json @@ -18,28 +18,28 @@ "line": 16, "column": 1, "endLine": 16, - "endColumn": 40, - "problem": "EntryHasInvalidParams", + "endColumn": 27, + "problem": "EntryHasInvalidLocalStorageWithV2", "autofix": [ { - "start": 612, - "end": 643, - "replacementText": "{}", + "start": 605, + "end": 631, + "replacementText": "@Entry", "line": 16, "column": 1, "endLine": 16, - "endColumn": 40 + "endColumn": 27 } ], "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has a \"LocalStorage\" type parameter cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-localstorage)", "severity": "ERROR" }, { "line": 16, - "column": 23, + "column": 12, "endLine": 16, - "endColumn": 35, + "endColumn": 24, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", @@ -49,48 +49,79 @@ "line": 24, "column": 1, "endLine": 24, - "endColumn": 35, - "problem": "EntryHasInvalidParams", + "endColumn": 40, + "problem": "EntryHasInvalidParamsWithV2", "autofix": [ { - "start": 725, - "end": 751, - "replacementText": "{}", + "start": 705, + "end": 744, + "replacementText": "@Entry", "line": 24, "column": 1, "endLine": 24, - "endColumn": 35 + "endColumn": 40 } ], "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { "line": 32, "column": 1, "endLine": 32, - "endColumn": 64, - "problem": "EntryHasInvalidParams", + "endColumn": 35, + "problem": "EntryHasInvalidParamsWithV2", "autofix": [ { - "start": 833, - "end": 888, - "replacementText": "{}", + "start": 818, + "end": 852, + "replacementText": "@Entry", "line": 32, "column": 1, "endLine": 32, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 1, + "endLine": 40, + "endColumn": 64, + "problem": "EntryHasInvalidParamsWithV2", + "autofix": [ + { + "start": 926, + "end": 989, + "replacementText": "@Entry", + "line": 40, + "column": 1, + "endLine": 40, "endColumn": 64 } ], "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { - "line": 32, + "line": 40, "column": 23, - "endLine": 32, + "endLine": 40, "endColumn": 35, "problem": "DynamicCtorCall", "suggest": "", @@ -108,9 +139,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -120,18 +151,18 @@ }, { "line": 16, - "column": 23, + "column": 12, "endLine": 16, - "endColumn": 35, + "endColumn": 24, "problem": "UIInterfaceImport", "autofix": [ { "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -150,9 +181,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -171,9 +202,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -192,9 +223,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -202,6 +233,27 @@ "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 35, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", + "line": 44, + "column": 5, + "endLine": 44, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, { "line": 25, "column": 2, @@ -213,9 +265,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -234,9 +286,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -255,9 +307,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -266,9 +318,72 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, + "column": 2, + "endLine": 33, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", + "line": 44, + "column": 5, + "endLine": 44, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", + "line": 44, + "column": 5, + "endLine": 44, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 2, + "endLine": 40, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", + "line": 44, + "column": 5, + "endLine": 44, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, "column": 23, - "endLine": 32, + "endLine": 40, "endColumn": 35, "problem": "UIInterfaceImport", "autofix": [ @@ -276,9 +391,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -287,9 +402,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 41, "column": 2, - "endLine": 33, + "endLine": 41, "endColumn": 13, "problem": "UIInterfaceImport", "autofix": [ @@ -297,9 +412,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], @@ -308,9 +423,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9, "problem": "UIInterfaceImport", "autofix": [ @@ -318,9 +433,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", - "line": 36, + "line": 44, "column": 5, - "endLine": 36, + "endLine": 44, "endColumn": 9 } ], diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.ets b/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.ets index 3f08b0c506..935020015e 100644 --- a/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.ets +++ b/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.ets @@ -20,7 +20,7 @@ import { Text, } from '@kit.ArkUI'; -@Entry({}) +@Entry @ComponentV2 struct MyPage1 { build() { @@ -28,7 +28,7 @@ struct MyPage1 { } } -@Entry({}) +@Entry @ComponentV2 struct MyPage2 { build() { @@ -36,10 +36,18 @@ struct MyPage2 { } } -@Entry({}) +@Entry @ComponentV2 struct MyPage3 { build() { Text("Hello World") } +} + +@Entry +@ComponentV2 +struct MyPage4 { + build() { + Text("Hello World") + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_2.ets b/ets2panda/linter/test/main/entry_componentv2_2.ets index cf444919a1..36c0e139b9 100644 --- a/ets2panda/linter/test/main/entry_componentv2_2.ets +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets @@ -39,7 +39,7 @@ struct MyPage3 { @Entry({ routeName: "Index" }) @ComponentV2 -struct MyPage3 { +struct MyPage4 { build() { Text("Hello World") } diff --git a/ets2panda/linter/test/main/entry_componentv2_2.ets.arkts2.json b/ets2panda/linter/test/main/entry_componentv2_2.ets.arkts2.json index 729d674774..ee4c9903e0 100644 --- a/ets2panda/linter/test/main/entry_componentv2_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets.arkts2.json @@ -19,9 +19,9 @@ "column": 1, "endLine": 16, "endColumn": 60, - "problem": "EntryHasInvalidParams", + "problem": "EntryHasInvalidParamsWithV2", "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { @@ -39,9 +39,9 @@ "column": 1, "endLine": 24, "endColumn": 55, - "problem": "EntryHasInvalidParams", + "problem": "EntryHasInvalidParamsWithV2", "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { @@ -49,9 +49,9 @@ "column": 1, "endLine": 32, "endColumn": 84, - "problem": "EntryHasInvalidParams", + "problem": "EntryHasInvalidParamsWithV2", "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/entry_componentv2_2.ets.autofix.json b/ets2panda/linter/test/main/entry_componentv2_2.ets.autofix.json index dbcdb633af..2e38ee329d 100644 --- a/ets2panda/linter/test/main/entry_componentv2_2.ets.autofix.json +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets.autofix.json @@ -19,12 +19,12 @@ "column": 1, "endLine": 16, "endColumn": 60, - "problem": "EntryHasInvalidParams", + "problem": "EntryHasInvalidParamsWithV2", "autofix": [ { - "start": 612, - "end": 663, - "replacementText": "{ routeName: \"Index\" }", + "start": 605, + "end": 664, + "replacementText": "@Entry({ routeName: \"Index\" })", "line": 16, "column": 1, "endLine": 16, @@ -32,7 +32,7 @@ } ], "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { @@ -50,12 +50,12 @@ "column": 1, "endLine": 24, "endColumn": 55, - "problem": "EntryHasInvalidParams", + "problem": "EntryHasInvalidParamsWithV2", "autofix": [ { - "start": 745, - "end": 791, - "replacementText": "{ routeName: \"Index\" }", + "start": 738, + "end": 792, + "replacementText": "@Entry({ routeName: \"Index\" })", "line": 24, "column": 1, "endLine": 24, @@ -63,7 +63,7 @@ } ], "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { @@ -71,12 +71,12 @@ "column": 1, "endLine": 32, "endColumn": 84, - "problem": "EntryHasInvalidParams", + "problem": "EntryHasInvalidParamsWithV2", "autofix": [ { - "start": 873, - "end": 948, - "replacementText": "{ routeName: \"Index\" }", + "start": 866, + "end": 949, + "replacementText": "@Entry({ routeName: \"Index\" })", "line": 32, "column": 1, "endLine": 32, @@ -84,7 +84,7 @@ } ], "suggest": "", - "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "rule": "The \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters cannot be used together with the \"@ComponentV2\" decorator (arkui-entry-invalid-params)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.ets b/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.ets index ee23d5281f..8e331525f7 100644 --- a/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.ets +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.ets @@ -46,7 +46,7 @@ struct MyPage3 { @Entry({ routeName: "Index" }) @ComponentV2 -struct MyPage3 { +struct MyPage4 { build() { Text("Hello World") } diff --git a/ets2panda/linter/test/main/ui_modules/common_ts_ets_api.d.ts b/ets2panda/linter/test/main/ui_modules/common_ts_ets_api.d.ts index 2634f5bd9f..cd5d8f9777 100644 --- a/ets2panda/linter/test/main/ui_modules/common_ts_ets_api.d.ts +++ b/ets2panda/linter/test/main/ui_modules/common_ts_ets_api.d.ts @@ -16,4 +16,9 @@ export declare class PersistentStorage { static persistProp(): void; static PersistProps(): void; +} + +export declare class LocalStorage { + static GetShared(): LocalStorage; + static getShared(): LocalStorage; } \ No newline at end of file -- Gitee