diff --git a/ets2panda/linter/.gitignore b/ets2panda/linter/.gitignore index 26590e3ca2b7477484ae2e04eb3e74159801e0bc..a9bcf7139e0c7bd0544a9b4a29435292ad9b21e8 100644 --- a/ets2panda/linter/.gitignore +++ b/ets2panda/linter/.gitignore @@ -3,6 +3,7 @@ bundle bundle-2.1.0.tgz dist node_modules +migration-results-statistics.json package-lock.json panda-tslinter-1.0.0.tgz coverage/ diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index e6a8017193e9c249bc88e3f1ca9ccf98f4639d94..cb6e60231607695fbcf308bb8f8c57ef2febaf09 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -13,8 +13,10 @@ "arkts-no-func-bind", "arkts-no-function-return-this", "arkts-limited-stdlib", + "arkts-no-class-add-super-prop-with-readonly", "arkts-no-classes-as-obj", "arkts-obj-literal-props", + "arkts-obj-literal-key-type", "arkts-optional-methods", "arkts-numeric-semantic", "arkts-incompatible-function-types", @@ -60,8 +62,9 @@ "arkts-numeric-bigint-compare", "arkts-only-support-decimal-bigint-literal", "arkts-unsupport-operator", - "arkts-no-duplicate-function-name", - "arkts-subclass-must-call-super-constructor-with-args" + "arkts-no-duplicate-function-name", + "arkts-require-func-arg-type", + "arkts-subclass-must-call-super-constructor-with-args" ], "interop": [ "arkts-interop-js2s-inherit-js-class", @@ -119,8 +122,12 @@ "arkui-no-localbuilder-decorator", "arkui-statestyles-block-need-arrow-func", "arkui-repeat-disable-default-virtualscroll", + "arkui-wrappedbuilder-require-arrow-func-generic", "arkui-wrapbuilder-require-arrow-func-generic", - "arkui-no-deprecated-api" + "arkui-no-deprecated-api", + "arkui-buildernode-generic-no-tuple", + "arkui-buildernode-update-no-literal", + "arkui-buildernode-no-nestingbuildersupported" ], "builtin": [ "arkts-builtin-thisArgs", diff --git a/ets2panda/linter/src/cli/CommandLineParser.ts b/ets2panda/linter/src/cli/CommandLineParser.ts index 04f6792b4dacab5d30bb281136a7f6358832371b..5da3f8192939beb3e21d5102cae3f331c915c06b 100644 --- a/ets2panda/linter/src/cli/CommandLineParser.ts +++ b/ets2panda/linter/src/cli/CommandLineParser.ts @@ -218,7 +218,7 @@ function getConfigureRulePath(options: OptionValues): string { } const stats = fs.statSync(path.normalize(options.ruleConfig)); if (!stats.isFile()) { - Logger.error(`The file at ${options.ruleConfigPath} path does not exist! + Logger.error(`The file at ${options.ruleConfigPath} path does not exist! And will use the default configure rule`); return getDefaultConfigurePath(); } diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index a99f72046c0ea148319576a5c3979911e5a9ed05..3d57443dac78dc01f25c86b8ad02f1ef30322461 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -102,8 +102,8 @@ cookBookTag[71] = 'The comma operator "," is supported only in "for" loops (arkt cookBookTag[72] = ''; cookBookTag[73] = ''; cookBookTag[74] = 'Destructuring variable declarations are not supported (arkts-no-destruct-decls)'; -cookBookTag[75] = ''; -cookBookTag[76] = ''; +cookBookTag[75] = 'Use string-literal keys with Record (arkts-obj-literal-key-type)'; +cookBookTag[76] = 'Type of parameter must be defined explicitly (arkts-require-func-arg-type)'; cookBookTag[77] = ''; cookBookTag[78] = ''; cookBookTag[79] = 'Type annotation in catch clause is not supported (arkts-no-types-in-catch)'; @@ -178,7 +178,8 @@ cookBookTag[144] = 'Usage of standard library is restricted (arkts-limited-stdli cookBookTag[145] = 'Strict type checking is enforced (arkts-strict-typing)'; cookBookTag[146] = 'Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)'; cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (arkts-no-ts-deps)'; -cookBookTag[148] = ''; +cookBookTag[148] = + 'Overriding with "readonly" field is not allowed when base field is not "readonly" (arkts-no-class-add-super-prop-with-readonly)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; cookBookTag[151] = 'Usage of \'ESValue\' type is restricted (arkts-limited-esobj)'; @@ -250,8 +251,7 @@ cookBookTag[206] = '"debugger" is not supported (arkts-no-debugger)'; cookBookTag[207] = 'Special arguments object inside functions are not supported (arkts-no-arguments-obj)'; cookBookTag[208] = 'Tagged templates are not supported (arkts-no-tagged-templates)'; cookBookTag[209] = 'The index expression must be of a numeric type (arkts-array-index-expr-type)'; -cookBookTag[210] = - 'The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)'; +cookBookTag[210] = 'The switch expression type must be of type number, string or enum (arkts-switch-expr)'; cookBookTag[211] = 'No two case constant expressions have identical values.(arkts-case-expr)'; cookBookTag[212] = 'The index expression must be zero or positive value.(arkts-array-index-negative)'; cookBookTag[213] = 'Class cannot have static codeblocks. (arkts-class-lazy-import)'; @@ -377,7 +377,13 @@ cookBookTag[359] = '"@LocalBuilder" Decorator is not supported (arkui-no-localbu cookBookTag[360] = '"Repeat" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)'; cookBookTag[361] = - 'When using "WrappedBuilder" and "wrapBuilder", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)'; + 'When using "WrappedBuilder", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)'; +cookBookTag[362] = + 'When using "wrapBuilder", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)'; +cookBookTag[363] = 'The generic of "BuilderNode" does not accept tuple (arkui-buildernode-generic-no-tuple)'; +cookBookTag[364] = + 'The "update" interface of "BuilderNode" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new "BuilderNode", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)'; +cookBookTag[365] = 'Property "nestingBuilderSupported" is not supported (arkui-buildernode-no-nestingbuildersupported)'; cookBookTag[370] = 'Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)'; cookBookTag[371] = 'Enum elements cannot be types in ArkTS1.2 (arkts-no-enum-prop-as-type)'; cookBookTag[372] = 'Smart type differences (arkts-no-ts-like-smart-type)'; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index 24902b1ec9be55ebb71d987607070802238dfc54..a862704a0c1a67da760d3d9f051eb45eaa45bf5f 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -64,6 +64,8 @@ faultsAttrs[FaultID.InOperator] = new FaultAttributes(66); faultsAttrs[FaultID.DestructuringAssignment] = new FaultAttributes(69); faultsAttrs[FaultID.CommaOperator] = new FaultAttributes(71); faultsAttrs[FaultID.DestructuringDeclaration] = new FaultAttributes(74); +faultsAttrs[FaultID.ObjectLiteralKeyType] = new FaultAttributes(75); +faultsAttrs[FaultID.ParameterType] = new FaultAttributes(76); faultsAttrs[FaultID.CatchWithUnsupportedType] = new FaultAttributes(79); faultsAttrs[FaultID.ForInStatement] = new FaultAttributes(80); faultsAttrs[FaultID.MappedType] = new FaultAttributes(83); @@ -106,6 +108,7 @@ faultsAttrs[FaultID.ImportAssertion] = new FaultAttributes(143); faultsAttrs[FaultID.LimitedStdLibApi] = new FaultAttributes(144); faultsAttrs[FaultID.StrictDiagnostic] = new FaultAttributes(145); faultsAttrs[FaultID.ErrorSuppression] = new FaultAttributes(146); +faultsAttrs[FaultID.NoClassSuperPropReadonly] = new FaultAttributes(148); faultsAttrs[FaultID.ClassAsObject] = new FaultAttributes(149, ProblemSeverity.WARNING); faultsAttrs[FaultID.ClassAsObjectError] = new FaultAttributes(149); faultsAttrs[FaultID.ImportAfterStatement] = new FaultAttributes(150); @@ -261,6 +264,10 @@ faultsAttrs[FaultID.BuiltinGetOwnPropertyNames] = new FaultAttributes(358); faultsAttrs[FaultID.LocalBuilderDecoratorNotSupported] = new FaultAttributes(359); faultsAttrs[FaultID.RepeatDisableVirtualScroll] = new FaultAttributes(360); faultsAttrs[FaultID.WrappedBuilderGenericNeedArrowFunc] = new FaultAttributes(361); +faultsAttrs[FaultID.WrapBuilderGenericNeedArrowFunc] = new FaultAttributes(362); +faultsAttrs[FaultID.BuilderNodeGenericNoTuple] = new FaultAttributes(363); +faultsAttrs[FaultID.BuilderNodeUpdateNoLiteral] = new FaultAttributes(364); +faultsAttrs[FaultID.BuilderNodeNoNestingBuilderSupported] = new FaultAttributes(365); faultsAttrs[FaultID.NosparseArray] = new FaultAttributes(370); faultsAttrs[FaultID.NoEnumPropAsType] = new FaultAttributes(371); faultsAttrs[FaultID.NoTsLikeSmartType] = new FaultAttributes(372); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 25fe395b073c1a37b74217053bc5f3b9b967664a..93a31cd080ed89812acd9ae2bcd38e709cb5b654 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -38,8 +38,10 @@ faultDesc[FaultID.UnknownType] = '"unknown" type'; faultDesc[FaultID.ForInStatement] = '"for-In" statements'; faultDesc[FaultID.InOperator] = '"in" operations'; faultDesc[FaultID.FunctionExpression] = 'function expressions'; +faultDesc[FaultID.ParameterType] = 'parameter type'; faultDesc[FaultID.IntersectionType] = 'intersection types and type literals'; faultDesc[FaultID.ObjectTypeLiteral] = 'Object type literals'; +faultDesc[FaultID.ObjectLiteralKeyType] = 'Object literal key types'; faultDesc[FaultID.CommaOperator] = 'comma operator'; faultDesc[FaultID.LimitedReturnTypeInference] = 'Functions with limited return type inference'; faultDesc[FaultID.ClassExpression] = 'Class expressions'; @@ -59,6 +61,7 @@ faultDesc[FaultID.PrivateIdentifier] = 'Private identifiers (with "#" prefix)'; faultDesc[FaultID.LocalFunction] = 'Local function declarations'; faultDesc[FaultID.ConditionalType] = 'Conditional type'; faultDesc[FaultID.MappedType] = 'Mapped type'; +faultDesc[FaultID.NoClassSuperPropReadonly] = 'Readonly property overrides non-readonly parent property'; faultDesc[FaultID.NamespaceAsObject] = 'Namespaces used as objects'; faultDesc[FaultID.ClassAsObject] = faultDesc[FaultID.ClassAsObjectError] = 'Class used as object'; faultDesc[FaultID.NonDeclarationInNamespace] = 'Non-declaration statements in namespaces'; @@ -261,4 +264,8 @@ faultDesc[FaultID.StateStylesBlockNeedArrowFunc] = 'StateStyles needs arrow func faultDesc[FaultID.PromiseVoidNeedResolveArg] = 'Promiseconstructor only supports using resolve (undefined)'; faultDesc[FaultID.RepeatDisableVirtualScroll] = '"Repeat" disable default "virtualScroll"'; faultDesc[FaultID.WrappedBuilderGenericNeedArrowFunc] = 'Generic of "WrappedBuilder" does not support parameter list'; +faultDesc[FaultID.WrapBuilderGenericNeedArrowFunc] = 'Generic of "wrappBuilder" does not support parameter list'; faultDesc[FaultID.NoDeprecatedApi] = 'ArkUI deprecated api check'; +faultDesc[FaultID.BuilderNodeGenericNoTuple] = 'Generic of "BuilderNode" does not support tuple"'; +faultDesc[FaultID.BuilderNodeUpdateNoLiteral] = '"update" interface of "BuilderNode" cannot pass an object literal'; +faultDesc[FaultID.BuilderNodeNoNestingBuilderSupported] = '"nestingBuilderSupported" is not supported'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index ab24db5928960e58ed088f0fd98e4bb03b95d9b4..649892bfc7c64b686f49ff1aae5d4c283b0ff335 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -37,6 +37,7 @@ export enum FaultID { FunctionExpression, IntersectionType, ObjectTypeLiteral, + ObjectLiteralKeyType, CommaOperator, LimitedReturnTypeInference, ClassExpression, @@ -57,6 +58,7 @@ export enum FaultID { ConditionalType, MappedType, NamespaceAsObject, + NoClassSuperPropReadonly, ClassAsObject, ClassAsObjectError, NonDeclarationInNamespace, @@ -78,6 +80,7 @@ export enum FaultID { ImportAssignment, GenericCallNoTypeArgs, ParameterProperties, + ParameterType, InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, @@ -261,7 +264,11 @@ export enum FaultID { PromiseVoidNeedResolveArg, RepeatDisableVirtualScroll, WrappedBuilderGenericNeedArrowFunc, + WrapBuilderGenericNeedArrowFunc, NoDeprecatedApi, + BuilderNodeGenericNoTuple, + BuilderNodeUpdateNoLiteral, + BuilderNodeNoNestingBuilderSupported, // 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 9a0f958dd60d3038f55a62e81d0ad1584875003d..e58892c5304b12d882aa65c1a7e5728daf368fb5 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -87,7 +87,12 @@ import { BUILTIN_GENERIC_CONSTRUCTORS } from './utils/consts/BuiltinGenericConst import { DEFAULT_DECORATOR_WHITE_LIST } from './utils/consts/DefaultDecoratorWhitelist'; import { INVALID_IDENTIFIER_KEYWORDS } from './utils/consts/InValidIndentifierKeywords'; import { WORKER_MODULES, WORKER_TEXT } from './utils/consts/WorkerAPI'; -import { COLLECTIONS_TEXT, COLLECTIONS_MODULES } from './utils/consts/CollectionsAPI'; +import { + COLLECTIONS_TEXT, + COLLECTIONS_MODULES, + BIT_VECTOR, + ARKTS_COLLECTIONS_MODULE +} from './utils/consts/CollectionsAPI'; import { ASON_TEXT, ASON_MODULES, ARKTS_UTILS_TEXT, JSON_TEXT, ASON_WHITE_SET } from './utils/consts/ArkTSUtilsAPI'; import { interanlFunction } from './utils/consts/InternalFunction'; import { ETS_PART, PATH_SEPARATOR } from './utils/consts/OhmUrl'; @@ -101,14 +106,17 @@ import { ENTRY_DECORATOR_NAME, PROVIDE_DECORATOR_NAME, PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME, - ARKUI_PACKAGE_NAME, + ARKUI_MODULE, MAKE_OBSERVED, - ARKUI_STATE_MANAGEMENT, + STATE_MANAGEMENT_MODULE, PropDecoratorName, PropFunctionName, StorageTypeName, customLayoutFunctionName, - VIRTUAL_SCROLL_IDENTIFIER + VIRTUAL_SCROLL_IDENTIFIER, + BUILDERNODE_D_TS, + BuilderNodeFunctionName, + NESTING_BUILDER_SUPPORTED } from './utils/consts/ArkuiConstants'; import { arkuiImportList } from './utils/consts/ArkuiImportList'; import type { IdentifierAndArguments, ForbidenAPICheckResult } from './utils/consts/InteropAPI'; @@ -623,6 +631,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const objectLiteralType = this.tsTypeChecker.getContextualType(objectLiteralExpr); + if (objectLiteralType && this.options.arkts2) { + this.isObjectLiteralKeyTypeValid(objectLiteralExpr, objectLiteralType); + } + if (objectLiteralType && this.tsUtils.typeContainsSendableClassOrInterface(objectLiteralType)) { this.incrementCounters(node, FaultID.SendableObjectInitialization); } else if ( @@ -1322,9 +1334,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handlePropertyAccessExpression(node: ts.Node): void { const propertyAccessNode = node as ts.PropertyAccessExpression; - this.handleMakeObserved(propertyAccessNode); - this.handleStateStyles(propertyAccessNode); - this.handleDoubleDollar(propertyAccessNode); + this.handlePropertyAccessExpressionForUI(propertyAccessNode); this.handleQuotedHyphenPropsDeprecated(propertyAccessNode); this.handleSdkTypeQuery(propertyAccessNode); this.checkUnionTypes(propertyAccessNode); @@ -1362,6 +1372,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.fixJsImportPropertyAccessExpression(node); } + private handlePropertyAccessExpressionForUI(node: ts.PropertyAccessExpression): void { + this.handleMakeObserved(node); + this.handleStateStyles(node); + this.handleDoubleDollar(node); + this.handlePropertyAccessExprForBuilderNode(node); + } + private checkSymbolAPI(node: ts.PropertyAccessExpression, exprSym: ts.Symbol | undefined): void { if ( !this.options.arkts2 && @@ -2092,6 +2109,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (tsFunctionDeclaration.body) { this.reportThisKeywordsInScope(tsFunctionDeclaration.body); } + if (this.options.arkts2) { + this.handleParamType(tsFunctionDeclaration); + } const funcDeclParent = tsFunctionDeclaration.parent; if (!ts.isSourceFile(funcDeclParent) && !ts.isModuleBlock(funcDeclParent)) { const autofix = this.autofixer?.fixNestedFunction(tsFunctionDeclaration); @@ -2101,21 +2121,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.GeneratorFunction); } if (TsUtils.hasSendableDecoratorFunctionOverload(tsFunctionDeclaration)) { - if (!this.isSendableDecoratorValid(tsFunctionDeclaration)) { - return; - } - TsUtils.getNonSendableDecorators(tsFunctionDeclaration)?.forEach((decorator) => { - this.incrementCounters(decorator, FaultID.SendableFunctionDecorator); - }); - if (!TsUtils.hasSendableDecorator(tsFunctionDeclaration)) { - const autofix = this.autofixer?.addSendableDecorator(tsFunctionDeclaration); - this.incrementCounters(tsFunctionDeclaration, FaultID.SendableFunctionOverloadDecorator, autofix); - } - this.scanCapturedVarsInSendableScope( - tsFunctionDeclaration, - tsFunctionDeclaration, - FaultID.SendableFunctionImportedVariables - ); + this.processSendableDecoratorFunctionOverload(tsFunctionDeclaration); } this.handleTSOverload(tsFunctionDeclaration); this.checkNumericSemanticsForFunction(tsFunctionDeclaration); @@ -2124,6 +2130,33 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleLimitedVoidFunction(tsFunctionDeclaration); } + private processSendableDecoratorFunctionOverload(tsFunctionDeclaration: ts.FunctionDeclaration): void { + if (!this.isSendableDecoratorValid(tsFunctionDeclaration)) { + return; + } + TsUtils.getNonSendableDecorators(tsFunctionDeclaration)?.forEach((decorator) => { + this.incrementCounters(decorator, FaultID.SendableFunctionDecorator); + }); + if (!TsUtils.hasSendableDecorator(tsFunctionDeclaration)) { + const autofix = this.autofixer?.addSendableDecorator(tsFunctionDeclaration); + this.incrementCounters(tsFunctionDeclaration, FaultID.SendableFunctionOverloadDecorator, autofix); + } + this.scanCapturedVarsInSendableScope( + tsFunctionDeclaration, + tsFunctionDeclaration, + FaultID.SendableFunctionImportedVariables + ); + } + + private handleParamType(decl: ts.FunctionLikeDeclaration): void { + for (const param of decl.parameters) { + if (param.type) { + continue; + } + this.incrementCounters(param, FaultID.ParameterType); + } + } + private handleMissingReturnType( funcLikeDecl: ts.FunctionLikeDeclaration | ts.MethodSignature ): [boolean, ts.TypeNode | undefined] { @@ -2696,6 +2729,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private isObjectLiteralKeyTypeValid(objectLiteral: ts.ObjectLiteralExpression, contextualType: ts.Type): void { + if (!this.tsUtils.isStdRecordType(contextualType)) { + return; + } + objectLiteral.properties.forEach((prop: ts.ObjectLiteralElementLike): void => { + if (ts.isPropertyAssignment(prop)) { + if (!this.tsUtils.isValidRecordObjectLiteralKey(prop.name)) { + this.incrementCounters(prop, FaultID.ObjectLiteralKeyType); + } + } + }); + } + private handleVariableDeclaration(node: ts.Node): void { const tsVarDecl = node as ts.VariableDeclaration; this.handleVariableDeclarationForProp(tsVarDecl); @@ -3700,6 +3746,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } } + if (this.options.arkts2) { + this.handleParamType(tsMethodDecl); + } if (tsMethodDecl.body && isStatic) { this.reportThisKeywordsInScope(tsMethodDecl.body); } @@ -3789,23 +3838,27 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const methodName = node.name.text; if (allBaseTypes && allBaseTypes.length > 0) { - this.checkMethodType(allBaseTypes, methodName, node); + this.checkMethodType(allBaseTypes, methodName, node, isStatic); } } - private checkMethodType(allBaseTypes: ts.Type[], methodName: string, node: ts.MethodDeclaration): void { + private checkMethodType(allBaseTypes: ts.Type[], methodName: string, node: ts.MethodDeclaration, isStatic: boolean = false): void { for (const baseType of allBaseTypes) { - const baseMethod = baseType.getProperty(methodName); + let baseMethod: ts.Symbol | undefined; + if (isStatic) { + const constructorType = this.tsTypeChecker.getTypeOfSymbolAtLocation(baseType.getSymbol()!, node); + baseMethod = constructorType.getProperty(methodName) || + baseType.getSymbol()?.members?.get(ts.escapeLeadingUnderscores(methodName)); + } else { + baseMethod = baseType.getProperty(methodName); + } if (!baseMethod) { continue; } - - const baseMethodDecl = baseMethod.declarations?.find((d) => { - return ( - (ts.isMethodDeclaration(d) || ts.isMethodSignature(d)) && - this.tsTypeChecker.getTypeAtLocation(d.parent) === baseType - ); - }) as ts.MethodDeclaration | ts.MethodSignature; + const baseMethodDecl = baseMethod.declarations?.find(d => + (ts.isMethodDeclaration(d) || ts.isMethodSignature(d)) && + this.isSameDeclarationType(d.parent, baseType, isStatic) + ) as ts.MethodDeclaration | ts.MethodSignature; if (!baseMethodDecl) { continue; @@ -3819,6 +3872,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private isSameDeclarationType(decl: ts.Node, type: ts.Type, isStatic: boolean): boolean { + if (isStatic && ts.isClassDeclaration(decl)) { + const staticType = this.tsTypeChecker.getTypeAtLocation(decl); + return this.isSameType(staticType, type); + } + return this.tsTypeChecker.getTypeAtLocation(decl) === type; + } + private checkIncompatibleFunctionTypes(method: ts.MethodDeclaration): void { const declaredReturnType = this.getActualReturnType(method); if (!declaredReturnType) { @@ -3926,21 +3987,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private getAllBaseTypes(type: ts.Type, classDecl: ts.ClassDeclaration, isStatic?: boolean): ts.Type[] | undefined { if (isStatic) { - const baseTypes: ts.Type[] = []; - if (!classDecl.heritageClauses) { - return baseTypes; - } - for (const clause of classDecl.heritageClauses) { - if (clause.token !== ts.SyntaxKind.ExtendsKeyword) { - continue; - } - for (const typeNode of clause.types) { - const baseType = this.tsTypeChecker.getTypeAtLocation(typeNode); - baseTypes.push(baseType); - } - } - - return baseTypes; + return this.getStaticAllBaseTypes(classDecl); } const baseClasses = type.getBaseTypes() || []; @@ -3952,6 +3999,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!classDecl.heritageClauses) { return resolvedBaseClasses; } + const interfaces: ts.Type[] = []; for (const clause of classDecl.heritageClauses) { if (clause.token !== ts.SyntaxKind.ImplementsKeyword) { @@ -3970,7 +4018,33 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { }); } } - return [...resolvedBaseClasses, ...interfaces]; + return [...resolvedBaseClasses, ...interfaces]; + } + + private getStaticAllBaseTypes(classDecl: ts.ClassDeclaration): ts.Type[] | undefined { + const baseTypes: ts.Type[] = []; + if (!classDecl.heritageClauses) { + return baseTypes; + } + + for (const clause of classDecl.heritageClauses) { + if (clause.token !== ts.SyntaxKind.ExtendsKeyword) { + continue; + } + + for (const typeNode of clause.types) { + const baseType = this.tsTypeChecker.getTypeAtLocation(typeNode); + baseTypes.push(baseType); + + const baseDecl = baseType.getSymbol()?.declarations?.[0]; + if (baseDecl && ts.isClassDeclaration(baseDecl)) { + const staticBaseType = this.tsTypeChecker.getTypeAtLocation(baseDecl); + const staticBaseTypes = this.getAllBaseTypes(staticBaseType, baseDecl, true) || []; + baseTypes.push(...staticBaseTypes); + } + } + } + return baseTypes; } /** @@ -3995,6 +4069,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const baseParamType = this.tsTypeChecker.getTypeAtLocation(baseParams[i]); const derivedParamType = this.tsTypeChecker.getTypeAtLocation(derivedParams[i]); + if (baseParamType.flags & ts.TypeFlags.TypeParameter) { + if (!(derivedParamType.flags & ts.TypeFlags.TypeParameter)) { + continue; + } + } + if (!this.isTypeSameOrWider(baseParamType, derivedParamType)) { this.incrementCounters(derivedParams[i], FaultID.MethodInheritRule); } @@ -4009,6 +4089,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { derivedMethod: ts.MethodDeclaration, baseMethod: ts.MethodDeclaration | ts.MethodSignature ): void { + if(this.shouldSkipTypeParameterCheck(derivedMethod, baseMethod)) { + return; + } const baseMethodType = this.getActualReturnType(baseMethod); const derivedMethodType = this.getActualReturnType(derivedMethod); const baseMethodTypeIsVoid = TypeScriptLinter.checkMethodTypeIsVoidOrAny(baseMethodType, true); @@ -4051,6 +4134,21 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private shouldSkipTypeParameterCheck( + derivedMethod: ts.MethodDeclaration, + baseMethod: ts.MethodDeclaration | ts.MethodSignature + ): boolean { + const baseMethodType = this.getActualReturnType(baseMethod); + const derivedMethodType = this.getActualReturnType(derivedMethod); + + if (baseMethodType && (baseMethodType.flags & ts.TypeFlags.TypeParameter)) { + if (derivedMethodType && !(derivedMethodType.flags & ts.TypeFlags.TypeParameter)) { + return true; + } + } + return false; + } + private static checkMethodTypeIsVoidOrAny( methodType: ts.Type | undefined, isVoidOrAny: boolean, @@ -4085,6 +4183,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private isTypeSameOrWider(baseType: ts.Type, derivedType: ts.Type): boolean { + if (this.tsTypeChecker.typeToString(baseType) === this.tsTypeChecker.typeToString(derivedType)) { + return true; + } + if (derivedType.flags & ts.TypeFlags.Any) { return true; } @@ -5470,7 +5572,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const providedTypeArgs = callLikeExpr.typeArguments; const startTypeArg = providedTypeArgs?.length ?? 0; let shouldReportError = startTypeArg !== resolvedTypeArgs.length; - if (this.options.arkts2 && callLikeExpr.kind === ts.SyntaxKind.NewExpression) { + const shouldCheck = this.shouldCheckGenericCallExpression(callLikeExpr as ts.CallExpression); + if ( + this.options.arkts2 && + (ts.isNewExpression(callLikeExpr) || ts.isCallExpression(callLikeExpr) && shouldCheck) + ) { shouldReportError = this.shouldReportGenericTypeArgsError( callLikeExpr, resolvedTypeArgs, @@ -5487,6 +5593,69 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private shouldCheckGenericCallExpression(callExpr: ts.CallExpression): boolean { + const signature = this.tsTypeChecker.getResolvedSignature(callExpr); + if (!signature?.declaration) { + return false; + } + const typeParamsSafeToInfer = this.areTypeParametersReturnTypeOnly(signature.declaration); + if (!typeParamsSafeToInfer) { + return false; + } + return TypeScriptLinter.isInStrictTypeContext(callExpr); + } + + private areTypeParametersReturnTypeOnly(decl: ts.SignatureDeclaration | ts.JSDocSignature): boolean { + if (!decl.typeParameters?.length) { + return false; + } + + const typeParamNames = new Set( + decl.typeParameters.map((tp) => { + return tp.name.getText(); + }) + ); + let affectsParams = false; + + decl.parameters.forEach((param) => { + if (param.type && this.containsTypeParameters(param.type, typeParamNames)) { + affectsParams = true; + } + }); + + return !affectsParams; + } + + private containsTypeParameters(node: ts.Node, typeParamNames: Set): boolean { + let found = false; + ts.forEachChild(node, (child) => { + if (ts.isIdentifier(child) && typeParamNames.has(child.text)) { + found = true; + } + if (!found) { + found = this.containsTypeParameters(child, typeParamNames); + } + }); + return found; + } + + private static isInStrictTypeContext(callExpr: ts.CallExpression): boolean { + const parent = callExpr.parent; + + if ((ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && parent.type) { + return true; + } + + if (ts.isAsExpression(parent) || ts.isTypeAssertionExpression(parent)) { + return true; + } + + if (ts.isCallExpression(parent.parent) && parent.parent.typeArguments) { + return true; + } + return false; + } + private checkForUnknownTypeInNonArkTS2( callLikeExpr: ts.CallExpression | ts.NewExpression | ts.ExpressionWithTypeArguments, resolvedTypeArgs: ts.NodeArray, @@ -5503,7 +5672,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { * in ArkTS and already have separate check for it. */ if (typeNode.kind === ts.SyntaxKind.UnknownKeyword) { - this.incrementCounters(callLikeExpr, FaultID.GenericCallNoTypeArgs); + const autofix = ts.isCallExpression(callLikeExpr) ? + this.autofixer?.fixGenericCallNoTypeArgsForUnknown(callLikeExpr) : + undefined; + this.incrementCounters(callLikeExpr, FaultID.GenericCallNoTypeArgs, autofix); break; } } @@ -5878,6 +6050,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSdkGlobalApi(tsNewExpr); this.checkCreatingPrimitiveTypes(tsNewExpr); this.handleNoDeprecatedApi(tsNewExpr); + this.handleNodeForBuilderNode(tsNewExpr); + if (this.options.advancedClassChecks || this.options.arkts2) { const calleeExpr = tsNewExpr.expression; const calleeType = this.tsTypeChecker.getTypeAtLocation(calleeExpr); @@ -6257,6 +6431,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSdkConstructorIface(typeRef); this.handleNodeForWrappedBuilder(typeRef); this.handleNoDeprecatedApi(typeRef); + this.handleNodeForBuilderNode(typeRef); + const isESValue = TsUtils.isEsValueType(typeRef); const isPossiblyValidContext = TsUtils.isEsValuePossiblyAllowed(typeRef); if (isESValue && !isPossiblyValidContext) { @@ -7241,7 +7417,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private validateSwitchExpression(switchStatement: ts.SwitchStatement): void { const expr = switchStatement.expression; const nodeType = this.tsTypeChecker.getTypeAtLocation(expr); - const { isLiteralInitialized, isFloatLiteral, hasExplicitTypeAnnotation } = this.getDeclarationInfo(expr); + const { isLiteralInitialized, hasExplicitTypeAnnotation } = this.getDeclarationInfo(expr); const isUnionType = (nodeType.flags & ts.TypeFlags.Union) !== 0; @@ -7250,8 +7426,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return Boolean( t.flags & ts.TypeFlags.StringLike || typeText === 'String' || + typeText === 'number' || t.flags & ts.TypeFlags.NumberLike && (/^\d+$/).test(typeText) || - isLiteralInitialized && !hasExplicitTypeAnnotation && !isFloatLiteral || + isLiteralInitialized && !hasExplicitTypeAnnotation || t.flags & ts.TypeFlags.EnumLike ); }; @@ -7270,14 +7447,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private getDeclarationInfo(expression: ts.Expression): { isLiteralInitialized: boolean; - isFloatLiteral: boolean; hasExplicitTypeAnnotation: boolean; } { const symbol = this.tsTypeChecker.getSymbolAtLocation(expression); const declaration = symbol?.valueDeclaration; if (!declaration || !ts.isVariableDeclaration(declaration)) { - return { isLiteralInitialized: false, isFloatLiteral: false, hasExplicitTypeAnnotation: false }; + return { isLiteralInitialized: false, hasExplicitTypeAnnotation: false }; } const hasExplicitTypeAnnotation = !!declaration.type; @@ -7285,30 +7461,20 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return { isLiteralInitialized: initializerInfo.isLiteralInitialized, - isFloatLiteral: initializerInfo.isFloatLiteral, hasExplicitTypeAnnotation }; } private static getInitializerInfo(initializer?: ts.Expression): { isLiteralInitialized: boolean; - isFloatLiteral: boolean; } { if (!initializer) { - return { isLiteralInitialized: false, isFloatLiteral: false }; + return { isLiteralInitialized: false }; } const isLiteralInitialized = ts.isNumericLiteral(initializer) || ts.isStringLiteral(initializer); - let isFloatLiteral = false; - if (ts.isNumericLiteral(initializer)) { - const literalText = initializer.getText(); - if (!(/^0[xX]/).test(literalText)) { - isFloatLiteral = (/\.|e[-+]|\dE[-+]/i).test(literalText); - } - } - - return { isLiteralInitialized, isFloatLiteral }; + return { isLiteralInitialized }; } private findDuplicateCases(switchStatement: ts.SwitchStatement): ts.CaseClause[] { @@ -7731,13 +7897,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(firstExpr, FaultID.DoubleExclaBindingNotSupported, autofix); } - private handleDoubleDollar(node: ts.Node): void { + private handleDoubleDollar(node: ts.PropertyAccessExpression): void { if (!this.options.arkts2) { return; } if ( - ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === DOUBLE_DOLLAR_IDENTIFIER + THIS_IDENTIFIER ) { @@ -7957,6 +8122,58 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleMissingSuperCallInExtendedClass(node); this.handleFieldTypesMatchingBetweenDerivedAndBaseClass(node); + this.checkReadonlyOverridesFromBase(node); + } + } + + private checkReadonlyOverridesFromBase(node: ts.HeritageClause): void { + if (!this.options.arkts2) { + return; + } + if (node.token !== ts.SyntaxKind.ExtendsKeyword) { + return; + } + const childClass = node.parent; + const baseTypeNode = node.types[0]; + if (!ts.isClassDeclaration(childClass) || !baseTypeNode) { + return; + } + const baseType = this.tsTypeChecker.getTypeAtLocation(baseTypeNode); + if (!baseType) { + return; + } + const baseProps = baseType.getProperties(); + this.validateReadonlyOverrides(childClass, baseProps); + } + + private validateReadonlyOverrides(childClass: ts.ClassDeclaration, baseProps: ts.Symbol[]): void { + for (const member of childClass.members) { + if (!ts.isPropertyDeclaration(member) || !member.name) { + continue; + } + const isDerivedReadonly = TsUtils.hasModifier(member.modifiers, ts.SyntaxKind.ReadonlyKeyword); + if (!isDerivedReadonly) { + continue; + } + const memberName = ts.isIdentifier(member.name) ? member.name.text : undefined; + if (!memberName) { + continue; + } + const baseProp = baseProps.find((p) => { + return p.name === memberName; + }); + if (!baseProp) { + continue; + } + + const baseDecl = baseProp.valueDeclaration; + if (!baseDecl || !ts.isPropertyDeclaration(baseDecl)) { + continue; + } + const isBaseReadonly = TsUtils.hasModifier(baseDecl.modifiers, ts.SyntaxKind.ReadonlyKeyword); + if (!isBaseReadonly) { + this.incrementCounters(member, FaultID.NoClassSuperPropReadonly); + } } } @@ -8052,6 +8269,29 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private checkCollectionsForPropAccess(node: ts.Node, ident: ts.Node): void { + if (!ts.isIdentifier(ident)) { + return; + } + const importBitVectorAutofix = this.checkBitVector(ident); + const replace = this.autofixer?.replaceNode(node, ident.getText()); + let autofix: Autofix[] | undefined = []; + + if (replace) { + autofix = replace; + } + + if (importBitVectorAutofix) { + autofix.push(importBitVectorAutofix); + } + + if (autofix.length === 0) { + autofix = undefined; + } + + this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); + } + private checkCollectionsSymbol(node: ts.Node): void { if (!this.options.arkts2) { return; @@ -8062,14 +8302,17 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!parent) { return; } + if (ts.isPropertyAccessExpression(parent)) { - const autofix = this.autofixer?.replaceNode(parent, parent.name.text); - this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); + this.checkCollectionsForPropAccess(parent, parent.name); + + return; } if (ts.isQualifiedName(parent)) { - const autofix = this.autofixer?.replaceNode(parent, parent.right.text); - this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); + this.checkCollectionsForPropAccess(parent, parent.right); + + return; } if (ts.isImportSpecifier(parent) && ts.isIdentifier(node)) { @@ -8142,6 +8385,64 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private checkBitVector(ident: ts.Identifier): Autofix | undefined { + if (!this.isBitVector(ident)) { + return undefined; + } + + let lastImportDeclaration: ts.Node | undefined; + let bitVectorImported: boolean = false; + for (const node of this.sourceFile.statements) { + if (!ts.isImportDeclaration(node)) { + continue; + } + lastImportDeclaration = node; + + if (this.checkImportDeclarationForBitVector(node)) { + bitVectorImported = true; + } + } + + if (bitVectorImported) { + return undefined; + } + + return this.autofixer?.importBitVector(ident, lastImportDeclaration); + } + + private isBitVector(ident: ts.Identifier): boolean { + void this; + + return ident.text === BIT_VECTOR; + } + + private checkImportDeclarationForBitVector(node: ts.ImportDeclaration): boolean { + const importSpecifier = node.moduleSpecifier; + if (!ts.isStringLiteral(importSpecifier)) { + return false; + } + const importSpecifierText = importSpecifier.text; + + const importClause = node.importClause; + if (!importClause) { + return false; + } + + const namedBindings = importClause.namedBindings; + if (!namedBindings || !ts.isNamedImports(namedBindings)) { + return false; + } + + let bitVectorImported = false; + for (const specifier of namedBindings.elements) { + if (this.isBitVector(specifier.name) && importSpecifierText === ARKTS_COLLECTIONS_MODULE) { + bitVectorImported = true; + } + } + + return bitVectorImported; + } + interfacesNeedToAlarm: ts.Identifier[] = []; interfacesNeedToImport: Set = new Set(); interfacesAlreadyImported: Set = new Set(); @@ -9974,21 +10275,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { for (const [idx, param] of ctorParams.entries()) { const argument = superCall.arguments[idx]; - if (!param.isOptional && !argument) { - matches[idx] = false; + if (!this.checkParameter(param, argument, matches, idx)) { continue outer; } - - if (!argument && param.isOptional) { - matches[idx] = true; - continue; - } - if (argument !== undefined) { - matches[idx] = this.checkIfArgumentAndParamMatches(param, argument); - if (!matches[idx]) { - continue outer; - } - } } if ( @@ -10004,6 +10293,51 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(classDecl, FaultID.MissingSuperCall); } + private checkParameter( + param: ConstructorParameter, + argument: ts.Expression | undefined, + matches: boolean[], + idx: number + ): boolean { + if (!param.isOptional && !argument) { + matches[idx] = false; + return false; + } + + if (!argument && param.isOptional) { + matches[idx] = true; + return true; + } + + if (argument !== undefined) { + if (this.isEnumArgument(argument)) { + matches[idx] = true; + return true; + } + matches[idx] = this.checkIfArgumentAndParamMatches(param, argument); + return matches[idx]; + } + return true; + } + + private isEnumArgument(argument: ts.Expression): boolean { + if (!ts.isPropertyAccessExpression(argument)) { + return false; + } + + const leftSide = argument.expression; + const symbol = this.tsTypeChecker?.getSymbolAtLocation(leftSide); + + return ( + symbol?.declarations?.some((decl) => { + return ( + ts.isEnumDeclaration(decl) || + ts.isVariableDeclaration(decl) && decl.initializer && ts.isEnumDeclaration(decl.initializer) + ); + }) ?? false + ); + } + private checkIfArgumentAndParamMatches(param: ConstructorParameter, argument: ts.Expression): boolean { const typeNode = this.tsTypeChecker.getTypeAtLocation(argument); const typeString = this.tsTypeChecker.typeToString(typeNode); @@ -10193,27 +10527,16 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const symbolToUse = defaultSymbol || symbol; if (symbolToUse) { - this.tryAutoFixInterOpImportJs(importDecl, importClause, symbolToUse, defaultSymbol); + this.tryAutoFixInterOpImportJs(importDecl, symbolToUse); } } - private tryAutoFixInterOpImportJs( - importDecl: ts.ImportDeclaration, - importClause: ts.ImportClause, - symbolToUse: ts.Symbol, - defaultSymbol?: ts.Symbol - ): void { + private tryAutoFixInterOpImportJs(importDecl: ts.ImportDeclaration, symbolToUse: ts.Symbol): void { const declaration = symbolToUse.declarations?.[0]; if (declaration) { const sourceFile = declaration.getSourceFile(); if (sourceFile.fileName.endsWith(EXTNAME_JS)) { - const autofix = this.autofixer?.fixInterOpImportJs( - importDecl, - importClause, - TsUtils.removeOrReplaceQuotes(importDecl.moduleSpecifier.getText(this.sourceFile), false), - defaultSymbol - ); - this.incrementCounters(importDecl, FaultID.InterOpImportJs, autofix); + this.incrementCounters(importDecl, FaultID.InterOpImportJs); } } } @@ -10306,7 +10629,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } for (const declaration of symbol.declarations ?? []) { - if (!this.tsUtils.isArkts12File(declaration.getSourceFile())) { + if (!this.tsUtils.isArkts12File(declaration.getSourceFile()) && !isStdLibrarySymbol(symbol)) { return true; } } @@ -10755,7 +11078,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isStringLiteral(moduleSpecifier)) { return; } - if (moduleSpecifier.text !== ARKUI_PACKAGE_NAME && moduleSpecifier.text !== ARKUI_STATE_MANAGEMENT) { + if (moduleSpecifier.text !== ARKUI_MODULE && moduleSpecifier.text !== STATE_MANAGEMENT_MODULE) { return; } @@ -10767,23 +11090,24 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - const decorators = ts.getDecorators(node); - if (!decorators || decorators.length === 0) { + const decorator = ts.getDecorators(node)?.[0]; + if (!decorator) { return; } - let decoratorName: string | undefined; - if (ts.isIdentifier(decorators[0].expression)) { - decoratorName = decorators[0].expression.getText(); - } else if (ts.isCallExpression(decorators[0].expression) && ts.isIdentifier(decorators[0].expression.expression)) { - decoratorName = decorators[0].expression.expression.getText(); + let identifier: ts.Identifier | undefined; + if (ts.isIdentifier(decorator.expression)) { + identifier = decorator.expression; + } else if (ts.isCallExpression(decorator.expression) && ts.isIdentifier(decorator.expression.expression)) { + identifier = decorator.expression.expression; } - if (!decoratorName) { + if (!identifier) { return; } - const autofix = this.autofixer?.fixPropDecorator(decorators[0], decoratorName); + const decoratorName = identifier.getText(); + const autofix = this.autofixer?.fixPropDecorator(identifier, decoratorName); switch (decoratorName) { case PropDecoratorName.Prop: this.incrementCounters(node, FaultID.PropDecoratorNotSupported, autofix); @@ -12512,22 +12836,29 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.RepeatDisableVirtualScroll, autofix); } - private handleNodeForWrappedBuilder(node: ts.Node): void { + private handleNodeForWrappedBuilder(node: ts.TypeReferenceNode | ts.NewExpression | ts.CallExpression): void { if (!this.options.arkts2) { return; } - if ( - ts.isTypeReferenceNode(node) && this.isTargetInterface(node.typeName, CustomInterfaceName.WrappedBuilder) || - ts.isNewExpression(node) && this.isTargetInterface(node.expression, CustomInterfaceName.WrappedBuilder) || - ts.isCallExpression(node) && this.isTargetInterface(node.expression, CustomInterfaceName.wrapBuilder) - ) { - this.incrementCounters(node, FaultID.WrappedBuilderGenericNeedArrowFunc); + const identifier = ts.isTypeReferenceNode(node) ? node.typeName : node.expression; + if (this.isDeclarationInSameFile(identifier)) { + return; } - } - private isTargetInterface(node: ts.Node, targetName: string): boolean { - return ts.isIdentifier(node) && node.getText() === targetName && !this.isDeclarationInSameFile(node); + switch (identifier.getText()) { + case CustomInterfaceName.WrappedBuilder: + this.incrementCounters(node, FaultID.WrappedBuilderGenericNeedArrowFunc); + break; + case CustomInterfaceName.wrapBuilder: { + const args = node.typeArguments; + if (args && args.length > 0 && ts.isTupleTypeNode(args[0])) { + this.incrementCounters(node, FaultID.WrapBuilderGenericNeedArrowFunc); + } + break; + } + default: + } } private checkImportJsonFile(node: ts.ImportDeclaration): void { @@ -13029,4 +13360,127 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return true; } + + private handleNodeForBuilderNode(node: ts.TypeReferenceNode | ts.NewExpression): void { + if (!this.options.arkts2) { + return; + } + + const identifier = ts.isTypeReferenceNode(node) ? node.typeName : node.expression; + if ( + identifier.getText() !== CustomInterfaceName.BuilderNode || + !this.isDeclInTargetFile(identifier, BUILDERNODE_D_TS) + ) { + return; + } + + const firstArg = node.typeArguments?.[0]; + if (firstArg && ts.isTupleTypeNode(firstArg)) { + this.incrementCounters(node, FaultID.BuilderNodeGenericNoTuple); + } + } + + private isDeclInTargetFile(node: ts.Node, targetFile: string): boolean { + const decl = this.tsUtils.getDeclarationNode(node); + const file = decl?.getSourceFile(); + if (file !== undefined) { + const fileName = path.basename(file.fileName); + if (fileName !== targetFile) { + return false; + } + } + + return true; + } + + private handlePropertyAccessExprForBuilderNode(node: ts.PropertyAccessExpression): void { + if (!this.options.arkts2) { + return; + } + + const identifier = node.name; + if (!ts.isIdentifier(identifier) || !this.isDeclInTargetFile(identifier, BUILDERNODE_D_TS)) { + return; + } + + const name = identifier.getText(); + const callExpr = ts.findAncestor(node, ts.isCallExpression); + if (!callExpr) { + return; + } + + switch (name) { + case BuilderNodeFunctionName.Update: + if (callExpr.arguments.length !== 0 && this.checkArgumentIsLiteral(callExpr.arguments[0])) { + this.incrementCounters(callExpr, FaultID.BuilderNodeUpdateNoLiteral); + } + break; + case BuilderNodeFunctionName.Build: { + const hasTargetParam = callExpr.arguments.filter(ts.isObjectLiteralExpression).some((literal) => { + return literal.properties.some((prop) => { + return prop.name?.getText() === NESTING_BUILDER_SUPPORTED; + }); + }); + if (hasTargetParam) { + this.incrementCounters(callExpr, FaultID.BuilderNodeNoNestingBuilderSupported); + } + break; + } + default: + } + } + + private checkArgumentIsLiteral(node: ts.Node): boolean { + switch (node.kind) { + case ts.SyntaxKind.ObjectLiteralExpression: + return true; + case ts.SyntaxKind.Identifier: + return this.checkIdentifierIsLiteral(node as ts.Identifier); + case ts.SyntaxKind.ConditionalExpression: + return this.checkConditionalExprIsLiteral(node as ts.ConditionalExpression); + case ts.SyntaxKind.CallExpression: + return this.checkCallExprIsLiteral(node as ts.CallExpression); + default: + return false; + } + } + + private checkIdentifierIsLiteral(node: ts.Identifier): boolean { + const decl = this.tsUtils.getDeclarationNode(node); + const initalizer = decl && ts.isVariableDeclaration(decl) ? decl.initializer : undefined; + if (!initalizer) { + return false; + } + return this.checkArgumentIsLiteral(initalizer); + } + + private checkConditionalExprIsLiteral(node: ts.ConditionalExpression): boolean { + return this.checkArgumentIsLiteral(node.whenTrue) || this.checkArgumentIsLiteral(node.whenFalse); + } + + private checkCallExprIsLiteral(node: ts.CallExpression): boolean { + const callExpr = node; + let identifier: ts.Identifier | undefined; + if (ts.isIdentifier(callExpr.expression)) { + identifier = callExpr.expression; + } else if (ts.isPropertyAccessExpression(callExpr.expression) && ts.isIdentifier(callExpr.expression.name)) { + identifier = callExpr.expression.name; + } + + if (!identifier) { + return false; + } + const funcDecl = this.tsUtils.getDeclarationNode(identifier); + const body = + funcDecl && (ts.isFunctionDeclaration(funcDecl) || ts.isMethodDeclaration(funcDecl)) ? funcDecl.body : undefined; + if (!body) { + return false; + } + for (const stmt of body.statements) { + if (ts.isReturnStatement(stmt) && stmt.expression) { + return this.checkArgumentIsLiteral(stmt.expression); + } + } + return false; + } } diff --git a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts index 375831c9a731489a8201edb6e69f1b31f35ffb47..dd3096cc61e605dc85be56b3389eefe6687626a4 100644 --- a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts +++ b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts @@ -56,7 +56,6 @@ export const cookBookRefToFixTitle: Map = new Map([ [282, '"@StorageProp" transform to "@StoragePropRef"'], [283, '"@LocalStorageProp" transform to "@LocalStoragePropRef"'], [300, 'Replace calling method of the TS-like `Function` type'], - [330, 'Convert import named objects from JS to ESValue'], [332, 'Using the ESValue interface to access properties'], [334, 'Call typeOf function'], [335, 'Call toNumber function to convert'], diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 6c0a96ff547a2811936705f49ccca19ffc4b3383..9d3a0c173263c77c4b9b4d2f709c5b90b174b933 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -30,7 +30,7 @@ import { COMMON_METHOD_IDENTIFIER, APPLY_STYLES_IDENTIFIER, CustomInterfaceName, - ARKUI_PACKAGE_NAME, + ARKUI_MODULE, VALUE_IDENTIFIER, INDENT_STEP, ENTRY_DECORATOR_NAME, @@ -47,7 +47,6 @@ import { import { ES_VALUE } from '../utils/consts/ESObject'; import type { IncrementDecrementNodeInfo } from '../utils/consts/InteropAPI'; import { - LOAD, GET_PROPERTY, SET_PROPERTY, ARE_EQUAL, @@ -64,6 +63,7 @@ import { import path from 'node:path'; import { isStdLibrarySymbol } from '../utils/functions/IsStdLibrary'; import { propertyAccessReplacements, identifierReplacements } from '../utils/consts/DeprecatedApi'; +import { ARKTS_COLLECTIONS_MODULE, BIT_VECTOR } from '../utils/consts/CollectionsAPI'; const UNDEFINED_NAME = 'undefined'; @@ -3696,7 +3696,7 @@ export class Autofixer { const importDeclaration = ts.factory.createImportDeclaration( undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(importSpecifiers)), - ts.factory.createStringLiteral(ARKUI_PACKAGE_NAME, true), + ts.factory.createStringLiteral(ARKUI_MODULE, true), undefined ); @@ -4150,7 +4150,7 @@ export class Autofixer { return undefined; } - private static findParentVariableDeclaration(node: ts.Node): ts.VariableDeclaration | undefined { + private static findParentVariableDeclaration(node: ts.Node): ts.VariableDeclaration | undefined { while (node) { if (ts.isVariableDeclaration(node)) { return node; @@ -4167,68 +4167,6 @@ export class Autofixer { return [{ start: pos, end: pos, replacementText: text }]; } - private static createVariableForInteropImport( - interopProperty: string, - symbolName: string, - propertyName: string - ): ts.VariableStatement { - const newVarDecl = ts.factory.createVariableStatement( - undefined, - ts.factory.createVariableDeclarationList( - [ - ts.factory.createVariableDeclaration( - ts.factory.createIdentifier(symbolName), - undefined, - undefined, - this.createVariableInitialForInteropImport(propertyName, interopProperty) - ) - ], - ts.NodeFlags.Let - ) - ); - return newVarDecl; - } - - private static createVariableInitialForInteropImport(propertyName: string, interopProperty: string): ts.Expression { - const initializer = ts.factory.createCallExpression( - ts.factory.createPropertyAccessExpression( - ts.factory.createCallExpression( - ts.factory.createPropertyAccessExpression( - ts.factory.createIdentifier(ES_VALUE), - ts.factory.createIdentifier(LOAD) - ), - undefined, - [ts.factory.createStringLiteral(interopProperty)] - ), - ts.factory.createIdentifier(GET_PROPERTY) - ), - undefined, - [ts.factory.createStringLiteral(propertyName)] - ); - return initializer; - } - - private static getOriginalNameAtSymbol(symbolName: string, symbol?: ts.Symbol): string { - if (symbol) { - const originalDeclaration = symbol.declarations?.[0]; - let originalName = ''; - if (originalDeclaration) { - const isReturnNameOnSomeCase = - ts.isFunctionDeclaration(originalDeclaration) || - ts.isClassDeclaration(originalDeclaration) || - ts.isInterfaceDeclaration(originalDeclaration) || - ts.isEnumDeclaration(originalDeclaration); - if (isReturnNameOnSomeCase) { - originalName = originalDeclaration.name?.text || symbolName; - } else if (ts.isVariableDeclaration(originalDeclaration)) { - originalName = originalDeclaration.name.getText(); - } - } - return originalName; - } - return ''; - } - private fixInterOpImportJsProcessNode(node: ts.Node): string | undefined { if (ts.isIdentifier(node)) { return node.text; @@ -4277,128 +4215,6 @@ export class Autofixer { return undefined; } - fixInterOpImportJs( - importDecl: ts.ImportDeclaration, - importClause: ts.ImportClause, - moduleSpecifier: string, - defaultSymbol?: ts.Symbol - ): Autofix[] | undefined { - if (!Autofixer.shouldTransformImport(moduleSpecifier)) { - return undefined; - } - - let statements: string[] = []; - if (importClause.name) { - const symbolName = importClause.name.text; - const originalName = Autofixer.getOriginalNameAtSymbol(symbolName, defaultSymbol); - statements = this.constructAndSaveimportDecl2Arrays( - importDecl, - moduleSpecifier, - symbolName, - originalName, - statements - ); - } - const namedBindings = importClause.namedBindings; - if (namedBindings) { - statements = this.getStatementForInterOpImportJsOnNamedBindings( - namedBindings, - importDecl, - moduleSpecifier, - statements - ); - } - - return [Autofixer.createImportDeclarationFix(importDecl), this.createInsertStatementsFix(importDecl, statements)]; - } - - private static createImportDeclarationFix(importDecl: ts.ImportDeclaration): Autofix { - return { - start: importDecl.getStart(), - end: importDecl.getEnd(), - replacementText: '' - }; - } - - private createInsertStatementsFix(importDecl: ts.ImportDeclaration, statements: string[]): Autofix { - const joinedStatements = statements.join(this.getNewLine()); - const replacementText = this.detectNeedsLeadingNewline(importDecl) ? - this.getNewLine() + joinedStatements : - joinedStatements; - - return { - start: importDecl.getEnd(), - end: importDecl.getEnd(), - replacementText - }; - } - - private static shouldTransformImport(moduleSpecifier: string): boolean { - return moduleSpecifier.endsWith('.js') || moduleSpecifier.startsWith('./') || moduleSpecifier.startsWith('../'); - } - - private detectNeedsLeadingNewline(importDecl: ts.ImportDeclaration): boolean { - const prevToken = ts.getLeadingCommentRanges(this.sourceFile.text, importDecl.getFullStart())?.[0]; - return !!prevToken && !(/^\s*$/).test(this.sourceFile.text.slice(prevToken.end, importDecl.getStart())); - } - - private getStatementForInterOpImportJsOnNamedBindings( - namedBindings: ts.NamedImportBindings, - importDecl: ts.ImportDeclaration, - moduleSpecifier: string, - statements: string[] - ): string[] { - if (ts.isNamespaceImport(namedBindings)) { - const symbolName = namedBindings.name.text; - statements = this.constructAndSaveimportDecl2Arrays( - importDecl, - moduleSpecifier, - symbolName, - symbolName, - statements - ); - } - if (ts.isNamedImports(namedBindings)) { - namedBindings.elements.map((element) => { - const symbolName = element.name.text; - const originalName = element.propertyName ? element.propertyName.text : symbolName; - statements = this.constructAndSaveimportDecl2Arrays( - importDecl, - moduleSpecifier, - symbolName, - originalName, - statements - ); - return statements; - }); - } - return statements; - } - - private constructAndSaveimportDecl2Arrays( - importDecl: ts.ImportDeclaration, - moduleSpecifier: string, - symbolName: string, - originalName: string | undefined, - statements: string[] - ): string[] { - const propertyName = originalName || symbolName; - const newVarDecl = Autofixer.createVariableForInteropImport(moduleSpecifier, symbolName, propertyName); - const text = this.printer.printNode(ts.EmitHint.Unspecified, newVarDecl, importDecl.getSourceFile()); - statements.push(TsUtils.removeOrReplaceQuotes(text, true)); - return statements; - } - - private getLastImportEnd(): number { - let lastImportEnd = 0; - this.sourceFile.statements.forEach((statement) => { - if (ts.isImportDeclaration(statement)) { - lastImportEnd = statement.getEnd(); - } - }); - return lastImportEnd; - } - fixInteropPropertyAccessExpression(express: ts.PropertyAccessExpression): Autofix[] | undefined { let text: string = ''; const statements = ts.factory.createCallExpression( @@ -4905,7 +4721,9 @@ export class Autofixer { ); } - private fixGenericCallNoTypeArgsWithContextualType(node: ts.NewExpression): Autofix[] | undefined { + private fixGenericCallNoTypeArgsWithContextualType( + node: ts.NewExpression | ts.CallExpression + ): Autofix[] | undefined { const contextualType = this.typeChecker.getContextualType(node); if (!contextualType) { return undefined; @@ -4921,18 +4739,26 @@ export class Autofixer { return this.generateGenericTypeArgumentsAutofix(node, reference); } - fixGenericCallNoTypeArgs(node: ts.NewExpression): Autofix[] | undefined { + fixGenericCallNoTypeArgs(node: ts.NewExpression | ts.CallExpression): Autofix[] | undefined { const typeNode = this.getTypeNodeForNewExpression(node); if (!typeNode) { return this.fixGenericCallNoTypeArgsWithContextualType(node); } + let nodeExpressionText = node.expression.getText(); + if (ts.isCallExpression(node)) { + const returnTypeText = this.getReturnTypeFromMethodDeclaration(node); + if (!returnTypeText) { + return undefined; + } + nodeExpressionText = returnTypeText; + } if (ts.isUnionTypeNode(typeNode)) { - return this.fixGenericCallNoTypeArgsForUnionType(node, typeNode); + return this.fixGenericCallNoTypeArgsForUnionType(node, typeNode, nodeExpressionText); } if (ts.isArrayTypeNode(typeNode)) { return this.fixGenericCallNoTypeArgsForArrayType(node, typeNode); } - if (!ts.isTypeReferenceNode(typeNode) || typeNode.typeName.getText() !== node.expression.getText()) { + if (!ts.isTypeReferenceNode(typeNode) || typeNode.typeName.getText() !== nodeExpressionText) { return undefined; } @@ -4945,8 +4771,141 @@ export class Autofixer { return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; } + fixGenericCallNoTypeArgsForUnknown(node: ts.CallExpression): Autofix[] | undefined { + if (ts.isPropertyAccessExpression(node.parent)) { + const insertPos = node.expression.getEnd(); + return [{ start: insertPos, end: insertPos, replacementText: '' }]; + } + + const typeNode = this.getTypeNodeForNewExpression(node); + if (!typeNode) { + return undefined; + } + + const nodeExpressionText = ts.isVariableDeclaration(node.parent) ? + this.getReturnTypeFromMethodDeclaration(node) ?? node.expression.getText() : + node.expression.getText(); + + if (ts.isUnionTypeNode(typeNode)) { + const targetTypeRef = typeNode.types.find((t): t is ts.TypeReferenceNode => { + return ts.isTypeReferenceNode(t) && t.typeName.getText() === nodeExpressionText; + }); + if (!targetTypeRef) { + return undefined; + } + return this.createFixWithTypeArgs(node, targetTypeRef.typeArguments); + } + + if (ts.isTypeReferenceNode(typeNode) && typeNode.typeName.getText() === nodeExpressionText) { + return this.createFixWithTypeArgs(node, typeNode.typeArguments); + } + + return undefined; + } + + private createFixWithTypeArgs( + node: ts.CallExpression, + typeArguments: ts.NodeArray | undefined + ): Autofix[] | undefined { + const typeArgsText = this.printGenericCallTypeArgs(node.getSourceFile(), typeArguments); + return typeArgsText ? + [ + { + start: node.expression.getEnd(), + end: node.expression.getEnd(), + replacementText: typeArgsText + } + ] : + undefined; + } + + getReturnTypeFromMethodDeclaration(node: ts.CallExpression): string | undefined { + if (ts.isPropertyAccessExpression(node.expression)) { + const propertyAccess = node.expression; + const methodName = propertyAccess.name.text; + const receiver = propertyAccess.expression; + const receiverType = this.typeChecker.getTypeAtLocation(receiver); + const methodSymbol = this.typeChecker.getPropertyOfType(receiverType, methodName); + + if (!methodSymbol) { + return undefined; + } + const methodDecl = methodSymbol.declarations?.[0] as ts.MethodSignature; + if (!methodDecl.type || !ts.isTypeReferenceNode(methodDecl.type) && !ts.isUnionTypeNode(methodDecl.type)) { + return undefined; + } + if (ts.isTypeReferenceNode(methodDecl.type)) { + return methodDecl.type.typeName.getText(); + } + if (ts.isUnionTypeNode(methodDecl.type)) { + const typeNode = this.getTypeNodeForNewExpression(node); + if (!typeNode) { + return undefined; + } + const targetTypeName = this.getTargetTypeName(typeNode, methodDecl.type); + + if (ts.isUnionTypeNode(typeNode)) { + return targetTypeName; + } + const targetTypeNode = methodDecl.type.types.find((type) => { + return ts.isTypeReferenceNode(type) && type.typeName.getText() === targetTypeName; + }) as ts.TypeReferenceNode; + if (!targetTypeNode) { + return undefined; + } + return targetTypeNode.typeName.getText(); + } + } + return undefined; + } + + private getTargetTypeName(typeNode: ts.TypeNode, methodDeclType: ts.UnionTypeNode): string | undefined { + if (ts.isTypeReferenceNode(typeNode)) { + return typeNode.typeName.getText(); + } + + if (!ts.isUnionTypeNode(typeNode)) { + return undefined; + } + + const hasGenericType = methodDeclType.types.some((type) => { + return this.isGenericTypeParameter(type); + }); + const typeNames = new Set(typeNode.types.map(Autofixer.getTypeName).filter(Boolean)); + + const candidateNames = hasGenericType ? + typeNode.types.map(Autofixer.getTypeName) : + methodDeclType.types.map(Autofixer.getTypeName); + const targetTypeName = candidateNames.find((name) => { + return name && name !== 'undefined' && (hasGenericType || typeNames.has(name)); + }); + return targetTypeName; + } + + private isGenericTypeParameter(type: ts.TypeNode): boolean { + const getType = this.typeChecker.getTypeFromTypeNode(type); + return getType.isTypeParameter(); + } + + private static getTypeName(type: ts.TypeNode): string { + if (ts.isTypeReferenceNode(type)) { + return type.typeName.getText(); + } + if (ts.isLiteralTypeNode(type)) { + return type.literal.getText(); + } + const typeNameMap = { + [ts.SyntaxKind.StringKeyword]: 'string', + [ts.SyntaxKind.NumberKeyword]: 'number', + [ts.SyntaxKind.BooleanKeyword]: 'boolean', + [ts.SyntaxKind.UndefinedKeyword]: 'undefined', + [ts.SyntaxKind.NullKeyword]: 'null' + }; + return typeNameMap[type.kind] || ''; + } + private fixGenericCallNoTypeArgsForArrayType( - node: ts.NewExpression, + node: ts.NewExpression | ts.CallExpression, arrayTypeNode: ts.ArrayTypeNode ): Autofix[] | undefined { const elementTypeNode = arrayTypeNode.elementType; @@ -4960,23 +4919,29 @@ export class Autofixer { } private fixGenericCallNoTypeArgsForUnionType( - node: ts.NewExpression, - unionType: ts.UnionTypeNode + node: ts.NewExpression | ts.CallExpression, + unionType: ts.UnionTypeNode, + nodeExpressionText: string ): Autofix[] | undefined { const matchingTypes = unionType.types.filter((type) => { - return ts.isTypeReferenceNode(type) && type.typeName.getText() === node.expression.getText(); - }) as ts.TypeReferenceNode[]; + return Autofixer.getTypeName(type) === nodeExpressionText; + }); if (matchingTypes.length === 1) { const matchingType = matchingTypes[0]; - if (matchingType.typeArguments) { - const srcFile = node.getSourceFile(); - const typeArgsText = this.printGenericCallTypeArgs(srcFile, matchingType.typeArguments); - if (!typeArgsText) { - return undefined; + if (ts.isTypeReferenceNode(matchingType)) { + if (matchingType.typeArguments) { + const srcFile = node.getSourceFile(); + const typeArgsText = this.printGenericCallTypeArgs(srcFile, matchingType.typeArguments); + if (!typeArgsText) { + return undefined; + } + const insertPos = node.expression.getEnd(); + return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; } + } else { const insertPos = node.expression.getEnd(); - return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; + return [{ start: insertPos, end: insertPos, replacementText: `<${nodeExpressionText}>` }]; } } return undefined; @@ -5044,7 +5009,7 @@ export class Autofixer { } private generateGenericTypeArgumentsAutofix( - node: ts.NewExpression, + node: ts.NewExpression | ts.CallExpression, typeArgs: ts.TypeReferenceNode[] ): Autofix[] | undefined { const srcFile = node.getSourceFile(); @@ -5076,7 +5041,7 @@ export class Autofixer { return []; } - private getTypeNodeForNewExpression(node: ts.NewExpression): ts.TypeNode | undefined { + private getTypeNodeForNewExpression(node: ts.NewExpression | ts.CallExpression): ts.TypeNode | undefined { if (ts.isVariableDeclaration(node.parent) || ts.isPropertyDeclaration(node.parent)) { return node.parent.type; } else if (ts.isBinaryExpression(node.parent)) { @@ -5231,15 +5196,44 @@ export class Autofixer { ]; } - fixPropDecorator(node: ts.Decorator, decoratorName: string): Autofix[] { - const newDecorator = ts.factory.createDecorator( - ts.factory.createIdentifier(decoratorName + NEW_PROP_DECORATOR_SUFFIX) - ); + fixPropDecorator(node: ts.Identifier, decoratorName: string): Autofix[] { + const newDecorator = ts.factory.createIdentifier(decoratorName + NEW_PROP_DECORATOR_SUFFIX); const text = this.printer.printNode(ts.EmitHint.Unspecified, newDecorator, node.getSourceFile()); return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; } + importBitVector(node: ts.Node, lastImportDeclaration: ts.Node | undefined): Autofix | undefined { + const importDeclaration = ts.factory.createImportDeclaration( + undefined, + ts.factory.createImportClause( + false, + undefined, + ts.factory.createNamedImports([ + ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(BIT_VECTOR)) + ]) + ), + ts.factory.createStringLiteral(ARKTS_COLLECTIONS_MODULE), + undefined + ); + // find the last import statement; + + let replacementText: string = this.nonCommentPrinter.printNode( + ts.EmitHint.Unspecified, + importDeclaration, + node.getSourceFile() + ); + let start: number = 0; + let end: number = 0; + + if (lastImportDeclaration) { + start = end = lastImportDeclaration.getEnd(); + replacementText = this.getNewLine() + replacementText + this.getNewLine(); + } + + return { start, end, replacementText }; + } + fixRepeat(stmt: ts.ExpressionStatement): Autofix[] { const newExpr = ts.factory.createCallExpression(ts.factory.createIdentifier(VIRTUAL_SCROLL_IDENTIFIER), undefined, [ ts.factory.createObjectLiteralExpression( @@ -5362,11 +5356,9 @@ export class Autofixer { } fixSideEffectImport(importDeclNode: ts.ImportDeclaration): Autofix[] { - const initModuleCall = ts.factory.createCallExpression( - ts.factory.createIdentifier("initModule"), - undefined, - [importDeclNode.moduleSpecifier] - ); + const initModuleCall = ts.factory.createCallExpression(ts.factory.createIdentifier('initModule'), undefined, [ + importDeclNode.moduleSpecifier + ]); const expressionStatement = ts.factory.createExpressionStatement(initModuleCall); const replacedText = this.printer.printNode( ts.EmitHint.Unspecified, @@ -5374,10 +5366,12 @@ export class Autofixer { importDeclNode.getSourceFile() ); - return [{ - start: importDeclNode.getStart(), - end: importDeclNode.getEnd(), - replacementText: replacedText - }]; + return [ + { + start: importDeclNode.getStart(), + end: importDeclNode.getEnd(), + replacementText: replacedText + } + ]; } } diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts index bcf0d2c1d04a17f370a318fe0af6c924796cbd60..40063205dac9d0f9b4ed214aec4b8922450b3a67 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts @@ -20,11 +20,9 @@ export const INSTANCE_IDENTIFIER = 'instance'; export const COMMON_METHOD_IDENTIFIER = 'CommonMethod'; export const APPLY_STYLES_IDENTIFIER = 'applyStyles'; export const STATE_STYLES = 'stateStyles'; -export const ARKUI_PACKAGE_NAME = '@kit.ArkUI'; export const VALUE_IDENTIFIER = 'value'; export const INDENT_STEP = 2; export const MAKE_OBSERVED = 'makeObserved'; -export const ARKUI_STATE_MANAGEMENT = '@ohos.arkui.StateManagement'; export const NEW_PROP_DECORATOR_SUFFIX = 'Ref'; export enum CustomInterfaceName { @@ -38,7 +36,8 @@ export enum CustomInterfaceName { CustomStyles = 'CustomStyles', Repeat = 'Repeat', WrappedBuilder = 'WrappedBuilder', - wrapBuilder = 'wrapBuilder' + wrapBuilder = 'wrapBuilder', + BuilderNode = 'BuilderNode' } export enum StorageTypeName { @@ -57,6 +56,11 @@ export enum PropFunctionName { SetAndProp = 'setAndProp' } +export enum BuilderNodeFunctionName { + Build = 'build', + Update = 'update' +} + export const observedDecoratorName: Set = new Set([ 'State', 'Prop', @@ -94,3 +98,9 @@ export const PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME = 'allowOverride'; export const VIRTUAL_SCROLL_IDENTIFIER = 'virtualScroll'; export const DISABLE_VIRTUAL_SCROLL_IDENTIFIER = 'disableVirtualScroll'; + +export const ARKUI_MODULE = '@kit.ArkUI'; +export const STATE_MANAGEMENT_MODULE = '@ohos.arkui.StateManagement'; + +export const BUILDERNODE_D_TS = 'BuilderNode.d.ts'; +export const NESTING_BUILDER_SUPPORTED = 'nestingBuilderSupported'; diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts index f00234df62db7c86386840c10b0289166a81e4e2..f95f5d338f6a74f4e4c750f916f458696f96dfc3 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts @@ -497,6 +497,8 @@ export const arkuiImportList: Set = new Set([ 'GestureRecognizerState', 'GestureStyle', 'GestureType', + 'getInspectorByKey', + 'getInspectorTree', 'GetItemMainSizeByIndex', 'GradientDirection', 'Grid', @@ -1615,7 +1617,9 @@ export const arkuiImportList: Set = new Set([ 'px2vp', 'setAppBgColor', 'sharedTransitionOptions', - 'vp2px' + 'vp2px', + '$r', + '$rawfile' ]); export const arkTsBuiltInTypeName: Set = new Set([ diff --git a/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts b/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts index a7c1698e3ba00a285e16df6ee6b1c418f3832d4b..331a36bb29639f47336a980fbe78db1f32e6ab0f 100644 --- a/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts @@ -14,4 +14,6 @@ */ export const COLLECTIONS_TEXT = 'collections'; +export const ARKTS_COLLECTIONS_MODULE = '@arkts.collections'; +export const BIT_VECTOR = 'BitVector'; export const COLLECTIONS_MODULES = ['@arkts.collections', '@kit.ArkTS']; diff --git a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts index afd7fcc08737fc52d29b37f99fa38852b6417450..6d4e230d392679d3c8957979217b92d8b85130ea 100644 --- a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts @@ -66,7 +66,6 @@ export const OBJECT_LITERAL = 'Object'; export const REFLECT_LITERAL = 'Reflect'; export const NONE = 'none'; export type ForbidenAPICheckResult = 'Object' | 'Reflect' | 'none'; -export const LOAD = 'load'; export const GET_PROPERTY = 'getProperty'; export const SET_PROPERTY = 'setProperty'; export const TO_NUMBER = 'toNumber'; diff --git a/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json index dcb5f51adacdac07a38c4bbff93dff9e6eef2f42..971a2bc65f74c58502743a89075ad9c35f5df3f4 100644 --- a/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json +++ b/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json @@ -134,6 +134,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 28, + "column": 7, + "endLine": 28, + "endColumn": 8, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 37, "column": 1, @@ -234,6 +244,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 49, + "column": 9, + "endLine": 49, + "endColumn": 10, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 57, "column": 11, @@ -285,4 +305,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/deprecatedapi/UIContext.ets.json.args.json b/ets2panda/linter/test/deprecatedapi/UIContext.ets.json.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/UIContext.ets.json.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.arkts2.json index 1fc946dc8d23ece21f715f7fa7a1717a3306f382..891eb9509c4b250bbf93436010f834933bbc42d5 100755 --- a/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/appStorageIsMutable_api.ets.arkts2.json @@ -34,6 +34,16 @@ "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", "severity": "ERROR" }, + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 44, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, { "line": 20, "column": 32, @@ -44,7 +54,7 @@ "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", "severity": "ERROR" }, - { + { "line": 22, "column": 31, "endLine": 22, diff --git a/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..1b80aa9e7367c4d206bb53f8fc43c77fc24045d7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..667d91d76ded29c2264848d9ce8089452797bddf --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/chip_group_api.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "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": 36, + "column": 3, + "endLine": 36, + "endColumn": 6, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 32, + "endLine": 24, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 33, + "endLine": 26, + "endColumn": 35, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 16, + "endLine": 35, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"IconOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 20, + "endLine": 39, + "endColumn": 31, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"IconOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 25, + "endLine": 40, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common.ets.args.json b/ets2panda/linter/test/deprecatedapi/common.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/common.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..1dc330e4e7defbd806a9b74001f9ded0f5204afe --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/common.ets.arkts2.json @@ -0,0 +1,448 @@ +{ + "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": 20, + "column": 21, + "endLine": 20, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 27, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 22, + "endLine": 28, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 28, + "endLine": 29, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 24, + "endLine": 30, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 29, + "endLine": 31, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 26, + "endLine": 38, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 36, + "endLine": 38, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 13, + "endLine": 41, + "endColumn": 29, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 13, + "endLine": 41, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 13, + "endLine": 42, + "endColumn": 29, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 13, + "endLine": 42, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 13, + "endLine": 47, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 13, + "endLine": 48, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 21, + "endLine": 58, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 20, + "endLine": 61, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 8, + "endLine": 66, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 8, + "endLine": 67, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 7, + "endLine": 68, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 7, + "endLine": 69, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 7, + "endLine": 70, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 7, + "endLine": 71, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 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": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 7, + "endLine": 21, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 9, + "endLine": 22, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Image\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 15, + "endLine": 22, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Circle\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 19, + "endLine": 27, + "endColumn": 33, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TransitionType\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 26, + "endLine": 34, + "endColumn": 33, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Context\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 36, + "endLine": 34, + "endColumn": 46, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"getContext\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 3, + "endLine": 38, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 27, + "endLine": 39, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TouchEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ClickEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 26, + "endLine": 51, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"MouseEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 1, + "endLine": 66, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"px2lpx\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 1, + "endLine": 67, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"lpx2px\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"px2fp\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"fp2px\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"px2vp\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 6, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"vp2px\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json old mode 100755 new mode 100644 index 9eb4d655c3bc4fab432f35a1de29db09dbe98baa..1f361a5a2763cdee61e3028b9c71ff02ac3d9527 --- a/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json @@ -804,6 +804,16 @@ "rule": "The ArkUI interface \"Image\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, + { + "line": 91, + "column": 15, + "endLine": 91, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, { "line": 103, "column": 7, diff --git a/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.args.json b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..ab200aca98a0c25e5488380a88ae795e2ec6c751 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/componentSnapshot.ets.arkts2.json @@ -0,0 +1,158 @@ +{ + "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": 25, + "column": 19, + "endLine": 25, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 16, + "endLine": 26, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 12, + "endLine": 30, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 19, + "endLine": 41, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 21, + "column": 4, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 20, + "endLine": 28, + "endColumn": 29, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 7, + "endLine": 35, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 17, + "endLine": 45, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"HorizontalAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/curves.ets.args.json b/ets2panda/linter/test/deprecatedapi/curves.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/curves.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SizeType.ets.json b/ets2panda/linter/test/deprecatedapi/curves.ets.arkts2.json old mode 100755 new mode 100644 similarity index 100% rename from ets2panda/linter/test/deprecatedapi/SizeType.ets.json rename to ets2panda/linter/test/deprecatedapi/curves.ets.arkts2.json diff --git a/ets2panda/linter/test/deprecatedapi/date_picker.ets.args.json b/ets2panda/linter/test/deprecatedapi/date_picker.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/date_picker.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/date_picker.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/date_picker.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..3c31119d9f80feda224ca75460f2c13228f98f0d --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/date_picker.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "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": 24, + "column": 17, + "endLine": 24, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 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": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 11, + "endLine": 26, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DatePickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DatePicker\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..ce2955ca55158612f1e3169e24143b3a5dbe5d9f --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_common_utils.ets.arkts2.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": 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": 27, + "column": 5, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json old mode 100755 new mode 100644 index d720ed0d4869125157fa8048467911e42cbf230d..00497d02618ba04db6d78378728574529f588c2e --- a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json @@ -84,6 +84,16 @@ "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, + { + "line": 26, + "column": 18, + "endLine": 26, + "endColumn": 26, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$rawfile\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, { "line": 31, "column": 5, @@ -123,6 +133,16 @@ "suggest": "", "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" + }, + { + "line": 42, + "column": 70, + "endLine": 42, + "endColumn": 78, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"$rawfile\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..33af06e3141b27c854edfb247704eea48773abab --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_prompt_action.ets.arkts2.json @@ -0,0 +1,118 @@ +{ + "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": 25, + "column": 17, + "endLine": 25, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 14, + "endLine": 48, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 9, + "endLine": 69, + "endColumn": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 14, + "endLine": 69, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 36, + "endLine": 72, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 76, + "column": 44, + "endLine": 76, + "endColumn": 63, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DismissDialogAction\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 5, + "endLine": 82, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.args.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..1af038e5b70c2a49a22760284383fc43921a23fa --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_time_picker.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "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": 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": 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": 21, + "column": 5, + "endLine": 21, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TimePickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TimePickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/dragController.ets.args.json b/ets2panda/linter/test/deprecatedapi/dragController.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/dragController.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..353facd04ad8d3e162743403e88474a6e2766a0b --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json @@ -0,0 +1,308 @@ +{ + "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": 29, + "column": 19, + "endLine": 29, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 12, + "endLine": 31, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 13, + "endLine": 32, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 19, + "endLine": 40, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 12, + "endLine": 43, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 13, + "endLine": 44, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 33, + "endLine": 48, + "endColumn": 46, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 17, + "endLine": 53, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 26, + "endLine": 60, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 27, + "endLine": 67, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 32, + "endLine": 67, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "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": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 4, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 20, + "endLine": 28, + "endColumn": 25, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 22, + "endLine": 33, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 4, + "endLine": 36, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 7, + "endLine": 39, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 20, + "endLine": 41, + "endColumn": 25, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 22, + "endLine": 45, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 33, + "endLine": 48, + "endColumn": 46, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"CustomBuilder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 49, + "endLine": 48, + "endColumn": 61, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DragItemInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 5, + "endLine": 51, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 7, + "endLine": 52, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 27, + "endLine": 57, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TouchEvent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/enums.ets.args.json b/ets2panda/linter/test/deprecatedapi/enums.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/enums.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/enums.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/enums.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..7be47bbee3b08773bf7e42d846b2c7547e1b8afe --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/enums.ets.arkts2.json @@ -0,0 +1,308 @@ +{ + "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": 19, + "column": 28, + "endLine": 19, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 31, + "endLine": 20, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 34, + "endLine": 20, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 37, + "endLine": 20, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 40, + "endLine": 20, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 43, + "endLine": 20, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 46, + "endLine": 20, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 49, + "endLine": 20, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 52, + "endLine": 20, + "endColumn": 53, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 55, + "endLine": 20, + "endColumn": 56, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 24, + "endLine": 37, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 35, + "endLine": 37, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 24, + "endLine": 43, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 35, + "endLine": 43, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 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": 19, + "column": 13, + "endLine": 19, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 28, + "endLine": 19, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Stack\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 27, + "endLine": 23, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Alignment\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroll\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 11, + "endLine": 26, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 13, + "endLine": 27, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 36, + "endLine": 35, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Edge\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 7, + "endLine": 38, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 36, + "endLine": 41, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Edge\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/image_animator.ets.args.json b/ets2panda/linter/test/deprecatedapi/image_animator.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/image_animator.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/image_animator.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/image_animator.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..5dba08427fc25db0e2685528623ab4dd5c785369 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/image_animator.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "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": 21, + "column": 21, + "endLine": 21, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 20, + "endLine": 23, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 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": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 20, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ImageAnimator\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/inspector.ets.args.json b/ets2panda/linter/test/deprecatedapi/inspector.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/inspector.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/SizeType.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/inspector.ets.arkts2.json old mode 100755 new mode 100644 similarity index 64% rename from ets2panda/linter/test/deprecatedapi/SizeType.ets.arkts2.json rename to ets2panda/linter/test/deprecatedapi/inspector.ets.arkts2.json index b0bd84bb5e8299499e1d08466994c432fe8cbfb6..e0f8c248c3d021a37f4d975a415f65f7d9676c03 --- a/ets2panda/linter/test/deprecatedapi/SizeType.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/inspector.ets.arkts2.json @@ -15,30 +15,30 @@ ], "result": [ { - "line": 20, - "column": 31, - "endLine": 20, - "endColumn": 39, - "problem": "NoDeprecatedApi", + "line": 24, + "column": 22, + "endLine": 24, + "endColumn": 23, + "problem": "NumericSemantics", "suggest": "", - "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 23, - "column": 21, - "endLine": 23, - "endColumn": 22, + "line": 26, + "column": 20, + "endLine": 26, + "endColumn": 23, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 24, - "column": 66, - "endLine": 24, - "endColumn": 67, + "line": 27, + "column": 21, + "endLine": 27, + "endColumn": 24, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -46,58 +46,58 @@ }, { "line": 28, - "column": 29, + "column": 30, "endLine": 28, - "endColumn": 37, - "problem": "NoDeprecatedApi", + "endColumn": 31, + "problem": "NumericSemantics", "suggest": "", - "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { "line": 32, - "column": 29, + "column": 14, "endLine": 32, - "endColumn": 37, - "problem": "NoDeprecatedApi", + "endColumn": 17, + "problem": "NumericSemantics", "suggest": "", - "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 36, - "column": 29, - "endLine": 36, - "endColumn": 37, - "problem": "NoDeprecatedApi", + "line": 32, + "column": 25, + "endLine": 32, + "endColumn": 28, + "problem": "NumericSemantics", "suggest": "", - "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 40, - "column": 29, - "endLine": 40, - "endColumn": 37, - "problem": "NoDeprecatedApi", + "line": 32, + "column": 47, + "endLine": 32, + "endColumn": 49, + "problem": "NumericSemantics", "suggest": "", - "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 43, - "column": 35, - "endLine": 43, - "endColumn": 36, + "line": 32, + "column": 56, + "endLine": 32, + "endColumn": 58, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 17, + "line": 18, "column": 2, - "endLine": 17, + "endLine": 18, "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", @@ -105,9 +105,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 19, "column": 2, - "endLine": 18, + "endLine": 19, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", @@ -115,83 +115,83 @@ "severity": "ERROR" }, { - "line": 20, - "column": 4, - "endLine": 20, - "endColumn": 9, + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { "line": 23, - "column": 5, + "column": 7, "endLine": 23, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"Flex\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 24, - "column": 7, - "endLine": 24, - "endColumn": 11, + "line": 23, + "column": 25, + "endLine": 23, + "endColumn": 38, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 25, - "column": 7, - "endLine": 25, - "endColumn": 10, + "line": 23, + "column": 39, + "endLine": 23, + "endColumn": 45, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 26, - "column": 9, - "endLine": 26, - "endColumn": 15, + "line": 23, + "column": 59, + "endLine": 23, + "endColumn": 68, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 30, + "line": 24, "column": 9, - "endLine": 30, - "endColumn": 15, + "endLine": 24, + "endColumn": 12, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 34, - "column": 9, - "endLine": 34, - "endColumn": 15, + "line": 25, + "column": 11, + "endLine": 25, + "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"Image\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 38, - "column": 9, - "endLine": 38, - "endColumn": 15, + "line": 25, + "column": 17, + "endLine": 25, + "endColumn": 19, "problem": "UIInterfaceImport", "suggest": "", - "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"$r\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.args.json b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d1068b2c6c902dc7da3ae85965b941d3d3f0aeea --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/lazy_for_each.ets.arkts2.json @@ -0,0 +1,298 @@ +{ + "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": 21, + "column": 12, + "endLine": 21, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 33, + "endLine": 25, + "endColumn": 38, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 44, + "endLine": 29, + "endColumn": 45, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 11, + "endLine": 36, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 16, + "endLine": 37, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 34, + "endLine": 39, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 27, + "endLine": 82, + "endColumn": 32, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 34, + "endLine": 86, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 48, + "endLine": 92, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 14, + "endLine": 102, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 18, + "endLine": 102, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 26, + "endLine": 102, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 19, + "endLine": 108, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 33, + "endLine": 112, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 28, + "endLine": 116, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 39, + "endLine": 116, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 119, + "column": 19, + "endLine": 119, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 34, + "endLine": 16, + "endColumn": 45, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"IDataSource\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 22, + "endLine": 17, + "endColumn": 40, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 40, + "endLine": 28, + "endColumn": 58, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 42, + "endLine": 35, + "endColumn": 60, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 2, + "endLine": 96, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 2, + "endLine": 97, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 5, + "endLine": 108, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 7, + "endLine": 109, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"LazyForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 11, + "endLine": 111, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 13, + "endLine": 112, + "endColumn": 17, + "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/deprecatedapi/measure.ets.args.json b/ets2panda/linter/test/deprecatedapi/measure.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/measure.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/measure.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/measure.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..a52ce66124292611d03e23134bd8d79db201d134 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/measure.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "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": 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": 21, + "column": 13, + "endLine": 21, + "endColumn": 24, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 4, + "endLine": 25, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 9, + "endLine": 33, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 9, + "endLine": 34, + "endColumn": 13, + "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/deprecatedapi/mediaquery.ets.args.json b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/mediaquery.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..da87e06462d7ba4ac3d6d827f41c71376652f0a7 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/mediaquery.ets.arkts2.json @@ -0,0 +1,128 @@ +{ + "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": 47, + "column": 32, + "endLine": 47, + "endColumn": 34, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 21, + "column": 4, + "endLine": 21, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" 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 \"Flex\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 23, + "endLine": 46, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexDirection\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 37, + "endLine": 46, + "endColumn": 43, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 57, + "endLine": 46, + "endColumn": 66, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 91, + "endLine": 46, + "endColumn": 100, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"FlexAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 7, + "endLine": 47, + "endColumn": 11, + "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/deprecatedapi/navigation.ets.args.json b/ets2panda/linter/test/deprecatedapi/navigation.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigation.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/navigation.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/navigation.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..3fe72f3f5a600ecead4a4dc985397f74e927b46e --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/navigation.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "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": 20, + "column": 21, + "endLine": 20, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 21, + "endLine": 26, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 20, + "endLine": 29, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 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": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 7, + "endLine": 21, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 9, + "endLine": 22, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Navigation\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.arkts2.json old mode 100755 new mode 100644 index 004254eb4c1ba743ae16e96dd7c64bd17f17405a..23bca9ca73b8c91083d1bdf04febefef58902c18 --- a/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/ohos_animator.ets.arkts2.json @@ -44,6 +44,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 30, + "column": 1, + "endLine": 30, + "endColumn": 31, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, { "line": 16, "column": 10, diff --git a/ets2panda/linter/test/deprecatedapi/refresh.ets.args.json b/ets2panda/linter/test/deprecatedapi/refresh.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/refresh.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/refresh.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/refresh.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..9a3dd460846c069c65f1b3e56256bb73acce6543 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/refresh.ets.arkts2.json @@ -0,0 +1,248 @@ +{ + "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": 26, + "column": 29, + "endLine": 26, + "endColumn": 48, + "problem": "DoubleDollarBindingNotSupported", + "suggest": "", + "rule": "\"$$\" for bidirectional data binding is not supported (arkui-no-$$-bidirectional-data-binding)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 58, + "endLine": 26, + "endColumn": 59, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 25, + "endLine": 32, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 27, + "endLine": 33, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 25, + "endLine": 34, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 31, + "endLine": 36, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 22, + "endLine": 51, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 12, + "endLine": 61, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 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": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 4, + "endLine": 21, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 7, + "endLine": 26, + "endColumn": 14, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Refresh\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 9, + "endLine": 27, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 13, + "endLine": 29, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 15, + "endLine": 30, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 28, + "endLine": 35, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 24, + "endLine": 46, + "endColumn": 37, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItemAlign\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 20, + "endLine": 47, + "endColumn": 28, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BarState\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 38, + "endLine": 52, + "endColumn": 51, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"RefreshStatus\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/slider_api.ets.args.json b/ets2panda/linter/test/deprecatedapi/slider_api.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/slider_api.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/slider_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/slider_api.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..811b3fa6edb311680f99de72c56efc371290d6cc --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/slider_api.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "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": 21, + "column": 21, + "endLine": 21, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 9, + "endLine": 23, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_input.ets.args.json b/ets2panda/linter/test/deprecatedapi/text_input.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_input.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_input.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/text_input.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..dd029d72759d079651eeae7e5aef81800af40361 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_input.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "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": 19, + "column": 41, + "endLine": 19, + "endColumn": 60, + "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": 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": 19, + "column": 15, + "endLine": 19, + "endColumn": 34, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextInputController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 41, + "endLine": 19, + "endColumn": 60, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextInputController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextInput\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_picker.ets.args.json b/ets2panda/linter/test/deprecatedapi/text_picker.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_picker.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/text_picker.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/text_picker.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..0579213c3c729ce6593b6816cc446f8cf5493058 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/text_picker.ets.arkts2.json @@ -0,0 +1,108 @@ +{ + "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": 19, + "column": 28, + "endLine": 19, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 17, + "endLine": 26, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 28, + "endLine": 34, + "endColumn": 39, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "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": 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": 24, + "column": 5, + "endLine": 24, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 7, + "endLine": 25, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextPickerDialog\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 7, + "endLine": 31, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"TextPicker\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/xcomponent.ets.args.json b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/xcomponent.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..0e998f08269e40119b64bda69f1b01fb3ee2f528 --- /dev/null +++ b/ets2panda/linter/test/deprecatedapi/xcomponent.ets.arkts2.json @@ -0,0 +1,148 @@ +{ + "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": 19, + "column": 52, + "endLine": 19, + "endColumn": 72, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 76, + "endLine": 28, + "endColumn": 80, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 95, + "endLine": 28, + "endColumn": 99, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 6, + "endLine": 32, + "endColumn": 14, + "problem": "SdkTypeQuery", + "suggest": "", + "rule": "Using typeof as a type is not allowed in this API (sdk-type-query)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 19, + "endLine": 32, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 25, + "endLine": 32, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "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": 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": 19, + "column": 25, + "endLine": 19, + "endColumn": 45, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponentController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 52, + "endLine": 19, + "endColumn": 72, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponentController\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 7, + "endLine": 22, + "endColumn": 17, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"XComponent\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 22, + "endLine": 31, + "endColumn": 27, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json index b66ee99fd1e2138ce303809ce29f899724b7fd03..950dead5c234a56c680131b73543475d20a7ba6c 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 53, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 656, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 53 - }, - { - "start": 656, - "end": 656, - "replacementText": "let foo = ESValue.load('./binary_operation_js_obj_js').getProperty('foo');\nlet m = ESValue.load('./binary_operation_js_obj_js').getProperty('m');\nlet n = ESValue.load('./binary_operation_js_obj_js').getProperty('n');", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 53 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets index b22867f793c806789f4c788301cdd18f0cffb154..5c4f835784d72e4a0bf720da6d48d176852e4ad1 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets @@ -12,9 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./binary_operation_js_obj_js').getProperty('foo'); -let m = ESValue.load('./binary_operation_js_obj_js').getProperty('m'); -let n = ESValue.load('./binary_operation_js_obj_js').getProperty('n'); +import {foo,m,n} from "./binary_operation_js_obj_js" let a = foo.getProperty("a") let b = foo.getProperty("b") a + b diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json index eba74eaf8742dbcfe30b877eb998a622f3a83a4a..0f7384dffa2b6c6d565e67310f0736f6dfa48252 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json @@ -16,19 +16,19 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 74, - "problem": "AnyType", + "endColumn": 53, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 16, "column": 5, "endLine": 16, - "endColumn": 70, + "endColumn": 29, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -38,26 +38,6 @@ "line": 17, "column": 5, "endLine": 17, - "endColumn": 70, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 29, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, "endColumn": 29, "problem": "AnyType", "suggest": "", @@ -65,9 +45,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 23, "column": 1, - "endLine": 25, + "endLine": 23, "endColumn": 15, "problem": "MathPow", "suggest": "", @@ -75,9 +55,9 @@ "severity": "ERROR" }, { - "line": 29, + "line": 27, "column": 1, - "endLine": 29, + "endLine": 27, "endColumn": 37, "problem": "MathPow", "suggest": "", @@ -85,9 +65,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 33, "column": 1, - "endLine": 35, + "endLine": 33, "endColumn": 15, "problem": "MathPow", "suggest": "", @@ -95,9 +75,9 @@ "severity": "ERROR" }, { - "line": 47, + "line": 45, "column": 1, - "endLine": 47, + "endLine": 45, "endColumn": 17, "problem": "MathPow", "suggest": "", diff --git a/ets2panda/linter/test/interop/call_function.ets.autofix.json b/ets2panda/linter/test/interop/call_function.ets.autofix.json index b1910efb3d5a91a376022ee75a391ec36a5cae32..206be26dd22cf08430da8f0425958201401b8c50 100644 --- a/ets2panda/linter/test/interop/call_function.ets.autofix.json +++ b/ets2panda/linter/test/interop/call_function.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 43, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 646, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 43 - }, - { - "start": 646, - "end": 646, - "replacementText": "let foo = ESValue.load('./call_function_js').getProperty('foo');\nlet bar = ESValue.load('./call_function_js').getProperty('bar');", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 43 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -50,26 +30,6 @@ "endLine": 16, "endColumn": 39, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 647, - "end": 685, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 39 - }, - { - "start": 685, - "end": 685, - "replacementText": "let a = ESValue.load('./call_function_js').getProperty('a');\nlet b = ESValue.load('./call_function_js').getProperty('b');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 39 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/call_function.ets.migrate.ets b/ets2panda/linter/test/interop/call_function.ets.migrate.ets index dfacfa530a2a15d81bfb991440298883f59da1ba..488924d012ea7a6c533ed9be6340ea7676f57123 100644 --- a/ets2panda/linter/test/interop/call_function.ets.migrate.ets +++ b/ets2panda/linter/test/interop/call_function.ets.migrate.ets @@ -12,10 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./call_function_js').getProperty('foo'); -let bar = ESValue.load('./call_function_js').getProperty('bar'); -let a = ESValue.load('./call_function_js').getProperty('a'); -let b = ESValue.load('./call_function_js').getProperty('b'); +import {foo,bar} from "./call_function_js" +import {a,b} from "./call_function_js" foo.invoke() bar.invoke(ESValue.wrap(123.0)) diff --git a/ets2panda/linter/test/interop/call_function.ets.migrate.json b/ets2panda/linter/test/interop/call_function.ets.migrate.json index 2ca11b5859e69c41117613fd5c92d56af705b129..c9ca5e0d96fd9c8b231049bc0b25fc487020c4e1 100644 --- a/ets2panda/linter/test/interop/call_function.ets.migrate.json +++ b/ets2panda/linter/test/interop/call_function.ets.migrate.json @@ -16,42 +16,22 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 64, - "problem": "AnyType", + "endColumn": 43, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 64, - "problem": "AnyType", + "endColumn": 39, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 60, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 60, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json b/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json index 00cdf6a59e5ec307ff6745fc7a892f1468ce27c7..afc8eb134a088f606ce6dcbacd6b0be75281bac7 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 47, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 650, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 47 - }, - { - "start": 650, - "end": 650, - "replacementText": "let foo = ESValue.load('./call_object_methods_js').getProperty('foo');", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 47 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets index c92ae9f532301f757cb685d7d746ea3f91203579..d18b4715365f3f292433fc55b19e04d98c724535 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets +++ b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./call_object_methods_js').getProperty('foo'); +import { foo } from "./call_object_methods_js" foo.invokeMethod("bar", ESValue.wrap(123.0)) diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json index 149a43f6f592beed295eb162f2eb5adb2f8c0e1c..94a7c680a7bed414b3aac1b4c0da3972817f96d1 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json @@ -16,12 +16,12 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 47, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json index 465ba2da807da1e35435da6a6f7b6a33016d2af3..e9af2d47b12258b4f93b91f9aae002c4d6acbca4 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 52, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 655, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 52 - }, - { - "start": 655, - "end": 655, - "replacementText": "let foo = ESValue.load('./increases_decreases_js_obj_js').getProperty('foo');", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 52 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -402,4 +382,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets index 1cd740b7b56eff7959389116baf2e35e3b15c86c..cde3dfacf9603ad8b8b0311c8fa27026fa5e7616 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./increases_decreases_js_obj_js').getProperty('foo'); +import {foo} from "./increases_decreases_js_obj_js" let a: number =0.0 a = foo.getProperty("num").toNumber() foo.setProperty(num, a + 1.0) diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json index f9906637d18ef0f43d5e7e4e13cef33aad5184fe..c1eebeb25c56ef572edb41bc0480ef0fb51e8bab 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json @@ -16,12 +16,12 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 77, - "problem": "AnyType", + "endColumn": 52, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { @@ -65,4 +65,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json index d00f4ee0da5ca1764dd8f2f81533ce6f14c0af62..a0da97f1f6ab56d0e9be78800c3a59ed8d78d18c 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 655, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 51 - }, - { - "start": 655, - "end": 655, - "replacementText": "let Foo = ESValue.load('./instantiated_js_obj_js').getProperty('Foo');\nlet Foo1 = ESValue.load('./instantiated_js_obj_js').getProperty('Foo1');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets index 5ad9c490c7a58acadc8886b9f09523ed64f8e8ad..c41c16e387b95fdbf4bf38b976b4b7a0e0aece46 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets @@ -13,8 +13,7 @@ * limitations under the License. */ -let Foo = ESValue.load('./instantiated_js_obj_js').getProperty('Foo'); -let Foo1 = ESValue.load('./instantiated_js_obj_js').getProperty('Foo1'); +import {Foo, Foo1} from "./instantiated_js_obj_js" class A { num: number = 1.0; constructor() { diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json index a1be17f7a40899eb98b78b56687678a26cf3b3fd..8ae4b51b2e860913274a052ebd930922bdafa5cc 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json @@ -16,22 +16,12 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 51, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json index 8f8b73e3cdbb7c0e0f2a2cfd2c00ea33fe9881d9..e90ddfedb1e2b6569ca3a200c81a31019f672661 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json @@ -30,26 +30,6 @@ "endLine": 17, "endColumn": 106, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 636, - "end": 740, - "replacementText": "", - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 106 - }, - { - "start": 740, - "end": 740, - "replacementText": "let foo = ESValue.load('./interop_convert_import_js.js').getProperty('foo');\r\nlet foo2 = ESValue.load('./interop_convert_import_js.js').getProperty('foo2');\r\nlet foo3 = ESValue.load('./interop_convert_import_js.js').getProperty('foo3');\r\nlet foo4 = ESValue.load('./interop_convert_import_js.js').getProperty('foo4');\r\nlet array_val = ESValue.load('./interop_convert_import_js.js').getProperty('array_val');\r\nlet null_val = ESValue.load('./interop_convert_import_js.js').getProperty('null_val');\r\nlet undefined_val = ESValue.load('./interop_convert_import_js.js').getProperty('undefined_val');", - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 106 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets index 2b727d66126cbe57d0abd8e2b63ea341b63ab076..a04503ccc23347821ab0beb697e7db0205ad8ada 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets @@ -14,13 +14,7 @@ */ 'use static' - let foo = ESValue.load('./interop_convert_import_js.js').getProperty('foo'); -let foo2 = ESValue.load('./interop_convert_import_js.js').getProperty('foo2'); -let foo3 = ESValue.load('./interop_convert_import_js.js').getProperty('foo3'); -let foo4 = ESValue.load('./interop_convert_import_js.js').getProperty('foo4'); -let array_val = ESValue.load('./interop_convert_import_js.js').getProperty('array_val'); -let null_val = ESValue.load('./interop_convert_import_js.js').getProperty('null_val'); -let undefined_val = ESValue.load('./interop_convert_import_js.js').getProperty('undefined_val'); + import {foo, foo2, foo3, foo4, array_val, null_val, undefined_val} from "./interop_convert_import_js.js" let a: number = foo.getProperty("num").toNumber() let a1: boolean = foo2.getProperty("bool").toBoolean() diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json index 169c0b6ce01c22d2aac5a7fd59241d93a5b78c79..477162ca035537626a2cdf2e2a5e633a98b9b8ba 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json @@ -16,89 +16,69 @@ "result": [ { "line": 17, - "column": 6, + "column": 2, "endLine": 17, - "endColumn": 77, - "problem": "AnyType", + "endColumn": 106, + "problem": "ImportAfterStatement", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", "severity": "ERROR" }, { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 78, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 78, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 78, - "problem": "AnyType", + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 106, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 88, - "problem": "AnyType", + "line": 25, + "column": 9, + "endLine": 25, + "endColumn": 27, + "problem": "InterOpConvertImport", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, { - "line": 22, - "column": 5, - "endLine": 22, - "endColumn": 86, - "problem": "AnyType", + "line": 25, + "column": 44, + "endLine": 25, + "endColumn": 68, + "problem": "GenericCallNoTypeArgs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, { - "line": 23, - "column": 5, - "endLine": 23, - "endColumn": 96, - "problem": "AnyType", + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 30, + "problem": "InterOpConvertImport", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, { - "line": 31, - "column": 44, - "endLine": 31, - "endColumn": 68, - "problem": "GenericCallNoTypeArgs", + "line": 35, + "column": 8, + "endLine": 35, + "endColumn": 24, + "problem": "InterOpConvertImport", "suggest": "", - "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, { - "line": 41, + "line": 40, "column": 8, - "endLine": 41, - "endColumn": 24, + "endLine": 40, + "endColumn": 34, "problem": "InterOpConvertImport", "suggest": "", "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json index 3203f645acdc0de2bb729cf49897e7bb51653af4..73d6eea5c8064980fd5c71ce5995ccb80999269c 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json @@ -14,32 +14,12 @@ "limitations under the License." ], "result": [ - { + { "line": 16, "column": 1, "endLine": 16, "endColumn": 58, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 662, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 58 - }, - { - "start": 662, - "end": 662, - "replacementText": "let a = ESValue.load('./interop_equality_judgment_js').getProperty('a');\nlet b = ESValue.load('./interop_equality_judgment_js').getProperty('b');\nlet c = ESValue.load('./interop_equality_judgment_js').getProperty('c');\nlet d = ESValue.load('./interop_equality_judgment_js').getProperty('d');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 58 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -380,5 +360,5 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" } - ] -} + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets index 97c56d0dda0f930edb5db48d1f6fd0b9810fae45..f0bdc4e3ea0e54767723b86fac1a5582629d621b 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets @@ -13,10 +13,7 @@ * limitations under the License. */ -let a = ESValue.load('./interop_equality_judgment_js').getProperty('a'); -let b = ESValue.load('./interop_equality_judgment_js').getProperty('b'); -let c = ESValue.load('./interop_equality_judgment_js').getProperty('c'); -let d = ESValue.load('./interop_equality_judgment_js').getProperty('d'); +import {a, b, c, d} from "./interop_equality_judgment_js" a.areEqual(b) !a.areEqual(b) a.areStrictlyEqual(b) diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json index 165b58c9e802e1c4e81e049eee1043ed8a65cff9..1f0874db0ddfe681b007ec3fd09c2c1d15cab099 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json @@ -13,46 +13,56 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 16, - "column": 5, - "endLine": 16, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - } - ] -} + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 58, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 12, + "endLine": 17, + "endColumn": 13, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 13, + "endLine": 18, + "endColumn": 14, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 20, + "endLine": 19, + "endColumn": 21, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 22, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json index 968a9c014ed5b655e79bef8a1209714677507427..f8dbfb7b6c507c635f7e41fd8c93a7b1ee20432a 100755 --- a/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 38, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 606, - "end": 643, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 38 - }, - { - "start": 643, - "end": 643, - "replacementText": "let Cjs = ESValue.load('../main/js_lib').getProperty('Cjs');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 38 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -50,26 +30,6 @@ "endLine": 17, "endColumn": 38, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 644, - "end": 681, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 38 - }, - { - "start": 681, - "end": 681, - "replacementText": "let fjs = ESValue.load('../main/js_lib').getProperty('fjs');", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 38 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -80,26 +40,6 @@ "endLine": 18, "endColumn": 64, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 682, - "end": 745, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 64 - }, - { - "start": 745, - "end": 745, - "replacementText": "let CPreview = ESValue.load('./jsfiles/preview_import_js').getProperty('CPreview');\nlet bar = ESValue.load('./jsfiles/preview_import_js').getProperty('bar');\nlet foo = ESValue.load('./jsfiles/preview_import_js').getProperty('foo');", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 64 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -110,26 +50,6 @@ "endLine": 19, "endColumn": 44, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 746, - "end": 789, - "replacementText": "", - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 44 - }, - { - "start": 789, - "end": 789, - "replacementText": "let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa');", - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 44 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -140,26 +60,6 @@ "endLine": 20, "endColumn": 57, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 790, - "end": 846, - "replacementText": "", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 57 - }, - { - "start": 846, - "end": 846, - "replacementText": "let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa');\nlet ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA');\nlet Dog = ESValue.load('./interop_import_js_js').getProperty('Dog');", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 57 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -170,26 +70,6 @@ "endLine": 21, "endColumn": 47, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 847, - "end": 893, - "replacementText": "", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 47 - }, - { - "start": 893, - "end": 893, - "replacementText": "let tjs = ESValue.load('./interop_import_js_js').getProperty('tjs');", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 47 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -200,26 +80,6 @@ "endLine": 22, "endColumn": 59, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 894, - "end": 952, - "replacementText": "", - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 59 - }, - { - "start": 952, - "end": 952, - "replacementText": "let Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki');\nlet Doge = ESValue.load('./interop_import_js_js').getProperty('Dog');", - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 59 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets index 8a7215433eb02d96fc996ea94e32321d41b25965..a4c0b8fea69eeb2c1cb904f44aac79c764e47804 100644 --- a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets @@ -13,15 +13,10 @@ * limitations under the License. */ -let Cjs = ESValue.load('../main/js_lib').getProperty('Cjs'); -let fjs = ESValue.load('../main/js_lib').getProperty('fjs'); -let CPreview = ESValue.load('./jsfiles/preview_import_js').getProperty('CPreview'); -let bar = ESValue.load('./jsfiles/preview_import_js').getProperty('bar'); -let foo = ESValue.load('./jsfiles/preview_import_js').getProperty('foo'); -let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa'); -let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa'); -let ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA'); -let Dog = ESValue.load('./interop_import_js_js').getProperty('Dog'); -let tjs = ESValue.load('./interop_import_js_js').getProperty('tjs'); -let Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki'); -let Doge = ESValue.load('./interop_import_js_js').getProperty('Dog'); \ No newline at end of file +import { Cjs } from '../main/js_lib'; +import { fjs } from '../main/js_lib'; +import { CPreview,bar,foo } from "./jsfiles/preview_import_js"; +import myAaa from "./interop_import_js_js"; +import myAaa,{ClassA,Dog} from "./interop_import_js_js"; +import * as tjs from "./interop_import_js_js"; +import { Wiki, Dog as Doge } from './interop_import_js_js' \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json index d20b189b4f292fa53920f6579a542b3f8c2651aa..f8dbfb7b6c507c635f7e41fd8c93a7b1ee20432a 100644 --- a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json @@ -16,122 +16,72 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 60, - "problem": "AnyType", + "endColumn": 38, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 17, - "column": 5, + "column": 1, "endLine": 17, - "endColumn": 60, - "problem": "AnyType", + "endColumn": 38, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 18, - "column": 5, + "column": 1, "endLine": 18, - "endColumn": 83, - "problem": "AnyType", + "endColumn": 64, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 19, - "column": 5, + "column": 1, "endLine": 19, - "endColumn": 73, - "problem": "AnyType", + "endColumn": 44, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 20, - "column": 5, + "column": 1, "endLine": 20, - "endColumn": 73, - "problem": "AnyType", + "endColumn": 57, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 21, - "column": 5, + "column": 1, "endLine": 21, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 47, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 22, - "column": 5, + "column": 1, "endLine": 22, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 59, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 5, - "endLine": 23, - "endColumn": 74, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 5, - "endLine": 24, - "endColumn": 68, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 5, - "endLine": 25, - "endColumn": 68, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 5, - "endLine": 26, - "endColumn": 70, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 5, - "endLine": 27, - "endColumn": 69, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json index d54c3071e70236a7f8a86ae847bce7285d7d6636..5c02835f89f300921d0236a6432c6b48207cf51b 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 17, "endColumn": 57, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 607, - "end": 663, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 57 - }, - { - "start": 663, - "end": 663, - "replacementText": "let foo = ESValue.load('./interop_import_js_compare_js').getProperty('foo');\nlet m = ESValue.load('./interop_import_js_compare_js').getProperty('m');\nlet n = ESValue.load('./interop_import_js_compare_js').getProperty('n');", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 57 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets index e9bab633c586092ecb5e0e4e11d6a1e4cefe7ff9..51e820d9092d3e093223e832564114cfdb140f9f 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets @@ -14,9 +14,7 @@ */ -let foo = ESValue.load('./interop_import_js_compare_js').getProperty('foo'); -let m = ESValue.load('./interop_import_js_compare_js').getProperty('m'); -let n = ESValue.load('./interop_import_js_compare_js').getProperty('n'); +import {foo, m, n} from "./interop_import_js_compare_js" let a = foo.getProperty("a") let b = foo.getProperty("b") a > b diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json index 69216fdae77b5bc16727b2286af5d86722cf4e9e..27f3d3c0d454d71d6ad5c5d374f723aa58558f6b 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json @@ -16,19 +16,19 @@ "result": [ { "line": 17, - "column": 5, + "column": 1, "endLine": 17, - "endColumn": 76, - "problem": "AnyType", + "endColumn": 57, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 18, "column": 5, "endLine": 18, - "endColumn": 72, + "endColumn": 29, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -38,26 +38,6 @@ "line": 19, "column": 5, "endLine": 19, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 29, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 5, - "endLine": 21, "endColumn": 29, "problem": "AnyType", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json index f837b56a6af8c56a76cbff4a72278f1cfa20851f..7467f08a68d90b50ad957c56000c7aae7be57a42 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 654, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - }, - { - "start": 654, - "end": 654, - "replacementText": "let ff3 = ESValue.load('./interop_import_js_rules_js').getProperty('ff3');", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -50,26 +30,6 @@ "endLine": 16, "endColumn": 49, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 655, - "end": 703, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 49 - }, - { - "start": 703, - "end": 703, - "replacementText": "let foo = ESValue.load('./interop_import_js_index_js').getProperty('foo');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 49 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets index 60b5b30251ea5240c208b64bac57a2d6bffd5ed3..11371d2a4f49baf5a939dd632fed067c61dbbf43 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let ff3 = ESValue.load('./interop_import_js_rules_js').getProperty('ff3'); -let foo = ESValue.load('./interop_import_js_index_js').getProperty('foo'); +import { ff3 } from "./interop_import_js_rules_js" +import {foo} from "./interop_import_js_index_js" let arr = foo.getProperty("arr") arr.getProperty(1.0) arr.setProperty(3.0, ESValue.wrap(4.0)) diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json index 191b2c2b9ec307fab46144da63bef106269577e4..bc5a9efda1c70321cd41c703b92a3ef695e946bd 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json @@ -16,22 +16,22 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 74, - "problem": "AnyType", + "endColumn": 51, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 74, - "problem": "AnyType", + "endColumn": 49, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { @@ -65,4 +65,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json index 702bfa960162802ac8bdef528ddf783aa0079d7d..4fb8162057de9a0e0273f80d9e0c6b97b87758b3 100644 --- a/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json @@ -30,26 +30,6 @@ "endLine": 17, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 619, - "end": 669, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51 - }, - { - "start": 669, - "end": 669, - "replacementText": "let foo = ESValue.load('./interop_import_js_rules_js').getProperty('foo');", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -70,26 +50,6 @@ "endLine": 18, "endColumn": 56, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 670, - "end": 725, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56 - }, - { - "start": 725, - "end": 725, - "replacementText": "let ff1 = ESValue.load('./interop_import_js_rules_js').getProperty('ff1');\nlet ff2 = ESValue.load('./interop_import_js_rules_js').getProperty('ff2');", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -110,26 +70,6 @@ "endLine": 20, "endColumn": 49, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 727, - "end": 775, - "replacementText": "", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49 - }, - { - "start": 775, - "end": 775, - "replacementText": "let A = ESValue.load('./interop_import_js_rules_js').getProperty('A');", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -150,26 +90,6 @@ "endLine": 21, "endColumn": 49, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 776, - "end": 824, - "replacementText": "", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49 - }, - { - "start": 824, - "end": 824, - "replacementText": "let C = ESValue.load('./interop_import_js_rules_js').getProperty('C');", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -190,26 +110,6 @@ "endLine": 23, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 826, - "end": 876, - "replacementText": "", - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51 - }, - { - "start": 876, - "end": 876, - "replacementText": "let ff3 = ESValue.load('./interop_import_js_rules_js').getProperty('ff3');", - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -230,26 +130,6 @@ "endLine": 25, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 878, - "end": 928, - "replacementText": "", - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51 - }, - { - "start": 928, - "end": 928, - "replacementText": "let ff4 = ESValue.load('./interop_import_js_rules_js').getProperty('ff4');", - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -270,26 +150,6 @@ "endLine": 27, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 930, - "end": 983, - "replacementText": "", - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54 - }, - { - "start": 983, - "end": 983, - "replacementText": "let handle = ESValue.load('./interop_import_js_rules_js').getProperty('handle');", - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -310,26 +170,6 @@ "endLine": 29, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 985, - "end": 1038, - "replacementText": "", - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54 - }, - { - "start": 1038, - "end": 1038, - "replacementText": "let expand = ESValue.load('./interop_import_js_rules_js').getProperty('expand');", - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -350,26 +190,6 @@ "endLine": 30, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 1039, - "end": 1092, - "replacementText": "", - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54 - }, - { - "start": 1092, - "end": 1092, - "replacementText": "let orange = ESValue.load('./interop_import_js_rules_js').getProperty('orange');", - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json index 616283816bbf0bb6f611360a8277ff27d8543a91..d6958993db88cdda9b601cc2e835179fcfc763f6 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 69, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 606, - "end": 674, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 69 - }, - { - "start": 674, - "end": 674, - "replacementText": "let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa');\nlet ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA');\nlet Dog = ESValue.load('./interop_import_js_js').getProperty('Dog');\nlet Person = ESValue.load('./interop_import_js_js').getProperty('Person');\nlet Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 69 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -50,26 +30,6 @@ "endLine": 17, "endColumn": 54, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 675, - "end": 728, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 54 - }, - { - "start": 728, - "end": 728, - "replacementText": "let Doge = ESValue.load('./interop_import_js_js').getProperty('Dog');", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 54 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -80,26 +40,6 @@ "endLine": 18, "endColumn": 55, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 729, - "end": 783, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 55 - }, - { - "start": 783, - "end": 783, - "replacementText": "let wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki');", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 55 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets index e50da4c9173f7bfd0f2eed73da25c765aa50da14..59105c01fa7da01ef0d7bdf25e9cdbcbfc26ab63 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets @@ -13,13 +13,9 @@ * limitations under the License. */ -let myAaa = ESValue.load('./interop_import_js_js').getProperty('aaa'); -let ClassA = ESValue.load('./interop_import_js_js').getProperty('ClassA'); -let Dog = ESValue.load('./interop_import_js_js').getProperty('Dog'); -let Person = ESValue.load('./interop_import_js_js').getProperty('Person'); -let Wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki'); -let Doge = ESValue.load('./interop_import_js_js').getProperty('Dog'); -let wiki = ESValue.load('./interop_import_js_js').getProperty('Wiki'); +import myAaa,{ClassA,Dog,Person,Wiki} from "./interop_import_js_js"; +import { Dog as Doge } from './interop_import_js_js'; +import { Wiki as wiki } from './interop_import_js_js'; myAaa.invoke().typeOf(); //error let fun = myAaa.invoke(); diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json index 5c235089d9987874d5bcaceb721be697c9149d90..b0154468d307ea51471633e2abd2216c3399b3dd 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json @@ -16,118 +16,98 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 69, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 17, - "column": 5, + "column": 1, "endLine": 17, - "endColumn": 74, - "problem": "AnyType", + "endColumn": 54, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 18, - "column": 5, + "column": 1, "endLine": 18, - "endColumn": 68, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 74, - "problem": "AnyType", + "endColumn": 55, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 70, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 21, "column": 5, "endLine": 21, - "endColumn": 69, + "endColumn": 25, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 22, + "line": 29, "column": 5, - "endLine": 22, - "endColumn": 70, + "endLine": 29, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 25, + "line": 35, "column": 5, - "endLine": 25, - "endColumn": 25, + "endLine": 35, + "endColumn": 37, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 33, + "line": 36, "column": 5, - "endLine": 33, - "endColumn": 35, + "endLine": 36, + "endColumn": 42, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 39, - "column": 5, - "endLine": 39, - "endColumn": 37, - "problem": "AnyType", + "line": 42, + "column": 10, + "endLine": 42, + "endColumn": 30, + "problem": "LimitedVoidType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, { - "line": 40, - "column": 5, - "endLine": 40, - "endColumn": 42, - "problem": "AnyType", + "line": 47, + "column": 21, + "endLine": 47, + "endColumn": 41, + "problem": "LimitedVoidType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, { - "line": 53, + "line": 49, "column": 7, - "endLine": 53, + "endLine": 49, "endColumn": 13, "problem": "InvalidIdentifier", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json index 3947650ebf6cea8ecc00ecee25461b05543d600b..66925f8b56c90b9336082f29d62d500a01d2bfd9 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json @@ -30,26 +30,6 @@ "endLine": 17, "endColumn": 106, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 618, - "end": 723, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 106 - }, - { - "start": 723, - "end": 723, - "replacementText": "let foo = ESValue.load('./interop_not_have_property_js').getProperty('foo');\nlet person = ESValue.load('./interop_not_have_property_js').getProperty('person');\nlet TestHelper = ESValue.load('./interop_not_have_property_js').getProperty('TestHelper');\nlet Machine = ESValue.load('./interop_not_have_property_js').getProperty('Machine');\nlet User = ESValue.load('./interop_not_have_property_js').getProperty('User');\nlet Person = ESValue.load('./interop_not_have_property_js').getProperty('Person');\nlet Employee = ESValue.load('./interop_not_have_property_js').getProperty('Employee');", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 106 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -1031,4 +1011,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets index 6320fe717df369223c3167f10f2ccae5a26d767d..f289defb389042127ad4212664ce9509ee694de9 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets @@ -14,13 +14,7 @@ */ 'use static' -let foo = ESValue.load('./interop_not_have_property_js').getProperty('foo'); -let person = ESValue.load('./interop_not_have_property_js').getProperty('person'); -let TestHelper = ESValue.load('./interop_not_have_property_js').getProperty('TestHelper'); -let Machine = ESValue.load('./interop_not_have_property_js').getProperty('Machine'); -let User = ESValue.load('./interop_not_have_property_js').getProperty('User'); -let Person = ESValue.load('./interop_not_have_property_js').getProperty('Person'); -let Employee = ESValue.load('./interop_not_have_property_js').getProperty('Employee'); +import { foo, person, TestHelper, Machine, User, Person, Employee } from "./interop_not_have_property_js" foo.getProperty("name") foo.setProperty("name", ESValue.wrap("456")) @@ -34,36 +28,36 @@ a.setProperty("age", ESValue.wrap(12.0)) let test_helper = TestHelper.instantiate(ESValue.wrap("TEST_INSTANTIATE_JS_OBJECT")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let machine = new Machine(); - return machine.name === "machine"; // arkts-interop-js2s-access-js-prop + let machine = Machine.instantiate(); + return machine.getProperty("name").areStrictlyEqual("machine"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("machine.name === 'machine'")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let user = new User("Bob"); - return user.id === "Bob"; // arkts-interop-js2s-access-js-prop + let user = User.instantiate(ESValue.wrap("Bob")); + return user.getProperty("id").areStrictlyEqual("Bob"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === 'Bob'")); test_helper.invokeMethod("test", ESValue.wrap(() => { -let user = new User(10.0); -return user.id === 10.0;// arkts-interop-js2s-access-js-prop +let user = User.instantiate(ESValue.wrap(10.0)); +return user.getProperty("id").areStrictlyEqual(10.0);// arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === 10")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let user = new User(123n); - return user.id === 123n; // arkts-interop-js2s-access-js-prop + let user = User.instantiate(ESValue.wrap(123n)); + return user.getProperty("id").areStrictlyEqual(123n); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === 123n")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let user = new User(true); - return user.id === true;// arkts-interop-js2s-access-js-prop + let user = User.instantiate(ESValue.wrap(true)); + return user.getProperty("id").areStrictlyEqual(true);// arkts-interop-js2s-access-js-prop }), ESValue.wrap("user.id === true")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let machine = new Person("John", 10.0); - return machine.name === "machine"; // arkts-interop-js2s-access-js-prop + let machine = Person.instantiate(ESValue.wrap("John"), ESValue.wrap(10.0)); + return machine.getProperty("name").areStrictlyEqual("machine"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("machine.name === 'machine'")); test_helper.invokeMethod("test", ESValue.wrap(() => { - let employee = new Employee(); - return employee.name === "employee"; // arkts-interop-js2s-access-js-prop + let employee = Employee.instantiate(); + return employee.getProperty("name").areStrictlyEqual("employee"); // arkts-interop-js2s-access-js-prop }), ESValue.wrap("employee.name === 'employee'")); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json index 02a85bc4f7389ef43420da02e57155643a3600ec..65c441a16bebab818412e967fc266a3ca72cc2e6 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json @@ -16,233 +16,183 @@ "result": [ { "line": 17, - "column": 5, + "column": 1, "endLine": 17, - "endColumn": 76, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 82, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 90, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 84, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 78, - "problem": "AnyType", + "endColumn": 106, + "problem": "ImportAfterStatement", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", "severity": "ERROR" }, { - "line": 22, - "column": 5, - "endLine": 22, - "endColumn": 82, - "problem": "AnyType", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 106, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 23, + "line": 26, "column": 5, - "endLine": 23, - "endColumn": 86, + "endLine": 26, + "endColumn": 26, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 32, + "line": 29, "column": 5, - "endLine": 32, - "endColumn": 26, + "endLine": 29, + "endColumn": 85, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 35, - "column": 5, - "endLine": 35, - "endColumn": 85, - "problem": "AnyType", + "line": 30, + "column": 47, + "endLine": 33, + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 37, + "line": 31, "column": 9, - "endLine": 37, - "endColumn": 32, + "endLine": 31, + "endColumn": 40, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 37, - "column": 23, - "endLine": 37, - "endColumn": 30, - "problem": "DynamicCtorCall", + "line": 35, + "column": 47, + "endLine": 38, + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 42, + "line": 36, "column": 9, - "endLine": 42, - "endColumn": 31, + "endLine": 36, + "endColumn": 53, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 42, - "column": 20, - "endLine": 42, - "endColumn": 24, - "problem": "DynamicCtorCall", + "line": 40, + "column": 47, + "endLine": 43, + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 47, + "line": 41, "column": 5, - "endLine": 47, - "endColumn": 26, + "endLine": 41, + "endColumn": 48, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 47, - "column": 16, - "endLine": 47, - "endColumn": 20, - "problem": "DynamicCtorCall", + "line": 45, + "column": 47, + "endLine": 48, + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 52, + "line": 46, "column": 9, - "endLine": 52, - "endColumn": 30, + "endLine": 46, + "endColumn": 52, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 52, - "column": 20, - "endLine": 52, - "endColumn": 24, - "problem": "DynamicCtorCall", + "line": 50, + "column": 47, + "endLine": 53, + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 57, + "line": 51, "column": 9, - "endLine": 57, - "endColumn": 30, + "endLine": 51, + "endColumn": 52, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 57, - "column": 20, - "endLine": 57, - "endColumn": 24, - "problem": "DynamicCtorCall", + "line": 55, + "column": 47, + "endLine": 58, + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 62, + "line": 56, "column": 9, - "endLine": 62, - "endColumn": 43, + "endLine": 56, + "endColumn": 79, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 62, - "column": 23, - "endLine": 62, - "endColumn": 29, - "problem": "DynamicCtorCall", + "line": 60, + "column": 47, + "endLine": 63, + "endColumn": 2, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, { - "line": 67, + "line": 61, "column": 9, - "endLine": 67, - "endColumn": 34, + "endLine": 61, + "endColumn": 42, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" - }, - { - "line": 67, - "column": 24, - "endLine": 67, - "endColumn": 32, - "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/interop/interop_not_have_property_num_arkts2.ets.autofix.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json index 25cdadbfd4c2e3743b117d209932ef636e18c2c3..5a00e93e85d4b302625e82ef5b3bfe8a8e648fe2 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 46, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 650, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 46 - }, - { - "start": 650, - "end": 650, - "replacementText": "let foo = ESValue.load('./interop_property_num_js').getProperty('foo');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 46 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets index 90055be46b6d01d93842863a922186d8022e2efa..397d49f4e68017f85604eb52118a48973d74f8f1 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -let foo = ESValue.load('./interop_property_num_js').getProperty('foo'); +import {foo} from "./interop_property_num_js" +foo.getProperty("num").toNumber(); -foo.getProperty("num").toNumber(); diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json index 8e9afac340f76cb36ff554e32f871a46d7f06406..923652a6ed843e53643967940e9a49e35e5e2616 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json @@ -16,12 +16,12 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 71, - "problem": "AnyType", + "endColumn": 46, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json index 84a00a559c9d9f6d6f93195bd855662ab88891d1..10055bdbb3c857fb01df06afa1e8b1b764f15480 100644 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 89, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 693, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 89 - }, - { - "start": 693, - "end": 693, - "replacementText": "let p = ESValue.load('./no_await_js_promise_export').getProperty('p');\nlet foo = ESValue.load('./no_await_js_promise_export').getProperty('foo');\nlet pFuncCall = ESValue.load('./no_await_js_promise_export').getProperty('pFuncCall');\nlet arrowFunc = ESValue.load('./no_await_js_promise_export').getProperty('arrowFunc');\nlet pArrowCall = ESValue.load('./no_await_js_promise_export').getProperty('pArrowCall');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 89 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets index 4454b4727ac15368882bf9900140174ed1ed5c8e..63fd6e25e811a3538b264edb96e5d30366412a2c 100644 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets @@ -13,11 +13,7 @@ * limitations under the License. */ -let p = ESValue.load('./no_await_js_promise_export').getProperty('p'); -let foo = ESValue.load('./no_await_js_promise_export').getProperty('foo'); -let pFuncCall = ESValue.load('./no_await_js_promise_export').getProperty('pFuncCall'); -let arrowFunc = ESValue.load('./no_await_js_promise_export').getProperty('arrowFunc'); -let pArrowCall = ESValue.load('./no_await_js_promise_export').getProperty('pArrowCall'); +import { p, foo, pFuncCall, arrowFunc, pArrowCall } from "./no_await_js_promise_export"; async function awaitPromise() { return await p.toPromise(); @@ -60,7 +56,7 @@ const exampleObj = { }; (async () => { - console.log("IIFE result:", await p); + console.log("IIFE result:", await p.toPromise()); })(); (async () => { diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json index 908d63c7c2200bdaaad08d4e0b3920a051552bf1..e83601dd74cdf19e93132d4109945addda867301 100644 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json @@ -16,58 +16,18 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 70, - "problem": "AnyType", + "endColumn": 89, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 74, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 86, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 86, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 88, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 22, "column": 16, - "endLine": 22, + "endLine": 18, "endColumn": 28, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -75,9 +35,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 22, "column": 16, - "endLine": 26, + "endLine": 22, "endColumn": 33, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -85,9 +45,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 26, "column": 16, - "endLine": 30, + "endLine": 26, "endColumn": 31, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -98,16 +58,6 @@ "line": 34, "column": 16, "endLine": 34, - "endColumn": 30, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, - { - "line": 38, - "column": 16, - "endLine": 38, "endColumn": 32, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -115,9 +65,9 @@ "severity": "ERROR" }, { - "line": 43, + "line": 39, "column": 9, - "endLine": 43, + "endLine": 39, "endColumn": 20, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -125,9 +75,9 @@ "severity": "ERROR" }, { - "line": 47, + "line": 43, "column": 13, - "endLine": 49, + "endLine": 45, "endColumn": 4, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -135,9 +85,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 48, "column": 20, - "endLine": 52, + "endLine": 48, "endColumn": 21, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -145,9 +95,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 49, "column": 3, - "endLine": 55, + "endLine": 51, "endColumn": 4, "problem": "ObjectLiteralProperty", "suggest": "", @@ -155,9 +105,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 49, "column": 9, - "endLine": 53, + "endLine": 49, "endColumn": 18, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -165,9 +115,9 @@ "severity": "ERROR" }, { - "line": 57, + "line": 53, "column": 17, - "endLine": 59, + "endLine": 55, "endColumn": 4, "problem": "LimitedReturnTypeInference", "suggest": "", diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json index 5f8e3d35ed8db01159f4d98d96c6dcdadc0ce492..eaa20eba2386671ee333872a2868b8c5553fcb23 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 16, "endColumn": 88, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 605, - "end": 692, - "replacementText": "", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 88 - }, - { - "start": 692, - "end": 692, - "replacementText": "let Foo = ESValue.load('./no_js_instanceof_file.js').getProperty('Foo');\nlet foo = ESValue.load('./no_js_instanceof_file.js').getProperty('foo');\nlet CreatePerson = ESValue.load('./no_js_instanceof_file.js').getProperty('CreatePerson');\nlet a = ESValue.load('./no_js_instanceof_file.js').getProperty('a');\nlet b = ESValue.load('./no_js_instanceof_file.js').getProperty('b');\nlet MyNamespace = ESValue.load('./no_js_instanceof_file.js').getProperty('MyNamespace');", - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 88 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" @@ -391,4 +371,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets index 514aa17d73fad1ecf96ea84c512d62f579b4b841..be46340ed8446bf6875928a2076f5ce47394f8d5 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets @@ -13,12 +13,7 @@ * limitations under the License. */ -let Foo = ESValue.load('./no_js_instanceof_file.js').getProperty('Foo'); -let foo = ESValue.load('./no_js_instanceof_file.js').getProperty('foo'); -let CreatePerson = ESValue.load('./no_js_instanceof_file.js').getProperty('CreatePerson'); -let a = ESValue.load('./no_js_instanceof_file.js').getProperty('a'); -let b = ESValue.load('./no_js_instanceof_file.js').getProperty('b'); -let MyNamespace = ESValue.load('./no_js_instanceof_file.js').getProperty('MyNamespace'); +import { Foo, foo, CreatePerson, a , b, MyNamespace } from "./no_js_instanceof_file.js" class Foo1 {} @@ -70,12 +65,12 @@ if(a.isInstanceOf(Array)) { } -if(b().isInstanceOf(Array)) { +if(b.invoke().isInstanceOf(Array)) { } -const myDog: MyNamespace.Dog = new MyNamespace.getProperty("Dog")('Buddy'); +const myDog: MyNamespace.Dog = new MyNamespace.getProperty("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("getProperty")("Dog")('Buddy'); -if (myDog.isInstanceOf(MyNamespace.Dog)) { +if (myDog.isInstanceOf(MyNamespace.getProperty("Dog"))) { console.log("This is a Dog!"); } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json index e84613a98b0ffcea08f2166fca6dd43a8c79448b..614491fbff0302bbd0e855eec4d722ef2d6c5c68 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json @@ -16,93 +16,73 @@ "result": [ { "line": 16, - "column": 5, + "column": 1, "endLine": 16, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 5, - "endLine": 17, - "endColumn": 72, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 5, - "endLine": 18, - "endColumn": 90, - "problem": "AnyType", + "endColumn": 88, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 68, - "problem": "AnyType", + "line": 64, + "column": 19, + "endLine": 64, + "endColumn": 24, + "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 68, - "problem": "AnyType", + "line": 64, + "column": 19, + "endLine": 64, + "endColumn": 24, + "problem": "ClassAsObjectError", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 88, - "problem": "AnyType", + "line": 68, + "column": 28, + "endLine": 68, + "endColumn": 33, + "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", "severity": "ERROR" }, { - "line": 69, - "column": 19, - "endLine": 69, - "endColumn": 24, + "line": 68, + "column": 28, + "endLine": 68, + "endColumn": 33, "problem": "ClassAsObjectError", "suggest": "", "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, { - "line": 73, - "column": 21, - "endLine": 73, - "endColumn": 26, - "problem": "ClassAsObjectError", + "line": 72, + "column": 36, + "endLine": 72, + "endColumn": 59, + "problem": "DynamicCtorCall", "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 77, + "line": 72, "column": 36, - "endLine": 77, + "endLine": 72, "endColumn": 59, - "problem": "DynamicCtorCall", + "problem": "InteropObjectProperty", "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/object_literal_union_type.ets b/ets2panda/linter/test/interop/object_literal_union_type.ets index 2e730940c353d44edcde943baabc3cbe84d96937..403b45935861d995d1acd0d4a479512da91863a4 100644 --- a/ets2panda/linter/test/interop/object_literal_union_type.ets +++ b/ets2panda/linter/test/interop/object_literal_union_type.ets @@ -25,4 +25,6 @@ let xyz: X | Y | Z = { name: "xyz" } let ab: A | B = { name: "hello" } // legal -let y: X | Y = { name: "hello" } as Y; // legal \ No newline at end of file +let y: X | Y = { name: "hello" } as Y; // legal + +let res: Record | object[] = {} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json index 1639c66b412dc43d47a5a1f6c9ffe703bc258160..a619d83610fe29ef5e2427badbd66e433ea96bcf 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json @@ -20,26 +20,6 @@ "endLine": 15, "endColumn": 51, "problem": "InterOpImportJs", - "autofix": [ - { - "start": 604, - "end": 654, - "replacementText": "", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - }, - { - "start": 654, - "end": 654, - "replacementText": "let foo = ESValue.load('./unary_operation_js_obj_js.js').getProperty('foo');", - "line": 15, - "column": 1, - "endLine": 15, - "endColumn": 51 - } - ], "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets index 2f5119402182c7fb7dd3ff4188c3ced36f307a0f..7fef071bd036dd04adf66fec6acb429e207bbd37 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -let foo = ESValue.load('./unary_operation_js_obj_js.js').getProperty('foo'); +import {foo} from "./unary_operation_js_obj_js.js" +foo.getProperty("num").toNumber(); -foo.getProperty("num").toNumber(); diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json index 8ebd88e3904eb9a6a65cbed9738408e716e0f904..0a055b7965f1bf8ab53fa19829d87d9a4e8491bc 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json @@ -16,12 +16,12 @@ "result": [ { "line": 15, - "column": 5, + "column": 1, "endLine": 15, - "endColumn": 76, - "problem": "AnyType", + "endColumn": 51, + "problem": "InterOpImportJs", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets new file mode 100644 index 0000000000000000000000000000000000000000..0079ae69de97af89494f2ec7d79b3c9e3e79ab39 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.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. + */ + + +class A{ + public age:number = 1.0; +} + +class B{ + public name:string = "Joe"; + public age:number = 30; +} + +class C{ + public salary:number = 100; + public age:number = 30; +} + +let a: A = {"age": 30} + +let b: Record = { age: 30} + +let c: B = {"name" : "Annie", "age" : 25} + +let d: Record = {salary : 250, age: 30} + diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.args.json b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..bc4d2071daf6e9354e711c3b74b6be2b56659066 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.arkts2.json b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d9865e34233a35209039277b727b8e0a08548d9f --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.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": 23, + "column": 25, + "endLine": 23, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 28, + "endLine": 27, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 25, + "endLine": 28, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 13, + "endLine": 31, + "endColumn": 18, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 20, + "endLine": 31, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 35, + "endLine": 33, + "endColumn": 42, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 33, + "endLine": 33, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 40, + "endLine": 33, + "endColumn": 42, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 13, + "endLine": 35, + "endColumn": 19, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 31, + "endLine": 35, + "endColumn": 36, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 39, + "endLine": 35, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 34, + "endLine": 37, + "endColumn": 46, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 48, + "endLine": 37, + "endColumn": 55, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 33, + "endLine": 37, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 43, + "endLine": 37, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 53, + "endLine": 37, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.json b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..c41e2343989fdaf2f20b1c92f4c941cf0fa1b469 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-obj-literal-key-type.ets.json @@ -0,0 +1,38 @@ +{ + "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": 33, + "column": 33, + "endLine": 33, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 33, + "endLine": 37, + "endColumn": 34, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa688edec8041d27fc0065562f5df524dcef238c --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets @@ -0,0 +1,31 @@ +/* + * 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. + */ + +function foo1(a = 2){} + +function foo2(a = 2, b:number = 3){} + +function foo3(a = 2, b = 3){} + +class Calculator { + // Method with parameters + add(a, b): number { + return a + b; + } + + multiply(x: number, y): number { + return x * y; + } +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.args.json b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..66fb88f85945924e8be0e83d90123507033f4c5d --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.arkts2.json b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d46010af5f9074ecd83285bb8ed5809eabe2ddb3 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.arkts2.json @@ -0,0 +1,168 @@ +{ + "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": 15, + "endLine": 16, + "endColumn": 20, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 19, + "endLine": 16, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 15, + "endLine": 18, + "endColumn": 20, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 19, + "endLine": 18, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 33, + "endLine": 18, + "endColumn": 34, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 15, + "endLine": 20, + "endColumn": 20, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 22, + "endLine": 20, + "endColumn": 27, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 19, + "endLine": 20, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 26, + "endLine": 20, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 8, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 11, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 7, + "endLine": 24, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 11, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 23, + "endLine": 28, + "endColumn": 24, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 23, + "endLine": 28, + "endColumn": 24, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.json b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..e2df81fe91730df3834d19d02b08f5278fb98ff5 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-require-func-arg-type.ets.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": 24, + "column": 7, + "endLine": 24, + "endColumn": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 11, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 23, + "endLine": 28, + "endColumn": 24, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2c357ee4cb4b59e0d55af1dea0d04b6c3ad3cdc --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets @@ -0,0 +1,83 @@ +/* + * 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. + */ + +class A { + readonly x: number = 10; +} +class B extends A { + readonly x: number = 20; // legal +} + +class C { + readonly y: string = "base"; +} +class D extends C { + readonly y: string = "child"; // legal +} + +class E { + z: boolean = true; +} +class F extends E { + z: boolean = false; // legal +} + +class G { + readonly foo: number = 42; +} +class H extends G {} // legal + +class M1 { + data: number = 1; +} +class M2 extends M1 { + readonly data: number = 2; // error +} + +class M3 { + version: string = "1.0"; +} +class M4 extends M3 { + readonly version: "2.0" = "2.0"; // error +} + +class M5 { + isReady: boolean = false; +} +class M6 extends M5 { + readonly isReady: true = true; // error +} + +class A1 { + data: number = 1; +} + +class A2 extends A1 { +} + +class A3 extends A2 { + readonly data: number= 2; // error +} + +class B1 { + readonly data: number = 1; +} + +class B2 extends B1 { +} + +class B3 extends B2 { + readonly data: number= 2; // legal +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.args.json b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.arkts2.json b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..0d2d081c9cd812e8e708e3776131d4039c407231 --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.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": 17, + "column": 24, + "endLine": 17, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 24, + "endLine": 20, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 26, + "endLine": 38, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 18, + "endLine": 43, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 3, + "endLine": 46, + "endColumn": 29, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 27, + "endLine": 46, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 12, + "endLine": 53, + "endColumn": 19, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 3, + "endLine": 53, + "endColumn": 35, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 12, + "endLine": 60, + "endColumn": 19, + "problem": "FieldTypeMismatch", + "suggest": "", + "rule": "The field types of the subclass and parent class must be the same (arkts-class-same-type-prop-with-super)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 3, + "endLine": 60, + "endColumn": 33, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 21, + "endLine": 60, + "endColumn": 25, + "problem": "LimitedLiteralType", + "suggest": "", + "rule": "Literal types are restricted(arkts-limited-literal-types)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 20, + "endLine": 64, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 5, + "endLine": 71, + "endColumn": 30, + "problem": "NoClassSuperPropReadonly", + "suggest": "", + "rule": "Overriding with \"readonly\" field is not allowed when base field is not \"readonly\" (arkts-no-class-add-super-prop-with-readonly)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 28, + "endLine": 71, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 29, + "endLine": 75, + "endColumn": 30, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 28, + "endLine": 82, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.json b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/arkts_no_class_super_prop_readonly.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/builder_node.ets b/ets2panda/linter/test/main/builder_node.ets new file mode 100644 index 0000000000000000000000000000000000000000..a277872e970debdb85bfe7d4f35e99d570c12d83 --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets @@ -0,0 +1,123 @@ +/* + * 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 { NodeController, BuilderNode, FrameNode } from './ui_modules/@kit.ArkUI'; + +class Params { + item: string = ''; + + constructor(item: string) { + this.item = item; + } +} + +interface CustomInterface { + item: string; + age: number; +} + +class CustomClass { + private item: string = 'C'; + age: number = 10; +} + +@Builder +function buildNode(param: Params) {} + +function getObject1() { + const customInterfaceParams: CustomInterface | number = 1 > 0 ? { item: 'C', age: 100 } : 1; + return customInterfaceParams; +} + +function getObject2() { + const customInterfaceParams: CustomInterface = { + item: 'C', + age: 100 + }; + return customInterfaceParams; +} + +class MyNodeController extends NodeController { + public builderNode1: BuilderNode<[Params]> | null = null; // error + public builderNode2: BuilderNode<[Params]> | null = null; // error + public builderNode3: BuilderNode<[]> | null = null; // error + public builderNode4: BuilderNode<[]> | null = null; // error + public frameNode: FrameNode | null = null; + public item: string = ""; + + getObject3() { + const customInterfaceParams: CustomInterface = { + item: 'C', + age: 100 + }; + return customInterfaceParams; + } + + makeNode(uiContext: UIContext): FrameNode | null { + if (this.builderNode1 == null || this.builderNode2 == null + || this.builderNode3 == null || this.builderNode4 == null) { + this.builderNode1 = new BuilderNode(uiContext, { selfIdealSize : { width: 300, height: 200} }); + this.builderNode2 = new BuilderNode<[Params]>(uiContext, { selfIdealSize: { width: 300, height: 200} }); // error + this.builderNode3 = new BuilderNode(uiContext, { selfIdealSize : { width: 300, height: 200} }); + this.builderNode4 = new BuilderNode<[]>(uiContext, { selfIdealSize : { width: 300, height: 200} }); // error + this.builderNode1.build(wrapBuilder<[Params]>(buildNode), new Params(this.item), { nestingBuilderSupported: false }) // error + let flag = true; + this.builderNode2.build(wrapBuilder<[Params]>(buildNode), new Params(this.item), { nestingBuilderSupported: flag }); // error + } + + return this.frameNode; + } + + updateItem(item: string, customParam: boolean): void { + this.item = item; + if (this.builderNode1 && this.builderNode2 && this.builderNode3 && this.builderNode4) { + if (customParam) { + const a1: CustomInterface = { + item: 'C', + age: 100 + }; + const a2: CustomInterface | number = 1 > 0 ? { item: 'C', age: 100 } : 1; + const a3 = getObject1(); + const a4 = getObject2(); + const customClassParams: CustomClass = new CustomClass(); + this.builderNode1.update(a1); // error + this.builderNode2.update(a2); // error + this.builderNode3.update(a3); // error + this.builderNode4.update(a4); // error + this.builderNode1.update({ item: 'C', age: 100 }); // error + this.builderNode2.update(1 > 0 ? a1 : 1); // error + this.builderNode3.update(customClassParams); + this.builderNode3.update({ item: 'C', age: 100}); // error + this.builderNode4.update(getObject1()); // error + this.builderNode4.update(getObject2()); // error + this.builderNode4.update(this.getObject3()); // error + } else {} + } + } +} + +@Reusable +@Component +struct ReusableChildComponent { + private controller: MyNodeController = new MyNodeController(); + + aboutToReuse(params: Record): void { + this.controller?.builderNode1?.reuse(params); + } + + build() { + + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/builder_node.ets.args.json b/ets2panda/linter/test/main/builder_node.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..ec9992d92461d66e16b80975e33f95872c06af54 --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/builder_node.ets.arkts2.json b/ets2panda/linter/test/main/builder_node.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..57d4b5b5c63d5f161643e86a0432f72ccaaa8fd3 --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets.arkts2.json @@ -0,0 +1,568 @@ +{ + "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": 33, + "column": 17, + "endLine": 33, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 60, + "endLine": 40, + "endColumn": 61, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 64, + "endLine": 40, + "endColumn": 65, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 86, + "endLine": 40, + "endColumn": 89, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 94, + "endLine": 40, + "endColumn": 95, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 10, + "endLine": 47, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 24, + "endLine": 53, + "endColumn": 45, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 24, + "endLine": 54, + "endColumn": 45, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 24, + "endLine": 55, + "endColumn": 39, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 24, + "endLine": 56, + "endColumn": 39, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 12, + "endLine": 63, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 27, + "endLine": 71, + "endColumn": 101, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 72, + "endLine": 71, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 81, + "endLine": 71, + "endColumn": 84, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 94, + "endLine": 71, + "endColumn": 97, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 27, + "endLine": 72, + "endColumn": 110, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 81, + "endLine": 72, + "endColumn": 82, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 90, + "endLine": 72, + "endColumn": 93, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 103, + "endLine": 72, + "endColumn": 106, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 27, + "endLine": 73, + "endColumn": 101, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 72, + "endLine": 73, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 81, + "endLine": 73, + "endColumn": 84, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 94, + "endLine": 73, + "endColumn": 97, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 27, + "endLine": 74, + "endColumn": 105, + "problem": "BuilderNodeGenericNoTuple", + "suggest": "", + "rule": "The generic of \"BuilderNode\" does not accept tuple (arkui-buildernode-generic-no-tuple)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 76, + "endLine": 74, + "endColumn": 77, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 85, + "endLine": 74, + "endColumn": 88, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 98, + "endLine": 74, + "endColumn": 101, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 7, + "endLine": 75, + "endColumn": 123, + "problem": "BuilderNodeNoNestingBuilderSupported", + "suggest": "", + "rule": "Property \"nestingBuilderSupported\" is not supported (arkui-buildernode-no-nestingbuildersupported)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 31, + "endLine": 75, + "endColumn": 63, + "problem": "WrapBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 7, + "endLine": 77, + "endColumn": 122, + "problem": "BuilderNodeNoNestingBuilderSupported", + "suggest": "", + "rule": "Property \"nestingBuilderSupported\" is not supported (arkui-buildernode-no-nestingbuildersupported)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 31, + "endLine": 77, + "endColumn": 63, + "problem": "WrapBuilderGenericNeedArrowFunc", + "suggest": "", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 16, + "endLine": 89, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 46, + "endLine": 91, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 50, + "endLine": 91, + "endColumn": 51, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 72, + "endLine": 91, + "endColumn": 75, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 80, + "endLine": 91, + "endColumn": 81, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 9, + "endLine": 95, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 9, + "endLine": 96, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 9, + "endLine": 97, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 9, + "endLine": 98, + "endColumn": 37, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 9, + "endLine": 99, + "endColumn": 58, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 52, + "endLine": 99, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 9, + "endLine": 100, + "endColumn": 49, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 34, + "endLine": 100, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 38, + "endLine": 100, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 47, + "endLine": 100, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 9, + "endLine": 102, + "endColumn": 57, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 52, + "endLine": 102, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 9, + "endLine": 103, + "endColumn": 47, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 9, + "endLine": 104, + "endColumn": 47, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 9, + "endLine": 105, + "endColumn": 52, + "problem": "BuilderNodeUpdateNoLiteral", + "suggest": "", + "rule": "The \"update\" interface of \"BuilderNode\" does not accept an object literal. Please replace it with an instance of the class specified in the generic when creating a new \"BuilderNode\", and ensure that the instance has the same field values as the literal (arkui-buildernode-update-no-literal)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 2, + "endLine": 36, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 23, + "endLine": 68, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"UIContext\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 2, + "endLine": 111, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Reusable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 2, + "endLine": 112, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" 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/builder_node.ets.json b/ets2panda/linter/test/main/builder_node.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..cbe274b6acf883f870cc6ad44d783f614d81fb8d --- /dev/null +++ b/ets2panda/linter/test/main/builder_node.ets.json @@ -0,0 +1,58 @@ +{ + "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": 71, + "column": 72, + "endLine": 71, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 81, + "endLine": 72, + "endColumn": 82, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 72, + "endLine": 73, + "endColumn": 73, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 76, + "endLine": 74, + "endColumn": 77, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/case_expr.ets.arkts2.json b/ets2panda/linter/test/main/case_expr.ets.arkts2.json index abc2f67950850ae0e8ee1634cee91d1c7cc073f1..44cd6542b5ef56b30ed8d9d729d7a9549071304a 100755 --- a/ets2panda/linter/test/main/case_expr.ets.arkts2.json +++ b/ets2panda/linter/test/main/case_expr.ets.arkts2.json @@ -121,7 +121,7 @@ "endColumn": 12, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/class_as_object.ets.arkts2.json b/ets2panda/linter/test/main/class_as_object.ets.arkts2.json index 461137accaf6240bf2fdf90a6d49561d3c968c57..44a60b85bb81f801a67c7fe752b4a1521a07c780 100644 --- a/ets2panda/linter/test/main/class_as_object.ets.arkts2.json +++ b/ets2panda/linter/test/main/class_as_object.ets.arkts2.json @@ -881,7 +881,7 @@ "endColumn": 12, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/collections_module.ets b/ets2panda/linter/test/main/collections_module.ets index 0d73282ec64470e2564c0681afdf0ec6ee331414..f61a5a5a4d52d648c5a17b1166ade1c58a424468 100644 --- a/ets2panda/linter/test/main/collections_module.ets +++ b/ets2panda/linter/test/main/collections_module.ets @@ -40,3 +40,7 @@ function tesCollectionsUsage() { function test(array: collections.Array) { const map = collections.Map(); } + +function testBitVector(bv: collections.BitVector) { + const bitVector = new collections.BitVector(); +} diff --git a/ets2panda/linter/test/main/collections_module.ets.arkts2.json b/ets2panda/linter/test/main/collections_module.ets.arkts2.json index 7286b3c366e4d8b32395b1830bd48e1ac22a1207..6fb86f244dfc3ed0b8908ed97460eb09399ffc6b 100644 --- a/ets2panda/linter/test/main/collections_module.ets.arkts2.json +++ b/ets2panda/linter/test/main/collections_module.ets.arkts2.json @@ -48,7 +48,7 @@ "line": 26, "column": 23, "endLine": 26, - "endColumn": 34, + "endColumn": 40, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -58,7 +58,7 @@ "line": 26, "column": 55, "endLine": 26, - "endColumn": 66, + "endColumn": 72, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -68,7 +68,7 @@ "line": 28, "column": 28, "endLine": 28, - "endColumn": 44, + "endColumn": 50, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -78,7 +78,7 @@ "line": 30, "column": 28, "endLine": 30, - "endColumn": 42, + "endColumn": 48, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -88,7 +88,7 @@ "line": 32, "column": 21, "endLine": 32, - "endColumn": 37, + "endColumn": 43, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -98,7 +98,7 @@ "line": 34, "column": 23, "endLine": 34, - "endColumn": 39, + "endColumn": 45, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -108,7 +108,7 @@ "line": 34, "column": 60, "endLine": 34, - "endColumn": 76, + "endColumn": 82, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -118,7 +118,7 @@ "line": 40, "column": 22, "endLine": 40, - "endColumn": 33, + "endColumn": 39, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -138,7 +138,7 @@ "line": 41, "column": 17, "endLine": 41, - "endColumn": 28, + "endColumn": 32, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -153,6 +153,46 @@ "suggest": "", "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" + }, + { + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49, + "problem": "NoNeedStdLibSendableContainer", + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "NoNeedStdLibSendableContainer", + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/collections_module.ets.autofix.json b/ets2panda/linter/test/main/collections_module.ets.autofix.json index 1d3cd393a428875374beb8c8f466ccfb77fa4307..9be897f59e5ec888e5fcf18f65ebcbdab3e3da2b 100644 --- a/ets2panda/linter/test/main/collections_module.ets.autofix.json +++ b/ets2panda/linter/test/main/collections_module.ets.autofix.json @@ -81,7 +81,7 @@ "line": 26, "column": 23, "endLine": 26, - "endColumn": 34, + "endColumn": 40, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -91,7 +91,7 @@ "line": 26, "column": 23, "endLine": 26, - "endColumn": 34 + "endColumn": 40 } ], "suggest": "", @@ -102,7 +102,7 @@ "line": 26, "column": 55, "endLine": 26, - "endColumn": 66, + "endColumn": 72, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -112,7 +112,7 @@ "line": 26, "column": 55, "endLine": 26, - "endColumn": 66 + "endColumn": 72 } ], "suggest": "", @@ -123,7 +123,7 @@ "line": 28, "column": 28, "endLine": 28, - "endColumn": 44, + "endColumn": 50, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -133,7 +133,7 @@ "line": 28, "column": 28, "endLine": 28, - "endColumn": 44 + "endColumn": 50 } ], "suggest": "", @@ -144,7 +144,7 @@ "line": 30, "column": 28, "endLine": 30, - "endColumn": 42, + "endColumn": 48, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -154,7 +154,7 @@ "line": 30, "column": 28, "endLine": 30, - "endColumn": 42 + "endColumn": 48 } ], "suggest": "", @@ -165,7 +165,7 @@ "line": 32, "column": 21, "endLine": 32, - "endColumn": 37, + "endColumn": 43, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -175,7 +175,7 @@ "line": 32, "column": 21, "endLine": 32, - "endColumn": 37 + "endColumn": 43 } ], "suggest": "", @@ -186,7 +186,7 @@ "line": 34, "column": 23, "endLine": 34, - "endColumn": 39, + "endColumn": 45, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -196,7 +196,7 @@ "line": 34, "column": 23, "endLine": 34, - "endColumn": 39 + "endColumn": 45 } ], "suggest": "", @@ -207,7 +207,7 @@ "line": 34, "column": 60, "endLine": 34, - "endColumn": 76, + "endColumn": 82, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -217,7 +217,7 @@ "line": 34, "column": 60, "endLine": 34, - "endColumn": 76 + "endColumn": 82 } ], "suggest": "", @@ -228,7 +228,7 @@ "line": 40, "column": 22, "endLine": 40, - "endColumn": 33, + "endColumn": 39, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -238,7 +238,7 @@ "line": 40, "column": 22, "endLine": 40, - "endColumn": 33 + "endColumn": 39 } ], "suggest": "", @@ -259,7 +259,7 @@ "line": 41, "column": 17, "endLine": 41, - "endColumn": 28, + "endColumn": 32, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -269,7 +269,7 @@ "line": 41, "column": 17, "endLine": 41, - "endColumn": 28 + "endColumn": 32 } ], "suggest": "", @@ -285,6 +285,86 @@ "suggest": "", "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" + }, + { + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 1514, + "end": 1535, + "replacementText": "BitVector", + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49 + }, + { + "start": 919, + "end": 919, + "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", + "line": 44, + "column": 28, + "endLine": 44, + "endColumn": 49 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 1573, + "end": 1594, + "replacementText": "BitVector", + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48 + }, + { + "start": 919, + "end": 919, + "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/collections_module.ets.json b/ets2panda/linter/test/main/collections_module.ets.json index c85948ef43d15c11df4ea2642653f1aa07028852..927ff202214f3a1090827f0856d16510b65298d6 100644 --- a/ets2panda/linter/test/main/collections_module.ets.json +++ b/ets2panda/linter/test/main/collections_module.ets.json @@ -33,6 +33,16 @@ "suggest": "", "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "WARNING" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/collections_module.ets.migrate.ets b/ets2panda/linter/test/main/collections_module.ets.migrate.ets index 81cfa37dfc52720a009fc7648421b1f1158efd5a..9915905ea53f6be768dfe0ad9871dd9059a031a9 100644 --- a/ets2panda/linter/test/main/collections_module.ets.migrate.ets +++ b/ets2panda/linter/test/main/collections_module.ets.migrate.ets @@ -19,7 +19,9 @@ -import { collections as definedCollections } from './ignore_files/user_defined_collections'; //legal +import { collections as definedCollections } from './ignore_files/user_defined_collections'; +import { BitVector } from "@arkts.collections"; + //legal function tesCollectionsUsage() { @@ -40,3 +42,7 @@ function tesCollectionsUsage() { function test(array: Array) { const map = Map(); } + +function testBitVector(bv: BitVector) { + const bitVector = new BitVector(); +} diff --git a/ets2panda/linter/test/main/collections_module.ets.migrate.json b/ets2panda/linter/test/main/collections_module.ets.migrate.json index dd7b500c7435da5e5cbdc0a12e60930e24375f66..e3768540dc783f9b6fe11d045ce1217df7aaff07 100644 --- a/ets2panda/linter/test/main/collections_module.ets.migrate.json +++ b/ets2panda/linter/test/main/collections_module.ets.migrate.json @@ -15,14 +15,34 @@ ], "result": [ { - "line": 41, + "line": 43, "column": 11, - "endLine": 41, + "endLine": 43, "endColumn": 38, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 47, + "column": 11, + "endLine": 47, + "endColumn": 46, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 27, + "endLine": 47, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json index ab41a3326a9ceca4e10b9e62c529cdeed8ad5d21..e485c6f536c40e478abb267572b243df161f06ab 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json @@ -84,16 +84,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 96, - "column": 17, - "endLine": 96, - "endColumn": 29, - "problem": "MethodInheritRule", - "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", - "severity": "ERROR" - }, { "line": 118, "column": 16, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json index cce8e07d1c1fab1b091c6a4f074adfc7d2b94787..f78396b2f083af0430c14f88c0f8f4f105057b05 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json @@ -150,16 +150,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 96, - "column": 17, - "endLine": 96, - "endColumn": 29, - "problem": "MethodInheritRule", - "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", - "severity": "ERROR" - }, { "line": 118, "column": 16, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json index 9c5d050cc76a943c1a57c9ddbd6c9eca934470d4..b17d2989de701fb9fea8cc55fa8e3e51164796d1 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json @@ -24,16 +24,6 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, - { - "line": 96, - "column": 17, - "endLine": 96, - "endColumn": 29, - "problem": "MethodInheritRule", - "suggest": "", - "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", - "severity": "ERROR" - }, { "line": 118, "column": 16, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets b/ets2panda/linter/test/main/func_inferred_type_args_3.ets index 0425eba064689ca5219efade26b51eb4ac409859..cefc55fba0a8f50f3fee8ff86e62b29abee5a8bf 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_3.ets +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets @@ -17,6 +17,7 @@ import B from './func_inferred_type_args_ts' import A2 from './func_inferred_type_args_ts2' import {A3} from './func_inferred_type_args_ts2' import { HashMap } from '@kit.ArkTS'; +import { IMonitorValue, IMonitor, LocalStorage, AbstractProperty, SubscribedAbstractProperty, AppStorage} from './oh_modules/common_ts_ets_api'; function test() { const a = new A(); @@ -40,4 +41,25 @@ class Demo{} function test4() { const a = new A4(); a.map = new HashMap(); //error -} \ No newline at end of file +} + +@ComponentV2 +struct Child { + @Param info: Info = new Info(); + @Monitor("info.message") + onMessageChange(monitor: IMonitor) { + let beforeValue: IMonitorValue = monitor.value(); + let beforeValue: IMonitorValue = monitor.value("info.message"); + console.info(`Child message change from ${monitor.value()?.before} to ${monitor.value('info.message')?.now}`); + } +} + +let para: Record = { 'PropA': 47 }; +let storage: LocalStorage = new LocalStorage(para); +let propA: number | undefined = storage.get('PropA'); +let link1: SubscribedAbstractProperty = storage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = storage.ref('PropA'); + +let propA: number | undefined = AppStorage.get('PropA'); +let link1: SubscribedAbstractProperty = AppStorage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = AppStorage.ref('PropA'); \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.arkts2.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.arkts2.json index 868ccdbc438558b589ceec51e7df32f9c8a0a575..3d3a2b6001a02fdfee09fc0c09db5c1525e5a7f6 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.arkts2.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.arkts2.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 23, + "line": 24, "column": 11, - "endLine": 23, + "endLine": 24, "endColumn": 20, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 28, "column": 11, - "endLine": 27, + "endLine": 28, "endColumn": 20, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 11, - "endLine": 31, + "endLine": 32, "endColumn": 20, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 42, + "line": 43, "column": 15, - "endLine": 42, + "endLine": 43, "endColumn": 22, "problem": "DynamicCtorCall", "suggest": "", @@ -55,14 +55,204 @@ "severity": "ERROR" }, { - "line": 42, + "line": 43, "column": 11, - "endLine": 42, + "endLine": 43, "endColumn": 24, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" + }, + { + "line": 48, + "column": 27, + "endLine": 48, + "endColumn": 31, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 46, + "endLine": 51, + "endColumn": 61, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 46, + "endLine": 52, + "endColumn": 75, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 47, + "endLine": 53, + "endColumn": 62, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 77, + "endLine": 53, + "endColumn": 106, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 46, + "endLine": 57, + "endColumn": 48, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 33, + "endLine": 59, + "endColumn": 53, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 49, + "endLine": 60, + "endColumn": 70, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 57, + "endLine": 61, + "endColumn": 77, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 33, + "endLine": 63, + "endColumn": 56, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 49, + "endLine": 64, + "endColumn": 73, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 57, + "endLine": 65, + "endColumn": 80, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 2, + "endLine": 46, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 4, + "endLine": 48, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Param\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Monitor\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 9, + "endLine": 51, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 60, + "column": 5, + "endLine": 60, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.autofix.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.autofix.json index 6c9b2975d94e94283827db705302981377fa29b6..a45c3a167352ec8374262312781c3717d6295c5b 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.autofix.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.autofix.json @@ -15,19 +15,19 @@ ], "result": [ { - "line": 23, + "line": 24, "column": 11, - "endLine": 23, + "endLine": 24, "endColumn": 20, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 888, - "end": 888, + "start": 1033, + "end": 1033, "replacementText": "", - "line": 23, + "line": 24, "column": 11, - "endLine": 23, + "endLine": 24, "endColumn": 20 } ], @@ -36,9 +36,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 28, "column": 11, - "endLine": 27, + "endLine": 28, "endColumn": 20, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -46,19 +46,19 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 11, - "endLine": 31, + "endLine": 32, "endColumn": 20, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1032, - "end": 1032, + "start": 1177, + "end": 1177, "replacementText": "", - "line": 31, + "line": 32, "column": 11, - "endLine": 31, + "endLine": 32, "endColumn": 20 } ], @@ -67,9 +67,9 @@ "severity": "ERROR" }, { - "line": 42, + "line": 43, "column": 15, - "endLine": 42, + "endLine": 43, "endColumn": 22, "problem": "DynamicCtorCall", "suggest": "", @@ -77,25 +77,369 @@ "severity": "ERROR" }, { - "line": 42, + "line": 43, "column": 11, - "endLine": 42, + "endLine": 43, "endColumn": 24, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1183, - "end": 1183, + "start": 1328, + "end": 1328, "replacementText": "", - "line": 42, + "line": 43, "column": 11, - "endLine": 42, + "endLine": 43, "endColumn": 24 } ], "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" + }, + { + "line": 48, + "column": 27, + "endLine": 48, + "endColumn": 31, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 46, + "endLine": 51, + "endColumn": 61, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1529, + "end": 1529, + "replacementText": "", + "line": 51, + "column": 46, + "endLine": 51, + "endColumn": 61 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 46, + "endLine": 52, + "endColumn": 75, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1591, + "end": 1591, + "replacementText": "", + "line": 52, + "column": 46, + "endLine": 52, + "endColumn": 75 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 47, + "endLine": 53, + "endColumn": 62, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1668, + "end": 1668, + "replacementText": "", + "line": 53, + "column": 47, + "endLine": 53, + "endColumn": 62 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 77, + "endLine": 53, + "endColumn": 106, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1698, + "end": 1698, + "replacementText": "", + "line": 53, + "column": 77, + "endLine": 53, + "endColumn": 106 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 46, + "endLine": 57, + "endColumn": 48, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1776, + "end": 1778, + "replacementText": "47.0", + "line": 57, + "column": 46, + "endLine": 57, + "endColumn": 48 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 33, + "endLine": 59, + "endColumn": 53, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1877, + "end": 1877, + "replacementText": "", + "line": 59, + "column": 33, + "endLine": 59, + "endColumn": 53 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 49, + "endLine": 60, + "endColumn": 70, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 1948, + "end": 1948, + "replacementText": "", + "line": 60, + "column": 49, + "endLine": 60, + "endColumn": 70 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 57, + "endLine": 61, + "endColumn": 77, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2026, + "end": 2026, + "replacementText": "", + "line": 61, + "column": 57, + "endLine": 61, + "endColumn": 77 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 33, + "endLine": 63, + "endColumn": 56, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2084, + "end": 2084, + "replacementText": "", + "line": 63, + "column": 33, + "endLine": 63, + "endColumn": 56 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 49, + "endLine": 64, + "endColumn": 73, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2158, + "end": 2158, + "replacementText": "", + "line": 64, + "column": 49, + "endLine": 64, + "endColumn": 73 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 57, + "endLine": 65, + "endColumn": 80, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2239, + "end": 2239, + "replacementText": "", + "line": 65, + "column": 57, + "endLine": 65, + "endColumn": 80 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 2, + "endLine": 46, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n ComponentV2,\n Param,\n Monitor,\n} from '@kit.ArkUI';\n", + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 4, + "endLine": 48, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n ComponentV2,\n Param,\n Monitor,\n} from '@kit.ArkUI';\n", + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Param\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n ComponentV2,\n Param,\n Monitor,\n} from '@kit.ArkUI';\n", + "line": 49, + "column": 4, + "endLine": 49, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Monitor\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 9, + "endLine": 51, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 60, + "column": 5, + "endLine": 60, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.json index b7a8809e02ae14f7f14ed7adbd6d2d3f630fa3f6..9b8ac8bc7dba0a8c8b78a0303ccffd0b78a19807 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.json @@ -13,5 +13,46 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 51, + "column": 9, + "endLine": 51, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 52, + "column": 9, + "endLine": 52, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 60, + "column": 5, + "endLine": 60, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.ets b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.ets index c038713ec982d79a09659471780a07ead58ffade..c98487895d216a7a1b4b1ead3a99988c0410d7a8 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.ets +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.ets @@ -12,11 +12,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import { + ComponentV2, + Param, + Monitor, +} from '@kit.ArkUI'; + import {A} from './func_inferred_type_args_ts'; import B from './func_inferred_type_args_ts' import A2 from './func_inferred_type_args_ts2' import {A3} from './func_inferred_type_args_ts2' import { HashMap } from '@kit.ArkTS'; +import { IMonitorValue, IMonitor, LocalStorage, AbstractProperty, SubscribedAbstractProperty, AppStorage} from './oh_modules/common_ts_ets_api'; function test() { const a = new A(); @@ -40,4 +48,25 @@ class Demo{} function test4() { const a = new A4(); a.map = new HashMap(); //error -} \ No newline at end of file +} + +@ComponentV2 +struct Child { + @Param info: Info = new Info(); + @Monitor("info.message") + onMessageChange(monitor: IMonitor) { + let beforeValue: IMonitorValue = monitor.value(); + let beforeValue: IMonitorValue = monitor.value("info.message"); + console.info(`Child message change from ${monitor.value()?.before} to ${monitor.value('info.message')?.now}`); + } +} + +let para: Record = { 'PropA': 47.0 }; +let storage: LocalStorage = new LocalStorage(para); +let propA: number | undefined = storage.get('PropA'); +let link1: SubscribedAbstractProperty = storage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = storage.ref('PropA'); + +let propA: number | undefined = AppStorage.get('PropA'); +let link1: SubscribedAbstractProperty = AppStorage.link('PropA'); +let refToPropA1: AbstractProperty | undefined = AppStorage.ref('PropA'); \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.json b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.json index f7a8d2c4bd57fe17e935fa31422c61b11a118be7..62f3ae72ba416c8d81e7056a12bd739734bbc4c4 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_3.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 27, + "line": 35, "column": 11, - "endLine": 27, + "endLine": 35, "endColumn": 20, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -25,14 +25,64 @@ "severity": "ERROR" }, { - "line": 42, + "line": 50, "column": 15, - "endLine": 42, + "endLine": 50, "endColumn": 22, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" + }, + { + "line": 55, + "column": 27, + "endLine": 55, + "endColumn": 31, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 9, + "endLine": 58, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 59, + "column": 9, + "endLine": 59, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "rule": "Type 'IMonitorValue | undefined' is not assignable to type 'IMonitorValue'.\n Type 'undefined' is not assignable to type 'IMonitorValue'.", + "severity": "ERROR" + }, + { + "line": 67, + "column": 5, + "endLine": 67, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" + }, + { + "line": 71, + "column": 5, + "endLine": 71, + "endColumn": 10, + "problem": "StrictDiagnostic", + "suggest": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "rule": "Type 'SubscribedAbstractProperty | undefined' is not assignable to type 'SubscribedAbstractProperty'.\n Type 'undefined' is not assignable to type 'SubscribedAbstractProperty'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json index 26b266ff8c62d21c13f89816f7c6c37d3b0f7490..5362d5eaba8a5429488bcaec6e3f7478363d9b11 100644 --- a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json +++ b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json @@ -91,7 +91,7 @@ "endColumn": 13, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json index d5851681b3cbccba32d5112080bd44cc294ca6e8..77cf362c1527086e6780739896b50bcf4d9fb6dc 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json @@ -1374,16 +1374,6 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, - { - "line": 251, - "column": 11, - "endLine": 251, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 252, "column": 10, diff --git a/ets2panda/linter/test/main/limit_void_type.ets.autofix.json b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json index 60cf6b289814a5d50e03aad0eb99b9634cc3fa9f..d80964b3403d86d70caba07f981713790f4387b4 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.autofix.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json @@ -1715,16 +1715,6 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, - { - "line": 251, - "column": 11, - "endLine": 251, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 252, "column": 10, diff --git a/ets2panda/linter/test/main/limit_void_type.ets.migrate.json b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json index 3644453e029b1f234d75a59250d1cd1efbf4ea60..45016261114b25295b9fbc45da97c51d76361c93 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.migrate.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json @@ -1074,16 +1074,6 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, - { - "line": 262, - "column": 11, - "endLine": 262, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 263, "column": 10, diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json index a1c3a4b9724091615941ad405ba2ef2ceaeaaf5c..25a3ca26f62f9baab6dbf8cc743387bf9b008a95 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json @@ -554,6 +554,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 15, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, { "line": 135, "column": 37, @@ -805,4 +815,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json index 4c95852a32b261a8705a0fc27cb1119ecc6bce3b..127be23a53799c26b92a3aa385e0036f4dc58ded 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json @@ -990,6 +990,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 15, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, { "line": 135, "column": 37, @@ -1351,4 +1361,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json index 40d660f102f671807bdb1a196838505d64ef1f6b..3b5d627860fa5ce150f836bb8f54f8e8cd5e0c38 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json @@ -224,6 +224,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 145, + "column": 3, + "endLine": 145, + "endColumn": 17, + "problem": "ObjectLiteralKeyType", + "suggest": "", + "rule": "Use string-literal keys with Record (arkts-obj-literal-key-type)", + "severity": "ERROR" + }, { "line": 144, "column": 37, @@ -385,4 +395,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json index 0a8b389c110fd996dd9ff65f6067e69b4f12f3ce..bfb88a65c82c067497faa74d062e2d596c7c90dc 100755 --- a/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json +++ b/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json @@ -104,6 +104,16 @@ "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" }, + { + "line": 103, + "column": 18, + "endLine": 103, + "endColumn": 19, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, { "line": 108, "column": 17, @@ -113,6 +123,16 @@ "suggest": "", "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" + }, + { + "line": 112, + "column": 18, + "endLine": 112, + "endColumn": 19, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets b/ets2panda/linter/test/main/method_inheritance3.ets new file mode 100755 index 0000000000000000000000000000000000000000..d31da9911bdba10fc816d7677500f8a4feae3ff1 --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.ets @@ -0,0 +1,63 @@ +/* + * 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. + */ + +class A{ + getData(a:T):T{ + return a; + } +} + +class B extends A{ + getData(a: number): number { // no error + return 123; + } +} + +enum E{ + E1, + E2 +} + +interface I { + fun(e:E):void +} + +class C implements I { + fun(e:E):void{ // no error + + } +} + +Class UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void; + onWindowStageCreate(windowStage: window.WindowStage): void; +} + +class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { // no error + + } + + onWindowStageCreate(windowStage: window.WindowStage): void { // no error + try { + windowStage.loadContent('pages/Index', (err: BusinessError | null): void => { + if (err && err.code) { + return; + } + }); + } catch (e) { + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets.args.json b/ets2panda/linter/test/main/method_inheritance3.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..d8d3390ad9befeca9b595017d9eea0f5ada3d049 --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..1dfcce5603792b0fa38a6e3c592a373b2d6103ac --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json @@ -0,0 +1,78 @@ +{ + "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": 24, + "column": 12, + "endLine": 24, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 67, + "endLine": 44, + "endColumn": 71, + "problem": "VoidOperator", + "suggest": "", + "rule": "\"void\" operator is not supported (arkts-no-void-operator)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 57, + "endLine": 45, + "endColumn": 61, + "problem": "VoidOperator", + "suggest": "", + "rule": "\"void\" operator is not supported (arkts-no-void-operator)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 18, + "endLine": 44, + "endColumn": 22, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Want\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 18, + "endLine": 49, + "endColumn": 22, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Want\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 52, + "endLine": 55, + "endColumn": 65, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BusinessError\" 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/method_inheritance3.ets.json b/ets2panda/linter/test/main/method_inheritance3.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/method_inheritance3.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/numeric_semantics.ets b/ets2panda/linter/test/main/numeric_semantics.ets index 39c3b1a564040c3ee5637e66bfacd6f9c8be9ca9..9cc9bf26f5c12e31bc14edba1078c2da493d057f 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets @@ -237,4 +237,10 @@ function testIndentation(): void { console.log('hello'); return 0; })(); -} \ No newline at end of file +} + +@Sendable +export function add(a: number, b: number) { + console.log("SharedModule: Hap call ShareFile add"); + return a + b; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json index 0cb967d9fef64e76cb78c887e31e707987585d35..35164935cf2df9b2676aa6a0056880d98c390fb6 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json @@ -374,6 +374,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 92, + "column": 19, + "endLine": 92, + "endColumn": 24, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 26, + "endLine": 92, + "endColumn": 31, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 92, "column": 1, @@ -1214,6 +1234,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 242, + "column": 1, + "endLine": 246, + "endColumn": 2, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 242, + "column": 1, + "endLine": 242, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -1305,4 +1345,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json index 6ece33eb7ae5eef6d36f8ee43560d4709b45c56f..99e139c5e9372ec72c4c887a1b7b5adacc4eb835 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json @@ -759,6 +759,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 92, + "column": 19, + "endLine": 92, + "endColumn": 24, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 26, + "endLine": 92, + "endColumn": 31, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 92, "column": 1, @@ -2301,6 +2321,48 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 242, + "column": 1, + "endLine": 246, + "endColumn": 2, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5739, + "end": 5739, + "replacementText": ": number", + "line": 242, + "column": 1, + "endLine": 246, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 242, + "column": 1, + "endLine": 242, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "autofix": [ + { + "start": 5687, + "end": 5696, + "replacementText": "", + "line": 242, + "column": 1, + "endLine": 242, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -2491,4 +2553,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets index b85c4166bf9a570cb41347ef11b238b949da1c2b..a5bab563d4debeb46c9ddb3bb0e990e41c26e0be 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets @@ -247,4 +247,10 @@ function testIndentation(): void { console.log('hello'); return 0.0; })(); -} \ No newline at end of file +} + + +export function add(a: number, b: number): number { + console.log("SharedModule: Hap call ShareFile add"); + return a + b; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json index ca3c08f73a465f3bebee27773db588d4ef40c245..ae0621e24de33924117743a1b7bf713ee3b4e9ac 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json @@ -255,4 +255,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json index 8c2a778ec9f98e3debce809d5fc606ab7aa784bc..afbbb893dfd27386d5c9c87f365feaeccc52296f 100755 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json @@ -715,4 +715,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json index b1ea53871472befedfd93b89519a5fc67e78c891..f4e1b08a2126a8a998f337a662aa36b8cd859662 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json @@ -1253,4 +1253,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json index 2103eb7cf5387f30295dca218d7ff81e6a850e86..3f86f1a88b08a4e9f8c826153a26827a9083cf8b 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json @@ -275,4 +275,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/oh_modules/common_ts_ets_api.d.ts b/ets2panda/linter/test/main/oh_modules/common_ts_ets_api.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0be36a0a8eb13282a0468bccffd1145ad19fc6e1 --- /dev/null +++ b/ets2panda/linter/test/main/oh_modules/common_ts_ets_api.d.ts @@ -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. + */ + +export declare interface IMonitor { + value(path?: string): IMonitorValue | undefined; +} +export declare interface IMonitorValue { + before: T; + now: T; + path: string; +} +export declare class LocalStorage { + get(propName: string): T | undefined; + ref(propName: string): AbstractProperty | undefined; + link(propName: string): SubscribedAbstractProperty | undefined; +} + +export declare class AppStorage { + static get(propName: string): T | undefined; + static ref(propName: string): AbstractProperty | undefined; + static link(propName: string): SubscribedAbstractProperty | undefined; +} + +export declare interface AbstractProperty { + get(): T; + set(newValue: T): void; + info(): string; +} +export declare abstract class SubscribedAbstractProperty { + info(): string; + abstract get(): T; + abstract set(newValue: T): void; + abstract aboutToBeDeleted(): void; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json index b96614d1d1551b528fe6479f872307057c021d46..fe3418b262b571c50dc73f6c3f14f3fcba7aef35 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json @@ -43,9 +43,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 704, + "start": 705, "end": 709, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 24, "column": 3, "endLine": 24, @@ -64,9 +64,9 @@ "problem": "StoragePropDecoratorNotSupported", "autofix": [ { - "start": 895, - "end": 916, - "replacementText": "@StoragePropRef", + "start": 896, + "end": 907, + "replacementText": "StoragePropRef", "line": 34, "column": 3, "endLine": 34, @@ -85,9 +85,9 @@ "problem": "LocalStoragePropDecoratorNotSupported", "autofix": [ { - "start": 944, - "end": 970, - "replacementText": "@LocalStoragePropRef", + "start": 945, + "end": 961, + "replacementText": "LocalStoragePropRef", "line": 35, "column": 3, "endLine": 35, diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets index ca03196a9306b8aabaffa4778e25e96a9aa46a63..598b9e31679d237abf9e60a8f37eecb50dd28a30 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets @@ -44,8 +44,8 @@ struct FatherComponent { @Component struct ChildComponent { - @StoragePropRef user2: User = new User() - @LocalStoragePropRef user3: User = new User() + @StoragePropRef("user2") user2: User = new User() + @LocalStoragePropRef("user3") user3: User = new User() build() { } diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json index 66e9c58bab9d619077975c856be68b9cec1c47f6..e03a31e43e674f46b9dd392f7638beff8289ece4 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json @@ -28,7 +28,7 @@ "line": 47, "column": 3, "endLine": 47, - "endColumn": 18, + "endColumn": 27, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", @@ -38,7 +38,7 @@ "line": 48, "column": 3, "endLine": 48, - "endColumn": 23, + "endColumn": 32, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json index 9a56497197e37b67f43078d6e4eca9c91d8f6e6d..cebe97786c9393b24b42b5afd4db049456941c06 100644 --- a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json @@ -115,9 +115,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 1396, + "start": 1397, "end": 1401, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 58, "column": 3, "endLine": 58, @@ -136,9 +136,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 1710, + "start": 1711, "end": 1715, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 76, "column": 3, "endLine": 76, @@ -199,9 +199,9 @@ "problem": "PropDecoratorNotSupported", "autofix": [ { - "start": 2040, + "start": 2041, "end": 2045, - "replacementText": "@PropRef", + "replacementText": "PropRef", "line": 94, "column": 3, "endLine": 94, diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json index 2247b1cc2e70af1c1a076519ab7bedee45e4528e..d53752ee4808099169beec98c3ba007c4bf70fef 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json @@ -868,7 +868,7 @@ "line": 177, "column": 23, "endLine": 177, - "endColumn": 34, + "endColumn": 44, "problem": "NoNeedStdLibSendableContainer", "suggest": "", "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", @@ -995,4 +995,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json index c63d81f2b66aa51101a405779bdcbd7b1e26967f..efd13151c42adb61ca4eccc3c89d3658bcbe0239 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json @@ -1,6 +1,6 @@ { "copyright": [ - "Copyright (c) 2023-2024 Huawei Device Co., Ltd.", + "Copyright (c) 2024-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", @@ -1374,7 +1374,7 @@ "line": 177, "column": 23, "endLine": 177, - "endColumn": 34, + "endColumn": 44, "problem": "NoNeedStdLibSendableContainer", "autofix": [ { @@ -1384,7 +1384,16 @@ "line": 177, "column": 23, "endLine": 177, - "endColumn": 34 + "endColumn": 44 + }, + { + "start": 713, + "end": 713, + "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", + "line": 177, + "column": 23, + "endLine": 177, + "endColumn": 44 } ], "suggest": "", @@ -1600,4 +1609,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets index 9d61b8611db3da19dc0cfbad2104808d626dda2c..6a3cbe36afb397b39f328e127c7b0533ce69429e 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets @@ -13,6 +13,8 @@ * limitations under the License. */ import {OhosInterface} from './oh_modules/ohos_lib'; +import { BitVector } from "@arkts.collections"; + // #14071 class A { diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json index e2746dde008b85a1c320af9f8162e34e82dd1c34..12bd72ca456622b4c439c477985f0c361bcf2c04 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 22, + "line": 24, "column": 3, - "endLine": 22, + "endLine": 24, "endColumn": 14, "problem": "PropertyAccessByIndex", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 27, "column": 10, - "endLine": 25, + "endLine": 27, "endColumn": 21, "problem": "PropertyAccessByIndex", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 37, + "line": 39, "column": 1, - "endLine": 37, + "endLine": 39, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 38, + "line": 40, "column": 1, - "endLine": 38, + "endLine": 40, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 39, + "line": 41, "column": 1, - "endLine": 39, + "endLine": 41, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 46, + "line": 48, "column": 3, - "endLine": 46, + "endLine": 48, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 50, + "line": 52, "column": 3, - "endLine": 50, + "endLine": 52, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 57, + "line": 59, "column": 5, - "endLine": 57, + "endLine": 59, "endColumn": 29, "problem": "AnyType", "suggest": "", @@ -95,35 +95,15 @@ "severity": "ERROR" }, { - "line": 57, + "line": 59, "column": 14, - "endLine": 57, + "endLine": 59, "endColumn": 29, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, - { - "line": 70, - "column": 1, - "endLine": 70, - "endColumn": 10, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 1, - "endLine": 71, - "endColumn": 10, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 72, "column": 1, @@ -198,7 +178,7 @@ "line": 79, "column": 1, "endLine": 79, - "endColumn": 11, + "endColumn": 10, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", @@ -208,7 +188,7 @@ "line": 80, "column": 1, "endLine": 80, - "endColumn": 11, + "endColumn": 10, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", @@ -265,9 +245,29 @@ "severity": "ERROR" }, { - "line": 97, + "line": 86, "column": 1, - "endLine": 97, + "endLine": 86, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 1, + "endLine": 87, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, "endColumn": 18, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -275,9 +275,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 100, "column": 1, - "endLine": 98, + "endLine": 100, "endColumn": 17, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -285,9 +285,9 @@ "severity": "ERROR" }, { - "line": 99, + "line": 101, "column": 1, - "endLine": 99, + "endLine": 101, "endColumn": 17, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -295,9 +295,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 24, - "endLine": 107, + "endLine": 109, "endColumn": 39, "problem": "ArrayIndexExprType", "suggest": "", @@ -305,9 +305,9 @@ "severity": "ERROR" }, { - "line": 107, + "line": 109, "column": 24, - "endLine": 107, + "endLine": 109, "endColumn": 39, "problem": "BuiltinSymbolIterator", "suggest": "", @@ -315,9 +315,9 @@ "severity": "ERROR" }, { - "line": 108, + "line": 110, "column": 5, - "endLine": 108, + "endLine": 110, "endColumn": 40, "problem": "AnyType", "suggest": "", @@ -325,9 +325,9 @@ "severity": "ERROR" }, { - "line": 117, + "line": 119, "column": 20, - "endLine": 117, + "endLine": 119, "endColumn": 35, "problem": "ArrayIndexExprType", "suggest": "", @@ -335,9 +335,9 @@ "severity": "ERROR" }, { - "line": 117, + "line": 119, "column": 20, - "endLine": 117, + "endLine": 119, "endColumn": 35, "problem": "BuiltinSymbolIterator", "suggest": "", @@ -345,9 +345,9 @@ "severity": "ERROR" }, { - "line": 118, + "line": 120, "column": 5, - "endLine": 118, + "endLine": 120, "endColumn": 36, "problem": "AnyType", "suggest": "", @@ -355,9 +355,9 @@ "severity": "ERROR" }, { - "line": 139, + "line": 141, "column": 12, - "endLine": 139, + "endLine": 141, "endColumn": 31, "problem": "CreatingPrimitiveTypes", "suggest": "", @@ -365,9 +365,9 @@ "severity": "ERROR" }, { - "line": 159, + "line": 161, "column": 3, - "endLine": 159, + "endLine": 161, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -375,9 +375,9 @@ "severity": "ERROR" }, { - "line": 172, + "line": 174, "column": 1, - "endLine": 172, + "endLine": 174, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -385,9 +385,9 @@ "severity": "ERROR" }, { - "line": 173, + "line": 175, "column": 1, - "endLine": 173, + "endLine": 175, "endColumn": 13, "problem": "PropertyAccessByIndex", "suggest": "", @@ -395,9 +395,9 @@ "severity": "ERROR" }, { - "line": 174, + "line": 176, "column": 1, - "endLine": 174, + "endLine": 176, "endColumn": 13, "problem": "PropertyAccessByIndex", "suggest": "", @@ -405,9 +405,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 7, - "endLine": 181, + "endLine": 183, "endColumn": 14, "problem": "PropertyAccessByIndex", "suggest": "", @@ -415,9 +415,9 @@ "severity": "ERROR" }, { - "line": 192, + "line": 194, "column": 1, - "endLine": 192, + "endLine": 194, "endColumn": 5, "problem": "PropertyAccessByIndex", "suggest": "", @@ -425,9 +425,9 @@ "severity": "ERROR" }, { - "line": 193, + "line": 195, "column": 1, - "endLine": 193, + "endLine": 195, "endColumn": 7, "problem": "PropertyAccessByIndex", "suggest": "", @@ -435,9 +435,9 @@ "severity": "ERROR" }, { - "line": 196, + "line": 198, "column": 1, - "endLine": 196, + "endLine": 198, "endColumn": 23, "problem": "PropertyAccessByIndex", "suggest": "", @@ -445,9 +445,9 @@ "severity": "ERROR" }, { - "line": 208, + "line": 210, "column": 1, - "endLine": 208, + "endLine": 210, "endColumn": 20, "problem": "PropertyAccessByIndex", "suggest": "", @@ -455,4 +455,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json index 9a76fd60376d25fe87eb98c5bad5f73c7682fb7c..c285b29dfe12480814ac4c36a17613ddca2ce542 100644 --- a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", "severity": "ERROR" }, + { + "line": 22, + "column": 23, + "endLine": 22, + "endColumn": 30, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 22, "column": 23, @@ -64,6 +74,16 @@ "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", "severity": "ERROR" }, + { + "line": 57, + "column": 23, + "endLine": 57, + "endColumn": 30, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 57, "column": 23, diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.arkts2.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.arkts2.json index e4b1cf0272d520cfef98a19210a6d6f54b659d81..f577df3546443ea934c88f8f1f08741bdcc54c69 100644 --- a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor_2.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", "severity": "ERROR" }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 30, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 29, "column": 23, @@ -55,4 +65,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/subclass_super_call.ets b/ets2panda/linter/test/main/subclass_super_call.ets index 7e8034806431ea58a666b1a78cf468910585e6f3..2ed960ed9071cc0141abcf6db8a1abe4ff6985bb 100644 --- a/ets2panda/linter/test/main/subclass_super_call.ets +++ b/ets2panda/linter/test/main/subclass_super_call.ets @@ -83,3 +83,21 @@ class EpicBar extends Error { super("foo") } } + +export enum EEE { + E1, + E2, +} + +export class A { + protected _e:EEE + constructor(e: EEE) { + this._e = e; + } +} + +class B extends A { + constructor() { + super(EEE.E1) + } +} diff --git a/ets2panda/linter/test/main/swicth_expr.ets b/ets2panda/linter/test/main/swicth_expr.ets index 45055cf2effb98cfa502ee3854ea24d1305b1372..f44ab3e8e278572230b170104e0cbdd99d03e9c1 100755 --- a/ets2panda/linter/test/main/swicth_expr.ets +++ b/ets2panda/linter/test/main/swicth_expr.ets @@ -193,7 +193,6 @@ switch (num1) { console.log('Other number'); } -1.0 let num111 = 1.0; switch (num111) { case 1.0: @@ -230,7 +229,7 @@ switch (isnum1) { default: console.log('F'); } -// 整型 5.2fail + type sw1 = number function FunSw4(): sw1 { @@ -245,7 +244,6 @@ switch (FunSw4()) { console.log('F'); } -// 浮点 5.2fail type sw2 = number | string function FunSw5(): sw2 { @@ -299,7 +297,6 @@ switch (FunSw2()) { console.log('F'); } -// 正无穷 let number4 = Infinity; switch (number4) { case Infinity: @@ -309,7 +306,6 @@ switch (number4) { console.log("Default case"); } -// 负无穷 let number5 = -Infinity; switch (number5) { case -Infinity: @@ -319,7 +315,6 @@ switch (number5) { console.log("Default case"); } -// NaN let number6 = NaN; switch (number6) { case NaN: @@ -338,7 +333,6 @@ switch (num111) { console.log('Other number'); } -// let声明整型,case浮点 let number33: number = 1; switch (number33) { case 1.1: @@ -354,7 +348,6 @@ switch (number33) { console.log("Default case"); } -// const声明,整型number,有类型 const num11: number = 2; switch (num11) { case 1: { @@ -367,7 +360,6 @@ switch (num11) { } } -// let声明,整型number,有类型 let num00: number = 2; switch (num00) { case 1: { @@ -380,7 +372,6 @@ switch (num00) { } } - enum Direction1 { North, South, @@ -390,7 +381,7 @@ enum Direction1 { function funSE() : string | Direction1 { return 'aaa' } -switch (funSE()) { // 误报 +switch (funSE()) { case 'aaa': console.log('aaa'); break; @@ -401,14 +392,20 @@ switch (funSE()) { // 误报 console.log('F'); } - enum H { RED, BLUE } -function foo11(e: H) { // 误报 +function foo11(e: H) { switch (e) { case H.RED: } } +function foo(index: number) { + switch (index) { + case 0: + break; + } +} + diff --git a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json index 207e0d7ebf74d0b53f12ef7ce8e7538c45e99f3e..3fbbc5b9b538f022d1af56aaa7a7b92d148f2579 100755 --- a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json +++ b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json @@ -21,7 +21,7 @@ "endColumn": 15, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -41,7 +41,7 @@ "endColumn": 17, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 19, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ "endColumn": 16, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -244,16 +244,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 91, - "column": 9, - "endLine": 91, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 95, "column": 8, @@ -274,16 +264,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 101, - "column": 9, - "endLine": 101, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 105, "column": 8, @@ -311,7 +291,7 @@ "endColumn": 12, "problem": "SwitchExpression", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "The switch expression type must be of type number, string or enum (arkts-switch-expr)", "severity": "ERROR" }, { @@ -394,16 +374,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 140, - "column": 11, - "endLine": 140, - "endColumn": 19, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 141, "column": 10, @@ -434,16 +404,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 152, - "column": 9, - "endLine": 152, - "endColumn": 14, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 153, "column": 8, @@ -514,16 +474,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 176, - "column": 9, - "endLine": 176, - "endColumn": 14, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, { "line": 177, "column": 8, @@ -575,9 +525,9 @@ "severity": "ERROR" }, { - "line": 197, + "line": 196, "column": 5, - "endLine": 197, + "endLine": 196, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -585,19 +535,9 @@ "severity": "ERROR" }, { - "line": 198, - "column": 9, - "endLine": 198, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 206, + "line": 205, "column": 7, - "endLine": 206, + "endLine": 205, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -605,9 +545,9 @@ "severity": "ERROR" }, { - "line": 206, + "line": 205, "column": 19, - "endLine": 206, + "endLine": 205, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -615,9 +555,9 @@ "severity": "ERROR" }, { - "line": 208, + "line": 207, "column": 8, - "endLine": 208, + "endLine": 207, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -625,9 +565,9 @@ "severity": "ERROR" }, { - "line": 211, + "line": 210, "column": 8, - "endLine": 211, + "endLine": 210, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -635,9 +575,9 @@ "severity": "ERROR" }, { - "line": 216, + "line": 215, "column": 13, - "endLine": 216, + "endLine": 215, "endColumn": 32, "problem": "CreatingPrimitiveTypes", "suggest": "", @@ -645,9 +585,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 224, "column": 31, - "endLine": 225, + "endLine": 224, "endColumn": 32, "problem": "NumericSemantics", "suggest": "", @@ -655,19 +595,9 @@ "severity": "ERROR" }, { - "line": 226, - "column": 9, - "endLine": 226, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 237, + "line": 236, "column": 10, - "endLine": 237, + "endLine": 236, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -676,18 +606,8 @@ }, { "line": 240, - "column": 9, - "endLine": 240, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 241, "column": 8, - "endLine": 241, + "endLine": 240, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -695,19 +615,9 @@ "severity": "ERROR" }, { - "line": 255, - "column": 9, - "endLine": 255, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 263, + "line": 261, "column": 5, - "endLine": 263, + "endLine": 261, "endColumn": 30, "problem": "NumericSemantics", "suggest": "", @@ -715,29 +625,9 @@ "severity": "ERROR" }, { - "line": 264, - "column": 9, - "endLine": 264, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 271, + "line": 269, "column": 9, - "endLine": 271, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 271, - "column": 9, - "endLine": 271, + "endLine": 269, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -745,9 +635,9 @@ "severity": "ERROR" }, { - "line": 279, + "line": 277, "column": 7, - "endLine": 279, + "endLine": 277, "endColumn": 27, "problem": "NumericSemantics", "suggest": "", @@ -755,9 +645,9 @@ "severity": "ERROR" }, { - "line": 279, + "line": 277, "column": 21, - "endLine": 279, + "endLine": 277, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -765,9 +655,9 @@ "severity": "ERROR" }, { - "line": 279, + "line": 277, "column": 25, - "endLine": 279, + "endLine": 277, "endColumn": 26, "problem": "NumericSemantics", "suggest": "", @@ -775,19 +665,9 @@ "severity": "ERROR" }, { - "line": 280, - "column": 9, - "endLine": 280, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 281, + "line": 279, "column": 8, - "endLine": 281, + "endLine": 279, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -795,9 +675,9 @@ "severity": "ERROR" }, { - "line": 284, + "line": 282, "column": 8, - "endLine": 284, + "endLine": 282, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -805,19 +685,9 @@ "severity": "ERROR" }, { - "line": 294, - "column": 9, - "endLine": 294, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 303, + "line": 300, "column": 5, - "endLine": 303, + "endLine": 300, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -825,19 +695,9 @@ "severity": "ERROR" }, { - "line": 304, - "column": 9, - "endLine": 304, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 313, + "line": 309, "column": 5, - "endLine": 313, + "endLine": 309, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -845,19 +705,9 @@ "severity": "ERROR" }, { - "line": 314, - "column": 9, - "endLine": 314, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 323, + "line": 318, "column": 5, - "endLine": 323, + "endLine": 318, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -865,19 +715,9 @@ "severity": "ERROR" }, { - "line": 324, - "column": 9, - "endLine": 324, - "endColumn": 16, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 332, + "line": 327, "column": 5, - "endLine": 332, + "endLine": 327, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -885,19 +725,9 @@ "severity": "ERROR" }, { - "line": 333, - "column": 9, - "endLine": 333, - "endColumn": 15, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 342, + "line": 336, "column": 24, - "endLine": 342, + "endLine": 336, "endColumn": 25, "problem": "NumericSemantics", "suggest": "", @@ -905,19 +735,9 @@ "severity": "ERROR" }, { - "line": 343, - "column": 9, - "endLine": 343, - "endColumn": 17, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 347, + "line": 341, "column": 8, - "endLine": 347, + "endLine": 341, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -925,9 +745,9 @@ "severity": "ERROR" }, { - "line": 350, + "line": 344, "column": 8, - "endLine": 350, + "endLine": 344, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -935,9 +755,9 @@ "severity": "ERROR" }, { - "line": 358, + "line": 351, "column": 23, - "endLine": 358, + "endLine": 351, "endColumn": 24, "problem": "NumericSemantics", "suggest": "", @@ -945,19 +765,9 @@ "severity": "ERROR" }, { - "line": 359, - "column": 9, - "endLine": 359, - "endColumn": 14, - "problem": "SwitchExpression", - "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", - "severity": "ERROR" - }, - { - "line": 360, + "line": 353, "column": 8, - "endLine": 360, + "endLine": 353, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -965,9 +775,9 @@ "severity": "ERROR" }, { - "line": 364, + "line": 357, "column": 8, - "endLine": 364, + "endLine": 357, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -975,9 +785,9 @@ "severity": "ERROR" }, { - "line": 371, + "line": 363, "column": 21, - "endLine": 371, + "endLine": 363, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -985,19 +795,19 @@ "severity": "ERROR" }, { - "line": 372, - "column": 9, - "endLine": 372, - "endColumn": 14, - "problem": "SwitchExpression", + "line": 365, + "column": 8, + "endLine": 365, + "endColumn": 9, + "problem": "NumericSemantics", "suggest": "", - "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 373, + "line": 369, "column": 8, - "endLine": 373, + "endLine": 369, "endColumn": 9, "problem": "NumericSemantics", "suggest": "", @@ -1005,10 +815,10 @@ "severity": "ERROR" }, { - "line": 377, - "column": 8, - "endLine": 377, - "endColumn": 9, + "line": 407, + "column": 10, + "endLine": 407, + "endColumn": 11, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", diff --git a/ets2panda/linter/test/main/ui_modules/@kit.ArkUI.d.ts b/ets2panda/linter/test/main/ui_modules/@kit.ArkUI.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf71890e70f66a55e52e5cc7d90ca8f1207ca921 --- /dev/null +++ b/ets2panda/linter/test/main/ui_modules/@kit.ArkUI.d.ts @@ -0,0 +1,17 @@ +/* + * 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 { BuilderNode } from './@ohos.arkui.node'; +export { BuilderNode }; \ No newline at end of file diff --git a/ets2panda/linter/test/main/ui_modules/@ohos.arkui.node.d.ts b/ets2panda/linter/test/main/ui_modules/@ohos.arkui.node.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbf489a77f1f965c1b646aa2e464ea4a2ce2b206 --- /dev/null +++ b/ets2panda/linter/test/main/ui_modules/@ohos.arkui.node.d.ts @@ -0,0 +1,16 @@ +/* + * 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. + */ + +export { BuilderNode } from './BuilderNode'; \ No newline at end of file diff --git a/ets2panda/linter/test/main/ui_modules/BuilderNode.d.ts b/ets2panda/linter/test/main/ui_modules/BuilderNode.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae79a092ff2c1ab1330a7637f53ae2f24c20ea26 --- /dev/null +++ b/ets2panda/linter/test/main/ui_modules/BuilderNode.d.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export class BuilderNode { + build(): void; + update(): void; + reuse(): void; +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.arkts2.json b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.arkts2.json index 301eb21df38fa5d991e9e5f3de784693eeaacc11..1c422977b254cf24de2672ba19d19aad0a6f135b 100644 --- a/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/wrapped_builder_generic_1.ets.arkts2.json @@ -21,17 +21,7 @@ "endColumn": 56, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 59, - "endLine": 22, - "endColumn": 81, - "problem": "WrappedBuilderGenericNeedArrowFunc", - "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -41,7 +31,7 @@ "endColumn": 56, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -49,9 +39,9 @@ "column": 59, "endLine": 23, "endColumn": 99, - "problem": "WrappedBuilderGenericNeedArrowFunc", + "problem": "WrapBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -61,7 +51,7 @@ "endColumn": 56, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -71,7 +61,7 @@ "endColumn": 88, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -91,7 +81,7 @@ "endColumn": 56, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -101,7 +91,7 @@ "endColumn": 106, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.arkts2.json b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.arkts2.json index a66118bc68d92ad987c1ba64e5acf3aa29f87ac3..735f83a19040fec8cf34dad391dad78b8fa560d0 100644 --- a/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/wrapped_builder_generic_2.ets.arkts2.json @@ -21,27 +21,7 @@ "endColumn": 52, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 58, - "endLine": 29, - "endColumn": 80, - "problem": "WrappedBuilderGenericNeedArrowFunc", - "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 82, - "endLine": 29, - "endColumn": 106, - "problem": "WrappedBuilderGenericNeedArrowFunc", - "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -51,7 +31,7 @@ "endColumn": 52, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -59,9 +39,9 @@ "column": 58, "endLine": 30, "endColumn": 98, - "problem": "WrappedBuilderGenericNeedArrowFunc", + "problem": "WrapBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -69,9 +49,9 @@ "column": 100, "endLine": 30, "endColumn": 142, - "problem": "WrappedBuilderGenericNeedArrowFunc", + "problem": "WrapBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"wrapBuilder\", generics must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -81,7 +61,7 @@ "endColumn": 52, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -91,7 +71,7 @@ "endColumn": 87, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -111,7 +91,7 @@ "endColumn": 120, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -131,7 +111,7 @@ "endColumn": 52, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -141,7 +121,7 @@ "endColumn": 105, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -161,7 +141,7 @@ "endColumn": 156, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -181,7 +161,7 @@ "endColumn": 65, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -201,7 +181,7 @@ "endColumn": 65, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -221,7 +201,7 @@ "endColumn": 65, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { @@ -241,7 +221,7 @@ "endColumn": 65, "problem": "WrappedBuilderGenericNeedArrowFunc", "suggest": "", - "rule": "When using \"WrappedBuilder\" and \"wrapBuilder\", generics are required and must be declared as arrow function (arkui-wrapbuilder-require-arrow-func-generic)", + "rule": "When using \"WrappedBuilder\", generics are required and must be declared as arrow function (arkui-wrappedbuilder-require-arrow-func-generic)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json index d351a537bd6a910bd2443741e098df05f14db2d7..76d25532694166291452e1d717bbc7c68b7b324b 100644 --- a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json @@ -194,6 +194,16 @@ "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", "severity": "ERROR" }, + { + "line": 54, + "column": 15, + "endLine": 54, + "endColumn": 37, + "problem": "ParameterType", + "suggest": "", + "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", + "severity": "ERROR" + }, { "line": 54, "column": 15, @@ -425,4 +435,4 @@ "severity": "ERROR" } ] -} \ No newline at end of file +}