From 98bae3a253df14002acf1d89d57a58e2f8da6576 Mon Sep 17 00:00:00 2001 From: ZhongNing Date: Fri, 1 Aug 2025 15:12:31 +0800 Subject: [PATCH] Add for BuiltIn Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICQDZ4 Test scenarios: update Require Signed-off-by: ZhongNing --- ets2panda/linter/rule-config.json | 8 +- ets2panda/linter/src/lib/CookBookMsg.ts | 7 + ets2panda/linter/src/lib/FaultAttrs.ts | 6 + ets2panda/linter/src/lib/FaultDesc.ts | 6 + ets2panda/linter/src/lib/Problems.ts | 6 + ets2panda/linter/src/lib/TypeScriptLinter.ts | 560 ++++-- .../linter/src/lib/data/BuiltinList.json | 1675 ++++++++++++++++- .../src/lib/utils/consts/BuiltinWhiteList.ts | 31 +- .../lib/utils/consts/DeprecateWhiteList.ts | 1 + .../consts/SdkCommonDeprecateWhiteList.ts | 1 + .../test/builtin/builtin_array_negative.ets | 78 + .../builtin_array_negative.ets.args.json | 19 + .../builtin_array_negative.ets.arkts2.json | 398 ++++ .../builtin/builtin_array_negative.ets.json | 78 + .../test/builtin/builtin_array_positive.ets | 25 + .../builtin_array_positive.ets.args.json | 19 + .../builtin_array_positive.ets.arkts2.json | 108 ++ .../builtin/builtin_array_positive.ets.json | 58 + .../builtin_callsignature.ets.arkts2.json | 10 + .../linter/test/builtin/builtin_class.ets | 102 + .../test/builtin/builtin_class.ets.args.json | 19 + .../builtin/builtin_class.ets.arkts2.json | 668 +++++++ .../test/builtin/builtin_class.ets.json | 68 + .../linter/test/builtin/builtin_decorator.ets | 229 +++ .../builtin/builtin_decorator.ets.args.json | 19 + .../builtin/builtin_decorator.ets.arkts2.json | 878 +++++++++ .../test/builtin/builtin_decorator.ets.json | 78 + .../test/builtin/builtin_error_negative.ets | 53 + .../builtin_error_negative.ets.args.json | 19 + .../builtin_error_negative.ets.arkts2.json | 238 +++ .../builtin/builtin_error_negative.ets.json | 17 + .../test/builtin/builtin_error_positive.ets | 20 + .../builtin_error_positive.ets.args.json | 19 + .../builtin_error_positive.ets.arkts2.json | 17 + .../builtin/builtin_error_positive.ets.json | 17 + .../test/builtin/builtin_iterator_result.ets | 21 + .../builtin_iterator_result.ets.args.json | 19 + .../builtin_iterator_result.ets.arkts2.json | 48 + .../builtin/builtin_iterator_result.ets.json | 17 + ...upport_property_descriptor.ets.arkts2.json | 160 ++ .../test/builtin/builtin_object_negative.ets | 114 ++ .../builtin_object_negative.ets.args.json | 19 + .../builtin_object_negative.ets.arkts2.json | 528 ++++++ .../builtin/builtin_object_negative.ets.json | 68 + .../test/builtin/builtin_object_positive.ets | 30 + .../builtin_object_positive.ets.args.json | 19 + .../builtin_object_positive.ets.arkts2.json | 68 + .../builtin/builtin_object_positive.ets.json | 17 + .../linter/test/builtin/builtin_thisArgs.ets | 2 +- .../builtin/builtin_thisArgs.ets.arkts2.json | 10 + .../builtin/builtin_uninitialized_element.ets | 29 + ...uiltin_uninitialized_element.ets.args.json | 19 + ...ltin_uninitialized_element.ets.arkts2.json | 228 +++ .../builtin_uninitialized_element.ets.json | 38 + .../action_sheet.ets.arkts2.json | 20 + .../deprecated_api_font.ets.arkts2.json | 10 + .../interop_convert_import.ets.arkts2.json | 10 + .../interop_convert_import.ets.autofix.json | 10 + .../interop_convert_import.ets.migrate.json | 10 + .../interop/object_built_in.ets.arkts2.json | 20 + .../interop/reflect_built_in.ets.arkts2.json | 72 +- ...arkts-array-type-immutable.ets.arkts2.json | 50 + ...imitive-type-normalization.ets.arkts2.json | 80 + ...o_signature_public_obj_api.ets.arkts2.json | 60 + .../main/arktsutils_module.ets.migrate.json | 80 + .../test/main/class_as_object.ets.arkts2.json | 110 ++ .../main/collections_module.ets.migrate.json | 40 + ...common_union_member_access.ets.arkts2.json | 23 +- .../func_inferred_type_args.ets.arkts2.json | 70 + .../func_inferred_type_args_2.ets.arkts2.json | 110 ++ ...func_inferred_type_args_2.ets.autofix.json | 110 ++ ...func_inferred_type_args_2.ets.migrate.json | 110 ++ .../test/main/limit_void_type.ets.arkts2.json | 10 + .../main/limit_void_type.ets.autofix.json | 10 + .../main/limit_void_type.ets.migrate.json | 10 + .../main/limited_stdlib_api.ets.arkts2.json | 80 + .../main/method_inheritance.ets.arkts2.json | 10 + .../test/main/no_sparse_array.ets.arkts2.json | 50 + .../main/no_sparse_array2.ets.arkts2.json | 50 + .../no_ts_like_smart_type.ets.arkts2.json | 40 + .../main/no_tuples_arrays.ets.arkts2.json | 50 + .../main/numeric_semantics.ets.arkts2.json | 20 + .../main/numeric_semantics.ets.autofix.json | 20 + .../main/numeric_semantics.ets.migrate.json | 20 + .../main/persist_serial_1.ets.arkts2.json | 70 + .../main/persist_serial_2.ets.arkts2.json | 60 + .../property_access_by_index.ets.arkts2.json | 90 + .../property_access_by_index.ets.autofix.json | 90 + .../property_access_by_index.ets.migrate.json | 90 + .../main/repeat_virtualscroll.ets.arkts2.json | 40 + .../repeat_virtualscroll.ets.autofix.json | 40 + .../repeat_virtualscroll.ets.migrate.json | 43 +- .../main/runtime_array_bound.ets.arkts2.json | 110 ++ .../main/runtime_array_bound.ets.migrate.json | 110 ++ .../main/structural_identity.ets.arkts2.json | 10 + ...ntity_extended_inheritance.ets.arkts2.json | 10 + .../test/main/swicth_expr.ets.arkts2.json | 10 + ...taskpool_deprecated_usages.ets.arkts2.json | 10 + .../test/main/ts_overload.ets.arkts2.json | 10 + .../linter/test/rules/rule207.ets.arkts2.json | 30 + .../linter/test/rules/rule37.ets.arkts2.json | 100 + .../linter/test/rules/rule37.ets.autofix.json | 202 +- .../linter/test/rules/rule37.ets.migrate.json | 273 ++- .../linter/test/sdkcommonapi/sdk_url.ets | 6 +- .../test/sdkcommonapi/sdk_url.ets.arkts2.json | 30 + .../test/sdkcommonapi/sdk_xml.ets.arkts2.json | 20 + ...cl_with_duplicate_name_sdk.ets.arkts2.json | 10 + 107 files changed, 9685 insertions(+), 153 deletions(-) create mode 100755 ets2panda/linter/test/builtin/builtin_array_negative.ets create mode 100755 ets2panda/linter/test/builtin/builtin_array_negative.ets.args.json create mode 100755 ets2panda/linter/test/builtin/builtin_array_negative.ets.arkts2.json create mode 100755 ets2panda/linter/test/builtin/builtin_array_negative.ets.json create mode 100755 ets2panda/linter/test/builtin/builtin_array_positive.ets create mode 100755 ets2panda/linter/test/builtin/builtin_array_positive.ets.args.json create mode 100755 ets2panda/linter/test/builtin/builtin_array_positive.ets.arkts2.json create mode 100755 ets2panda/linter/test/builtin/builtin_array_positive.ets.json create mode 100755 ets2panda/linter/test/builtin/builtin_class.ets create mode 100755 ets2panda/linter/test/builtin/builtin_class.ets.args.json create mode 100755 ets2panda/linter/test/builtin/builtin_class.ets.arkts2.json create mode 100755 ets2panda/linter/test/builtin/builtin_class.ets.json create mode 100644 ets2panda/linter/test/builtin/builtin_decorator.ets create mode 100644 ets2panda/linter/test/builtin/builtin_decorator.ets.args.json create mode 100644 ets2panda/linter/test/builtin/builtin_decorator.ets.arkts2.json create mode 100644 ets2panda/linter/test/builtin/builtin_decorator.ets.json create mode 100755 ets2panda/linter/test/builtin/builtin_error_negative.ets create mode 100755 ets2panda/linter/test/builtin/builtin_error_negative.ets.args.json create mode 100755 ets2panda/linter/test/builtin/builtin_error_negative.ets.arkts2.json create mode 100755 ets2panda/linter/test/builtin/builtin_error_negative.ets.json create mode 100755 ets2panda/linter/test/builtin/builtin_error_positive.ets create mode 100755 ets2panda/linter/test/builtin/builtin_error_positive.ets.args.json create mode 100755 ets2panda/linter/test/builtin/builtin_error_positive.ets.arkts2.json create mode 100755 ets2panda/linter/test/builtin/builtin_error_positive.ets.json create mode 100644 ets2panda/linter/test/builtin/builtin_iterator_result.ets create mode 100644 ets2panda/linter/test/builtin/builtin_iterator_result.ets.args.json create mode 100644 ets2panda/linter/test/builtin/builtin_iterator_result.ets.arkts2.json create mode 100644 ets2panda/linter/test/builtin/builtin_iterator_result.ets.json create mode 100755 ets2panda/linter/test/builtin/builtin_object_negative.ets create mode 100755 ets2panda/linter/test/builtin/builtin_object_negative.ets.args.json create mode 100755 ets2panda/linter/test/builtin/builtin_object_negative.ets.arkts2.json create mode 100755 ets2panda/linter/test/builtin/builtin_object_negative.ets.json create mode 100755 ets2panda/linter/test/builtin/builtin_object_positive.ets create mode 100755 ets2panda/linter/test/builtin/builtin_object_positive.ets.args.json create mode 100755 ets2panda/linter/test/builtin/builtin_object_positive.ets.arkts2.json create mode 100755 ets2panda/linter/test/builtin/builtin_object_positive.ets.json create mode 100644 ets2panda/linter/test/builtin/builtin_uninitialized_element.ets create mode 100644 ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.args.json create mode 100644 ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.arkts2.json create mode 100644 ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.json diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index ac4230ae61..2b4b13d656 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -151,7 +151,13 @@ "arkts-builtin-thisArgs", "arkts-builtin-symbol-iterator", "arkts-builtin-no-property-descriptor", - "arkts-builtin-cotr" + "arkts-builtin-cotr", + "arkts-builtin-new-cotr", + "arkts-builtin-uninitialized-element", + "arkts-builtin-final-class", + "arkts-builtin-narrow-types", + "arkts-builtin-disable-api", + "arkts-builtin-iterator-result-value" ], "OHMURL": [ "arkts-require-fullpath-name" diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 0536594a90..eb595308ca 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -425,6 +425,13 @@ cookBookTag[399] = 'ArkUI deprecated api check (arkui-no-deprecated-api)'; cookBookTag[400] = 'ArkUI sdk common deprecated api check (arkui-sdk-common-deprecated-api)'; cookBookTag[401] = 'ArkUI sdk common whitelist api check (arkui-sdk-common-whitelist-api)'; cookBookTag[402] = 'ArkUI sdk common behavior change api check (arkui-sdk-common-behaviorchange-api)'; +cookBookTag[403] = 'API is not support initial ctor signature (arkts-builtin-new-cotr)'; +cookBookTag[404] = + 'Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)'; +cookBookTag[405] = 'API is not support use class in this API (arkts-builtin-final-class)'; +cookBookTag[406] = 'Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)'; +cookBookTag[407] = 'API has been disabled (arkts-builtin-disable-api)'; +cookBookTag[408] = 'The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)'; for (let i = 0; i <= cookBookTag.length; i++) { cookBookMsg[i] = ''; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index a3de17fb3f..d7d64f4e67 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -299,3 +299,9 @@ faultsAttrs[FaultID.NoDeprecatedApi] = new FaultAttributes(399); faultsAttrs[FaultID.SdkCommonApiDeprecated] = new FaultAttributes(400); faultsAttrs[FaultID.SdkCommonApiWhiteList] = new FaultAttributes(401); faultsAttrs[FaultID.SdkCommonApiBehaviorChange] = new FaultAttributes(402); +faultsAttrs[FaultID.BuiltinNewCtor] = new FaultAttributes(403); +faultsAttrs[FaultID.UninitializedArrayElements] = new FaultAttributes(404, ProblemSeverity.WARNING); +faultsAttrs[FaultID.BuiltinFinalClass] = new FaultAttributes(405); +faultsAttrs[FaultID.BuiltinNarrowTypes] = new FaultAttributes(406); +faultsAttrs[FaultID.BuiltinDisableApi] = new FaultAttributes(407); +faultsAttrs[FaultID.BuiltinIteratorResultValue] = new FaultAttributes(408); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index f6cd393f2c..eebe9aef41 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -289,3 +289,9 @@ faultDesc[FaultID.SdkCommonApiBehaviorChange] = 'ArkUI sdk common behavior chang faultDesc[FaultID.PersistentPropNeedImplementMethod] = 'Serialization needs class to implement the specific methods'; faultDesc[FaultID.PersistentPropsNeedImplementMethod] = 'Serialization needs class to implement the specific methods'; faultDesc[FaultID.PersistenceV2ConnectNeedAddParam] = 'Serialization needs class to implement the specific methods'; +faultDesc[FaultID.BuiltinNewCtor] = 'Api is not support ctor-signature in builtin'; +faultDesc[FaultID.UninitializedArrayElements] = 'Uninitialized array elements'; +faultDesc[FaultID.BuiltinFinalClass] = 'Not support use class in this APIe'; +faultDesc[FaultID.BuiltinNarrowTypes] = 'Using narrowing of types is not allowed'; +faultDesc[FaultID.BuiltinDisableApi] = 'Disable Api'; +faultDesc[FaultID.BuiltinIteratorResultValue] = 'IteratorResult.value is not supported'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index 60422d36c5..99bdbd2687 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -288,6 +288,12 @@ export enum FaultID { PersistentPropNeedImplementMethod, PersistentPropsNeedImplementMethod, PersistenceV2ConnectNeedAddParam, + BuiltinNewCtor, + UninitializedArrayElements, + BuiltinFinalClass, + BuiltinNarrowTypes, + BuiltinDisableApi, + BuiltinIteratorResultValue, // 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 5e7a8387f8..c2f34353a2 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -65,7 +65,20 @@ import { } from './utils/consts/SendableAPI'; import { DEFAULT_COMPATIBLE_SDK_VERSION, DEFAULT_COMPATIBLE_SDK_VERSION_STAGE } from './utils/consts/VersionInfo'; import { TYPED_ARRAYS } from './utils/consts/TypedArrays'; -import { BUILTIN_CONSTRUCTORS, COLLECTION_METHODS, COLLECTION_TYPES } from './utils/consts/BuiltinWhiteList'; +import { + BuiltinProblem, + BuiltinProblemInfos, + SYMBOL_ITERATOR, + BUILTIN_CONSTRUCTORS, + COLLECTION_METHODS, + COLLECTION_TYPES, + BUILTIN_TYPE, + BUILTIN_DISABLE_CALLSIGNATURE, + GET_OWN_PROPERTY_NAMES_TEXT, + BUILTIN_CONSTRUCTOR_API_TYPE, + BUILTIN_CONSTRUCTOR_API_NAME, + BUILTIN_CALLSIGNATURE_NEWCTOR +} from './utils/consts/BuiltinWhiteList'; import { forEachNodeInSubtree } from './utils/functions/ForEachNodeInSubtree'; import { hasPredecessor } from './utils/functions/HasPredecessor'; import { isStdLibrarySymbol, isStdLibraryType } from './utils/functions/IsStdLibrary'; @@ -163,15 +176,15 @@ import { SDK_COMMON_FUNCTIONLIKE, SDK_COMMON_PROPERTYLIKE, SDK_COMMON_CONSTRUCTORLIKE, - SDK_COMMON_TYPEKEY + SDK_COMMON_TYPEKEY, + SDK_COMMON_TYPE } from './utils/consts/SdkCommonDeprecateWhiteList'; -import { DeprecateProblem, DEPRECATE_CHECK_KEY, DEPRECATE_UNNAMED } from './utils/consts/DeprecateWhiteList'; import { - BuiltinProblem, - SYMBOL_ITERATOR, - BUILTIN_DISABLE_CALLSIGNATURE, - GET_OWN_PROPERTY_NAMES_TEXT -} from './utils/consts/BuiltinWhiteList'; + DeprecateProblem, + DEPRECATE_CHECK_KEY, + DEPRECATE_UNNAMED, + DEPRECATE_TYPE +} from './utils/consts/DeprecateWhiteList'; import { USE_SHARED, USE_CONCURRENT, @@ -231,6 +244,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { static pathMap: Map>; static indexedTypeSet: Set; static globalApiInfo: Map>; + static builtApiInfo: Set; + static builtinNewCtorSet: Set; + static builtinFinalClassSet: Set; static deprecatedApiInfo: Set; static sdkCommonApiInfo: Set; static sdkCommonSymbotIterSet: Set; @@ -248,6 +264,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { TypeScriptLinter.nameSpaceFunctionCache = new Map>(); TypeScriptLinter.pathMap = new Map>(); TypeScriptLinter.globalApiInfo = new Map>(); + TypeScriptLinter.builtApiInfo = new Set(); + TypeScriptLinter.builtinNewCtorSet = new Set(); + TypeScriptLinter.builtinFinalClassSet = new Set(); TypeScriptLinter.deprecatedApiInfo = new Set(); TypeScriptLinter.sdkCommonApiInfo = new Set(); TypeScriptLinter.funcMap = new Map>>(); @@ -282,6 +301,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { case BuiltinProblem.LimitedThisArg: TypeScriptLinter.initSdkBuiltinThisArgsWhitelist(item); break; + case BuiltinProblem.BuiltinNewCtor: + TypeScriptLinter.builtinNewCtorSet.add(item); + break; + case BuiltinProblem.BuiltinFinalClass: + TypeScriptLinter.builtinFinalClassSet.add(item); + break; default: } } @@ -376,6 +401,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const list: ApiList = new ApiList(builtinWhiteList); if (list?.api_list?.length > 0) { for (const item of list.api_list) { + this.builtApiInfo.add(item); TypeScriptLinter.addGlobalApiInfosCollocetionData(item); } } @@ -1453,6 +1479,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkFunctionProperty(propertyAccessNode, baseExprSym, baseExprType); this.handleSdkForConstructorFuncs(propertyAccessNode); this.fixJsImportPropertyAccessExpression(node); + this.handleBuiltinIteratorResult(propertyAccessNode); } private handlePropertyAccessExpressionForUI(node: ts.PropertyAccessExpression): void { @@ -6458,6 +6485,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleInstantiatedJsObject(tsNewExpr, sym); this.handlePromiseNeedVoidResolve(tsNewExpr); this.handleFunctionReturnThisCall(tsNewExpr); + this.checkArrayInitialization(tsNewExpr); } handlePromiseNeedVoidResolve(newExpr: ts.NewExpression): void { @@ -7549,6 +7577,16 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } this.handleNotSupportCustomDecorators(decorator); + switch (decorator.parent.kind) { + case ts.SyntaxKind.PropertyDeclaration: + case ts.SyntaxKind.ClassDeclaration: + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.Parameter: + this.handleBuiltinDisableDecorator(decorator); + break; + default: + break; + } } private handleProvideDecorator(node: ts.Node): void { @@ -8399,6 +8437,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.options.arkts2) { return; } + this.handleNoDeprecatedApi(node as ts.TaggedTemplateExpression); this.incrementCounters(node, FaultID.TaggedTemplates); } @@ -10944,7 +10983,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ) { continue; } - this.handleExtendCustomClassForSdkCommonApiDeprecated(extendedClassName, superCall); + this.handleExtendCustomClassForSdkApiDeprecated(extendedClassName, superCall, SDK_COMMON_TYPE); + this.handleExtendCustomClassForSdkApiDeprecated(extendedClassName, superCall, BUILTIN_TYPE); return; } @@ -10996,20 +11036,26 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); } - private handleExtendCustomClassForSdkCommonApiDeprecated( + private handleExtendCustomClassForSdkApiDeprecated( extendedClassName: string, - superCall: ts.CallExpression + superCall: ts.CallExpression, + apiType: string ): void { - const problemStr = TypeScriptLinter.getFaultIdSdkCommonApiInfoWithConstructorDecl(extendedClassName); + const problemStr = TypeScriptLinter.getFaultIdSdkApiInfoWithConstructorDecl(extendedClassName, apiType); if (problemStr) { const faultID = sdkCommonAllDeprecatedTypeName.has(extendedClassName) ? FaultID.SdkCommonApiDeprecated : - TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr); + TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr, apiType); + if (!faultID) { + return; + } this.incrementCounters( superCall, faultID, undefined, - TypeScriptLinter.getErrorMsgForSdkCommonApi(extendedClassName, faultID) + apiType === SDK_COMMON_TYPE ? + TypeScriptLinter.getErrorMsgForSdkCommonApi(extendedClassName, faultID) : + undefined ); } } @@ -13521,6 +13567,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { | ts.PropertyAccessExpression | ts.ElementAccessExpression | ts.HeritageClause + | ts.TaggedTemplateExpression ): void { if (!this.options.arkts2) { return; @@ -13543,8 +13590,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkMethodDeclarationForDeprecatedApi(node); break; case ts.SyntaxKind.PropertyAssignment: - this.checkPropertyAssignmentForDeprecatedApi(node); - break; + case ts.SyntaxKind.TaggedTemplateExpression: case ts.SyntaxKind.NewExpression: case ts.SyntaxKind.CallExpression: case ts.SyntaxKind.BinaryExpression: @@ -13563,6 +13609,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { | ts.BinaryExpression | ts.PropertyAccessExpression | ts.ElementAccessExpression + | ts.TaggedTemplateExpression + | ts.PropertyAssignment ): void { switch (node.kind) { case ts.SyntaxKind.NewExpression: @@ -13580,6 +13628,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { case ts.SyntaxKind.ElementAccessExpression: this.checkSdkCommonOnElementAccess(node); break; + case ts.SyntaxKind.TaggedTemplateExpression: + this.checkTaggedTemplateExpressionForBuiltinApi(node); + break; + case ts.SyntaxKind.PropertyAssignment: + this.checkPropertyAssignmentForDeprecatedApi(node); + break; default: } } @@ -13648,24 +13702,27 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (sym) { this.hanldeSdkCommonTypeName(node, sym, sym.name, decl); } - if (decl && (ts.isInterfaceDeclaration(decl) || ts.isClassDeclaration(decl))) { + if (decl && (ts.isInterfaceDeclaration(decl) || ts.isClassDeclaration(decl) || ts.isTypeAliasDeclaration(decl))) { let parentName = decl.name ? decl.name.text : 'unnamed'; if (ts.isQualifiedName(node.typeName)) { parentName = node.typeName.getText(); + } else if (ts.isTypeAliasDeclaration(decl)) { + parentName = ''; } const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( parentName, undefined, - undefined, + ts.isTypeAliasDeclaration(decl) ? decl.type.getText() : undefined, path.basename(decl.getSourceFile().fileName + '') ); this.processApiNodeDeprecatedApi(typeName.getText(), typeName, deprecatedApiCheckMap); + this.processApiNodeDeprecatedApi(typeName.getText(), typeName, deprecatedApiCheckMap, undefined, BUILTIN_TYPE); } } private checkNewExpressionForDeprecatedApi(node: ts.NewExpression): void { const expression = node.expression; - this.checkNewExpressionForSdkCommonApi(node); + this.checkNewExpressionForSdkApi(node); if (ts.isIdentifier(expression)) { const decl = this.tsUtils.getDeclarationNode(expression); if (decl && ts.isClassDeclaration(decl)) { @@ -13680,7 +13737,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkNewExpressionForSdkCommonApi(newExpr: ts.NewExpression): void { + private checkNewExpressionForSdkApi(newExpr: ts.NewExpression): void { const type = this.tsTypeChecker.getTypeAtLocation(newExpr.expression); const resolvedSignature = this.tsTypeChecker.getResolvedSignature(newExpr); if (!resolvedSignature) { @@ -13702,9 +13759,46 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { newExpr.expression, deprecatedApiCheckMap, undefined, - true + SDK_COMMON_TYPE ); + if (BUILTIN_CALLSIGNATURE_NEWCTOR.includes(newExpr.expression.getText())) { + this.handleNewExpressionForBuiltNewCtor(newExpr.expression, deprecatedApiCheckMap); + } else { + this.processApiNodeDeprecatedApi( + BUILTIN_CONSTRUCTOR_API_NAME, + newExpr.expression, + deprecatedApiCheckMap, + undefined, + BUILTIN_TYPE + ); + } + } + } + + private handleNewExpressionForBuiltNewCtor( + errorNode: ts.Node, + deprecatedApiCheckMap?: Map> + ): void { + if (TypeScriptLinter.builtinNewCtorSet.size === 0 || !deprecatedApiCheckMap) { + return; } + [...TypeScriptLinter.builtinNewCtorSet].some((item) => { + if (item.api_info.parent_api?.length <= 0) { + return false; + } + const isBuiltinNewConstruct = + BUILTIN_CONSTRUCTOR_API_TYPE.includes(item.api_info.api_type) && + item.api_info.parent_api[0].api_name === deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.PARENT_NAME) + '' && + path.basename(item.file_path) === deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.FILE_NAME) + ''; + if (isBuiltinNewConstruct) { + const problemStr = item.api_info.problem; + if (problemStr.length > 0) { + this.incrementCounters(errorNode, FaultID.BuiltinNewCtor); + } + return true; + } + return false; + }); } private checkHeritageClauseForDeprecatedApi(node: ts.HeritageClause): void { @@ -13717,11 +13811,16 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { expr = type.expression.name; } const decl = this.tsUtils.getDeclarationNode(expr); - this.checkHeritageClauseForSdkCommonApiDeprecated(node, decl); + this.checkHeritageClauseForSdkApiDeprecated(node, decl, SDK_COMMON_TYPE); + this.checkHeritageClauseForSdkApiDeprecated(node, decl, BUILTIN_TYPE); }); } - private checkHeritageClauseForSdkCommonApiDeprecated(node: ts.HeritageClause, decl: ts.Node | undefined): void { + private checkHeritageClauseForSdkApiDeprecated( + node: ts.HeritageClause, + decl: ts.Node | undefined, + apiType: string + ): void { if ( decl && (ts.isClassDeclaration(decl) || ts.isInterfaceDeclaration(decl)) && @@ -13729,35 +13828,45 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { decl.name ) { const extendClassName = decl.name.text; - if (TypeScriptLinter.checkIsSameAsParenName(extendClassName)) { + const newSet = TypeScriptLinter.refactorSetWhitSameAsParenName(extendClassName, apiType); + if (newSet && newSet.size > 0) { const sourceFunlikeArrs = node.parent.members.filter(ts.isFunctionLike); const sourceProDeclArrs = node.parent.members.filter(ts.isPropertyDeclaration); - this.checkSdkCommonApiInfoWithClassMember(sourceFunlikeArrs, extendClassName, SDK_COMMON_TYPEKEY[0]); - this.checkSdkCommonApiInfoWithClassMember(sourceProDeclArrs, extendClassName, SDK_COMMON_TYPEKEY[1]); + this.checkSdkApiInfoWithClassMember(sourceFunlikeArrs, decl, SDK_COMMON_TYPEKEY[0], apiType, newSet); + this.checkSdkApiInfoWithClassMember(sourceProDeclArrs, decl, SDK_COMMON_TYPEKEY[1], apiType, newSet); } } } - private checkSdkCommonApiInfoWithClassMember( + private checkSdkApiInfoWithClassMember( sourceMembers: ts.ClassElement[] | ts.PropertyDeclaration[], - extendClassName: string, - typeKey: string + decl: ts.ClassDeclaration | ts.InterfaceDeclaration, + typeKey: string, + apiType: string, + mergedSet: Set ): void { sourceMembers.some((func) => { - const funcName = func.name?.getText(); - if (!funcName) { + if (!func.name || !decl.name) { return; } - const problemStr = TypeScriptLinter.getFaultIdSdkCommonApiInfoWithClassMember(extendClassName, funcName, typeKey); + const funcName = func.name.getText(); + const extendClassName = decl.name.text; + const problemStr = TypeScriptLinter.getFaultIdSdkApiInfoWithClassMember(decl, funcName, typeKey, mergedSet); if (problemStr) { - const faultID = sdkCommonAllDeprecatedTypeName.has(extendClassName) ? - FaultID.SdkCommonApiDeprecated : - TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr); + let faultID = TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr, apiType); + if (apiType === SDK_COMMON_TYPE) { + faultID = sdkCommonAllDeprecatedTypeName.has(extendClassName) ? FaultID.SdkCommonApiDeprecated : faultID; + } + if (!faultID) { + return; + } this.incrementCounters( func, faultID, undefined, - TypeScriptLinter.getErrorMsgForSdkCommonApi(extendClassName, faultID) + apiType === SDK_COMMON_TYPE ? + TypeScriptLinter.getErrorMsgForSdkCommonApi(extendClassName, faultID) : + undefined ); } }); @@ -13767,14 +13876,27 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const sym = this.tsUtils.trueSymbolAtLocation(node); const decl = this.tsUtils.getDeclarationNode(node); if (decl && (ts.isInterfaceDeclaration(decl) || ts.isClassDeclaration(decl))) { + const fileName = path.basename(decl.getSourceFile().fileName + ''); const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( decl.name?.getText() + '', undefined, undefined, - path.basename(decl.getSourceFile().fileName + '') + fileName ); this.processApiNodeDeprecatedApi(node.getText(), node, deprecatedApiCheckMap); this.hanldeSdkCommonTypeName(node, sym, decl.name?.getText() + '', decl); + this.hanldeBuiltinFinalClassOnHeritageClause(node, fileName); + } + } + + private hanldeBuiltinFinalClassOnHeritageClause(node: ts.Node, fileName: string): void { + let isMatch = false; + for (const item of TypeScriptLinter.builtinFinalClassSet) { + isMatch = item.api_info.api_name === node.getText() && path.basename(item.file_path) === fileName; + if (isMatch) { + this.incrementCounters(node, FaultID.BuiltinFinalClass); + break; + } } } @@ -13833,7 +13955,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleCallExpressionBufferIndexOf(node, name, parName + '', funSymbol, decl); const deprecatedApiCheckMap = TypeScriptLinter.getDeprecatedApiCheckMapForCallExpression(decl, parName); this.reportDeprecatedApi(node, name, deprecatedApiCheckMap); - this.checkCallExpressionForSdkCommonApi(node, name, parName, !!isNeedGetResolvedSignature, deprecatedApiCheckMap); + this.checkCallExpressionForSdkApi(node, name, parName, !!isNeedGetResolvedSignature, deprecatedApiCheckMap); this.checkSpecialApiForDeprecatedApi(node, name, decl); } @@ -13853,7 +13975,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return undefined; } - private checkCallExpressionForSdkCommonApi( + private checkCallExpressionForSdkApi( node: ts.CallExpression, name: ts.Identifier, parName: string | undefined, @@ -13861,13 +13983,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { deprecatedApiCheckMap: Map> | undefined ): void { if (isNeedGetResolvedSignature) { - this.checkCallExpressionForSdkCommonApiWithSignature(node, name, parName); + this.checkCallExpressionForSdkApiWithSignature(node, name, parName); } else { - this.reportDeprecatedApi(node, name, deprecatedApiCheckMap, true); + this.reportDeprecatedApi(node, name, deprecatedApiCheckMap, SDK_COMMON_TYPE); + this.reportDeprecatedApi(node, name, deprecatedApiCheckMap, BUILTIN_TYPE); } } - private checkCallExpressionForSdkCommonApiWithSignature( + private checkCallExpressionForSdkApiWithSignature( node: ts.CallExpression, name: ts.Identifier, parName: string | undefined @@ -13878,44 +14001,76 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const functionSymbol = this.getFunctionSymbol(signature.declaration); const functionDeclaration = functionSymbol?.valueDeclaration; + let returnType = this.tsTypeChecker.typeToString(signature.getReturnType()); + let isSpecialTypeForBuiltIn = false; if (!functionDeclaration) { - return; + const signatureDecl = signature.getDeclaration(); + if (signatureDecl && ts.isFunctionLike(signatureDecl) && signatureDecl.type) { + returnType = signatureDecl.type.getText(); + if (!parName && BUILTIN_CALLSIGNATURE_NEWCTOR.includes(name.text)) { + const type = this.tsTypeChecker.getTypeAtLocation(name); + parName = this.tsTypeChecker.typeToString(type); + isSpecialTypeForBuiltIn = !!parName; + } + } } - const returnType = this.tsTypeChecker.typeToString(signature.getReturnType()); + const fileName = signature.getDeclaration().getSourceFile().fileName; const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( parName === undefined ? '' : parName + '', TypeScriptLinter.getParameterDeclarationsBySignature(signature), returnType, - path.basename(functionDeclaration.getSourceFile().fileName) + path.basename(fileName) ); - this.reportDeprecatedApi(node, name, deprecatedApiCheckMap, true); + this.reportDeprecatedApi(node, name, deprecatedApiCheckMap, SDK_COMMON_TYPE); + if (isSpecialTypeForBuiltIn) { + this.processApiNodeDeprecatedApi( + BUILTIN_CONSTRUCTOR_API_NAME, + name, + deprecatedApiCheckMap, + undefined, + BUILTIN_TYPE + ); + } else { + this.reportDeprecatedApi(node, name, deprecatedApiCheckMap, BUILTIN_TYPE); + } } private reportDeprecatedApi( node: ts.CallExpression, name: ts.Identifier, deprecatedApiCheckMap?: Map>, - isSdkCommon?: boolean + apiType?: string ): void { - const problemStr = this.getFaultIdWithMatchedDeprecatedApi(name.text, deprecatedApiCheckMap, isSdkCommon); + const problemStr = this.getFaultIdWithMatchedDeprecatedApi(name.text, deprecatedApiCheckMap, apiType); if (problemStr.length > 0) { const autofix = this.autofixer?.fixDeprecatedApiForCallExpression(node); if (autofix) { this.interfacesNeedToImport.add('getUIContext'); } - const faultID = isSdkCommon ? TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr) : FaultID.NoDeprecatedApi; + const isSdkCommon = apiType === SDK_COMMON_TYPE; + const faultID = TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr, apiType); + if (!faultID) { + return; + } this.incrementCounters( name, faultID, - isSdkCommon ? undefined : autofix, + isSdkCommon || apiType === BUILTIN_TYPE ? undefined : autofix, isSdkCommon ? TypeScriptLinter.getErrorMsgForSdkCommonApi(name.text, faultID) : undefined ); } } - private static getFinalSdkFaultIdByProblem(problem: string): number { - const sdkFaultId = SdkCommonApiProblemInfos.get(problem); - return sdkFaultId ? sdkFaultId : FaultID.SdkCommonApiWhiteList; + private static getFinalSdkFaultIdByProblem(problem: string, apiType: string | undefined): number | undefined { + let sdkFaultId: number | undefined = FaultID.NoDeprecatedApi; + if (apiType === SDK_COMMON_TYPE) { + sdkFaultId = SdkCommonApiProblemInfos.get(problem); + return sdkFaultId ? sdkFaultId : FaultID.SdkCommonApiWhiteList; + } else if (apiType === BUILTIN_TYPE) { + sdkFaultId = BuiltinProblemInfos.get(problem); + return sdkFaultId ? sdkFaultId : undefined; + } + return sdkFaultId; } private checkSpecialApiForDeprecatedApi( @@ -14014,7 +14169,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { expression, this.getPropertyTypeForPropertyAssignment(node, contextualType, true), undefined, - true + SDK_COMMON_TYPE + ); + this.processApiNodeDeprecatedApi( + expression.getText(), + expression, + this.getPropertyTypeForPropertyAssignment(node, contextualType), + undefined, + BUILTIN_TYPE ); } } @@ -14048,7 +14210,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { path.basename(decl.getSourceFile().fileName) ); this.processApiNodeDeprecatedApi(expression.text, expression, deprecatedApiCheckMap); - this.processApiNodeDeprecatedApi(expression.text, expression, deprecatedApiCheckMap, undefined, true); + this.processApiNodeDeprecatedApi( + expression.text, + expression, + deprecatedApiCheckMap, + undefined, + SDK_COMMON_TYPE + ); + this.processApiNodeDeprecatedApi(expression.text, expression, deprecatedApiCheckMap, undefined, BUILTIN_TYPE); } }); } @@ -14191,6 +14360,33 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return isFileMatch; } + private checkTaggedTemplateExpressionForBuiltinApi(node: ts.TaggedTemplateExpression): void { + const expression = node.tag; + if (ts.isPropertyAccessExpression(expression)) { + const funSymbol = this.tsUtils.trueSymbolAtLocation(expression.name); + const decl = TsUtils.getDeclaration(funSymbol); + const parName = this.tsUtils.getParentSymbolName(funSymbol); + if (decl) { + const returnType: string | undefined = this.tsTypeChecker.typeToString( + this.tsTypeChecker.getTypeAtLocation(decl) + ); + const deprecatedApiCheckMap = TypeScriptLinter.updateDeprecatedApiCheckMap( + parName === undefined ? DEPRECATE_UNNAMED : parName + '', + undefined, + expression.name.text === 'raw' ? 'string' : returnType, + path.basename(decl.getSourceFile().fileName) + ); + this.processApiNodeDeprecatedApi( + expression.name.text, + expression.name, + deprecatedApiCheckMap, + undefined, + BUILTIN_TYPE + ); + } + } + } + private checkPropertyDeclarationForDeprecatedApi(node: ts.PropertyDeclaration): void { const expression = node.name; if (ts.isIdentifier(expression)) { @@ -14203,15 +14399,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { errorNode: ts.Node, deprecatedApiCheckMap?: Map>, autofix?: Autofix[], - isSdkCommon?: boolean + apiType?: string ): void { - const problemStr = this.getFaultIdWithMatchedDeprecatedApi(apiName, deprecatedApiCheckMap, isSdkCommon); + const problemStr = this.getFaultIdWithMatchedDeprecatedApi(apiName, deprecatedApiCheckMap, apiType); if (problemStr.length > 0) { - const faultID = isSdkCommon ? TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr) : FaultID.NoDeprecatedApi; + const isSdkCommon = apiType === SDK_COMMON_TYPE; + const faultID = TypeScriptLinter.getFinalSdkFaultIdByProblem(problemStr, apiType); + if (!faultID) { + return; + } this.incrementCounters( errorNode, faultID, - isSdkCommon ? undefined : autofix, + isSdkCommon || apiType === BUILTIN_TYPE ? undefined : autofix, isSdkCommon ? TypeScriptLinter.getErrorMsgForSdkCommonApi(apiName, faultID) : undefined ); } @@ -14220,57 +14420,87 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private getFaultIdWithMatchedDeprecatedApi( apiName: string, deprecatedApiCheckMap?: Map>, - isSdkCommon?: boolean + apiType?: string ): string { void this; - let setApiListItem = TypeScriptLinter.deprecatedApiInfo; - if (isSdkCommon) { - setApiListItem = TypeScriptLinter.sdkCommonApiInfo; + if (!apiType) { + apiType = DEPRECATE_TYPE; } + const setApiListItem = apiType && TypeScriptLinter.getApiListItemSetFromAllWhiteList(apiType); if (!setApiListItem || !deprecatedApiCheckMap) { return ''; } const apiNamesArr = [...setApiListItem]; + const isSpecial = apiType === SDK_COMMON_TYPE || apiType === BUILTIN_TYPE; let problem = ''; apiNamesArr.some((apiInfoItem) => { - if (apiInfoItem.api_info.parent_api?.length <= 0) { - return false; - } - let isSameApi = apiInfoItem.api_info.api_name === apiName; - isSameApi &&= TypeScriptLinter.checkParentNameUnderSdkList( - apiInfoItem, - deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.PARENT_NAME) + '', - isSdkCommon - ); - const return_type = this.getReturnTypeByApiInfoItem(apiInfoItem, isSdkCommon); - const actual_return_type = this.normalizeTypeString(deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.RETURN_TYPE)); - isSameApi &&= return_type === actual_return_type; - const api_func_args = apiInfoItem.api_info.api_func_args; - const params = deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.PARAM_SET); - if (api_func_args && params) { - const isParametersEqual = TypeScriptLinter.areParametersEqualForDeprecated( - api_func_args, - params as ts.NodeArray + if (!apiInfoItem.api_info.api_name && !apiName || BUILTIN_CONSTRUCTOR_API_NAME === apiName) { + problem = TypeScriptLinter.getFaultIdWithMatchedBuiltinConstructApi( + apiInfoItem, + deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.PARENT_NAME) + '' ); - isSameApi &&= isParametersEqual; + if (problem) { + return true; + } } + const isSameApi = this.checkIsSameApiWithSdkList(apiInfoItem, apiName, deprecatedApiCheckMap, apiType); const fileName = deprecatedApiCheckMap?.get(DEPRECATE_CHECK_KEY.FILE_NAME) + ''; const isSameFile = fileName.endsWith(path.basename(apiInfoItem.file_path)); const res = isSameApi && isSameFile; if (res) { - problem = isSdkCommon ? apiInfoItem.api_info.problem : DeprecateProblem.NoDeprecatedApi; + problem = isSpecial ? apiInfoItem.api_info.problem : DeprecateProblem.NoDeprecatedApi; } return res; }); return problem; } + private checkIsSameApiWithSdkList( + apiInfoItem: ApiListItem, + apiName: string, + deprecatedApiCheckMap: Map>, + apiType?: string + ): boolean { + let isSameApi = apiInfoItem.api_info.api_name === apiName; + isSameApi &&= TypeScriptLinter.checkParentNameUnderSdkList( + apiInfoItem, + deprecatedApiCheckMap.get(DEPRECATE_CHECK_KEY.PARENT_NAME) + '', + apiType === SDK_COMMON_TYPE || apiType === BUILTIN_TYPE + ); + const return_type = this.getReturnTypeByApiInfoItem( + apiInfoItem, + apiType === SDK_COMMON_TYPE || apiType === BUILTIN_TYPE + ); + const actual_return_type = this.normalizeTypeString(deprecatedApiCheckMap.get(DEPRECATE_CHECK_KEY.RETURN_TYPE)); + isSameApi &&= return_type === actual_return_type; + const api_func_args = apiInfoItem.api_info.api_func_args; + const params = deprecatedApiCheckMap.get(DEPRECATE_CHECK_KEY.PARAM_SET); + if (api_func_args && params) { + const isParametersEqual = TypeScriptLinter.areParametersEqualForDeprecated( + api_func_args, + params as ts.NodeArray + ); + isSameApi &&= isParametersEqual; + } + return isSameApi; + } + + private static getFaultIdWithMatchedBuiltinConstructApi(apiInfoItem: ApiListItem, parentName: string): string { + if (apiInfoItem.api_info.parent_api?.length <= 0) { + return ''; + } + const isBuiltinConstruct = + BUILTIN_CONSTRUCTOR_API_TYPE.includes(apiInfoItem.api_info.api_type) && + apiInfoItem.api_info.parent_api[0].api_name === parentName; + return isBuiltinConstruct ? apiInfoItem.api_info.problem : ''; + } + private getReturnTypeByApiInfoItem( apiInfoItem: ApiListItem, - isSdkCommon: boolean | undefined + isSpecial: boolean | undefined ): string | ts.NodeArray | undefined { let return_type = this.normalizeTypeString(apiInfoItem.api_info.method_return_type); - if (isSdkCommon) { + if (isSpecial) { return_type = apiInfoItem.api_info.method_return_type ? this.normalizeTypeString(apiInfoItem.api_info.method_return_type) : this.normalizeTypeString(apiInfoItem.api_info.api_property_type); @@ -14281,7 +14511,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private static checkParentNameUnderSdkList( apiInfoItem: ApiListItem, sourceParentName: string, - isSdkCommon?: boolean + isSpecial?: boolean ): boolean { const parentApis = apiInfoItem.api_info.parent_api; const possibleNames: string[] = []; @@ -14289,18 +14519,18 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (primaryParentName) { possibleNames.push(primaryParentName); - if (!!isSdkCommon && parentApis.length > 1) { + if (!!isSpecial && parentApis.length > 1) { const secondaryParentName = parentApis[1]?.api_name || ''; possibleNames.push(`${secondaryParentName}.${primaryParentName}`); } } - return possibleNames.includes(sourceParentName); + return possibleNames.includes(sourceParentName) || parentApis.length === 0 && !sourceParentName; } private getPropertyTypeForPropertyAssignment( propertyAssignment: ts.PropertyAssignment, contextualType: ts.Type, - isSdkCommon?: boolean + isSpecial?: boolean ): Map> | undefined { const propertyName = propertyAssignment.name.getText(); if (contextualType.isUnion()) { @@ -14309,21 +14539,21 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { type, propertyName, propertyAssignment, - isSdkCommon + isSpecial ); if (deprecatedApiCheckMap) { return deprecatedApiCheckMap; } } } - return this.getPropertyInfoByContextualType(contextualType, propertyName, propertyAssignment, isSdkCommon); + return this.getPropertyInfoByContextualType(contextualType, propertyName, propertyAssignment, isSpecial); } private getPropertyInfoByContextualType( type: ts.Type, propertyName: string, node: ts.Node, - isSdkCommon?: boolean + isSpecial?: boolean ): Map> | undefined { const propertySymbol = type.getProperty(propertyName); if (!propertySymbol) { @@ -14338,7 +14568,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { propertyDecl.type.getText(), path.basename(propertyDecl.getSourceFile().fileName + '') ); - if (isSdkCommon) { + if (isSpecial) { this.hanldeSdkCommonTypeName(node, type.getSymbol(), type.getSymbol()?.name + '', propertyDecl); } } @@ -14601,13 +14831,27 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ]); } - private static getFaultIdSdkCommonApiInfoWithConstructorDecl(extendClassName: string): string { - const mergedSet = TypeScriptLinter.mergeSdkCommonApiListInfo(); + private static getFaultIdSdkApiInfoWithConstructorDecl(extendClassName: string, apiType: string): string { + const mergedSet = TypeScriptLinter.getApiListItemSetFromAllWhiteList( + apiType, + apiType === SDK_COMMON_TYPE ? true : undefined + ); + if (!mergedSet) { + return ''; + } + let api_types = ['']; + if (apiType === SDK_COMMON_TYPE) { + api_types = SDK_COMMON_CONSTRUCTORLIKE; + } else if (apiType === BUILTIN_TYPE) { + api_types = BUILTIN_CONSTRUCTOR_API_TYPE; + } let problem = ''; for (const item of mergedSet) { + if (item.api_info.parent_api?.length <= 0) { + continue; + } const isCompare = - item.api_info.parent_api[0].api_name === extendClassName && - SDK_COMMON_CONSTRUCTORLIKE.includes(item.api_info.api_type); + item.api_info.parent_api[0].api_name === extendClassName && api_types.includes(item.api_info.api_type); if (isCompare) { problem = item.api_info.problem; break; @@ -14616,19 +14860,29 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return problem; } - private static getFaultIdSdkCommonApiInfoWithClassMember( - extendClassName: string, + private static getFaultIdSdkApiInfoWithClassMember( + decl: ts.ClassDeclaration | ts.InterfaceDeclaration, targetName: string, - typeKey: string + typeKey: string, + mergedSet: Set ): string { - const mergedSet = TypeScriptLinter.mergeSdkCommonApiListInfo(); + const extendClassName = decl.name?.text; + const fileName = path.basename(decl.getSourceFile().fileName); + if (!extendClassName || !fileName) { + return ''; + } const memberLike = typeKey === SDK_COMMON_TYPEKEY[0] ? SDK_COMMON_FUNCTIONLIKE : SDK_COMMON_PROPERTYLIKE; let problem = ''; + const apiFilePath = this.getApiFilePathsFromSdkList(mergedSet); for (const item of mergedSet) { + if (item.api_info.parent_api?.length <= 0) { + continue; + } const isFunLikeCompare = item.api_info.parent_api[0].api_name === extendClassName && memberLike.includes(item.api_info.api_type) && - item.api_info.api_name === targetName; + item.api_info.api_name === targetName && + apiFilePath.includes(fileName); if (isFunLikeCompare) { problem = item.api_info.problem; break; @@ -14637,15 +14891,107 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return problem; } - private static checkIsSameAsParenName(targetName: string): boolean { - let res = false; - const mergedSet = TypeScriptLinter.mergeSdkCommonApiListInfo(); + private static getApiFilePathsFromSdkList(mergedSet: Set): string[] { + const apiFilePath: string[] = []; + mergedSet.forEach((mem) => { + apiFilePath.push(path.basename(mem.file_path)); + }); + return apiFilePath; + } + + private static refactorSetWhitSameAsParenName(targetName: string, apiType: string): Set | undefined { + const mergedSet = TypeScriptLinter.getApiListItemSetFromAllWhiteList( + apiType, + apiType === SDK_COMMON_TYPE ? true : undefined + ); + if (!mergedSet) { + return undefined; + } + const newMergedSet = new Set(); for (const item of mergedSet) { + if (item.api_info.parent_api?.length <= 0) { + continue; + } if (item.api_info.parent_api[0].api_name === targetName) { - res = true; + newMergedSet.add(item); } } - return res; + return newMergedSet; + } + + private static getApiListItemSetFromAllWhiteList( + type: string, + isMergeSdkCommonApi?: boolean + ): Set | undefined { + if (type === DEPRECATE_TYPE) { + return TypeScriptLinter.deprecatedApiInfo; + } else if (type === SDK_COMMON_TYPE) { + return isMergeSdkCommonApi ? TypeScriptLinter.mergeSdkCommonApiListInfo() : TypeScriptLinter.sdkCommonApiInfo; + } else if (type === BUILTIN_TYPE) { + return TypeScriptLinter.builtApiInfo; + } + return undefined; + } + + private checkArrayInitialization(tsNewExpr: ts.NewExpression): void { + if (!this.options.arkts2) { + return; + } + if (!tsNewExpr.arguments || tsNewExpr.arguments.length !== 1) { + return; + } + const newExprType = this.tsTypeChecker.getTypeAtLocation(tsNewExpr); + const argType = this.tsTypeChecker.getTypeAtLocation(tsNewExpr.arguments[0]); + if (this.tsUtils.isGenericArrayType(newExprType) && this.tsUtils.isNumberLikeType(argType)) { + this.incrementCounters(tsNewExpr, FaultID.UninitializedArrayElements); + } + } + + private handleBuiltinIteratorResult(propAccessExpr: ts.PropertyAccessExpression): void { + if (!this.options.arkts2 || !TypeScriptLinter.builtApiInfo || propAccessExpr.name.getText() !== 'value') { + return; + } + + const type = this.tsTypeChecker.getTypeAtLocation(propAccessExpr.expression); + const aliasSymbol = type.aliasSymbol; + const declaration = aliasSymbol?.declarations?.[0]; + if (!declaration || !ts.isTypeAliasDeclaration(declaration)) { + return; + } + + const name = declaration.name.getText(); + const typeStr = declaration.type.getText(); + const fileName = declaration.getSourceFile().fileName; + this.processApiNodeDeprecatedApi( + name, + propAccessExpr, + TypeScriptLinter.updateDeprecatedApiCheckMap('', undefined, typeStr, path.basename(fileName)), + undefined, + BUILTIN_TYPE + ); + } + + private handleBuiltinDisableDecorator(decorator: ts.Decorator): void { + if (!this.options.arkts2 || !TypeScriptLinter.builtApiInfo) { + return; + } + const type = this.tsTypeChecker.getTypeAtLocation(decorator.expression); + const aliasSymbol = type.aliasSymbol; + const declaration = aliasSymbol?.declarations?.[0]; + if (!declaration || !ts.isTypeAliasDeclaration(declaration) || !ts.isFunctionLike(declaration.type)) { + return; + } + const name = declaration.name.getText(); + const params = declaration.type.parameters; + const typeStr = declaration.type.type?.getText(); + const fileName = declaration.getSourceFile().fileName; + this.processApiNodeDeprecatedApi( + name, + decorator, + TypeScriptLinter.updateDeprecatedApiCheckMap('', params, typeStr, path.basename(fileName)), + undefined, + BUILTIN_TYPE + ); } private handleUnsignedShiftOnNegative(node: ts.BinaryExpression): void { diff --git a/ets2panda/linter/src/lib/data/BuiltinList.json b/ets2panda/linter/src/lib/data/BuiltinList.json index 659a25bbd5..e2a086ed83 100644 --- a/ets2panda/linter/src/lib/data/BuiltinList.json +++ b/ets2panda/linter/src/lib/data/BuiltinList.json @@ -4,13 +4,13 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 107, - "problem": "BuiltinAll", + "problem": "BuiltinNarrowTypes", "api_name": "PropertyKey", "api_type": "TypeAliasDeclaration", "api_func_args": [], "parent_api": [], "code_kind": 268, - "api_property_type": "string | number | symbol" + "method_return_type": "string | number | symbol" }, "import_path": [], "is_global": true @@ -148,7 +148,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 133, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "valueOf", "api_type": "MethodSignature", "api_optional": false, @@ -189,8 +189,8 @@ { "file_path": "lib.es5.d.ts", "api_info": { - "line": 156, - "problem": "BuiltinAll", + "line": 157, + "problem": "BuiltinDisableApi", "api_type": "CallSignature", "parent_api": [ { @@ -206,8 +206,8 @@ { "file_path": "lib.es5.d.ts", "api_info": { - "line": 157, - "problem": "BuiltinAll", + "line": 576, + "problem": "BuiltinNewCtor", "api_type": "CallSignature", "parent_api": [ { @@ -224,7 +224,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 392, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "length", "api_type": "PropertySignature", "api_optional": false, @@ -244,7 +244,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 393, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "callee", "api_type": "PropertySignature", "api_optional": false, @@ -277,6 +277,23 @@ "import_path": [], "is_global": true }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 522, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "StringConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, { "file_path": "lib.es5.d.ts", "api_info": { @@ -294,6 +311,23 @@ "import_path": [], "is_global": true }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 539, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "BooleanConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, { "file_path": "lib.es5.d.ts", "api_info": { @@ -311,11 +345,28 @@ "import_path": [], "is_global": true }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 576, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "NumberConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, { "file_path": "lib.es5.d.ts", "api_info": { "line": 608, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "raw", "api_type": "PropertySignature", "api_optional": false, @@ -348,6 +399,23 @@ "import_path": [], "is_global": true }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 916, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "DateConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, { "file_path": "lib.es5.d.ts", "api_info": { @@ -399,6 +467,23 @@ "import_path": [], "is_global": true }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1060, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "ErrorConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, { "file_path": "lib.es5.d.ts", "api_info": { @@ -539,7 +624,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 1188, - "problem": "BuiltinAll", + "problem": "BuiltinNarrowTypes", "api_name": "concat", "api_type": "MethodSignature", "api_optional": false, @@ -825,7 +910,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 1334, - "problem": "BuiltinAll", + "problem": "BuiltinNarrowTypes", "api_name": "concat", "api_type": "MethodSignature", "api_optional": false, @@ -1070,6 +1155,23 @@ "import_path": [], "is_global": true }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1490, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, { "file_path": "lib.es5.d.ts", "api_info": { @@ -1194,7 +1296,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 1506, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "ClassDecorator", "api_type": "TypeAliasDeclaration", "api_func_args": [ @@ -1215,7 +1317,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 1507, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "PropertyDecorator", "api_type": "TypeAliasDeclaration", "api_func_args": [ @@ -1241,7 +1343,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 1508, - "problem": "NoPropertyDescriptor", + "problem": "BuiltinDisableApi", "api_name": "MethodDecorator", "api_type": "TypeAliasDeclaration", "api_func_args": [ @@ -1272,7 +1374,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 1509, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "ParameterDecorator", "api_type": "TypeAliasDeclaration", "api_func_args": [ @@ -1303,7 +1405,7 @@ "file_path": "lib.es5.d.ts", "api_info": { "line": 1681, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "ArrayBuffer", "api_type": "PropertySignature", "api_optional": false, @@ -3505,7 +3607,7 @@ "file_path": "lib.es2015.iterable.d.ts", "api_info": { "line": 46, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "return", "api_type": "MethodSignature", "api_optional": true, @@ -3533,7 +3635,7 @@ "file_path": "lib.es2015.iterable.d.ts", "api_info": { "line": 47, - "problem": "BuiltinAll", + "problem": "BuiltinDisableApi", "api_name": "throw", "api_type": "MethodSignature", "api_optional": true, @@ -5762,6 +5864,23 @@ "import_path": [], "is_global": true }, + { + "file_path": "lib.es2021.promise.d.ts", + "api_info": { + "line": 1, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "AggregateErrorConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, { "file_path": "lib.es2015.core.d.ts", "api_info": { @@ -5795,6 +5914,1524 @@ }, "import_path": [], "is_global": true + }, + { + "file_path": "lib.es2021.promise.d.ts", + "api_info": { + "line": 110, + "problem": "NoPropertyDescriptor", + "api_name": "errors", + "api_type": "PropertySignature", + "api_optional": true, + "parent_api": [ + { + "api_name": "AggregateError", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "any[]" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2019.array.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinDisableApi", + "api_name": "flat", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "this", + "type": "A", + "is_optional": false, + "has_default": false + }, + { + "name": "depth", + "type": "D", + "is_optional": true, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Array", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "FlatArray[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "day", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "dayPeriod", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "era", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "hour", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "literal", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "minute", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "month", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "second", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "timeZoneName", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "weekday", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "year", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DateTimeFormatPartTypesRegistry", + "api_type": "InterfaceDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "any", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2020.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "prototype", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "DisplayNames", + "api_type": "VariableDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "DisplayNames", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2021.intl.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "prototype", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "ListFormat", + "api_type": "VariableDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "ListFormat", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 114, + "problem": "BuiltinDisableApi", + "api_name": "prototype", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "NumberFormat", + "api_type": "VariableDeclaration" + }, + { + "api_name": "Intl", + "api_type": "ModuleDeclaration" + } + ], + "api_property_type": "NumberFormat", + "code_kind": 170 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2019.array.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinDisableApi", + "api_name": "flat", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "this", + "type": "A", + "is_optional": false, + "has_default": false + }, + { + "name": "depth", + "type": "D", + "is_optional": true, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ReadonlyArray", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "FlatArray[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2019.array.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinDisableApi", + "api_name": "flatMap", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "callback", + "type": "(this: This, value: T, index: number, array: T[]) => U | ReadonlyArray", + "is_optional": false, + "has_default": false + }, + { + "name": "thisArg", + "type": "This", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ReadonlyArray", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "U[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2018.regexp.d.ts", + "api_info": { + "line": 110, + "problem": "BuiltinDisableApi", + "api_name": "groups", + "api_type": "PropertySignature", + "api_optional": true, + "parent_api": [ + { + "api_name": "RegExpExecArray", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "{[key: string]: string}" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2018.regexp.d.ts", + "api_info": { + "line": 110, + "problem": "BuiltinDisableApi", + "api_name": "groups", + "api_type": "PropertySignature", + "api_optional": true, + "parent_api": [ + { + "api_name": "RegExpMatchArray", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "{[key: string]: string}" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2019.array.d.ts", + "api_info": { + "line": 110, + "problem": "BuiltinDisableApi", + "api_name": "FlatArray", + "api_type": "TypeAliasDeclaration", + "api_optional": true, + "parent_api": [], + "code_kind": 170, + "method_return_type": "{\"done\": Arr, \"recur\": Arr extends ReadonlyArray ? FlatArray : Arr}[Depth extends -1 ? \"done\" : \"recur\"]" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinNarrowTypes", + "api_name": "isFinite", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "number", + "type": "unknown", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "NumberConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "boolean", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinNarrowTypes", + "api_name": "isInteger", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "number", + "type": "unknown", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "NumberConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "boolean", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinNarrowTypes", + "api_name": "isNaN", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "number", + "type": "unknown", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "NumberConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "boolean", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinNarrowTypes", + "api_name": "isSafeInteger", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "number", + "type": "unknown", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "NumberConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "boolean", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.reflect.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinAll", + "api_name": "get", + "api_type": "MethodDeclaration", + "api_func_args": [ + { + "name": "target", + "type": "T", + "is_optional": false, + "has_default": false + }, + { + "name": "propertyKey", + "type": "P", + "is_optional": false, + "has_default": false + }, + { + "name": "receiver", + "type": "unknown", + "is_optional": true, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Reflect", + "api_type": "ModuleDeclaration" + } + ], + "method_return_type": "P extends keyof T ? T[P] : any", + "code_kind": 174 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.reflect.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinNarrowTypes", + "api_name": "has", + "api_type": "MethodDeclaration", + "api_func_args": [ + { + "name": "target", + "type": "object", + "is_optional": false, + "has_default": false + }, + { + "name": "propertyKey", + "type": "PropertyKey", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Reflect", + "api_type": "ModuleDeclaration" + } + ], + "method_return_type": "boolean", + "code_kind": 174 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.reflect.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinNarrowTypes", + "api_name": "ownKeys", + "api_type": "MethodDeclaration", + "api_func_args": [ + { + "name": "target", + "type": "object", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Reflect", + "api_type": "ModuleDeclaration" + } + ], + "method_return_type": "(string | symbol)[]", + "code_kind": 174 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.reflect.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinAll", + "api_name": "set", + "api_type": "MethodDeclaration", + "api_func_args": [ + { + "name": "target", + "type": "T", + "is_optional": false, + "has_default": false + }, + { + "name": "propertyKey", + "type": "P", + "is_optional": false, + "has_default": false + }, + { + "name": "value", + "type": "P extends keyof T ? T[P] : any", + "is_optional": false, + "has_default": false + }, + { + "name": "receiver", + "type": "any", + "is_optional": true, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Reflect", + "api_type": "ModuleDeclaration" + } + ], + "method_return_type": "boolean", + "code_kind": 174 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.core.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinDisableApi", + "api_name": "raw", + "api_type": "MethodSignature", + "api_func_args": [ + { + "name": "template", + "type": "{ raw: readonly string[] | ArrayLike}", + "is_optional": false, + "has_default": false + }, + { + "name": "substitutions", + "type": "any[]", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "StringConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "string", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1, + "problem": "BuiltinDisableApi", + "api_name": "from", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "iterable", + "type": "Iterable | ArrayLike", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "T[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1, + "problem": "BuiltinNarrowTypes", + "api_name": "isArray", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ArrayConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "arg is any[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1506, + "problem": "BuiltinIteratorResultValue", + "api_name": "IteratorResult", + "api_type": "TypeAliasDeclaration", + "api_func_args": [], + "parent_api": [], + "method_return_type": "IteratorYieldResult | IteratorReturnResult", + "code_kind": 268 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1681, + "problem": "BuiltinDisableApi", + "api_name": "done", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "IteratorReturnResult", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "true" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1681, + "problem": "BuiltinDisableApi", + "api_name": "value", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "IteratorReturnResult", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "TReturn" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1681, + "problem": "BuiltinDisableApi", + "api_name": "done", + "api_type": "PropertySignature", + "api_optional": true, + "parent_api": [ + { + "api_name": "IteratorYieldResult", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "false" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.iterable.d.ts", + "api_info": { + "line": 1681, + "problem": "BuiltinDisableApi", + "api_name": "value", + "api_type": "PropertySignature", + "api_optional": false, + "parent_api": [ + { + "api_name": "IteratorYieldResult", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "TYield" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1244, + "problem": "BuiltinNarrowTypes", + "api_name": "isView", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "arg", + "type": "any", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ArrayBufferConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "arg is ArrayBufferView", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1244, + "problem": "BuiltinNarrowTypes", + "api_name": "toJSON", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "key", + "type": "any", + "is_optional": true, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "Date", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "string", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2022.error.d.ts", + "api_info": { + "line": 110, + "problem": "NoPropertyDescriptor", + "api_name": "cause", + "api_type": "PropertySignature", + "api_optional": true, + "parent_api": [ + { + "api_name": "ErrorOptions", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "unknown" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2022.error.d.ts", + "api_info": { + "line": 110, + "problem": "NoPropertyDescriptor", + "api_name": "cause", + "api_type": "PropertySignature", + "api_optional": true, + "parent_api": [ + { + "api_name": "Error", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 170, + "api_property_type": "unknown" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1139, + "problem": "BuiltinNarrowTypes", + "api_name": "stringify", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "any", + "is_optional": false, + "has_default": false + }, + { + "name": "replacer", + "type": "(this: any, key: string, value: any) => any", + "is_optional": true, + "has_default": false + }, + { + "name": "space", + "type": "string | number", + "is_optional": true, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "JSON", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "string", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1139, + "problem": "BuiltinNarrowTypes", + "api_name": "stringify", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "value", + "type": "any", + "is_optional": false, + "has_default": false + }, + { + "name": "replacer", + "type": "(number | string)[] | null", + "is_optional": true, + "has_default": false + }, + { + "name": "space", + "type": "string | number", + "is_optional": true, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "JSON", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "string", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.object.d.ts", + "api_info": { + "line": 1139, + "problem": "BuiltinNarrowTypes", + "api_name": "entries", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "o", + "type": "{}", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ObjectConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "[string, any][]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2017.object.d.ts", + "api_info": { + "line": 1139, + "problem": "BuiltinNarrowTypes", + "api_name": "values", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "o", + "type": "{}", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ObjectConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "any[]", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2019.object.d.ts", + "api_info": { + "line": 1139, + "problem": "BuiltinNarrowTypes", + "api_name": "fromEntries", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "entries", + "type": "Iterable", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "ObjectConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "{ [k: string]: T }", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 1139, + "problem": "BuiltinNarrowTypes", + "api_name": "replace", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "searchValue", + "type": "string | RegExp", + "is_optional": false, + "has_default": false + }, + { + "name": "replacer", + "type": "(substring: string, ...args: any[]) => string", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "String", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "string", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2021.string.d.ts", + "api_info": { + "line": 1139, + "problem": "BuiltinNarrowTypes", + "api_name": "replaceAll", + "api_type": "MethodSignature", + "api_optional": false, + "api_func_args": [ + { + "name": "searchValue", + "type": "string | RegExp", + "is_optional": false, + "has_default": false + }, + { + "name": "replacer", + "type": "(substring: string, ...args: any[]) => string", + "is_optional": false, + "has_default": false + } + ], + "parent_api": [ + { + "api_name": "String", + "api_type": "InterfaceDeclaration" + } + ], + "method_return_type": "string", + "code_kind": 173 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.collection.d.ts", + "api_info": { + "line": 522, + "problem": "BuiltinNoCtorFunc", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "WeakMapConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.collection.d.ts", + "api_info": { + "line": 522, + "problem": "BuiltinNewCtor", + "api_type": "CallSignature", + "parent_api": [ + { + "api_name": "WeakMapConstructor", + "api_type": "InterfaceDeclaration" + } + ], + "code_kind": 179 + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2020.bigint.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "BigInt", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "BigIntConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "DataView", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "DataViewConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "Int8Array", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "Int8ArrayConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "Int16Array", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "Int16ArrayConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "Int32Array", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "Int32ArrayConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2020.bigint.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "BigInt64Array", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "BigInt64ArrayConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "Float32Array", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "Float32ArrayConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "Float64Array", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "Float64ArrayConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "Boolean", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "BooleanConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "String", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "StringConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.collection.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "WeakMap", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "WeakMapConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2015.collection.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "WeakSet", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "WeakSetConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es2021.weakref.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "FinalizationRegistry", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "FinalizationRegistryConstructor" + }, + "import_path": [], + "is_global": true + }, + { + "file_path": "lib.es5.d.ts", + "api_info": { + "line": 126, + "problem": "BuiltinFinalClass", + "api_name": "Promise", + "api_type": "VariableDeclaration", + "api_optional": false, + "parent_api": [], + "code_kind": 260, + "api_property_type": "PromiseConstructor" + }, + "import_path": [], + "is_global": true } ] } \ No newline at end of file diff --git a/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts b/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts index 297b5fba00..3a2fb5e275 100644 --- a/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts +++ b/ets2panda/linter/src/lib/utils/consts/BuiltinWhiteList.ts @@ -13,12 +13,19 @@ * limitations under the License. */ +import { FaultID } from '../../Problems'; + export enum BuiltinProblem { LimitedThisArg = 'ThisArg', SymbolIterator = 'SymbolIterator', BuiltinNoCtorFunc = 'BuiltinNoCtorFunc', BuiltinNoPropertyDescriptor = 'NoPropertyDescriptor', - MissingAttributes = 'MissingAttributes' + MissingAttributes = 'MissingAttributes', + BuiltinNewCtor = 'BuiltinNewCtor', + BuiltinFinalClass = 'BuiltinFinalClass', + BuiltinNarrowTypes = 'BuiltinNarrowTypes', + BuiltinDisableApi = 'BuiltinDisableApi', + BuiltinIteratorResultValue = 'BuiltinIteratorResultValue' } export const SYMBOL_ITERATOR: string = 'Symbol.iterator'; @@ -51,3 +58,25 @@ export const BUILTIN_CONSTRUCTORS = ['Boolean', 'Number', 'Object', 'String']; export const COLLECTION_TYPES = new Set(['Map', 'Set', 'WeakMap', 'WeakSet']); export const COLLECTION_METHODS = new Set(['add', 'delete', 'get', 'has', 'set']); + +export const BUILTIN_TYPE = 'BuiltinApi'; +export const BuiltinProblemInfos = new Map([ + [BuiltinProblem.BuiltinNoCtorFunc, FaultID.BuiltinNoCtorFunc], + [BuiltinProblem.BuiltinNoPropertyDescriptor, FaultID.NoPropertyDescriptor], + [BuiltinProblem.BuiltinNarrowTypes, FaultID.BuiltinNarrowTypes], + [BuiltinProblem.BuiltinDisableApi, FaultID.BuiltinDisableApi], + [BuiltinProblem.BuiltinIteratorResultValue, FaultID.BuiltinIteratorResultValue] +]); +export const BUILTIN_CONSTRUCTOR_API_NAME: string = 'builtin_constructor'; +export const BUILTIN_CONSTRUCTOR_API_TYPE = ['CallSignature']; +export const BUILTIN_CALLSIGNATURE_NEWCTOR = [ + 'AggregateError', + 'Array', + 'Boolean', + 'Date', + 'Error', + 'Number', + 'String', + 'WeakMap', + 'Object' +]; diff --git a/ets2panda/linter/src/lib/utils/consts/DeprecateWhiteList.ts b/ets2panda/linter/src/lib/utils/consts/DeprecateWhiteList.ts index 0cdf0e2aba..e89e671d0d 100644 --- a/ets2panda/linter/src/lib/utils/consts/DeprecateWhiteList.ts +++ b/ets2panda/linter/src/lib/utils/consts/DeprecateWhiteList.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +export const DEPRECATE_TYPE = 'DeprecatedApi'; export enum DeprecateProblem { NoDeprecatedApi = 'NoDeprecatedApi' } diff --git a/ets2panda/linter/src/lib/utils/consts/SdkCommonDeprecateWhiteList.ts b/ets2panda/linter/src/lib/utils/consts/SdkCommonDeprecateWhiteList.ts index 992e803740..7a6c52b469 100644 --- a/ets2panda/linter/src/lib/utils/consts/SdkCommonDeprecateWhiteList.ts +++ b/ets2panda/linter/src/lib/utils/consts/SdkCommonDeprecateWhiteList.ts @@ -15,6 +15,7 @@ import { FaultID } from '../../Problems'; +export const SDK_COMMON_TYPE = 'SdkCommonApi'; export const SdkCommonApiProblemInfos = new Map([ ['WhiteList', FaultID.SdkCommonApiWhiteList], ['BehaviorChange', FaultID.SdkCommonApiBehaviorChange], diff --git a/ets2panda/linter/test/builtin/builtin_array_negative.ets b/ets2panda/linter/test/builtin/builtin_array_negative.ets new file mode 100755 index 0000000000..dbf1092470 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_negative.ets @@ -0,0 +1,78 @@ +/* + * 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 { collections } from '@kit.ArkTS'; + +let arr1 = new Array(); //BuiltinNewCtor +let arr2 = new Array(); //BuiltinNewCtor +arr1.concat(1, arr2); //BuiltinAll +Array.length; +let arr11: ReadonlyArray = new Array(); //BuiltinNewCtor +let arr22: ReadonlyArray = new Array(); //BuiltinNewCtor +arr11.concat(1, arr22); //BuiltinAll + +const isArr = Array.isArray([1]); //BuiltinAll +let arr = new Array(); //BuiltinNewCtor + +const date = new Date("August 19,1975 23:00:00 UTC");//lib.es2015.core.d.ts +const jsonDate = date.toJSON(); //BuiltinAll +new Date().toJSON(); //BuiltinAll+BuiltinNewCtor +function getDate(){ + return date; +} +getDate().toJSON(); //BuiltinAll +console.log(new Demo().localDate?.toJSON()) //BuiltinAll +const demo = new Demo(); +demo.get()?.toJSON(); //BuiltinAll +Date.toString(); +//Reflect +let a1 = new Array(1,2,3) //BuiltinNewCtor +Reflect.ownKeys(a1) //BuiltinAll + +//ArrayBufferConstructor +ArrayBuffer.isView(1); //BuiltinAll +ArrayBuffer.isView(100n); //BuiltinAll +interface ArrayBufferConstructor{} +class Demo implements ArrayBufferConstructor,Date{ + localDate:Date|undefined = undefined; + set(localDate:Date|undefined){ + localDate = new Date(); //BuiltinNewCtor + return localDate + } + get():Date|undefined{ + return this.set(this.localDate); + } + isView(arg: string): arg is ArrayBufferView { + this.localDate?.toJSON(); //BuiltinAll + } + toJSON(key?: number): string { //BuiltinAll + return ''; + } +} + +let array = new collections.Array(1, 2, 3); +let array1 = new collections.Array(4, 5, 6); +let array2 = new collections.Array(7, 8, 9); +let concatArray = array.concat(array1, array2); +let arr3: collections.Array = new collections.Array('a', 'b', 'c', 'd'); +let result: boolean = collections.Array.isArray(arr3); +console.info(result + ''); + +const uint8 = new Uint8Array([1, 2, 3]); +ArrayBuffer.isView(uint8) //BuiltinAll +const buffer = new ArrayBuffer(16); +const dataView = new DataView(buffer); +ArrayBuffer.isView(dataView) //BuiltinAll + +//sum:24 \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_array_negative.ets.args.json b/ets2panda/linter/test/builtin/builtin_array_negative.ets.args.json new file mode 100755 index 0000000000..4dfa4f2017 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_negative.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/builtin/builtin_array_negative.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_array_negative.ets.arkts2.json new file mode 100755 index 0000000000..86ad8dac2f --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_negative.ets.arkts2.json @@ -0,0 +1,398 @@ +{ + "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": 15, + "column": 10, + "endLine": 15, + "endColumn": 21, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 16, + "endLine": 17, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 16, + "endLine": 18, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 6, + "endLine": 19, + "endColumn": 12, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 40, + "endLine": 21, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 40, + "endLine": 22, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 13, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 21, + "endLine": 25, + "endColumn": 28, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 15, + "endLine": 26, + "endColumn": 20, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 29, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 12, + "endLine": 30, + "endColumn": 18, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 5, + "endLine": 30, + "endColumn": 9, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 11, + "endLine": 34, + "endColumn": 17, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 35, + "endLine": 35, + "endColumn": 41, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 13, + "endLine": 37, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 14, + "endLine": 40, + "endColumn": 19, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 1, + "endLine": 41, + "endColumn": 20, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 9, + "endLine": 41, + "endColumn": 16, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 13, + "endLine": 44, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 13, + "endLine": 45, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 46, + "endLine": 47, + "endColumn": 50, + "problem": "ExtendsExpression", + "suggest": "", + "rule": "Extends or implements expression are not supported(arkts-no-extends-expression)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 7, + "endLine": 47, + "endColumn": 11, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 3, + "endLine": 61, + "endColumn": 4, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 21, + "endLine": 50, + "endColumn": 25, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 21, + "endLine": 54, + "endColumn": 35, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 24, + "endLine": 56, + "endColumn": 46, + "problem": "IsOperator", + "suggest": "", + "rule": "Type guarding is supported with \"instanceof\" and \"as\" (arkts-no-is)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 21, + "endLine": 57, + "endColumn": 27, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 10, + "endLine": 59, + "endColumn": 22, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 43, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 17, + "endLine": 64, + "endColumn": 34, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 5, + "endLine": 65, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 18, + "endLine": 65, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 5, + "endLine": 66, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 18, + "endLine": 66, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 5, + "endLine": 67, + "endColumn": 47, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 43, + "endLine": 68, + "endColumn": 60, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 13, + "endLine": 73, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 13, + "endLine": 76, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_array_negative.ets.json b/ets2panda/linter/test/builtin/builtin_array_negative.ets.json new file mode 100755 index 0000000000..f96a03d6a0 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_negative.ets.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": 41, + "column": 1, + "endLine": 41, + "endColumn": 20, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 24, + "endLine": 56, + "endColumn": 46, + "problem": "IsOperator", + "suggest": "", + "rule": "Type guarding is supported with \"instanceof\" and \"as\" (arkts-no-is)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 5, + "endLine": 64, + "endColumn": 43, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 5, + "endLine": 65, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 5, + "endLine": 66, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 5, + "endLine": 67, + "endColumn": 47, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_array_positive.ets b/ets2panda/linter/test/builtin/builtin_array_positive.ets new file mode 100755 index 0000000000..73b998f458 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_positive.ets @@ -0,0 +1,25 @@ +/* + * 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 { collections } from '@kit.ArkTS'; +Array.length; +const date = new Date("August 19,1975 23:00:00 UTC");//lib.es2015.core.d.ts + +let array = new collections.Array(1, 2, 3); +let array1 = new collections.Array(4, 5, 6); +let array2 = new collections.Array(7, 8, 9); +let concatArray = array.concat(array1, array2); +let arr3: collections.Array = new collections.Array('a', 'b', 'c', 'd'); +let result: boolean = collections.Array.isArray(arr3); +console.info(result + ''); diff --git a/ets2panda/linter/test/builtin/builtin_array_positive.ets.args.json b/ets2panda/linter/test/builtin/builtin_array_positive.ets.args.json new file mode 100755 index 0000000000..4dfa4f2017 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_positive.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/builtin/builtin_array_positive.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_array_positive.ets.arkts2.json new file mode 100755 index 0000000000..2352209dcd --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_positive.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": 15, + "column": 10, + "endLine": 15, + "endColumn": 21, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 43, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 17, + "endLine": 19, + "endColumn": 34, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 18, + "endLine": 20, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 18, + "endLine": 21, + "endColumn": 35, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 47, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 43, + "endLine": 23, + "endColumn": 60, + "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/builtin/builtin_array_positive.ets.json b/ets2panda/linter/test/builtin/builtin_array_positive.ets.json new file mode 100755 index 0000000000..e44cb0bda3 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_array_positive.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": 19, + "column": 5, + "endLine": 19, + "endColumn": 43, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 47, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_callsignature.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_callsignature.ets.arkts2.json index 8263890683..6cdfec1941 100644 --- a/ets2panda/linter/test/builtin/builtin_callsignature.ets.arkts2.json +++ b/ets2panda/linter/test/builtin/builtin_callsignature.ets.arkts2.json @@ -34,6 +34,16 @@ "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", "severity": "ERROR" }, + { + "line": 20, + "column": 10, + "endLine": 20, + "endColumn": 15, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 23, "column": 29, diff --git a/ets2panda/linter/test/builtin/builtin_class.ets b/ets2panda/linter/test/builtin/builtin_class.ets new file mode 100755 index 0000000000..49d613c096 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_class.ets @@ -0,0 +1,102 @@ +/* + * 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 MyIntArray extends Int8Array implements Int8Array{} //BuiltinFinalClass*2 +interface MyIntArray2 extends Int8Array {} //BuiltinFinalClass + +class MyBigInt1 extends BigInt implements BigInt { //BuiltinFinalClass*2 + constructor(value: bigint | string | number) { + super(value); + } + [Symbol.iterator](): IterableIterator{ //BuiltinSymbolIterator + return this; + } +} + +class MyDataView1 extends DataView implements DataView{} //BuiltinFinalClass*2 +interface MyDataView3 extends DataView {} //BuiltinFinalClass + +class MyInt16Array1 extends Int16Array implements Int16Array { //BuiltinFinalClass*2 + filter(predicate: (value: number, index: number, array: Int16Array) => number, thisArg?: number): Int16Array {//BuiltinAll + return new Int16Array; + } +} +interface MyInt16Array2 extends Int16Array{ //BuiltinFinalClass + every(predicate: (value: number, index: number, array: Int16Array) => void, thisArg?: string): void; +} +class MyInt32Array1 extends Int32Array{}//BuiltinFinalClass +class MyInt32Array2 implements Int32Array{} //BuiltinFinalClass +interface MyInt32Array3 extends Int32Array{}; //BuiltinFinalClass + +class MyBigInt64Array1 extends BigInt64Array implements BigInt64Array{}//BuiltinFinalClass*2 +interface MyBigInt64Array2 extends BigInt64Array{}//BuiltinFinalClass + +class EmptyIterator implements IterableIterator{// + next(): IteratorResult {//BuiltinAll + return { done: true, value: undefined as void as T }; + } + + [Symbol.iterator](): IterableIterator {//BuiltinSymbolIterator*2 + return this; + }} +interface EmptyIterator2 extends IterableIterator{} + +class MyFloatArray1 extends Float32Array implements Float32Array,Float64Array {} //BuiltinFinalClass*3 +interface MyFloat32Array3 extends Float32Array{} //BuiltinFinalClass +interface MyFloat64Array3 extends Float64Array{} //BuiltinFinalClass + +class MyWeak extends WeakMapimplements WeakMap,WeakSet{} //BuiltinFinalClass*3 +interface MyWeakMap3 extends WeakMap{} //BuiltinFinalClass +class MyWeakSet1 extends WeakSet{} //BuiltinFinalClass +interface MyWeakSet3 extends WeakSet{} //BuiltinFinalClass + +class MyObject extends Boolean implements Boolean,String{} //BuiltinFinalClass*3 +interface MyBoolean3 extends Boolean {} //BuiltinFinalClass +interface MyString3 extends String{} //BuiltinFinalClass +class MyFinalizationRegistry1 extends FinalizationRegistry{} //BuiltinFinalClass +class MyFinalizationRegistry2 implements FinalizationRegistry { //BuiltinFinalClass + [Symbol.toStringTag]: "FinalizationRegistry"|undefined=undefined; + register(target: object, heldValue: T, unregisterToken?: object): void {} + unregister(unregisterToken: object): void {} +} +interface MyFinalizationRegistry3 extends FinalizationRegistry{} //BuiltinFinalClass +class MyPromise1 extends Promise { + constructor(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: number) => void) => void) { + super(executor); + } +} + +class MyPromise2 implements Promise { + then( + onfulfilled?: ((value: string) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: string) => TResult2 | PromiseLike) | null + ): Promise { + return Promise.resolve() as Promise; + } + + catch( + onrejected?: ((reason: string) => TResult | PromiseLike) | null + ): Promise { + return Promise.resolve() as Promise; + } + + finally(onfinally?: (() => void) | null): Promise { + return Promise.resolve() as Promise; + } + + [Symbol.toStringTag]: string = "Promise"; +} + +interface MyPromise3 extends Promise {} diff --git a/ets2panda/linter/test/builtin/builtin_class.ets.args.json b/ets2panda/linter/test/builtin/builtin_class.ets.args.json new file mode 100755 index 0000000000..4dfa4f2017 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_class.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/builtin/builtin_class.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_class.ets.arkts2.json new file mode 100755 index 0000000000..11d39cae87 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_class.ets.arkts2.json @@ -0,0 +1,668 @@ +{ + "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": 26, + "endLine": 16, + "endColumn": 35, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 7, + "endLine": 16, + "endColumn": 17, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 47, + "endLine": 16, + "endColumn": 56, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 31, + "endLine": 17, + "endColumn": 40, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 25, + "endLine": 19, + "endColumn": 31, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 7, + "endLine": 19, + "endColumn": 16, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 43, + "endLine": 19, + "endColumn": 49, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 4, + "endLine": 23, + "endColumn": 19, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 27, + "endLine": 28, + "endColumn": 35, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 7, + "endLine": 28, + "endColumn": 18, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 48, + "endLine": 28, + "endColumn": 56, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 31, + "endLine": 29, + "endColumn": 39, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 29, + "endLine": 31, + "endColumn": 39, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 7, + "endLine": 31, + "endColumn": 20, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 51, + "endLine": 31, + "endColumn": 61, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 10, + "endLine": 32, + "endColumn": 80, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 82, + "endLine": 32, + "endColumn": 98, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 33, + "endLine": 36, + "endColumn": 43, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 29, + "endLine": 39, + "endColumn": 39, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 20, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 32, + "endLine": 40, + "endColumn": 42, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 33, + "endLine": 41, + "endColumn": 43, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 32, + "endLine": 43, + "endColumn": 45, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 7, + "endLine": 43, + "endColumn": 23, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 57, + "endLine": 43, + "endColumn": 70, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 37, + "endLine": 44, + "endColumn": 50, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 7, + "endLine": 46, + "endColumn": 20, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 11, + "endLine": 47, + "endColumn": 25, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 14, + "endLine": 48, + "endColumn": 18, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 26, + "endLine": 48, + "endColumn": 31, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 46, + "endLine": 48, + "endColumn": 50, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 4, + "endLine": 51, + "endColumn": 19, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 29, + "endLine": 56, + "endColumn": 41, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 7, + "endLine": 56, + "endColumn": 20, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 53, + "endLine": 56, + "endColumn": 65, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 66, + "endLine": 56, + "endColumn": 78, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 35, + "endLine": 57, + "endColumn": 47, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 35, + "endLine": 58, + "endColumn": 47, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 43, + "endLine": 60, + "endColumn": 50, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 7, + "endLine": 60, + "endColumn": 13, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 67, + "endLine": 60, + "endColumn": 74, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 81, + "endLine": 60, + "endColumn": 88, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 51, + "endLine": 61, + "endColumn": 58, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 44, + "endLine": 62, + "endColumn": 51, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 48, + "endLine": 63, + "endColumn": 55, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 24, + "endLine": 65, + "endColumn": 31, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 7, + "endLine": 65, + "endColumn": 15, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 43, + "endLine": 65, + "endColumn": 50, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 51, + "endLine": 65, + "endColumn": 57, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 30, + "endLine": 66, + "endColumn": 37, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 29, + "endLine": 67, + "endColumn": 35, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 42, + "endLine": 68, + "endColumn": 62, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 45, + "endLine": 69, + "endColumn": 65, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 3, + "endLine": 70, + "endColumn": 23, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 11, + "endLine": 70, + "endColumn": 22, + "problem": "SymbolType", + "suggest": "", + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 46, + "endLine": 74, + "endColumn": 66, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 29, + "endLine": 75, + "endColumn": 36, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 32, + "endLine": 81, + "endColumn": 39, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 5, + "endLine": 83, + "endColumn": 79, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 5, + "endLine": 84, + "endColumn": 79, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 5, + "endLine": 90, + "endColumn": 77, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 3, + "endLine": 99, + "endColumn": 23, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 11, + "endLine": 99, + "endColumn": 22, + "problem": "SymbolType", + "suggest": "", + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 33, + "endLine": 102, + "endColumn": 40, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 3, + "endLine": 70, + "endColumn": 23, + "problem": "StrictDiagnostic", + "suggest": "Property '[Symbol.toStringTag]' in type 'MyFinalizationRegistry2' is not assignable to the same property in base type 'FinalizationRegistry'.\n Type '\"FinalizationRegistry\" | undefined' is not assignable to type '\"FinalizationRegistry\"'.\n Type 'undefined' is not assignable to type '\"FinalizationRegistry\"'.", + "rule": "Property '[Symbol.toStringTag]' in type 'MyFinalizationRegistry2' is not assignable to the same property in base type 'FinalizationRegistry'.\n Type '\"FinalizationRegistry\" | undefined' is not assignable to type '\"FinalizationRegistry\"'.\n Type 'undefined' is not assignable to type '\"FinalizationRegistry\"'.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_class.ets.json b/ets2panda/linter/test/builtin/builtin_class.ets.json new file mode 100755 index 0000000000..93d76b4694 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_class.ets.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": 70, + "column": 3, + "endLine": 70, + "endColumn": 23, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 4, + "endLine": 70, + "endColumn": 22, + "problem": "SymbolType", + "suggest": "", + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 3, + "endLine": 99, + "endColumn": 23, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 4, + "endLine": 99, + "endColumn": 22, + "problem": "SymbolType", + "suggest": "", + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 3, + "endLine": 70, + "endColumn": 23, + "problem": "StrictDiagnostic", + "suggest": "Property '[Symbol.toStringTag]' in type 'MyFinalizationRegistry2' is not assignable to the same property in base type 'FinalizationRegistry'.\n Type '\"FinalizationRegistry\" | undefined' is not assignable to type '\"FinalizationRegistry\"'.\n Type 'undefined' is not assignable to type '\"FinalizationRegistry\"'.", + "rule": "Property '[Symbol.toStringTag]' in type 'MyFinalizationRegistry2' is not assignable to the same property in base type 'FinalizationRegistry'.\n Type '\"FinalizationRegistry\" | undefined' is not assignable to type '\"FinalizationRegistry\"'.\n Type 'undefined' is not assignable to type '\"FinalizationRegistry\"'.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_decorator.ets b/ets2panda/linter/test/builtin/builtin_decorator.ets new file mode 100644 index 0000000000..68c12e6790 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_decorator.ets @@ -0,0 +1,229 @@ +/* + * 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. + */ + +let propertyDecorator: PropertyDecorator = (ttt, yyy) => { + console.log(yyy as string); +} + +class A { + @propertyDecorator + prop = 1 +} + +let classDecorator: ClassDecorator = (target) => { return target } + +@classDecorator +class B {} + +let methodDecorator: MethodDecorator = (target, propertyKey, descriptor) => { +console.log(JSON.stringify(descriptor)); +} + +class C { + @methodDecorator + method(): void {} +} + +let paramDecorator: ParameterDecorator = (target, methodName, paramIdx) => { + console.log(methodName as string); +} + +class D { + method(@paramDecorator param: string): void {} +} + +class C implements Iterator { + a: number = 0; + b: number; + constructor (b:number) { + this.b = b; + } + next(): IteratorResult { + if (this.a >= this.b) { + return {value:undefined, done:true} + } + this.a++; + return {value:this.a, done:false} + } + return(): IteratorResult { //error + console.log("call return") + this.a = 0; + return {value:undefined, done:true} + } + throw(e:Error): IteratorResult { //error + console.error("Error: " + e); + return { value: undefined, done: true }; + } +} +let a = new C(5) +a.next() +a.return() +a.throw(new Error("test")) + + +let b = String.raw`a\nb\nc` //error + + +function f(c:TemplateStringsArray, ...values: Object[]) { + c.raw; //error +} +const c: string = "123" +f`Hello, ${c}!` + + +type T1 = number | T1[]; +let arr1: ReadonlyArray = [1, [1]]; +arr1.flat(2); //error + + +type T = number | T[]; +let arr: ReadonlyArray = [1, [1]]; +arr.flatMap((value, index, array) => { //error + return value; +}); + + +let num = new Object(); +num.valueOf(); //error + + +type T2 = number | T2[]; +let arr2: Array = [1, [1]]; +arr2.flat(2); //error + + +const str = ''; +const arr3 = Array.from(str); //error + + +let buff: ArrayBufferTypes = { + ArrayBuffer: new ArrayBuffer(10), + SharedArrayBuffer: new SharedArrayBuffer(10) +} +buff.ArrayBuffer; //error +buff.SharedArrayBuffer; + + +function fn1(iArguments: IArguments) { + Reflect.get(iArguments, Symbol.iterator); //error +} + + +function fn2(iArguments: IArguments) { + iArguments.callee; //error +} + + +function fn3(iArguments: IArguments) { + iArguments.length; //error +} + + +let o: Intl.DateTimeFormatPartTypesRegistry = { + day: undefined, //error + dayPeriod: undefined, //error + era: undefined, //error + hour: undefined, //error + literal: undefined, //error + minute: undefined, //error + month: undefined, //error + second: undefined, //error + timeZoneName: undefined, //error + weekday: undefined, //error + year: undefined, //error + unknown: undefined, + fractionalSecond: undefined +} + + +Intl.DisplayNames.prototype; //error + + +Intl.ListFormat.prototype; //error + + +Intl.NumberFormat.prototype; //error + + +const arr4 = [0, 1, 2, [3, 4]]; +let arr5: FlatArray = arr4.flat(); //error + + +let d: Object = Object(); //error + + +let d1: Object = Object({}); //error + + +const text = '2025-01-01'; +const regex = /(?\d{4})-(?\d{2})-(?\d{2})/; +const match = regex.exec(text); +console.log(match!.groups!.year); //error + + +const text1 = '2025-01-01'; +const regex1 = /(?\d{4})-(?\d{2})-(?\d{2})/; +const match1 = text1.match(regex1); +console.log(match1!.groups!.year); //error + + +class FileReader { + private lines: string[] = ["Line 1", "Line 2", "Line 3"]; + + [Symbol.iterator](): Iterator { + let index = 0; + const self = this; + + return { + next(): IteratorResult { + if (index < self.lines.length) { + return { value: self.lines[index++], done: false }; + } else { + return { value: undefined, done: true }; + } + }, + + return(): IteratorReturnResult { //error + return { done: true, value: index }; + }, + }; + } +} + + +class Counter { + private count: number = 0; + private max: number; + + constructor(max: number) { + this.max = max; + } + + [Symbol.iterator](): Iterator { + const self = this; + + return { + next(): IteratorYieldResult { //error + if (self.count < self.max) { + return { + value: self.count++, + }; + } + + return { done: false, value: -1 }; + }, + }; + } +} diff --git a/ets2panda/linter/test/builtin/builtin_decorator.ets.args.json b/ets2panda/linter/test/builtin/builtin_decorator.ets.args.json new file mode 100644 index 0000000000..ec9992d924 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_decorator.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/builtin/builtin_decorator.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_decorator.ets.arkts2.json new file mode 100644 index 0000000000..f064799fd9 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_decorator.ets.arkts2.json @@ -0,0 +1,878 @@ +{ + "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": 3, + "endLine": 21, + "endColumn": 21, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 3, + "endLine": 21, + "endColumn": 21, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 16, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 16, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 62, + "endLine": 30, + "endColumn": 72, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 18, + "endLine": 31, + "endColumn": 27, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 18, + "endLine": 31, + "endColumn": 27, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 19, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 19, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 10, + "endLine": 44, + "endColumn": 25, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 10, + "endLine": 44, + "endColumn": 25, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 3, + "endLine": 64, + "endColumn": 4, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 3, + "endLine": 68, + "endColumn": 4, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 11, + "endLine": 53, + "endColumn": 25, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 15, + "endLine": 55, + "endColumn": 20, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 32, + "endLine": 55, + "endColumn": 36, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 13, + "endLine": 58, + "endColumn": 18, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 27, + "endLine": 58, + "endColumn": 31, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 3, + "endLine": 60, + "endColumn": 9, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 13, + "endLine": 60, + "endColumn": 27, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 13, + "endLine": 63, + "endColumn": 18, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 30, + "endLine": 63, + "endColumn": 34, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 3, + "endLine": 65, + "endColumn": 8, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 19, + "endLine": 65, + "endColumn": 33, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 14, + "endLine": 67, + "endColumn": 19, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 32, + "endLine": 67, + "endColumn": 36, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 16, + "endLine": 76, + "endColumn": 19, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 9, + "endLine": 76, + "endColumn": 28, + "problem": "TaggedTemplates", + "suggest": "", + "rule": "Tagged templates are not supported (arkts-no-tagged-templates)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 5, + "endLine": 80, + "endColumn": 8, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 1, + "endLine": 83, + "endColumn": 16, + "problem": "TaggedTemplates", + "suggest": "", + "rule": "Tagged templates are not supported (arkts-no-tagged-templates)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 6, + "endLine": 88, + "endColumn": 10, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 5, + "endLine": 93, + "endColumn": 12, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 15, + "endLine": 98, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 5, + "endLine": 99, + "endColumn": 12, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 6, + "endLine": 104, + "endColumn": 10, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 20, + "endLine": 108, + "endColumn": 24, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 3, + "endLine": 112, + "endColumn": 14, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 26, + "endLine": 113, + "endColumn": 43, + "problem": "SharedArrayBufferDeprecated", + "suggest": "", + "rule": "SharedArrayBuffer is not supported (arkts-no-need-stdlib-sharedArrayBuffer)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 6, + "endLine": 115, + "endColumn": 17, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 3, + "endLine": 120, + "endColumn": 44, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 27, + "endLine": 120, + "endColumn": 42, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 14, + "endLine": 125, + "endColumn": 20, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 14, + "endLine": 130, + "endColumn": 20, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 3, + "endLine": 135, + "endColumn": 6, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 12, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 137, + "column": 3, + "endLine": 137, + "endColumn": 6, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 3, + "endLine": 138, + "endColumn": 7, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 3, + "endLine": 139, + "endColumn": 10, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 3, + "endLine": 140, + "endColumn": 9, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 141, + "column": 3, + "endLine": 141, + "endColumn": 8, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 3, + "endLine": 142, + "endColumn": 9, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 143, + "column": 3, + "endLine": 143, + "endColumn": 15, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 3, + "endLine": 144, + "endColumn": 10, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 145, + "column": 3, + "endLine": 145, + "endColumn": 7, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 151, + "column": 19, + "endLine": 151, + "endColumn": 28, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 151, + "column": 19, + "endLine": 151, + "endColumn": 28, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 17, + "endLine": 154, + "endColumn": 26, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 17, + "endLine": 154, + "endColumn": 26, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 19, + "endLine": 157, + "endColumn": 28, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 19, + "endLine": 157, + "endColumn": 28, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 1, + "endLine": 157, + "endColumn": 18, + "problem": "PropertyDeclOnFunction", + "suggest": "", + "rule": "Declaring properties on functions is not supported (arkts-no-func-props)", + "severity": "ERROR" + }, + { + "line": 161, + "column": 11, + "endLine": 161, + "endColumn": 20, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 161, + "column": 31, + "endLine": 161, + "endColumn": 33, + "problem": "LimitedLiteralType", + "suggest": "", + "rule": "Literal types are restricted(arkts-limited-literal-types)", + "severity": "ERROR" + }, + { + "line": 161, + "column": 42, + "endLine": 161, + "endColumn": 46, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 164, + "column": 17, + "endLine": 164, + "endColumn": 23, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 167, + "column": 18, + "endLine": 167, + "endColumn": 24, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 171, + "column": 15, + "endLine": 171, + "endColumn": 61, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 173, + "column": 20, + "endLine": 173, + "endColumn": 26, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 177, + "column": 16, + "endLine": 177, + "endColumn": 62, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 179, + "column": 21, + "endLine": 179, + "endColumn": 27, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 185, + "column": 4, + "endLine": 185, + "endColumn": 19, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, + { + "line": 189, + "column": 12, + "endLine": 189, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 190, + "column": 15, + "endLine": 190, + "endColumn": 29, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 192, + "column": 20, + "endLine": 192, + "endColumn": 25, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 192, + "column": 38, + "endLine": 192, + "endColumn": 45, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 192, + "column": 48, + "endLine": 192, + "endColumn": 52, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 194, + "column": 20, + "endLine": 194, + "endColumn": 25, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 194, + "column": 38, + "endLine": 194, + "endColumn": 42, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 198, + "column": 7, + "endLine": 198, + "endColumn": 13, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 199, + "column": 18, + "endLine": 199, + "endColumn": 22, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 199, + "column": 30, + "endLine": 199, + "endColumn": 35, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 214, + "column": 4, + "endLine": 214, + "endColumn": 19, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 12, + "endLine": 217, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 221, + "column": 13, + "endLine": 221, + "endColumn": 18, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 18, + "endLine": 225, + "endColumn": 22, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 31, + "endLine": 225, + "endColumn": 36, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_decorator.ets.json b/ets2panda/linter/test/builtin/builtin_decorator.ets.json new file mode 100644 index 0000000000..653a0772bb --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_decorator.ets.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": 120, + "column": 3, + "endLine": 120, + "endColumn": 44, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 151, + "column": 19, + "endLine": 151, + "endColumn": 28, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 17, + "endLine": 154, + "endColumn": 26, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 19, + "endLine": 157, + "endColumn": 28, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)", + "severity": "ERROR" + }, + { + "line": 189, + "column": 12, + "endLine": 189, + "endColumn": 13, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 12, + "endLine": 217, + "endColumn": 13, + "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/builtin/builtin_error_negative.ets b/ets2panda/linter/test/builtin/builtin_error_negative.ets new file mode 100755 index 0000000000..36716c22fd --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_negative.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let err1: AggregateError = new AggregateError([1]); //NoPropertyDescriptor +let err2: AggregateError = new AggregateError([1]); //NoPropertyDescriptor +let errors: Object[] = err2.errors; // NoPropertyDescriptor +try { + throw new Error(); //lib.es2022.error.d.ts +} catch (e) { + new Error("Connecting to database failed.", {cause: e}); +} +function get(err: AggregateError):Error { //NoPropertyDescriptor + const a = AggregateError.name; + const errr = Error() //BuiltinNoCtorFunc + return new Error; //lib.es2022.error.d.ts +} +const err3 = new AggregateError([1, "two", new Error("fail")]); //NoPropertyDescriptor +console.log(err3.errors.toString()); // NoPropertyDescriptor +console.log(err3.message); // NoPropertyDescriptor? + +const err4 = new AggregateError( //NoPropertyDescriptor + [new TypeError("invalid type"), new RangeError("out of bounds")], + "Multiple errors occurred" +); +console.log(err4.errors.length.toString()); // NoPropertyDescriptor + BuiltinAll + +function fetchData() { + try { + throw new Error("Network timeout"); //BuiltinNoCtorFunc lib.es2022.error.d.ts + } catch (e) { + return new Error("Fetch failed", { cause: e }); + } +} + +const result = fetchData(); +if (result.cause) {//NoPropertyDescriptor + console.log("Root cause:", result.cause.message); // NoPropertyDescriptor +} +console.log(err4.errors.toString()); // NoPropertyDescriptor + +//sum:18-1 \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_error_negative.ets.args.json b/ets2panda/linter/test/builtin/builtin_error_negative.ets.args.json new file mode 100755 index 0000000000..4dfa4f2017 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_negative.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/builtin/builtin_error_negative.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_error_negative.ets.arkts2.json new file mode 100755 index 0000000000..4b1ce86a71 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_negative.ets.arkts2.json @@ -0,0 +1,238 @@ +{ + "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": 5, + "endLine": 16, + "endColumn": 9, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 9, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 35, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 24, + "endLine": 18, + "endColumn": 28, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 29, + "endLine": 18, + "endColumn": 35, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 48, + "endLine": 22, + "endColumn": 53, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 14, + "endLine": 24, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 16, + "endLine": 26, + "endColumn": 21, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 13, + "endLine": 30, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 18, + "endLine": 30, + "endColumn": 24, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 13, + "endLine": 31, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 7, + "endLine": 33, + "endColumn": 11, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 8, + "endLine": 34, + "endColumn": 17, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 39, + "endLine": 34, + "endColumn": 49, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 13, + "endLine": 37, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 18, + "endLine": 37, + "endColumn": 24, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 40, + "endLine": 43, + "endColumn": 45, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 12, + "endLine": 48, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 37, + "endLine": 49, + "endColumn": 42, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 13, + "endLine": 51, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 18, + "endLine": 51, + "endColumn": 24, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_error_negative.ets.json b/ets2panda/linter/test/builtin/builtin_error_negative.ets.json new file mode 100755 index 0000000000..7633c79b6a --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_negative.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/builtin/builtin_error_positive.ets b/ets2panda/linter/test/builtin/builtin_error_positive.ets new file mode 100755 index 0000000000..80579bdae4 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_positive.ets @@ -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. + */ + +try { + throw new Error(); //lib.es2022.error.d.ts +} catch (e) { + new Error("Connecting to database failed."); +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_error_positive.ets.args.json b/ets2panda/linter/test/builtin/builtin_error_positive.ets.args.json new file mode 100755 index 0000000000..4dfa4f2017 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_positive.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/builtin/builtin_error_positive.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_error_positive.ets.arkts2.json new file mode 100755 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_positive.ets.arkts2.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/builtin/builtin_error_positive.ets.json b/ets2panda/linter/test/builtin/builtin_error_positive.ets.json new file mode 100755 index 0000000000..7633c79b6a --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_error_positive.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/builtin/builtin_iterator_result.ets b/ets2panda/linter/test/builtin/builtin_iterator_result.ets new file mode 100644 index 0000000000..cbe6df9118 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_iterator_result.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +let arr = new Array('a'); +let iterator = arr.entries(); +let result = iterator.next(); +result.value[0]; + +arr.entries().next().value; \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_iterator_result.ets.args.json b/ets2panda/linter/test/builtin/builtin_iterator_result.ets.args.json new file mode 100644 index 0000000000..ec9992d924 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_iterator_result.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/builtin/builtin_iterator_result.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_iterator_result.ets.arkts2.json new file mode 100644 index 0000000000..424cd6f851 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_iterator_result.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": 16, + "column": 15, + "endLine": 16, + "endColumn": 20, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 13, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 27, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_iterator_result.ets.json b/ets2panda/linter/test/builtin/builtin_iterator_result.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_iterator_result.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/builtin/builtin_not_support_property_descriptor.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_not_support_property_descriptor.ets.arkts2.json index aa44c0c86e..f0f3bcf5e3 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 @@ -54,6 +54,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 17, + "column": 4, + "endLine": 17, + "endColumn": 16, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 18, "column": 2, @@ -64,6 +74,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 18, + "column": 4, + "endLine": 18, + "endColumn": 14, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 19, "column": 2, @@ -74,6 +94,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 20, "column": 2, @@ -84,6 +114,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 20, + "column": 4, + "endLine": 20, + "endColumn": 12, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 21, "column": 2, @@ -124,6 +164,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 26, + "column": 3, + "endLine": 26, + "endColumn": 8, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 28, "column": 7, @@ -134,6 +184,36 @@ "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", "severity": "ERROR" }, + { + "line": 29, + "column": 3, + "endLine": 29, + "endColumn": 13, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 3, + "endLine": 30, + "endColumn": 15, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 3, + "endLine": 31, + "endColumn": 11, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 37, "column": 1, @@ -164,6 +244,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 38, + "column": 7, + "endLine": 38, + "endColumn": 19, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 39, "column": 5, @@ -174,6 +264,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 39, + "column": 7, + "endLine": 39, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 40, "column": 5, @@ -184,6 +284,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 12, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 41, "column": 5, @@ -194,6 +304,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 41, + "column": 7, + "endLine": 41, + "endColumn": 15, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 42, "column": 5, @@ -224,6 +344,16 @@ "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", "severity": "ERROR" }, + { + "line": 47, + "column": 5, + "endLine": 47, + "endColumn": 10, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 49, "column": 9, @@ -234,6 +364,36 @@ "rule": "Type of parameter must be defined explicitly (arkts-require-func-arg-type)", "severity": "ERROR" }, + { + "line": 50, + "column": 5, + "endLine": 50, + "endColumn": 15, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 5, + "endLine": 51, + "endColumn": 17, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 5, + "endLine": 52, + "endColumn": 13, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, { "line": 57, "column": 11, diff --git a/ets2panda/linter/test/builtin/builtin_object_negative.ets b/ets2panda/linter/test/builtin/builtin_object_negative.ets new file mode 100755 index 0000000000..cc99adc965 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_negative.ets @@ -0,0 +1,114 @@ +/* + * 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. + */ +//NumberConstructor +const num1 = new Number('123');//BuiltinNewCtor 1 +Number('123');//BuiltinNoCtorFunc 1 +console.log(Number(undefined).toString());//BuiltinNoCtorFunc 1 +Number.isFinite(1) //BuiltinAll 1 +Number.isInteger(true) //BuiltinAll 1 +Number.isNaN(true) //BuiltinAll 1 +Number.isSafeInteger(true) //BuiltinAll 1 +isFinite(11); +//ObjectConstructor +interface Person { + name: string; + age: number; +} +const obj: Person = { + name: '', + age: 42 +}; +const a: [string, number][] = Object.entries(obj);//BuiltinAll 1 +Object.values(obj);//BuiltinAll 1 + +const entries: Map = new Map([ + ['1', '2'] +]); +const obj1 = Object.fromEntries(entries);//BuiltinAll 1 +typeof new Object();//BuiltinAll 1 + +//String +new String(undefined);//BuiltinNewCtor 1 +String('');//BuiltinNoCtorFunc 1 +const str: string = 'abc'; +str.replace('a', 'b'); +str.replaceAll('a', 'b'); +class Demo implements String{ + replaceAll1(searchValue: string | RegExp, replacer: string): string { + + } + replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string{//BuiltinAll 1 + + } +} +//replace(searchValue: string | RegExp, replaceValue: string): string; +const text = "Hello World, World!"; +const result1 = text.replace("World", "TypeScript"); +const result2 = text.replace(/World/g, "TypeScript"); + +//replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; +function toUpperCaseReplacer(match: string): string { + return match.toUpperCase(); +} +text.replace('',toUpperCaseReplacer)//BuiltinAll 1 +const result4 = text.replace("world", (match) => match.toUpperCase());//BuiltinAll 1 +const result5 = text.replace("/(\w+) (\w+)/", (first, last:number) => `${last}, ${first}`);//BuiltinAll 1 +//replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; +//lib.es2015.symbol.wellknown.d.ts +const result6 = text.replace(/-/g, (match, offset:string) => `-${offset}-`);//BuiltinAll!! +const camelCase = text.replace(/_(\w)/g, (_, char:string) => char.toUpperCase());//BuiltinAll!! +console.log(camelCase); +const prices = { apple: 5, banana: 3 }; +function pricesChange(count:string, fruit:string){ + const price = prices[fruit as keyof typeof prices] || 0; + return `${count} ${fruit} ($${price * parseInt(count)})`; +} +const result7 = text.replaceAll(/(\d+)\s+(\w+)/g, pricesChange);//BuiltinAll 1 + +//WeakMapConstructor +interface Person1 { + age: number; +} +const key1: Person1 = {age: 12}; +const key2: Person1 = {age: 123}; +const weakMap = new WeakMap([ // 0 lib.es2015.iterable.d.ts + [key1, 'value1'], + [key2, 'value2'] +]); +//JSON +const a = JSON.stringify({x: 5, y: 6});//BuiltinAll 1 +class Test implements JSON{ + stringify(value: string, replacer?: (number | string)[] | null, space?: string | number): string{//BuiltinAll 1 + return ''; + } + str: String = ''; + get() { + return this.str; + } +} +const d = new Test(); +d.get().replaceAll('a', pricesChange);//BuiltinAll 1 + +const boolObj1 = new Boolean(true); //BuiltinNewCtor +console.log(boolObj1.valueOf()); +console.log(new Test().valueOf()); //BuiltinAll +console.log(typeof boolObj1); +const tt = new Test(); +typeof tt.valueOf; //BuiltinAll?? +const boolObj2 = new Boolean(""); //BuiltinNewCtor +const boolObj3 = new Boolean(null); //BuiltinNewCtor +const boolObj4 = new Boolean(0); //BuiltinNewCtor + +//sum:27 diff --git a/ets2panda/linter/test/builtin/builtin_object_negative.ets.args.json b/ets2panda/linter/test/builtin/builtin_object_negative.ets.args.json new file mode 100755 index 0000000000..4dfa4f2017 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_negative.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/builtin/builtin_object_negative.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_object_negative.ets.arkts2.json new file mode 100755 index 0000000000..533a742ee1 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_negative.ets.arkts2.json @@ -0,0 +1,528 @@ +{ + "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": 14, + "endLine": 16, + "endColumn": 31, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 18, + "endLine": 16, + "endColumn": 24, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 7, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 13, + "endLine": 18, + "endColumn": 19, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 16, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 8, + "endLine": 20, + "endColumn": 17, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 8, + "endLine": 21, + "endColumn": 13, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 8, + "endLine": 22, + "endColumn": 21, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 7, + "endLine": 33, + "endColumn": 50, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 38, + "endLine": 33, + "endColumn": 45, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 8, + "endLine": 34, + "endColumn": 14, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 38, + "endLine": 38, + "endColumn": 3, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 21, + "endLine": 39, + "endColumn": 32, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 21, + "endLine": 39, + "endColumn": 32, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 12, + "endLine": 40, + "endColumn": 18, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 22, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 5, + "endLine": 43, + "endColumn": 11, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 1, + "endLine": 44, + "endColumn": 7, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 7, + "endLine": 48, + "endColumn": 11, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 23, + "endLine": 48, + "endColumn": 29, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 3, + "endLine": 54, + "endColumn": 4, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 44, + "endLine": 52, + "endColumn": 99, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 83, + "endLine": 52, + "endColumn": 86, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 30, + "endLine": 59, + "endColumn": 38, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 6, + "endLine": 65, + "endColumn": 13, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 22, + "endLine": 66, + "endColumn": 29, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 22, + "endLine": 67, + "endColumn": 29, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 30, + "endLine": 70, + "endColumn": 34, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 32, + "endLine": 71, + "endColumn": 40, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 16, + "endLine": 73, + "endColumn": 17, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 17, + "endLine": 75, + "endColumn": 53, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 39, + "endLine": 75, + "endColumn": 45, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 22, + "endLine": 78, + "endColumn": 32, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 33, + "endLine": 78, + "endColumn": 49, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 16, + "endLine": 91, + "endColumn": 25, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 16, + "endLine": 91, + "endColumn": 25, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 7, + "endLine": 92, + "endColumn": 11, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 3, + "endLine": 95, + "endColumn": 4, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"JSON\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 3, + "endLine": 95, + "endColumn": 4, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 13, + "endLine": 93, + "endColumn": 26, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 28, + "endLine": 93, + "endColumn": 65, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 9, + "endLine": 102, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 18, + "endLine": 104, + "endColumn": 35, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 22, + "endLine": 104, + "endColumn": 29, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 24, + "endLine": 106, + "endColumn": 31, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 18, + "endLine": 110, + "endColumn": 33, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 22, + "endLine": 110, + "endColumn": 29, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 18, + "endLine": 111, + "endColumn": 35, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 22, + "endLine": 111, + "endColumn": 29, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 18, + "endLine": 112, + "endColumn": 32, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 22, + "endLine": 112, + "endColumn": 29, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_object_negative.ets.json b/ets2panda/linter/test/builtin/builtin_object_negative.ets.json new file mode 100755 index 0000000000..3ca8258156 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_negative.ets.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": 39, + "column": 14, + "endLine": 39, + "endColumn": 41, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 83, + "endLine": 52, + "endColumn": 86, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 16, + "endLine": 73, + "endColumn": 17, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 17, + "endLine": 75, + "endColumn": 53, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 39, + "endLine": 75, + "endColumn": 45, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_object_positive.ets b/ets2panda/linter/test/builtin/builtin_object_positive.ets new file mode 100755 index 0000000000..876d5d13ce --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_positive.ets @@ -0,0 +1,30 @@ +/* + * 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. + */ +const str: string = 'abc'; +str.replace('a', 'b'); +str.replaceAll('a', 'b'); +class Demo implements String{ //BuiltinFinalClass + replaceAll1(searchValue: string | RegExp, replacer: string): string { + + } +} +//replace(searchValue: string | RegExp, replaceValue: string): string; +const text = "Hello World, World!"; +const result1 = text.replace("World", "TypeScript"); +const result2 = text.replace(/World/g, "TypeScript"); + +//lib.es2015.symbol.wellknown.d.ts +const result6 = text.replace(/-/g, (match, offset:string) => `-${offset}-`); +const camelCase = text.replace(/_(\w)/g, (_, char:string) => char.toUpperCase()); \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_object_positive.ets.args.json b/ets2panda/linter/test/builtin/builtin_object_positive.ets.args.json new file mode 100755 index 0000000000..4dfa4f2017 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_positive.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/builtin/builtin_object_positive.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_object_positive.ets.arkts2.json new file mode 100755 index 0000000000..86f288bc70 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_positive.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": 18, + "column": 7, + "endLine": 18, + "endColumn": 11, + "problem": "InterfaceFieldNotImplemented", + "suggest": "", + "rule": "ArkTS 1.2 should implement all fields in the interface in the class (arkts-no-class-omit-interface-optional-prop)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 23, + "endLine": 18, + "endColumn": 29, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 30, + "endLine": 26, + "endColumn": 38, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 30, + "endLine": 29, + "endColumn": 34, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 32, + "endLine": 30, + "endColumn": 40, + "problem": "RegularExpressionLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_object_positive.ets.json b/ets2panda/linter/test/builtin/builtin_object_positive.ets.json new file mode 100755 index 0000000000..7633c79b6a --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_object_positive.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/builtin/builtin_thisArgs.ets b/ets2panda/linter/test/builtin/builtin_thisArgs.ets index b296e847c1..912735bad5 100755 --- a/ets2panda/linter/test/builtin/builtin_thisArgs.ets +++ b/ets2panda/linter/test/builtin/builtin_thisArgs.ets @@ -23,7 +23,7 @@ Class MyClass { } } -let arr: Array = new Array(1, 2, 3); +let arr: Array = new Array(1, 2, 3); //BuiltinNewCtor let a = new MyClass(2); let b = new MyClass(3); arr.filter(a.compare, a); diff --git a/ets2panda/linter/test/builtin/builtin_thisArgs.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_thisArgs.ets.arkts2.json index eb2072ee24..738f2b023c 100755 --- a/ets2panda/linter/test/builtin/builtin_thisArgs.ets.arkts2.json +++ b/ets2panda/linter/test/builtin/builtin_thisArgs.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" }, + { + "line": 26, + "column": 30, + "endLine": 26, + "endColumn": 35, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 27, "column": 5, diff --git a/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets b/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets new file mode 100644 index 0000000000..50efe4e895 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets @@ -0,0 +1,29 @@ +/* + * 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. + */ + +let arr = new Array(10); +let arr1 = new Array(10); +let arr2 = new Array(); +new Array(100); +new Array(100); +new Array([1, 2]); +new Array([1, 2]); +new Array(['1', '2']); + +function test(): number { + return 1; +} + +new Array(test()); \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.args.json b/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.args.json new file mode 100644 index 0000000000..66fb88f859 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_uninitialized_element.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/builtin/builtin_uninitialized_element.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.arkts2.json new file mode 100644 index 0000000000..5642d59659 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.arkts2.json @@ -0,0 +1,228 @@ +{ + "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": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 11, + "endLine": 16, + "endColumn": 32, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 25, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 16, + "endLine": 17, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 12, + "endLine": 17, + "endColumn": 25, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 12, + "endLine": 17, + "endColumn": 25, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 23, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 16, + "endLine": 18, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 12, + "endLine": 18, + "endColumn": 23, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 10, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 23, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 10, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 15, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 15, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 10, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 18, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 10, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 10, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 10, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 18, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 18, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.json b/ets2panda/linter/test/builtin/builtin_uninitialized_element.ets.json new file mode 100644 index 0000000000..1de3f8f971 --- /dev/null +++ b/ets2panda/linter/test/builtin/builtin_uninitialized_element.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": 17, + "column": 5, + "endLine": 17, + "endColumn": 25, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 23, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/deprecatedapi/action_sheet.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.arkts2.json index 35e1e2cbd1..16b900fecb 100644 --- a/ets2panda/linter/test/deprecatedapi/action_sheet.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/action_sheet.ets.arkts2.json @@ -24,6 +24,26 @@ "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", "severity": "ERROR" }, + { + "line": 41, + "column": 45, + "endLine": 41, + "endColumn": 54, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 45, + "endLine": 41, + "endColumn": 54, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 18, "column": 2, diff --git a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json index 00497d0261..38f8794a0f 100644 --- a/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/deprecated_api_font.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "ArkUI deprecated api check (arkui-no-deprecated-api)", "severity": "ERROR" }, + { + "line": 21, + "column": 33, + "endLine": 21, + "endColumn": 38, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 24, "column": 10, diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json b/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json index 741e95d38a..cbd68cf1d7 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json @@ -124,6 +124,16 @@ "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, + { + "line": 25, + "column": 48, + "endLine": 25, + "endColumn": 53, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 25, "column": 44, 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 48479f4d9e..b2c74f81c8 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json @@ -212,6 +212,16 @@ "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, + { + "line": 25, + "column": 48, + "endLine": 25, + "endColumn": 53, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 25, "column": 44, 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 056c6e9c99..a0ef855021 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json @@ -44,6 +44,16 @@ "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, + { + "line": 25, + "column": 48, + "endLine": 25, + "endColumn": 53, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 25, "column": 44, diff --git a/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json b/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json index 41a2db7981..1c34bb456b 100644 --- a/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json +++ b/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json @@ -34,6 +34,26 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 21, + "column": 12, + "endLine": 21, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 12, + "endLine": 23, + "endColumn": 18, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 24, "column": 9, diff --git a/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json b/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json index c76a12de83..77b9d8ee5c 100644 --- a/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json +++ b/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json @@ -44,6 +44,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 20, + "column": 10, + "endLine": 20, + "endColumn": 17, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 24, "column": 5, @@ -54,6 +64,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 24, + "column": 20, + "endLine": 24, + "endColumn": 23, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 27, "column": 1, @@ -134,6 +154,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 38, + "column": 13, + "endLine": 38, + "endColumn": 20, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 41, "column": 1, @@ -174,6 +204,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 44, + "column": 9, + "endLine": 44, + "endColumn": 16, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 46, "column": 1, @@ -214,6 +254,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 49, + "column": 9, + "endLine": 49, + "endColumn": 16, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 51, "column": 1, @@ -254,6 +304,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 54, + "column": 9, + "endLine": 54, + "endColumn": 16, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 56, "column": 1, @@ -293,6 +353,16 @@ "suggest": "", "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" + }, + { + "line": 59, + "column": 9, + "endLine": 59, + "endColumn": 16, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json index b8110abb5b..8ef0297136 100644 --- a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json @@ -54,6 +54,16 @@ "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", "severity": "ERROR" }, + { + "line": 32, + "column": 35, + "endLine": 32, + "endColumn": 40, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 36, "column": 3, @@ -324,6 +334,16 @@ "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", "severity": "ERROR" }, + { + "line": 149, + "column": 40, + "endLine": 149, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 149, "column": 36, @@ -334,6 +354,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 150, + "column": 21, + "endLine": 150, + "endColumn": 26, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 150, "column": 17, @@ -344,6 +374,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 150, + "column": 17, + "endLine": 150, + "endColumn": 29, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 151, "column": 1, @@ -364,6 +404,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 155, + "column": 17, + "endLine": 155, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 156, "column": 1, diff --git a/ets2panda/linter/test/main/arkts-primitive-type-normalization.ets.arkts2.json b/ets2panda/linter/test/main/arkts-primitive-type-normalization.ets.arkts2.json index 6265f75a79..517754f2cf 100644 --- a/ets2panda/linter/test/main/arkts-primitive-type-normalization.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts-primitive-type-normalization.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 16, + "column": 12, + "endLine": 16, + "endColumn": 18, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 17, "column": 1, @@ -34,6 +44,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 11, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 17, "column": 18, @@ -44,6 +64,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 17, + "column": 22, + "endLine": 17, + "endColumn": 28, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 18, "column": 5, @@ -54,6 +84,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 18, + "column": 9, + "endLine": 18, + "endColumn": 16, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 19, "column": 9, @@ -64,6 +104,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 19, + "column": 13, + "endLine": 19, + "endColumn": 19, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 20, "column": 1, @@ -74,6 +124,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 12, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 21, "column": 1, @@ -84,6 +144,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 11, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 22, "column": 1, @@ -93,6 +163,16 @@ "suggest": "", "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts_class_no_signature_public_obj_api.ets.arkts2.json b/ets2panda/linter/test/main/arkts_class_no_signature_public_obj_api.ets.arkts2.json index 0352c42e8b..45b2c20266 100644 --- a/ets2panda/linter/test/main/arkts_class_no_signature_public_obj_api.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts_class_no_signature_public_obj_api.ets.arkts2.json @@ -34,6 +34,16 @@ "rule": "The signature of a method in a class/interface cannot be different from the public interface in an object. (arkts-class-no-signature-distinct-with-object-public-api)", "severity": "ERROR" }, + { + "line": 37, + "column": 27, + "endLine": 37, + "endColumn": 38, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 45, "column": 3, @@ -84,6 +94,26 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 55, + "column": 21, + "endLine": 55, + "endColumn": 32, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 27, + "endLine": 63, + "endColumn": 38, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 70, "column": 3, @@ -124,6 +154,26 @@ "rule": "The signature of a method in a class/interface cannot be different from the public interface in an object. (arkts-class-no-signature-distinct-with-object-public-api)", "severity": "ERROR" }, + { + "line": 84, + "column": 21, + "endLine": 84, + "endColumn": 32, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 27, + "endLine": 86, + "endColumn": 38, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 90, "column": 3, @@ -164,6 +214,16 @@ "rule": "The signature of a method in a class/interface cannot be different from the public interface in an object. (arkts-class-no-signature-distinct-with-object-public-api)", "severity": "ERROR" }, + { + "line": 95, + "column": 27, + "endLine": 95, + "endColumn": 38, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 100, "column": 3, diff --git a/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json b/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json index a3e735670a..c48332a4e2 100644 --- a/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json +++ b/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json @@ -14,6 +14,86 @@ "limitations under the License." ], "result": [ + { + "line": 27, + "column": 31, + "endLine": 27, + "endColumn": 40, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 31, + "endLine": 27, + "endColumn": 40, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 32, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 32, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 32, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 32, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 31, + "endLine": 33, + "endColumn": 40, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 31, + "endLine": 33, + "endColumn": 40, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 35, "column": 22, 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 46d9c9c834..8513dde89d 100644 --- a/ets2panda/linter/test/main/class_as_object.ets.arkts2.json +++ b/ets2panda/linter/test/main/class_as_object.ets.arkts2.json @@ -664,6 +664,76 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, + { + "line": 171, + "column": 7, + "endLine": 171, + "endColumn": 14, + "problem": "NoPropertyDescriptor", + "suggest": "", + "rule": "Not support propertydescriptor (arkts-builtin-no-property-descriptor)", + "severity": "ERROR" + }, + { + "line": 171, + "column": 17, + "endLine": 171, + "endColumn": 31, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 172, + "column": 15, + "endLine": 172, + "endColumn": 20, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 174, + "column": 14, + "endLine": 174, + "endColumn": 21, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 175, + "column": 14, + "endLine": 175, + "endColumn": 18, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 13, + "endLine": 176, + "endColumn": 18, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 179, + "column": 13, + "endLine": 179, + "endColumn": 19, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 180, "column": 7, @@ -674,6 +744,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 180, + "column": 13, + "endLine": 180, + "endColumn": 19, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 183, "column": 15, @@ -684,6 +764,16 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 184, + "column": 13, + "endLine": 184, + "endColumn": 19, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 185, "column": 13, @@ -704,6 +794,16 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, + { + "line": 192, + "column": 15, + "endLine": 192, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 193, "column": 9, @@ -723,6 +823,16 @@ "suggest": "", "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" + }, + { + "line": 202, + "column": 30, + "endLine": 202, + "endColumn": 36, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/collections_module.ets.migrate.json b/ets2panda/linter/test/main/collections_module.ets.migrate.json index 9b9298a1b6..3c02aec6ac 100644 --- a/ets2panda/linter/test/main/collections_module.ets.migrate.json +++ b/ets2panda/linter/test/main/collections_module.ets.migrate.json @@ -14,6 +14,46 @@ "limitations under the License." ], "result": [ + { + "line": 26, + "column": 43, + "endLine": 26, + "endColumn": 48, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 28, + "endLine": 28, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 28, + "endLine": 30, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 43, + "endLine": 34, + "endColumn": 48, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 41, "column": 11, diff --git a/ets2panda/linter/test/main/common_union_member_access.ets.arkts2.json b/ets2panda/linter/test/main/common_union_member_access.ets.arkts2.json index ca88f857e9..72664bab13 100644 --- a/ets2panda/linter/test/main/common_union_member_access.ets.arkts2.json +++ b/ets2panda/linter/test/main/common_union_member_access.ets.arkts2.json @@ -13,5 +13,26 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 21, + "column": 31, + "endLine": 21, + "endColumn": 47, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 27, + "endLine": 22, + "endColumn": 43, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json b/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json index 125bd65b78..1db059acba 100755 --- a/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json +++ b/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json @@ -244,6 +244,56 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 81, + "column": 3, + "endLine": 81, + "endColumn": 10, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 3, + "endLine": 82, + "endColumn": 10, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 3, + "endLine": 83, + "endColumn": 10, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 3, + "endLine": 84, + "endColumn": 10, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 1, + "endLine": 87, + "endColumn": 8, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 89, "column": 5, @@ -254,6 +304,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 89, + "column": 16, + "endLine": 89, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 89, "column": 12, @@ -354,6 +414,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 93, + "column": 20, + "endLine": 93, + "endColumn": 27, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 93, "column": 16, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json index 255cfcd961..b04045a8b8 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 17, + "column": 28, + "endLine": 17, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 17, "column": 24, @@ -34,6 +44,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 18, + "column": 40, + "endLine": 18, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 18, "column": 36, @@ -44,6 +64,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 19, + "column": 21, + "endLine": 19, + "endColumn": 26, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 19, "column": 17, @@ -394,6 +424,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 81, + "column": 29, + "endLine": 81, + "endColumn": 34, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 81, "column": 25, @@ -404,6 +444,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 83, + "column": 9, + "endLine": 83, + "endColumn": 14, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 83, "column": 5, @@ -424,6 +474,16 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 97, + "column": 40, + "endLine": 97, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 97, "column": 36, @@ -434,6 +494,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 98, + "column": 55, + "endLine": 98, + "endColumn": 60, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 98, "column": 51, @@ -444,6 +514,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 99, + "column": 56, + "endLine": 99, + "endColumn": 61, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 99, "column": 52, @@ -454,6 +534,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 100, + "column": 26, + "endLine": 100, + "endColumn": 31, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 100, "column": 22, @@ -514,6 +604,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 117, + "column": 26, + "endLine": 117, + "endColumn": 33, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 119, "column": 26, @@ -524,6 +624,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 119, + "column": 26, + "endLine": 119, + "endColumn": 33, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 124, "column": 17, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json index 990925b779..c75c354033 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json @@ -24,6 +24,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 17, + "column": 28, + "endLine": 17, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 17, "column": 24, @@ -34,6 +44,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 18, + "column": 40, + "endLine": 18, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 18, "column": 36, @@ -55,6 +75,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 19, + "column": 21, + "endLine": 19, + "endColumn": 26, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 19, "column": 17, @@ -570,6 +600,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 81, + "column": 29, + "endLine": 81, + "endColumn": 34, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 81, "column": 25, @@ -591,6 +631,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 83, + "column": 9, + "endLine": 83, + "endColumn": 14, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 83, "column": 5, @@ -622,6 +672,16 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 97, + "column": 40, + "endLine": 97, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 97, "column": 36, @@ -643,6 +703,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 98, + "column": 55, + "endLine": 98, + "endColumn": 60, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 98, "column": 51, @@ -664,6 +734,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 99, + "column": 56, + "endLine": 99, + "endColumn": 61, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 99, "column": 52, @@ -674,6 +754,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 100, + "column": 26, + "endLine": 100, + "endColumn": 31, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 100, "column": 22, @@ -756,6 +846,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 117, + "column": 26, + "endLine": 117, + "endColumn": 33, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 119, "column": 26, @@ -766,6 +866,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 119, + "column": 26, + "endLine": 119, + "endColumn": 33, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 124, "column": 17, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json index 452d9d6225..0012a4b9ea 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.json @@ -24,6 +24,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 24, + "column": 28, + "endLine": 24, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 24, "column": 24, @@ -34,6 +44,26 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 25, + "column": 40, + "endLine": 25, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 21, + "endLine": 26, + "endColumn": 26, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 28, "column": 7, @@ -234,6 +264,26 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 88, + "column": 29, + "endLine": 88, + "endColumn": 34, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 9, + "endLine": 90, + "endColumn": 14, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 93, "column": 77, @@ -244,6 +294,36 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 104, + "column": 40, + "endLine": 104, + "endColumn": 45, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 55, + "endLine": 105, + "endColumn": 60, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 56, + "endLine": 106, + "endColumn": 61, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 106, "column": 52, @@ -254,6 +334,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 107, + "column": 26, + "endLine": 107, + "endColumn": 31, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 118, "column": 22, @@ -294,6 +384,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 124, + "column": 26, + "endLine": 124, + "endColumn": 33, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 126, "column": 26, @@ -304,6 +404,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 126, + "column": 26, + "endLine": 126, + "endColumn": 33, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 110, "column": 22, 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 b388ce8814..fb694d6a80 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json @@ -494,6 +494,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 91, + "column": 15, + "endLine": 91, + "endColumn": 37, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, { "line": 94, "column": 8, 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 eed9dfb9db..1d19340246 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.autofix.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json @@ -505,6 +505,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 91, + "column": 15, + "endLine": 91, + "endColumn": 37, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, { "line": 94, "column": 8, 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 4af5f71eae..2d6fa2f245 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.migrate.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json @@ -484,6 +484,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 91, + "column": 15, + "endLine": 91, + "endColumn": 37, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, { "line": 94, "column": 8, diff --git a/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json b/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json index fa489440e0..3402934671 100644 --- a/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json +++ b/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json @@ -134,6 +134,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 62, + "column": 8, + "endLine": 62, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 62, "column": 8, @@ -294,6 +304,26 @@ "rule": "Using \"Object.getOwnPropertyNames\" is not allowed in this API (arkts-builtin-object-getOwnPropertyNames))", "severity": "ERROR" }, + { + "line": 81, + "column": 20, + "endLine": 81, + "endColumn": 26, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 20, + "endLine": 82, + "endColumn": 27, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 85, "column": 1, @@ -514,6 +544,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 95, + "column": 21, + "endLine": 95, + "endColumn": 24, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 96, "column": 1, @@ -524,6 +564,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 96, + "column": 21, + "endLine": 96, + "endColumn": 24, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 97, "column": 1, @@ -554,6 +604,16 @@ "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, + { + "line": 99, + "column": 21, + "endLine": 99, + "endColumn": 28, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 100, "column": 1, @@ -854,6 +914,26 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 120, + "column": 13, + "endLine": 120, + "endColumn": 19, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 7, + "endLine": 123, + "endColumn": 14, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 127, "column": 12, diff --git a/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json index 0e4ea28d2f..bac26d04ac 100644 --- a/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json +++ b/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json @@ -94,6 +94,16 @@ "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" }, + { + "line": 95, + "column": 16, + "endLine": 95, + "endColumn": 22, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 124, "column": 7, diff --git a/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json b/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json index ca26b319a6..292a9e3ce5 100644 --- a/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 46, + "column": 16, + "endLine": 46, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 47, "column": 13, @@ -34,6 +44,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 47, + "column": 17, + "endLine": 47, + "endColumn": 24, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 48, "column": 12, @@ -43,6 +63,36 @@ "suggest": "", "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" + }, + { + "line": 48, + "column": 16, + "endLine": 48, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 16, + "endLine": 49, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 16, + "endLine": 86, + "endColumn": 23, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json b/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json index acd50132f8..6451b27b1d 100644 --- a/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_sparse_array2.ets.arkts2.json @@ -264,6 +264,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 47, + "column": 16, + "endLine": 47, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 47, "column": 23, @@ -284,6 +294,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 48, + "column": 17, + "endLine": 48, + "endColumn": 24, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 48, "column": 25, @@ -304,6 +324,16 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 49, + "column": 16, + "endLine": 49, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 49, "column": 23, @@ -314,6 +344,16 @@ "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", "severity": "ERROR" }, + { + "line": 50, + "column": 16, + "endLine": 50, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 50, "column": 23, @@ -354,6 +394,16 @@ "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", "severity": "ERROR" }, + { + "line": 57, + "column": 16, + "endLine": 57, + "endColumn": 23, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 58, "column": 10, diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json index 3ab8448c63..d3a7239f5d 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json @@ -114,6 +114,36 @@ "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, + { + "line": 93, + "column": 66, + "endLine": 93, + "endColumn": 75, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 66, + "endLine": 93, + "endColumn": 75, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 54, + "endLine": 101, + "endColumn": 58, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 105, "column": 8, @@ -124,6 +154,16 @@ "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, + { + "line": 109, + "column": 50, + "endLine": 109, + "endColumn": 54, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 114, "column": 9, diff --git a/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json b/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json index e485672d32..2928b0dcbd 100644 --- a/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json @@ -234,6 +234,26 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, + { + "line": 102, + "column": 27, + "endLine": 102, + "endColumn": 36, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 27, + "endLine": 102, + "endColumn": 36, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 103, "column": 16, @@ -394,6 +414,16 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, + { + "line": 126, + "column": 33, + "endLine": 126, + "endColumn": 40, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 127, "column": 1, @@ -404,6 +434,16 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, + { + "line": 128, + "column": 12, + "endLine": 128, + "endColumn": 16, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 128, "column": 1, @@ -414,6 +454,16 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, + { + "line": 129, + "column": 12, + "endLine": 129, + "endColumn": 19, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 129, "column": 1, diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json index a41ae5fb22..9ad06d0111 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json @@ -134,6 +134,26 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 206, + "column": 33, + "endLine": 206, + "endColumn": 37, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 207, + "column": 33, + "endLine": 207, + "endColumn": 37, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 207, "column": 42, diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json index ea95d2fc5c..d9ef5529e7 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json @@ -134,6 +134,26 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 206, + "column": 33, + "endLine": 206, + "endColumn": 37, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 207, + "column": 33, + "endLine": 207, + "endColumn": 37, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 207, "column": 42, diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json index dc507ae5a9..cf68563bf6 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json @@ -134,6 +134,26 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 216, + "column": 33, + "endLine": 216, + "endColumn": 37, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 33, + "endLine": 217, + "endColumn": 37, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 217, "column": 42, diff --git a/ets2panda/linter/test/main/persist_serial_1.ets.arkts2.json b/ets2panda/linter/test/main/persist_serial_1.ets.arkts2.json index 5a82da735e..e2c1626588 100644 --- a/ets2panda/linter/test/main/persist_serial_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/persist_serial_1.ets.arkts2.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 38, + "column": 35, + "endLine": 38, + "endColumn": 40, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 38, "column": 31, @@ -54,6 +64,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 48, + "column": 44, + "endLine": 48, + "endColumn": 48, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 49, "column": 1, @@ -94,6 +114,16 @@ "rule": "The class of the second parameter passed to the \"persistProp\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-prop-serialization)", "severity": "ERROR" }, + { + "line": 55, + "column": 44, + "endLine": 55, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 55, "column": 40, @@ -104,6 +134,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 56, + "column": 44, + "endLine": 56, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 56, "column": 40, @@ -124,6 +164,16 @@ "rule": "The class of the second parameter passed to the \"persistProp\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-prop-serialization)", "severity": "ERROR" }, + { + "line": 57, + "column": 44, + "endLine": 57, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 57, "column": 40, @@ -144,6 +194,16 @@ "rule": "The class of the second parameter passed to the \"persistProp\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-prop-serialization)", "severity": "ERROR" }, + { + "line": 58, + "column": 44, + "endLine": 58, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 58, "column": 40, @@ -164,6 +224,16 @@ "rule": "The class of the second parameter passed to the \"persistProp\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-prop-serialization)", "severity": "ERROR" }, + { + "line": 59, + "column": 44, + "endLine": 59, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 59, "column": 40, diff --git a/ets2panda/linter/test/main/persist_serial_2.ets.arkts2.json b/ets2panda/linter/test/main/persist_serial_2.ets.arkts2.json index 16144bf46d..1c0b6ba77c 100644 --- a/ets2panda/linter/test/main/persist_serial_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/persist_serial_2.ets.arkts2.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 38, + "column": 35, + "endLine": 38, + "endColumn": 40, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 38, "column": 31, @@ -84,6 +94,16 @@ "rule": "The class of the \"defaultValue\" parameter in the literal passed to the \"persistProps\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-props-serialization)", "severity": "ERROR" }, + { + "line": 52, + "column": 104, + "endLine": 52, + "endColumn": 109, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 52, "column": 100, @@ -94,6 +114,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 53, + "column": 104, + "endLine": 53, + "endColumn": 109, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 53, "column": 100, @@ -114,6 +144,16 @@ "rule": "The class of the \"defaultValue\" parameter in the literal passed to the \"persistProps\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-props-serialization)", "severity": "ERROR" }, + { + "line": 54, + "column": 104, + "endLine": 54, + "endColumn": 109, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 54, "column": 100, @@ -134,6 +174,16 @@ "rule": "The class of the \"defaultValue\" parameter in the literal passed to the \"persistProps\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-props-serialization)", "severity": "ERROR" }, + { + "line": 55, + "column": 104, + "endLine": 55, + "endColumn": 109, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 55, "column": 100, @@ -154,6 +204,16 @@ "rule": "The class of the \"defaultValue\" parameter in the literal passed to the \"persistProps\" method must be a primitive type or Date type, or implement the \"toJson\" and \"fromJson\" methods (arkui-persistent-props-serialization)", "severity": "ERROR" }, + { + "line": 56, + "column": 104, + "endLine": 56, + "endColumn": 109, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 56, "column": 100, 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 01ea1d9c16..b9634f30d1 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 @@ -94,6 +94,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 57, + "column": 18, + "endLine": 57, + "endColumn": 23, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 57, "column": 14, @@ -104,6 +114,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 57, + "column": 14, + "endLine": 57, + "endColumn": 27, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 70, "column": 1, @@ -324,6 +344,36 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 108, + "column": 17, + "endLine": 108, + "endColumn": 40, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 15, + "endLine": 112, + "endColumn": 38, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 15, + "endLine": 115, + "endColumn": 20, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 117, "column": 20, @@ -354,6 +404,26 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 118, + "column": 15, + "endLine": 118, + "endColumn": 36, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 13, + "endLine": 121, + "endColumn": 34, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, { "line": 139, "column": 12, @@ -364,6 +434,26 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 139, + "column": 16, + "endLine": 139, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 23, + "endLine": 150, + "endColumn": 29, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 159, "column": 3, 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 79d7fb7b1f..81759dc802 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 @@ -94,6 +94,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 57, + "column": 18, + "endLine": 57, + "endColumn": 23, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 57, "column": 14, @@ -104,6 +114,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 57, + "column": 14, + "endLine": 57, + "endColumn": 27, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 70, "column": 1, @@ -324,6 +344,36 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 108, + "column": 17, + "endLine": 108, + "endColumn": 40, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 15, + "endLine": 112, + "endColumn": 38, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 15, + "endLine": 115, + "endColumn": 20, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 117, "column": 20, @@ -354,6 +404,26 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 118, + "column": 15, + "endLine": 118, + "endColumn": 36, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 13, + "endLine": 121, + "endColumn": 34, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, { "line": 139, "column": 12, @@ -364,6 +434,26 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 139, + "column": 16, + "endLine": 139, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 23, + "endLine": 150, + "endColumn": 29, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 159, "column": 3, 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 373804e464..aaf5bc6ce1 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 @@ -94,6 +94,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 57, + "column": 18, + "endLine": 57, + "endColumn": 23, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 57, "column": 14, @@ -104,6 +114,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 57, + "column": 14, + "endLine": 57, + "endColumn": 27, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 70, "column": 1, @@ -324,6 +344,36 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 108, + "column": 17, + "endLine": 108, + "endColumn": 40, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 15, + "endLine": 112, + "endColumn": 38, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 15, + "endLine": 115, + "endColumn": 20, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 117, "column": 20, @@ -354,6 +404,26 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 118, + "column": 15, + "endLine": 118, + "endColumn": 36, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 13, + "endLine": 121, + "endColumn": 34, + "problem": "BuiltinIteratorResultValue", + "suggest": "", + "rule": "The property of IteratorResult is not supported (arkts-builtin-iterator-result-value)", + "severity": "ERROR" + }, { "line": 139, "column": 12, @@ -364,6 +434,26 @@ "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" }, + { + "line": 139, + "column": 16, + "endLine": 139, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 23, + "endLine": 150, + "endColumn": 29, + "problem": "BuiltinFinalClass", + "suggest": "", + "rule": "API is not support use class in this API (arkts-builtin-final-class)", + "severity": "ERROR" + }, { "line": 159, "column": 3, diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.arkts2.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.arkts2.json index e9f013b081..b6272423c4 100644 --- a/ets2panda/linter/test/main/repeat_virtualscroll.ets.arkts2.json +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.arkts2.json @@ -14,6 +14,26 @@ "limitations under the License." ], "result": [ + { + "line": 36, + "column": 62, + "endLine": 36, + "endColumn": 71, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 62, + "endLine": 36, + "endColumn": 71, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 40, "column": 9, @@ -24,6 +44,26 @@ "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", "severity": "ERROR" }, + { + "line": 46, + "column": 62, + "endLine": 46, + "endColumn": 71, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 62, + "endLine": 46, + "endColumn": 71, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 48, "column": 9, diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json index 50e60f2e52..b06ce8f882 100644 --- a/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json @@ -14,6 +14,26 @@ "limitations under the License." ], "result": [ + { + "line": 36, + "column": 62, + "endLine": 36, + "endColumn": 71, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 62, + "endLine": 36, + "endColumn": 71, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 40, "column": 9, @@ -35,6 +55,26 @@ "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", "severity": "ERROR" }, + { + "line": 46, + "column": 62, + "endLine": 46, + "endColumn": 71, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 62, + "endLine": 46, + "endColumn": 71, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 48, "column": 9, diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.json index ca88f857e9..e82e1454e9 100644 --- a/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.json +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.json @@ -13,5 +13,46 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 48, + "column": 62, + "endLine": 48, + "endColumn": 71, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 62, + "endLine": 48, + "endColumn": 71, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 62, + "endLine": 58, + "endColumn": 71, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 62, + "endLine": 58, + "endColumn": 71, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json b/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json index 2c19de62ff..0f96cd9029 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json @@ -384,6 +384,16 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 169, + "column": 28, + "endLine": 169, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 169, "column": 24, @@ -394,6 +404,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 169, + "column": 24, + "endLine": 169, + "endColumn": 43, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 185, "column": 23, @@ -434,6 +454,36 @@ "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, + { + "line": 219, + "column": 16, + "endLine": 219, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 220, + "column": 16, + "endLine": 220, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 220, + "column": 12, + "endLine": 220, + "endColumn": 33, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 227, "column": 1, @@ -464,6 +514,16 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 254, + "column": 28, + "endLine": 254, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 254, "column": 24, @@ -474,6 +534,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 254, + "column": 24, + "endLine": 254, + "endColumn": 43, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 266, "column": 3, @@ -484,6 +554,16 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 270, + "column": 28, + "endLine": 270, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 270, "column": 24, @@ -494,6 +574,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 270, + "column": 24, + "endLine": 270, + "endColumn": 42, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 276, "column": 7, @@ -534,6 +624,16 @@ "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", "severity": "ERROR" }, + { + "line": 299, + "column": 44, + "endLine": 299, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 301, "column": 23, @@ -544,6 +644,16 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 313, + "column": 36, + "endLine": 313, + "endColumn": 41, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 316, "column": 9, diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json index e9b3765b05..1d451093ec 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json @@ -264,6 +264,26 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 169, + "column": 28, + "endLine": 169, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 24, + "endLine": 169, + "endColumn": 51, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 194, "column": 14, @@ -274,6 +294,36 @@ "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, + { + "line": 219, + "column": 16, + "endLine": 219, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 220, + "column": 16, + "endLine": 220, + "endColumn": 21, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 220, + "column": 12, + "endLine": 220, + "endColumn": 33, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 227, "column": 1, @@ -304,6 +354,26 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 254, + "column": 28, + "endLine": 254, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 254, + "column": 24, + "endLine": 254, + "endColumn": 51, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 266, "column": 3, @@ -314,6 +384,26 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 270, + "column": 28, + "endLine": 270, + "endColumn": 33, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, + { + "line": 270, + "column": 24, + "endLine": 270, + "endColumn": 50, + "problem": "UninitializedArrayElements", + "suggest": "", + "rule": "Please init elements of array before read elements. If not, there will be a runtime error. We recommend you to use Array.create(len, T) (arkts-builtin-uninitialized-element)", + "severity": "WARNING" + }, { "line": 276, "column": 7, @@ -344,6 +434,16 @@ "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", "severity": "ERROR" }, + { + "line": 299, + "column": 44, + "endLine": 299, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 301, "column": 23, @@ -354,6 +454,16 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 313, + "column": 36, + "endLine": 313, + "endColumn": 41, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 316, "column": 9, diff --git a/ets2panda/linter/test/main/structural_identity.ets.arkts2.json b/ets2panda/linter/test/main/structural_identity.ets.arkts2.json index bdec107230..8be66d0736 100644 --- a/ets2panda/linter/test/main/structural_identity.ets.arkts2.json +++ b/ets2panda/linter/test/main/structural_identity.ets.arkts2.json @@ -1064,6 +1064,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 622, + "column": 45, + "endLine": 622, + "endColumn": 49, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 626, "column": 5, diff --git a/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json b/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json index 39ff7c832c..f4b9ec6f67 100644 --- a/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json +++ b/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 49, + "column": 15, + "endLine": 49, + "endColumn": 20, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 56, "column": 1, diff --git a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json index 2d6e11c515..c5a72fe073 100644 --- a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json +++ b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json @@ -93,6 +93,16 @@ "suggest": "", "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", "severity": "ERROR" + }, + { + "line": 215, + "column": 17, + "endLine": 215, + "endColumn": 23, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json index 4b786c5828..4fbd4f4e2c 100644 --- a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json @@ -84,6 +84,16 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 22, + "column": 17, + "endLine": 22, + "endColumn": 22, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 24, "column": 5, diff --git a/ets2panda/linter/test/main/ts_overload.ets.arkts2.json b/ets2panda/linter/test/main/ts_overload.ets.arkts2.json index ca097aeaa4..8e4ea2ce66 100644 --- a/ets2panda/linter/test/main/ts_overload.ets.arkts2.json +++ b/ets2panda/linter/test/main/ts_overload.ets.arkts2.json @@ -44,6 +44,16 @@ "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", "severity": "ERROR" }, + { + "line": 20, + "column": 16, + "endLine": 20, + "endColumn": 20, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 30, "column": 3, diff --git a/ets2panda/linter/test/rules/rule207.ets.arkts2.json b/ets2panda/linter/test/rules/rule207.ets.arkts2.json index d286d0d82d..0b4e1a6415 100644 --- a/ets2panda/linter/test/rules/rule207.ets.arkts2.json +++ b/ets2panda/linter/test/rules/rule207.ets.arkts2.json @@ -54,6 +54,16 @@ "rule": "Special arguments object inside functions are not supported (arkts-no-arguments-obj)", "severity": "ERROR" }, + { + "line": 25, + "column": 35, + "endLine": 25, + "endColumn": 41, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 25, "column": 25, @@ -84,6 +94,16 @@ "rule": "Special arguments object inside functions are not supported (arkts-no-arguments-obj)", "severity": "ERROR" }, + { + "line": 31, + "column": 51, + "endLine": 31, + "endColumn": 57, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 31, "column": 41, @@ -224,6 +244,16 @@ "rule": "Special arguments object inside functions are not supported (arkts-no-arguments-obj)", "severity": "ERROR" }, + { + "line": 57, + "column": 19, + "endLine": 57, + "endColumn": 25, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 57, "column": 9, diff --git a/ets2panda/linter/test/rules/rule37.ets.arkts2.json b/ets2panda/linter/test/rules/rule37.ets.arkts2.json index e07b57d6df..907deb012b 100644 --- a/ets2panda/linter/test/rules/rule37.ets.arkts2.json +++ b/ets2panda/linter/test/rules/rule37.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 18, + "column": 27, + "endLine": 18, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 20, "column": 17, @@ -34,6 +44,16 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 21, + "column": 29, + "endLine": 21, + "endColumn": 35, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 23, "column": 23, @@ -44,6 +64,26 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 25, + "column": 27, + "endLine": 25, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 27, + "endLine": 27, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 27, "column": 34, @@ -54,6 +94,26 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 29, + "column": 27, + "endLine": 29, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 38, + "endLine": 29, + "endColumn": 44, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 31, "column": 23, @@ -64,6 +124,16 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 33, + "column": 28, + "endLine": 33, + "endColumn": 34, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 36, "column": 44, @@ -84,6 +154,16 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 40, + "column": 32, + "endLine": 40, + "endColumn": 38, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 43, "column": 22, @@ -94,6 +174,16 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 47, + "column": 34, + "endLine": 47, + "endColumn": 40, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 51, "column": 22, @@ -104,6 +194,16 @@ "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 55, + "column": 34, + "endLine": 55, + "endColumn": 40, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 59, "column": 17, diff --git a/ets2panda/linter/test/rules/rule37.ets.autofix.json b/ets2panda/linter/test/rules/rule37.ets.autofix.json index 3cad91ca09..73acc1da3e 100644 --- a/ets2panda/linter/test/rules/rule37.ets.autofix.json +++ b/ets2panda/linter/test/rules/rule37.ets.autofix.json @@ -24,13 +24,27 @@ { "start": 631, "end": 637, - "replacementText": "new RegExp(\"bc*d\")" + "replacementText": "new RegExp(\"bc*d\")", + "line": 16, + "column": 22, + "endLine": 16, + "endColumn": 28 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 18, + "column": 27, + "endLine": 18, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 20, "column": 17, @@ -41,13 +55,27 @@ { "start": 699, "end": 764, - "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")" + "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")", + "line": 20, + "column": 17, + "endLine": 20, + "endColumn": 82 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 21, + "column": 29, + "endLine": 21, + "endColumn": 35, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 23, "column": 23, @@ -58,13 +86,37 @@ { "start": 892, "end": 900, - "replacementText": "new RegExp(\"bc*d\", \"ig\")" + "replacementText": "new RegExp(\"bc*d\", \"ig\")", + "line": 23, + "column": 23, + "endLine": 23, + "endColumn": 31 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 25, + "column": 27, + "endLine": 25, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 27, + "endLine": 27, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 27, "column": 34, @@ -75,13 +127,37 @@ { "start": 985, "end": 992, - "replacementText": "new RegExp(\"bc*d\", \"i\")" + "replacementText": "new RegExp(\"bc*d\", \"i\")", + "line": 27, + "column": 34, + "endLine": 27, + "endColumn": 41 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 29, + "column": 27, + "endLine": 29, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 38, + "endLine": 29, + "endColumn": 44, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 31, "column": 23, @@ -92,13 +168,27 @@ { "start": 1088, "end": 1093, - "replacementText": "new RegExp(\"a\\\\\\\\\")" + "replacementText": "new RegExp(\"a\\\\\\\\\")", + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 28 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 33, + "column": 28, + "endLine": 33, + "endColumn": 34, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 36, "column": 44, @@ -109,7 +199,11 @@ { "start": 1195, "end": 1201, - "replacementText": "new RegExp(\"bc*d\")" + "replacementText": "new RegExp(\"bc*d\")", + "line": 36, + "column": 44, + "endLine": 36, + "endColumn": 50 } ], "suggest": "", @@ -126,13 +220,27 @@ { "start": 1239, "end": 1304, - "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")" + "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")", + "line": 38, + "column": 36, + "endLine": 38, + "endColumn": 101 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 40, + "column": 32, + "endLine": 40, + "endColumn": 38, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 43, "column": 22, @@ -143,13 +251,27 @@ { "start": 1410, "end": 1416, - "replacementText": "new RegExp(\"bc*d\")" + "replacementText": "new RegExp(\"bc*d\")", + "line": 43, + "column": 22, + "endLine": 43, + "endColumn": 28 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 47, + "column": 34, + "endLine": 47, + "endColumn": 40, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 51, "column": 22, @@ -160,13 +282,27 @@ { "start": 1557, "end": 1563, - "replacementText": "new RegExp(\"bc*d\")" + "replacementText": "new RegExp(\"bc*d\")", + "line": 51, + "column": 22, + "endLine": 51, + "endColumn": 28 } ], "suggest": "", "rule": "RegExp literals are not supported (arkts-no-regexp-literals)", "severity": "ERROR" }, + { + "line": 55, + "column": 34, + "endLine": 55, + "endColumn": 40, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, { "line": 59, "column": 17, @@ -177,7 +313,11 @@ { "start": 1694, "end": 1759, - "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")" + "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")", + "line": 59, + "column": 17, + "endLine": 59, + "endColumn": 82 } ], "suggest": "", @@ -194,7 +334,11 @@ { "start": 1799, "end": 1864, - "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")" + "replacementText": "new RegExp(\"^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\\\.[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)*$\")", + "line": 63, + "column": 28, + "endLine": 63, + "endColumn": 93 } ], "suggest": "", @@ -211,7 +355,11 @@ { "start": 1890, "end": 1904, - "replacementText": "new RegExp(\"ab*c\")" + "replacementText": "new RegExp(\"ab*c\")", + "line": 65, + "column": 24, + "endLine": 65, + "endColumn": 38 } ], "suggest": "", @@ -228,7 +376,11 @@ { "start": 1929, "end": 1947, - "replacementText": "new RegExp(\"ab*c\", \"i\")" + "replacementText": "new RegExp(\"ab*c\", \"i\")", + "line": 67, + "column": 24, + "endLine": 67, + "endColumn": 42 } ], "suggest": "", @@ -245,7 +397,11 @@ { "start": 1968, "end": 1992, - "replacementText": "new RegExp('dawfgr' + '12345')" + "replacementText": "new RegExp('dawfgr' + '12345')", + "line": 69, + "column": 20, + "endLine": 69, + "endColumn": 44 } ], "suggest": "", @@ -262,7 +418,11 @@ { "start": 2013, "end": 2169, - "replacementText": "new RegExp('.∗?(?:(?:元宵|三八|妇女|母亲|父亲|七夕|重阳|情人|儿童|六一' + '|愚人|复活|青年|护士|建军|教师|建党|万圣|感恩|秘书|七一|五四|八一|腊八|光棍|植树|中元)节|除夕|大年三十|大年30|七夕' + '|平安夜|六一|七一|五四|八一|三八|腊八|双十一|双十二).∗')" + "replacementText": "new RegExp('.∗?(?:(?:元宵|三八|妇女|母亲|父亲|七夕|重阳|情人|儿童|六一' + '|愚人|复活|青年|护士|建军|教师|建党|万圣|感恩|秘书|七一|五四|八一|腊八|光棍|植树|中元)节|除夕|大年三十|大年30|七夕' + '|平安夜|六一|七一|五四|八一|三八|腊八|双十一|双十二).∗')", + "line": 71, + "column": 20, + "endLine": 71, + "endColumn": 176 } ], "suggest": "", @@ -279,7 +439,11 @@ { "start": 2195, "end": 2227, - "replacementText": "new RegExp('dawfgr'.concat('12345'))" + "replacementText": "new RegExp('dawfgr'.concat('12345'))", + "line": 73, + "column": 24, + "endLine": 73, + "endColumn": 56 } ], "suggest": "", @@ -296,7 +460,11 @@ { "start": 2250, "end": 2282, - "replacementText": "new RegExp('dawfgr' + '12345' + '789')" + "replacementText": "new RegExp('dawfgr' + '12345' + '789')", + "line": 75, + "column": 21, + "endLine": 75, + "endColumn": 53 } ], "suggest": "", diff --git a/ets2panda/linter/test/rules/rule37.ets.migrate.json b/ets2panda/linter/test/rules/rule37.ets.migrate.json index ca88f857e9..37f9ac9251 100644 --- a/ets2panda/linter/test/rules/rule37.ets.migrate.json +++ b/ets2panda/linter/test/rules/rule37.ets.migrate.json @@ -13,5 +13,276 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 16, + "column": 26, + "endLine": 16, + "endColumn": 32, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 27, + "endLine": 18, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 21, + "endLine": 20, + "endColumn": 27, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 29, + "endLine": 21, + "endColumn": 35, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 27, + "endLine": 23, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 27, + "endLine": 25, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 27, + "endLine": 27, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 38, + "endLine": 27, + "endColumn": 44, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 27, + "endLine": 29, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 38, + "endLine": 29, + "endColumn": 44, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 27, + "endLine": 31, + "endColumn": 33, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 28, + "endLine": 33, + "endColumn": 34, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 48, + "endLine": 36, + "endColumn": 54, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 40, + "endLine": 38, + "endColumn": 46, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 32, + "endLine": 40, + "endColumn": 38, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 26, + "endLine": 43, + "endColumn": 32, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 34, + "endLine": 47, + "endColumn": 40, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 26, + "endLine": 51, + "endColumn": 32, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 34, + "endLine": 55, + "endColumn": 40, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 21, + "endLine": 59, + "endColumn": 27, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 32, + "endLine": 63, + "endColumn": 38, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 28, + "endLine": 65, + "endColumn": 34, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 28, + "endLine": 67, + "endColumn": 34, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 24, + "endLine": 69, + "endColumn": 30, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 24, + "endLine": 71, + "endColumn": 30, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 28, + "endLine": 73, + "endColumn": 34, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 25, + "endLine": 75, + "endColumn": 31, + "problem": "BuiltinNoCtorFunc", + "suggest": "", + "rule": "API is not support ctor signature and func (arkts-builtin-cotr)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/sdkcommonapi/sdk_url.ets b/ets2panda/linter/test/sdkcommonapi/sdk_url.ets index 2a2f5e1d0d..e9a14fb806 100755 --- a/ets2panda/linter/test/sdkcommonapi/sdk_url.ets +++ b/ets2panda/linter/test/sdkcommonapi/sdk_url.ets @@ -30,7 +30,7 @@ paramsObject2.delete('fod');//error let searchParamsObject1 = new url.URLSearchParams("keyName1=valueName1&keyName2=valueName2");//error let iter: Iterable = searchParamsObject1.entries();//error -let pairs = Array.from(iter); +let pairs = Array.from(iter); //BuiltinAll for (let pair of pairs) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); } @@ -53,7 +53,7 @@ let paramsObject4 = new url.URLSearchParams(urlObject2.search.slice(1));//error* paramsObject4.has('bard') === true;//error let searchParamsObject2 = new url.URLSearchParams("key1=value1&key2=value2"); //error -let keys = Array.from(searchParamsObject2.keys());//error +let keys = Array.from(searchParamsObject2.keys());//error+BuiltinAll for (let key of keys) { console.log(key); } @@ -71,7 +71,7 @@ params.append('fod', '3');//error console.log(params.toString()); //error let searchParams = new url.URLSearchParams("key1=value1&key2=value2");//error -let values = Array.from(searchParams.values());//error +let values = Array.from(searchParams.values());//error+BuiltinAll for (let value of values) { console.log(value); } //sum:40 \ No newline at end of file diff --git a/ets2panda/linter/test/sdkcommonapi/sdk_url.ets.arkts2.json b/ets2panda/linter/test/sdkcommonapi/sdk_url.ets.arkts2.json index a8458bc115..d538bc711d 100755 --- a/ets2panda/linter/test/sdkcommonapi/sdk_url.ets.arkts2.json +++ b/ets2panda/linter/test/sdkcommonapi/sdk_url.ets.arkts2.json @@ -134,6 +134,16 @@ "rule": "The \"url.URLSearchParams\" in SDK is no longer supported.(sdk-method-not-supported)", "severity": "ERROR" }, + { + "line": 33, + "column": 19, + "endLine": 33, + "endColumn": 23, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 35, "column": 15, @@ -304,6 +314,16 @@ "rule": "The \"URLSearchParams\" in SDK is no longer supported.(sdk-method-not-supported)", "severity": "ERROR" }, + { + "line": 56, + "column": 18, + "endLine": 56, + "endColumn": 22, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 56, "column": 43, @@ -424,6 +444,16 @@ "rule": "The \"URLSearchParams\" in SDK is no longer supported.(sdk-method-not-supported)", "severity": "ERROR" }, + { + "line": 74, + "column": 20, + "endLine": 74, + "endColumn": 24, + "problem": "BuiltinDisableApi", + "suggest": "", + "rule": "API has been disabled (arkts-builtin-disable-api)", + "severity": "ERROR" + }, { "line": 74, "column": 38, diff --git a/ets2panda/linter/test/sdkcommonapi/sdk_xml.ets.arkts2.json b/ets2panda/linter/test/sdkcommonapi/sdk_xml.ets.arkts2.json index e3df86ce85..84f3263b20 100755 --- a/ets2panda/linter/test/sdkcommonapi/sdk_xml.ets.arkts2.json +++ b/ets2panda/linter/test/sdkcommonapi/sdk_xml.ets.arkts2.json @@ -154,6 +154,26 @@ "rule": "The \"ConvertOptions\" in SDK is no longer supported.(sdk-method-not-supported)", "severity": "ERROR" }, + { + "line": 32, + "column": 19, + "endLine": 32, + "endColumn": 28, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 19, + "endLine": 32, + "endColumn": 28, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, { "line": 32, "column": 34, 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 ec1d247f94..250fb9600a 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 @@ -64,6 +64,16 @@ "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", "severity": "ERROR" }, + { + "line": 22, + "column": 44, + "endLine": 22, + "endColumn": 49, + "problem": "BuiltinNewCtor", + "suggest": "", + "rule": "API is not support initial ctor signature (arkts-builtin-new-cotr)", + "severity": "ERROR" + }, { "line": 22, "column": 40, -- Gitee