From e2638b3a895b38521fcec993a689bebd8acb637c Mon Sep 17 00:00:00 2001 From: sniperc96 Date: Thu, 28 Aug 2025 21:17:57 +0800 Subject: [PATCH] arkui entry Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICWELG Signed-off-by: sniperc96 --- ets2panda/linter/rule-config.json | 3 +- ets2panda/linter/src/lib/CookBookMsg.ts | 2 + ets2panda/linter/src/lib/FaultAttrs.ts | 1 + ets2panda/linter/src/lib/FaultDesc.ts | 1 + ets2panda/linter/src/lib/Problems.ts | 1 + ets2panda/linter/src/lib/TypeScriptLinter.ts | 74 +++- .../linter/src/lib/autofixes/Autofixer.ts | 41 +- .../src/lib/utils/consts/ArkuiConstants.ts | 5 +- .../linter/test/main/entry_componentv2_1.ets | 38 ++ .../main/entry_componentv2_1.ets.args.json | 21 + .../main/entry_componentv2_1.ets.arkts2.json | 178 ++++++++ .../main/entry_componentv2_1.ets.autofix.json | 332 +++++++++++++++ .../test/main/entry_componentv2_1.ets.json | 17 + .../main/entry_componentv2_1.ets.migrate.ets | 45 ++ .../main/entry_componentv2_1.ets.migrate.json | 17 + .../linter/test/main/entry_componentv2_2.ets | 46 ++ .../main/entry_componentv2_2.ets.args.json | 21 + .../main/entry_componentv2_2.ets.arkts2.json | 208 +++++++++ .../main/entry_componentv2_2.ets.autofix.json | 395 ++++++++++++++++++ .../test/main/entry_componentv2_2.ets.json | 17 + .../main/entry_componentv2_2.ets.migrate.ets | 53 +++ .../main/entry_componentv2_2.ets.migrate.json | 17 + 22 files changed, 1520 insertions(+), 13 deletions(-) create mode 100644 ets2panda/linter/test/main/entry_componentv2_1.ets create mode 100644 ets2panda/linter/test/main/entry_componentv2_1.ets.args.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_1.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_1.ets.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.ets create mode 100644 ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_2.ets create mode 100644 ets2panda/linter/test/main/entry_componentv2_2.ets.args.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_2.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_2.ets.autofix.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_2.ets.json create mode 100644 ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.ets create mode 100644 ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.json diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index 0c613f3a2f..ce23e601c8 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -151,7 +151,8 @@ "arkui-sdk-common-behaviorchange-api", "arkui-persistent-prop-serialization", "arkui-persistent-props-serialization", - "arkui-persistencev2-connect-serialization" + "arkui-persistencev2-connect-serialization", + "arkui-entry-invalid-params" ], "builtin": [ "arkts-builtin-thisArgs", diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 7a3f6d4552..1378f22f9b 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -424,6 +424,8 @@ cookBookTag[392] = 'The class of the "defaultValue" parameter in the literal passed to the "persistProps" method must be a primitive type or Date type, or implement the "toJson" and "fromJson" methods (arkui-persistent-props-serialization)'; 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)' 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 7de7999b99..383491da21 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -296,6 +296,7 @@ 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.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 5b39e917f8..573acfd0c0 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -299,3 +299,4 @@ faultDesc[FaultID.BuiltinIteratorResultValue] = 'IteratorResult.value is not sup faultDesc[FaultID.OptionalTupleType] = 'No optional tuple type'; faultDesc[FaultID.LargeNumericLiteral] = 'Numeric literal exceeds allowed range'; faultDesc[FaultID.unfixedTuple] = 'No unfixed tuple'; +faultDesc[FaultID.EntryHasInvalidParams] = 'Entry has invalid parameters'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index fd32b020c0..ddf7244972 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -300,6 +300,7 @@ export enum FaultID { InstanceOfFunction, unfixedTuple, SuperInStaticContext, + EntryHasInvalidParams, // 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 bdd815d5ef..eaba7d5f29 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -143,7 +143,10 @@ import { GLOBAL_CONNECT_FUNC_NAME, CONNECT_FUNC_NAME, serializationTypeFlags, - serializationTypeName + serializationTypeName, + COMPONENTV2_DECORATOR_NAME, + ENTRY_STORAGE, + ENTRY_USE_SHARED_STORAGE } from './utils/consts/ArkuiConstants'; import { arkuiImportList } from './utils/consts/ArkuiImportList'; import type { IdentifierAndArguments, ForbidenAPICheckResult } from './utils/consts/InteropAPI'; @@ -955,6 +958,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } this.handleStructDeclarationForLayout(node); this.handleInvalidIdentifier(node); + this.handleStructDeclForEntryAndComponentV2(node); } private handleParameter(node: ts.Node): void { @@ -8557,6 +8561,20 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } + const structDecl = node.parent; + if (!ts.isStructDeclaration(structDecl)) { + return; + } + + const decorators = ts.getDecorators(structDecl); + const hasComponentV2 = decorators?.some((decorator) => { + return decorator.expression.getText() === COMPONENTV2_DECORATOR_NAME; + }); + + if (hasComponentV2) { + return; + } + if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression)) { if (node.expression.expression.escapedText !== ENTRY_DECORATOR_NAME || node.expression.arguments.length !== 1) { return; @@ -15608,4 +15626,58 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.SuperInStaticContext); } } + + private handleStructDeclForEntryAndComponentV2(node: ts.StructDeclaration): void { + if (!this.options.arkts2) { + return; + } + + const decorators = ts.getDecorators(node); + if (!decorators) { + return; + } + + let entryDecorator: ts.Decorator | undefined; + const hasEntry = decorators.some((decorator) => { + if (TsUtils.getDecoratorName(decorator) === ENTRY_DECORATOR_NAME) { + entryDecorator = decorator; + return 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; + } + + const autofix = this.autofixer?.fixEntryAndComponentV2(entryDecorator); + this.incrementCounters(entryDecorator, FaultID.EntryHasInvalidParams, autofix); + } + + private static checkEntryDecoratorHasInvalidParams(entryDecorator: ts.Decorator): boolean { + const callExpr = entryDecorator.expression; + if (!ts.isCallExpression(callExpr)) { + return false; + } + + const arg = callExpr.arguments?.[0]; + if (!ts.isObjectLiteralExpression(arg)) { + return false; + } + + const hasInvalidParams = arg.properties.some((property) => { + const name = property.name?.getText(); + return name === ENTRY_STORAGE || name === ENTRY_USE_SHARED_STORAGE; + }); + + return hasInvalidParams; + } } diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 8fec792915..99faeb64c8 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -34,7 +34,8 @@ import { VALUE_IDENTIFIER, INDENT_STEP, ENTRY_DECORATOR_NAME, - ENTRY_STORAGE_PROPERITY, + ENTRY_STORAGE, + ENTRY_USE_SHARED_STORAGE, LOCAL_STORAGE_TYPE_NAME, GET_LOCAL_STORAGE_FUNC_NAME, PROVIDE_DECORATOR_NAME, @@ -2934,23 +2935,22 @@ export class Autofixer { return undefined; } - const parentNode = entryDecorator.parent; const arg = args[0]; - let getLocalStorageStatement: ts.VariableStatement | undefined; + let getLocalStorageStmt: ts.VariableStatement | undefined; if (ts.isIdentifier(arg) || ts.isNewExpression(arg) || ts.isCallExpression(arg)) { - getLocalStorageStatement = Autofixer.createGetLocalStorageLambdaStatement(arg); + getLocalStorageStmt = Autofixer.createGetLocalStorageLambdaStatement(arg); } else if (ts.isObjectLiteralExpression(arg)) { - getLocalStorageStatement = Autofixer.processEntryAnnotationObjectLiteralExpression(arg); + getLocalStorageStmt = Autofixer.processEntryAnnotationObjectLiteralExpression(arg); } - if (getLocalStorageStatement !== undefined) { - let text = this.printer.printNode(ts.EmitHint.Unspecified, getLocalStorageStatement, parentNode.getSourceFile()); + 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, - parentNode.getSourceFile() + entryDecorator.getSourceFile() ); text = text + this.getNewLine() + fixedEntryDecoratorText; return [{ start: entryDecorator.getStart(), end: entryDecorator.getEnd(), replacementText: text }]; @@ -2960,7 +2960,7 @@ export class Autofixer { private static createFixedEntryDecorator(): ts.Decorator { const storageProperty = ts.factory.createPropertyAssignment( - ts.factory.createIdentifier(ENTRY_STORAGE_PROPERITY), + ts.factory.createIdentifier(ENTRY_STORAGE), ts.factory.createStringLiteral(GET_LOCAL_STORAGE_FUNC_NAME) ); const objectLiteralExpr = ts.factory.createObjectLiteralExpression([storageProperty], false); @@ -2982,7 +2982,7 @@ export class Autofixer { return undefined; } if (ts.isIdentifier(objectProperty.name)) { - if (objectProperty.name.escapedText !== ENTRY_STORAGE_PROPERITY) { + if (objectProperty.name.escapedText !== ENTRY_STORAGE) { return undefined; } const properityInitializer = objectProperty.initializer; @@ -5428,4 +5428,25 @@ export class Autofixer { } ]; } + + fixEntryAndComponentV2(entryDecorator: ts.Decorator): Autofix[] | undefined { + const callExpr = entryDecorator.expression; + if (!ts.isCallExpression(callExpr)) { + return undefined; + } + + const arg = callExpr.arguments?.[0]; + if (!ts.isObjectLiteralExpression(arg)) { + return undefined; + } + + const newProperties = arg.properties.filter((property) => { + const name = property.name?.getText(); + 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 }]; + } } diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts index 5b17c7dad5..a8f2862eb1 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts @@ -160,10 +160,13 @@ export const serializationTypeName: Set = new Set([ export const customLayoutFunctionName: Set = new Set(['onMeasureSize', 'onPlaceChildren']); export const ENTRY_DECORATOR_NAME = 'Entry'; -export const ENTRY_STORAGE_PROPERITY = 'storage'; +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 COMPONENTV2_DECORATOR_NAME = 'ComponentV2'; + export const PROVIDE_DECORATOR_NAME = 'Provide'; export const PROVIDE_ALIAS_PROPERTY_NAME = 'alias'; export const PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME = 'allowOverride'; diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets b/ets2panda/linter/test/main/entry_componentv2_1.ets new file mode 100644 index 0000000000..ac140a9514 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_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() }) +@ComponentV2 +struct MyPage1 { + build() { + Text("Hello World") + } +} + +@Entry({ useSharedStorage: true }) +@ComponentV2 +struct MyPage2 { + build() { + Text("Hello World") + } +} + +@Entry({ storage: new LocalStorage(), useSharedStorage: true }) +@ComponentV2 +struct MyPage3 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets.args.json b/ets2panda/linter/test/main/entry_componentv2_1.ets.args.json new file mode 100644 index 0000000000..ee0734c0fc --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_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_componentv2_1.ets.arkts2.json b/ets2panda/linter/test/main/entry_componentv2_1.ets.arkts2.json new file mode 100644 index 0000000000..6e46e3a973 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_1.ets.arkts2.json @@ -0,0 +1,178 @@ +{ + "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": 40, + "problem": "EntryHasInvalidParams", + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "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": 35, + "problem": "EntryHasInvalidParams", + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 64, + "problem": "EntryHasInvalidParams", + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "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": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" 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": 25, + "column": 2, + "endLine": 25, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" 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": 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" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json b/ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json new file mode 100644 index 0000000000..bb47a5be22 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_1.ets.autofix.json @@ -0,0 +1,332 @@ +{ + "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": 40, + "problem": "EntryHasInvalidParams", + "autofix": [ + { + "start": 612, + "end": 643, + "replacementText": "{}", + "line": 16, + "column": 1, + "endLine": 16, + "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)", + "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": 35, + "problem": "EntryHasInvalidParams", + "autofix": [ + { + "start": 725, + "end": 751, + "replacementText": "{}", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 64, + "problem": "EntryHasInvalidParams", + "autofix": [ + { + "start": 833, + "end": 888, + "replacementText": "{}", + "line": 32, + "column": 1, + "endLine": 32, + "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)", + "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 ComponentV2,\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 ComponentV2,\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": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" 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 ComponentV2,\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 ComponentV2,\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": 25, + "column": 2, + "endLine": 25, + "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": 36, + "column": 5, + "endLine": 36, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" 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 ComponentV2,\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 ComponentV2,\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 ComponentV2,\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": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n LocalStorage,\n ComponentV2,\n Text,\n} from '@kit.ArkUI';", + "line": 36, + "column": 5, + "endLine": 36, + "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": 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_componentv2_1.ets.json b/ets2panda/linter/test/main/entry_componentv2_1.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_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_componentv2_1.ets.migrate.ets b/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.ets new file mode 100644 index 0000000000..3f08b0c506 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.ets @@ -0,0 +1,45 @@ +/* + * 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, + ComponentV2, + Text, +} from '@kit.ArkUI'; + +@Entry({}) +@ComponentV2 +struct MyPage1 { + build() { + Text("Hello World") + } +} + +@Entry({}) +@ComponentV2 +struct MyPage2 { + build() { + Text("Hello World") + } +} + +@Entry({}) +@ComponentV2 +struct MyPage3 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.json b/ets2panda/linter/test/main/entry_componentv2_1.ets.migrate.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_1.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_2.ets b/ets2panda/linter/test/main/entry_componentv2_2.ets new file mode 100644 index 0000000000..cf444919a1 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets @@ -0,0 +1,46 @@ +/* + * 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({ routeName: "Index", storage: new LocalStorage() }) +@ComponentV2 +struct MyPage1 { + build() { + Text("Hello World") + } +} + +@Entry({ routeName: "Index", useSharedStorage: true }) +@ComponentV2 +struct MyPage2 { + build() { + Text("Hello World") + } +} + +@Entry({ routeName: "Index", storage: new LocalStorage(), useSharedStorage: true }) +@ComponentV2 +struct MyPage3 { + build() { + Text("Hello World") + } +} + +@Entry({ routeName: "Index" }) +@ComponentV2 +struct MyPage3 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_2.ets.args.json b/ets2panda/linter/test/main/entry_componentv2_2.ets.args.json new file mode 100644 index 0000000000..ee0734c0fc --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_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_componentv2_2.ets.arkts2.json b/ets2panda/linter/test/main/entry_componentv2_2.ets.arkts2.json new file mode 100644 index 0000000000..729d674774 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets.arkts2.json @@ -0,0 +1,208 @@ +{ + "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": 60, + "problem": "EntryHasInvalidParams", + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 43, + "endLine": 16, + "endColumn": 55, + "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": "EntryHasInvalidParams", + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 84, + "problem": "EntryHasInvalidParams", + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 43, + "endLine": 32, + "endColumn": 55, + "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": 43, + "endLine": 16, + "endColumn": 55, + "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": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" 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": 25, + "column": 2, + "endLine": 25, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" 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": 43, + "endLine": 32, + "endColumn": 55, + "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": 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": 41, + "column": 2, + "endLine": 41, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 5, + "endLine": 44, + "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_componentv2_2.ets.autofix.json b/ets2panda/linter/test/main/entry_componentv2_2.ets.autofix.json new file mode 100644 index 0000000000..dbcdb633af --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets.autofix.json @@ -0,0 +1,395 @@ +{ + "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": 60, + "problem": "EntryHasInvalidParams", + "autofix": [ + { + "start": 612, + "end": 663, + "replacementText": "{ routeName: \"Index\" }", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 60 + } + ], + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 43, + "endLine": 16, + "endColumn": 55, + "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": "EntryHasInvalidParams", + "autofix": [ + { + "start": 745, + "end": 791, + "replacementText": "{ routeName: \"Index\" }", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 55 + } + ], + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 84, + "problem": "EntryHasInvalidParams", + "autofix": [ + { + "start": 873, + "end": 948, + "replacementText": "{ routeName: \"Index\" }", + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 84 + } + ], + "suggest": "", + "rule": "The \"@ComponentV2\" decorator cannot be used together with the \"@Entry\" decorator that has \"storage\" or \"useSharedStorage\" parameters (arkui-entry-invalid-params)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 43, + "endLine": 32, + "endColumn": 55, + "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 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": 16, + "column": 43, + "endLine": 16, + "endColumn": 55, + "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": 17, + "column": 2, + "endLine": 17, + "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": 20, + "column": 5, + "endLine": 20, + "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": 24, + "column": 2, + "endLine": 24, + "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": 25, + "column": 2, + "endLine": 25, + "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": 28, + "column": 5, + "endLine": 28, + "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": 32, + "column": 2, + "endLine": 32, + "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": 32, + "column": 43, + "endLine": 32, + "endColumn": 55, + "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": 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": 41, + "column": 2, + "endLine": 41, + "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": 44, + "column": 5, + "endLine": 44, + "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" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_2.ets.json b/ets2panda/linter/test/main/entry_componentv2_2.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_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_componentv2_2.ets.migrate.ets b/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.ets new file mode 100644 index 0000000000..ee23d5281f --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.ets @@ -0,0 +1,53 @@ +/* + * 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, + ComponentV2, + Text, +} from '@kit.ArkUI'; + +@Entry({ routeName: "Index" }) +@ComponentV2 +struct MyPage1 { + build() { + Text("Hello World") + } +} + +@Entry({ routeName: "Index" }) +@ComponentV2 +struct MyPage2 { + build() { + Text("Hello World") + } +} + +@Entry({ routeName: "Index" }) +@ComponentV2 +struct MyPage3 { + build() { + Text("Hello World") + } +} + +@Entry({ routeName: "Index" }) +@ComponentV2 +struct MyPage3 { + build() { + Text("Hello World") + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.json b/ets2panda/linter/test/main/entry_componentv2_2.ets.migrate.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/entry_componentv2_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 -- Gitee