From a5cdd64af03bc065be03da43cd7373c6fa53e2a5 Mon Sep 17 00:00:00 2001 From: tangbin <2387440390@qq.com> Date: Thu, 3 Jul 2025 17:15:36 +0800 Subject: [PATCH] sync 0328 to 0603 Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICJTKZ Test scenarios: new tests added to the linter Signed-off-by: tangbin <2387440390@qq.com> --- ets2panda/linter/src/lib/CookBookMsg.ts | 2 + ets2panda/linter/src/lib/FaultAttrs.ts | 1 + ets2panda/linter/src/lib/FaultDesc.ts | 2 + ets2panda/linter/src/lib/LinterRunner.ts | 69 +- ets2panda/linter/src/lib/MigrationInfo.ts | 19 + ets2panda/linter/src/lib/Problems.ts | 1 + ets2panda/linter/src/lib/ProgressBarInfo.ts | 25 + ets2panda/linter/src/lib/TypeScriptLinter.ts | 159 +- .../linter/src/lib/autofixes/Autofixer.ts | 128 +- .../src/lib/utils/consts/ConcurrentAPI.ts | 1 + .../linter/src/lib/utils/consts/ErrorProp.ts | 14 +- .../consts/InValidIndentifierKeywords.ts | 92 +- .../src/lib/utils/consts/LimitedStdAPI.ts | 6 +- .../no_support_isconcurrent2.ets.arkts2.json | 4 +- .../test/main/func_inferred_type_args_2.ets | 12 +- .../func_inferred_type_args_2.ets.arkts2.json | 20 + ...func_inferred_type_args_2.ets.autofix.json | 37 +- .../main/func_inferred_type_args_2.ets.json | 10 + .../func_inferred_type_args_2.ets.migrate.ets | 12 +- ...func_inferred_type_args_2.ets.migrate.json | 10 + .../linter/test/main/invalid_identifier.ets | 7 +- .../main/invalid_identifier.ets.arkts2.json | 20 + .../linter/test/main/method_inheritance.ets | 35 + .../main/method_inheritance.ets.arkts2.json | 30 + .../test/main/no_import_concurrency.ets | 27 +- .../no_import_concurrency.ets.arkts2.json | 100 +- .../no_import_concurrency.ets.autofix.json | 317 +- .../no_import_concurrency.ets.migrate.ets | 26 +- .../linter/test/main/numeric_semantics2.ets | 4 +- .../main/numeric_semantics2.ets.autofix.json | 2654 ++++++++--------- .../main/numeric_semantics2.ets.migrate.ets | 7 +- .../main/numeric_semantics2.ets.migrate.json | 454 +-- .../main/sdk_ability_lifecycle_monitor.ets | 35 + ...dk_ability_lifecycle_monitor.ets.args.json | 19 + ..._ability_lifecycle_monitor.ets.arkts2.json | 74 + .../sdk_ability_lifecycle_monitor.ets.json | 34 + .../test/main/stdlib_array.ets.arkts2.json | 80 + ...taskpool_deprecated_usages.ets.arkts2.json | 4 +- ...askpool_deprecated_usages2.ets.arkts2.json | 4 +- ...askpool_deprecated_usages3.ets.arkts2.json | 4 +- .../linter/test/main/ts-like-catch-type.ets | 8 + .../main/ts-like-catch-type.ets.arkts2.json | 34 +- .../test/main/ts-like-catch-type.ets.json | 13 +- 43 files changed, 2849 insertions(+), 1765 deletions(-) create mode 100644 ets2panda/linter/src/lib/MigrationInfo.ts create mode 100644 ets2panda/linter/src/lib/ProgressBarInfo.ts create mode 100644 ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets create mode 100644 ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.args.json create mode 100644 ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 512bc0b739..31ef5659cb 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -267,6 +267,8 @@ cookBookTag[257] = cookBookTag[258] = 'Data observation needs to add "@Observed" (arkui-data-observation)'; cookBookTag[259] = 'The ArkUI interface should be imported before it is used (arkui-modular-interface)'; cookBookTag[260] = 'The "@Entry" annotation does not support dynamic parameters (arkui-entry-annotation-parameters)'; +cookBookTag[261] = + 'The UIAbility of 1.2 needs to be listened by the new StaticAbilityLifecycleCallback. The original AbilityLifecycleCallback can only listen to the UIAbility of 1.1 (sdk-ability-lifecycle-monitor)'; cookBookTag[262] = 'The makeObserved function is not supported (arkui-no-makeobserved-function)'; cookBookTag[263] = 'The "@Provide" annotation does not support dynamic parameters (arkui-provide-annotation-parameters)'; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index 9a0e13b638..c183485e36 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -184,6 +184,7 @@ faultsAttrs[FaultID.AnimatableExtendDecoratorTransform] = new FaultAttributes(25 faultsAttrs[FaultID.DataObservation] = new FaultAttributes(258); faultsAttrs[FaultID.UIInterfaceImport] = new FaultAttributes(259); faultsAttrs[FaultID.EntryAnnotation] = new FaultAttributes(260); +faultsAttrs[FaultID.SdkAbilityLifecycleMonitor] = new FaultAttributes(261); faultsAttrs[FaultID.MakeObservedIsNotSupported] = new FaultAttributes(262); faultsAttrs[FaultID.ProvideAnnotation] = new FaultAttributes(263); faultsAttrs[FaultID.InteropJsObjectInheritance] = new FaultAttributes(265); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index f1c2603b4f..2ae56f2bd1 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -188,6 +188,8 @@ faultDesc[FaultID.UseSharedDeprecated] = '"use shared" is not supported'; faultDesc[FaultID.UseConcurrentDeprecated] = '"use concurrent" is not supported'; faultDesc[FaultID.MethodInheritRule] = 'Method parameters/returns violate inheritance principles'; faultDesc[FaultID.EntryAnnotation] = '"@Entry" decorator parameter'; +faultDesc[FaultID.SdkAbilityLifecycleMonitor] = + 'UIAbility of 1.2 needs to be listened by the new StaticAbilityLifecycleCallback'; faultDesc[FaultID.ProvideAnnotation] = '"@Provide" decorator parameter'; faultDesc[FaultID.InteropJsObjectInheritance] = 'Interop JS class inheritance'; faultDesc[FaultID.InteropJsObjectTraverseJsInstance] = 'Interop JS object traverse usage'; diff --git a/ets2panda/linter/src/lib/LinterRunner.ts b/ets2panda/linter/src/lib/LinterRunner.ts index 863687d554..256566c1ee 100644 --- a/ets2panda/linter/src/lib/LinterRunner.ts +++ b/ets2panda/linter/src/lib/LinterRunner.ts @@ -25,7 +25,9 @@ import type { LinterConfig } from './LinterConfig'; import type { LinterOptions } from './LinterOptions'; import type { LintRunResult } from './LintRunResult'; import { Logger } from './Logger'; +import type { MigrationInfo } from './MigrationInfo'; import type { ProblemInfo } from './ProblemInfo'; +import type { ProgressBarInfo } from './ProgressBarInfo'; import { ProjectStatistics } from './statistics/ProjectStatistics'; import { generateMigrationStatisicsReport } from './statistics/scan/ProblemStatisticsCommonFunction'; import type { TimeRecorder } from './statistics/scan/TimeRecorder'; @@ -93,7 +95,7 @@ export function lint( lintResult; } -function lintImpl(config: LinterConfig): LintRunResult { +function lintImpl(config: LinterConfig, migrationInfo?: MigrationInfo): LintRunResult { const { cmdOptions, tscCompiledProgram } = config; const tsProgram = tscCompiledProgram.getProgram(); const options = cmdOptions.linterOptions; @@ -114,7 +116,7 @@ function lintImpl(config: LinterConfig): LintRunResult { const tscStrictDiagnostics = getTscDiagnostics(tscCompiledProgram, srcFiles); LibraryTypeCallDiagnosticChecker.instance.rebuildTscDiagnostics(tscStrictDiagnostics); - const lintResult = lintFiles(tsProgram, srcFiles, options, tscStrictDiagnostics); + const lintResult = lintFiles(tsProgram, srcFiles, options, tscStrictDiagnostics, migrationInfo); LibraryTypeCallDiagnosticChecker.instance.clear(); if (!options.ideInteractive) { @@ -129,7 +131,8 @@ function lintFiles( tsProgram: ts.Program, srcFiles: ts.SourceFile[], options: LinterOptions, - tscStrictDiagnostics: Map + tscStrictDiagnostics: Map, + migrationInfo?: MigrationInfo ): LintRunResult { const projectStats: ProjectStatistics = new ProjectStatistics(); const problemsInfos: Map = new Map(); @@ -146,10 +149,11 @@ function lintFiles( const problems = linter.problemsInfos; problemsInfos.set(path.normalize(srcFile.fileName), [...problems]); projectStats.fileStats.push(linter.fileStats); - fileCount = fileCount + 1; - if (options.ideInteractive) { - processSyncErr(`{"content":"${srcFile.fileName}","messageType":1,"indicator":${fileCount / srcFiles.length}}\n`); - } + fileCount += 1; + processProgressBar( + { migrationInfo: migrationInfo, currentSrcFile: srcFile, srcFiles: srcFiles, options: options }, + fileCount + ); } return { @@ -159,6 +163,32 @@ function lintFiles( }; } +function processProgressBar(progressBarInfo: ProgressBarInfo, fileCount: number): void { + const { currentSrcFile, srcFiles, options } = progressBarInfo; + + if (!options.ideInteractive) { + return; + } + + const isMigrationStep = options.migratorMode && progressBarInfo.migrationInfo; + const phasePrefix = isMigrationStep ? 'Migration Phase' : 'Scan Phase'; + + const migrationPhase = isMigrationStep ? + ` ${progressBarInfo.migrationInfo!.currentPass + 1} / ${progressBarInfo.migrationInfo!.maxPasses}` : + ''; + + const progressRatio = fileCount / srcFiles.length; + const displayContent = `currentFile: ${currentSrcFile.fileName}, ${phasePrefix}${migrationPhase}`; + + processSyncErr( + JSON.stringify({ + content: displayContent, + messageType: 1, + indicator: progressRatio + }) + '\n' + ); +} + function migrate( initialConfig: LinterConfig, initialLintResult: LintRunResult, @@ -172,7 +202,8 @@ function migrate( let lintResult: LintRunResult = initialLintResult; const problemsInfosBeforeMigrate = lintResult.problemsInfos; - for (let pass = 0; pass < (cmdOptions.linterOptions.migrationMaxPass ?? qEd.DEFAULT_MAX_AUTOFIX_PASSES); pass++) { + const migrationMaxPass = cmdOptions.linterOptions.migrationMaxPass ?? qEd.DEFAULT_MAX_AUTOFIX_PASSES; + for (let pass = 0; pass < migrationMaxPass; pass++) { const appliedFix = fix(linterConfig, lintResult, updatedSourceTexts, hcResults); hcResults = undefined; @@ -183,18 +214,11 @@ function migrate( // Re-compile and re-lint project after applying the fixes. linterConfig = compileLintOptions(cmdOptions, getMigrationCreateProgramCallback(updatedSourceTexts)); - lintResult = lintImpl(linterConfig); + lintResult = lintImpl(linterConfig, { currentPass: pass, maxPasses: migrationMaxPass }); } // Write new text for updated source files. - updatedSourceTexts.forEach((newText, fileName) => { - if (!cmdOptions.linterOptions.noMigrationBackupFile) { - qEd.QuasiEditor.backupSrcFile(fileName); - } - const filePathMap = cmdOptions.linterOptions.migrationFilePathMap; - const writeFileName = filePathMap?.get(fileName) ?? fileName; - fs.writeFileSync(writeFileName, newText); - }); + updateSourceFiles(updatedSourceTexts, cmdOptions); timeRecorder.endMigration(); generateMigrationStatisicsReport(lintResult, timeRecorder, cmdOptions.outputFilePath); @@ -206,6 +230,17 @@ function migrate( return lintResult; } +function updateSourceFiles(updatedSourceTexts: Map, cmdOptions: CommandLineOptions): void { + updatedSourceTexts.forEach((newText, fileName) => { + if (!cmdOptions.linterOptions.noMigrationBackupFile) { + qEd.QuasiEditor.backupSrcFile(fileName); + } + const filePathMap = cmdOptions.linterOptions.migrationFilePathMap; + const writeFileName = filePathMap?.get(fileName) ?? fileName; + fs.writeFileSync(writeFileName, newText); + }); +} + function hasUseStaticDirective(srcFile: ts.SourceFile): boolean { if (!srcFile?.statements.length) { return false; diff --git a/ets2panda/linter/src/lib/MigrationInfo.ts b/ets2panda/linter/src/lib/MigrationInfo.ts new file mode 100644 index 0000000000..6bfafb5f08 --- /dev/null +++ b/ets2panda/linter/src/lib/MigrationInfo.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface MigrationInfo { + currentPass: number; + maxPasses: number; +} diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index e00674dce2..e8a9b611d3 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -184,6 +184,7 @@ export enum FaultID { InteropJSFunctionInvoke, LimitedVoidTypeFromSdk, EntryAnnotation, + SdkAbilityLifecycleMonitor, ProvideAnnotation, UseSharedDeprecated, UseConcurrentDeprecated, diff --git a/ets2panda/linter/src/lib/ProgressBarInfo.ts b/ets2panda/linter/src/lib/ProgressBarInfo.ts new file mode 100644 index 0000000000..9a2dc34e3b --- /dev/null +++ b/ets2panda/linter/src/lib/ProgressBarInfo.ts @@ -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 type * as ts from 'typescript'; +import type { LinterOptions } from './LinterOptions'; +import type { MigrationInfo } from './MigrationInfo'; + +export interface ProgressBarInfo { + migrationInfo?: MigrationInfo; + currentSrcFile: ts.SourceFile; + srcFiles: ts.SourceFile[]; + options: LinterOptions; +} diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 2ba0b44631..0b7067a939 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -130,7 +130,8 @@ import { USE_CONCURRENT, ESLIB_SHAREDMEMORY_FILENAME, ESLIB_SHAREDARRAYBUFFER, - TASKPOOL_MODULES + TASKPOOL_MODULES, + SYSTEM_MODULES } from './utils/consts/ConcurrentAPI'; import { DEPRECATED_TASKPOOL_METHOD_SETCLONELIST, @@ -3542,32 +3543,28 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { derivedMethod: ts.MethodDeclaration, baseMethod: ts.MethodDeclaration | ts.MethodSignature ): void { - if ( - this.IsVoidTypeOnActualReturnType(baseMethod) && - derivedMethod.type && - !this.IsVoidTypeOnActualReturnType(derivedMethod) - ) { + const baseMethodType = this.getActualReturnType(baseMethod); + const derivedMethodType = this.getActualReturnType(derivedMethod); + const baseMethodTypeIsVoid = baseMethodType && TsUtils.isVoidType(baseMethodType) || !baseMethod.type; + const derivedMethodTypeIsVoid = derivedMethodType && TsUtils.isVoidType(derivedMethodType); + if (baseMethodTypeIsVoid && derivedMethod.type && !derivedMethodTypeIsVoid) { this.incrementCounters(derivedMethod.type, FaultID.MethodInheritRule); return; } - if (!baseMethod.type || !derivedMethod.type) { + if (!baseMethodType || !derivedMethodType || baseMethodTypeIsVoid && derivedMethodTypeIsVoid) { return; } - - const baseReturnType = this.tsTypeChecker.getTypeAtLocation(baseMethod.type); - const derivedReturnType = this.tsTypeChecker.getTypeAtLocation(derivedMethod.type); - - if (this.isDerivedTypeAssignable(derivedReturnType, baseReturnType)) { + if (this.isDerivedTypeAssignable(derivedMethodType, baseMethodType)) { return; } - if (!this.isTypeAssignable(derivedReturnType, baseReturnType)) { - this.incrementCounters(derivedMethod.type, FaultID.MethodInheritRule); + if (!this.isTypeAssignable(derivedMethodType, baseMethodType)) { + this.incrementCounters(derivedMethod.type ? derivedMethod.type : derivedMethod.name, FaultID.MethodInheritRule); } } - private IsVoidTypeOnActualReturnType(method: ts.MethodDeclaration | ts.MethodSignature): boolean | undefined { + private getActualReturnType(method: ts.MethodDeclaration | ts.MethodSignature): ts.Type | undefined { let type: ts.Type | undefined; if (method.type) { type = this.tsTypeChecker.getTypeAtLocation(method.type); @@ -3577,7 +3574,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { type = this.tsTypeChecker.getReturnTypeOfSignature(signature); } } - return type && TsUtils.isVoidType(type); + return type; } /** @@ -4499,6 +4496,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleCallExpression(node: ts.Node): void { const tsCallExpr = node as ts.CallExpression; + this.checkSdkAbilityLifecycleMonitor(tsCallExpr); this.handleStateStyles(tsCallExpr); this.handleBuiltinCtorCallSignature(tsCallExpr); this.handleSdkConstructorIfaceForCallExpression(tsCallExpr); @@ -4530,14 +4528,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const faultId = this.options.arkts2 ? FaultID.EsValueTypeError : FaultID.EsValueType; this.incrementCounters(node, faultId); } - if ( - !ts.isExpressionStatement(tsCallExpr.parent) && - !ts.isVoidExpression(tsCallExpr.parent) && - !ts.isArrowFunction(tsCallExpr.parent) && - !(ts.isConditionalExpression(tsCallExpr.parent) && ts.isExpressionStatement(tsCallExpr.parent.parent)) - ) { - this.handleLimitedVoidWithCall(tsCallExpr); - } + this.handleLimitedVoidWithCall(tsCallExpr); this.handleAppStorageCallExpression(tsCallExpr); this.fixJsImportCallExpression(tsCallExpr); this.handleInteropForCallJSExpression(tsCallExpr, calleeSym, callSignature); @@ -6364,6 +6355,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private handleLimitedVoidWithCall(node: ts.CallExpression): void { + if ( + ts.isExpressionStatement(node.parent) || + ts.isVoidExpression(node.parent) || + ts.isArrowFunction(node.parent) || + ts.isConditionalExpression(node.parent) && ts.isExpressionStatement(node.parent.parent) + ) { + return; + } if (!this.options.arkts2) { return; } @@ -7091,7 +7090,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const checkIdentifier = (identifier: ts.Identifier | undefined): void => { const text = identifier && ts.isIdentifier(identifier) ? identifier.text : ''; - if (identifier && text && INVALID_IDENTIFIER_KEYWORDS.includes(text)) { + if (identifier && text && INVALID_IDENTIFIER_KEYWORDS.includes(text) && !this.checkImportSymbol(identifier)) { this.incrementCounters(identifier, FaultID.InvalidIdentifier); } }; @@ -7111,6 +7110,21 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private checkImportSymbol(identifier: ts.Identifier): boolean { + let symbol = this.tsUtils.trueSymbolAtLocation(identifier); + if (symbol && 'unknown' === symbol.name) { + symbol = this.tsTypeChecker.getSymbolAtLocation(identifier); + } + let res = false; + const cb = (): void => { + res = true; + }; + if (symbol) { + this.checkSymbolAndExecute(symbol, identifier.text, SYSTEM_MODULES, cb); + } + return res; + } + private handleHeritageClause(node: ts.HeritageClause): void { this.checkEWTArgumentsForSdkDuplicateDeclName(node); if (!this.options.arkts2 || !this.useStatic) { @@ -7286,8 +7300,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - const sourceFile = decl.getSourceFile(); - const fileName = path.basename(sourceFile.fileName); + const fileName = TypeScriptLinter.getFileName(decl); if ( modules.some((moduleName) => { @@ -8772,6 +8785,64 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return TypeScriptLinter.checkModuleSpecifierForTaskPoolDeprecatedUsages(importDeclaration); } + private checkSdkAbilityLifecycleMonitor(callExpr: ts.CallExpression): void { + if (!this.options.arkts2) { + return; + } + + // Guard: must be a property-access .on + if (!this.isOnMethod(callExpr)) { + return; + } + + // Guard: left side must be applicationContext + if (!this.isApplicationContext(callExpr)) { + return; + } + + // Guard: exactly two arguments + const args = callExpr.arguments; + if (args.length !== 2) { + return; + } + + // Guard: first arg must be string literal "abilityLifecycle" + const eventArg = args[0]; + if (!ts.isStringLiteral(eventArg) || eventArg.text !== 'abilityLifecycle') { + return; + } + + // Guard: second arg must be a variable declared as AbilityLifecycleCallback + const cbArg = args[1]; + if (!ts.isIdentifier(cbArg)) { + return; + } + const varSym = this.tsUtils.trueSymbolAtLocation(cbArg); + const decl = varSym?.declarations?.find(ts.isVariableDeclaration); + if ( + !decl?.type || + !ts.isTypeReferenceNode(decl.type) || + decl.type.typeName.getText() !== 'AbilityLifecycleCallback' + ) { + return; + } + + // Report the legacy callback usage + this.incrementCounters(callExpr, FaultID.SdkAbilityLifecycleMonitor); + } + + private isOnMethod(node: ts.CallExpression): boolean { + void this; + const expr = node.expression; + return ts.isPropertyAccessExpression(expr) && expr.name.text === 'on'; + } + + private isApplicationContext(node: ts.CallExpression): boolean { + void this; + const left = (node.expression as ts.PropertyAccessExpression).expression; + return ts.isIdentifier(left) && left.text === 'applicationContext'; + } + private handleForOfJsArray(node: ts.ForOfStatement): void { if (!this.options.arkts2 || !this.useStatic) { return; @@ -8812,27 +8883,18 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const namedImports = namedBindings && ts.isNamedImports(namedBindings) ? namedBindings.elements : []; - const defaultIsForbidden = defaultImport && expectedImports.includes(defaultImport.getText()); + const FORBIDDEN_DEFAULT_IMPORT_MODULES = Object.keys(MODULE_IMPORTS).filter((name) => { + return name !== '@kit.ArkTS'; + }); + + const defaultIsForbidden = defaultImport && FORBIDDEN_DEFAULT_IMPORT_MODULES.includes(moduleName); const forbiddenNamed = namedImports.filter((spec) => { const name = spec.propertyName ? spec.propertyName.getText() : spec.name.getText(); return expectedImports.includes(name); }); - if ( - TypeScriptLinter.shouldRemoveWholeImport( - defaultIsForbidden, - forbiddenNamed.length, - namedImports.length, - defaultImport - ) - ) { - const autofix = this.autofixer?.removeNode(importDeclaration); - this.incrementCounters(importDeclaration, FaultID.LimitedStdLibNoImportConcurrency, autofix); - return; - } - if (defaultIsForbidden) { - const autofix = this.autofixer?.removeDefaultImport(importDeclaration, defaultImport); + const autofix = this.autofixer?.removeDefaultImport(importDeclaration, defaultImport, expectedImports[0]); this.incrementCounters(defaultImport, FaultID.LimitedStdLibNoImportConcurrency, autofix); } @@ -8842,19 +8904,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private static shouldRemoveWholeImport( - defaultIsForbidden: boolean | undefined, - forbiddenNamedCount: number, - namedImportsCount: number, - defaultImport: ts.Identifier | undefined - ): boolean { - return ( - defaultIsForbidden && forbiddenNamedCount === namedImportsCount || - defaultIsForbidden && namedImportsCount === 0 || - !defaultImport && forbiddenNamedCount === namedImportsCount && namedImportsCount > 0 - ); - } - /** * Checks for missing super() call in child classes that extend a parent class * with parameterized constructors. If parent class only has parameterized constructors diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index a29f4742e4..323536e118 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -2423,20 +2423,14 @@ export class Autofixer { return [{ start: node.getStart(), end: node.getEnd(), replacementText }]; } - removeImportSpecifier( - specToRemove: ts.ImportSpecifier, - importDeclaration: ts.ImportDeclaration - ): Autofix[] | undefined { - if (!importDeclaration) { - return undefined; - } - - const importClause = importDeclaration.importClause; - if (!importClause?.namedBindings || !ts.isNamedImports(importClause.namedBindings)) { + removeImportSpecifier(specToRemove: ts.ImportSpecifier, importDecl: ts.ImportDeclaration): Autofix[] | undefined { + const importClause = importDecl.importClause; + const namedBindings = importClause?.namedBindings; + if (!importClause || !namedBindings || !ts.isNamedImports(namedBindings)) { return undefined; } - const namedBindings = importClause.namedBindings; + const fixes: Autofix[] = []; const allSpecifiers = namedBindings.elements; const remainingSpecifiers = allSpecifiers.filter((spec) => { return spec !== specToRemove; @@ -2444,48 +2438,88 @@ export class Autofixer { // If none are valid, remove all named imports. if (remainingSpecifiers.length === 0) { - if (importClause.name) { - const start = importClause.name.end; - const end = namedBindings.end; - return [{ start, end, replacementText: '' }]; - } - return this.removeNode(importDeclaration); - } - - const specIndex = allSpecifiers.findIndex((spec) => { - return spec === specToRemove; - }); - const isLast = specIndex === allSpecifiers.length - 1; - const isFirst = specIndex === 0; + fixes.push({ + start: importClause.name ? importClause.name.end : importDecl.getStart(), + end: importClause.name ? namedBindings.end : importDecl.getEnd(), + replacementText: '' + }); + } else { + const specIndex = allSpecifiers.findIndex((spec) => { + return spec === specToRemove; + }); + const isLast = specIndex === allSpecifiers.length - 1; + const isFirst = specIndex === 0; - let start = specToRemove.getStart(); - let end = specToRemove.getEnd(); + let start = specToRemove.getStart(); + let end = specToRemove.getEnd(); - if (!isLast) { - end = allSpecifiers[specIndex + 1].getStart(); - } else if (!isFirst) { - const prev = allSpecifiers[specIndex - 1]; - start = prev.getEnd(); + if (!isLast) { + end = allSpecifiers[specIndex + 1].getStart(); + } else if (!isFirst) { + const prev = allSpecifiers[specIndex - 1]; + start = prev.getEnd(); + } + fixes.push({ + start: start, + end: end, + replacementText: '' + }); } - return [{ start, end, replacementText: '' }]; + const alias = specToRemove.name; + const original = specToRemove.propertyName ?? specToRemove.name; + const replacements = this.replaceIdentifierUsages(alias, original.getText()); + fixes.push(...replacements); + return fixes; } - removeDefaultImport(importDecl: ts.ImportDeclaration, defaultImport: ts.Identifier): Autofix[] | undefined { + removeDefaultImport( + importDecl: ts.ImportDeclaration, + defaultImport: ts.Identifier, + replacementName: string + ): Autofix[] | undefined { const importClause = importDecl.importClause; if (!importClause || !defaultImport) { return undefined; } - + const fixes: Autofix[] = []; const namedBindings = importClause.namedBindings; + fixes.push({ + start: namedBindings ? defaultImport.getStart() : importDecl.getStart(), + end: namedBindings ? namedBindings.getStart() : importDecl.getEnd(), + replacementText: '' + }); - if (!namedBindings) { - return this.removeNode(importDecl); + const replacements = this.replaceIdentifierUsages(defaultImport, replacementName); + fixes.push(...replacements); + + return fixes; + } + + replaceIdentifierUsages(importedIdentifier: ts.Identifier, replacementName: string): Autofix[] { + const fixes: Autofix[] = []; + const file = importedIdentifier.getSourceFile(); + const originalSymbol = this.typeChecker.getSymbolAtLocation(importedIdentifier); + if (!originalSymbol) { + return fixes; } - const start = defaultImport.getStart(); - const end = namedBindings.getStart(); - return [{ start, end, replacementText: '' }]; + const visit = (node: ts.Node): void => { + if (ts.isIdentifier(node) && !ts.isImportClause(node.parent) && !ts.isImportSpecifier(node.parent)) { + const nodeSymbol = this.typeChecker.getSymbolAtLocation(node); + if (nodeSymbol === originalSymbol) { + fixes.push({ + start: node.getStart(), + end: node.getEnd(), + replacementText: replacementName + }); + } + } + ts.forEachChild(node, visit); + }; + + visit(file); + return fixes; } fixSendableExplicitFieldType(node: ts.PropertyDeclaration): Autofix[] | undefined { @@ -3340,9 +3374,10 @@ export class Autofixer { const initializer = node.initializer; const name = node.name; const sym = this.typeChecker.getSymbolAtLocation(name); - if (!sym) { + if (!sym || !initializer) { return undefined; } + ts.setCommentRange(initializer, { pos: -1, end: -1 }); const type = this.typeChecker.getTypeOfSymbolAtLocation(sym, name); const typeText = this.typeChecker.typeToString(type); @@ -4657,7 +4692,7 @@ export class Autofixer { void this; const expr = callExpr.expression; const hasOptionalChain = !!callExpr.questionDotToken; - + const replacementText = hasOptionalChain ? `${expr.getText()}${callExpr.questionDotToken.getText()}unsafeCall` : `${expr.getText()}.unsafeCall`; @@ -4918,7 +4953,6 @@ export class Autofixer { return this.printer.printNode(ts.EmitHint.Unspecified, arg, srcFile); }). join(', ')}>`; - // Insert the type arguments immediately after the constructor name const insertPos = node.expression.getEnd(); return [{ start: insertPos, end: insertPos, replacementText: typeArgsText }]; @@ -4960,7 +4994,6 @@ export class Autofixer { ): Autofix[] | undefined { const srcFile = node.getSourceFile(); const identifier = node.expression; - const args = node.arguments; const hasValidArgs = typeArgs.some((arg) => { return arg?.typeName && ts.isIdentifier(arg.typeName); }); @@ -4973,9 +5006,12 @@ export class Autofixer { if (hasAnyType) { return undefined; } - const newExpression = ts.factory.createNewExpression(identifier, typeArgs, args); - const text = this.printer.printNode(ts.EmitHint.Unspecified, newExpression, srcFile); - return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; + const typeArgsText = `<${typeArgs?. + map((arg) => { + return this.printer.printNode(ts.EmitHint.Unspecified, arg, srcFile); + }). + join(', ')}>`; + return [{ start: identifier.getEnd(), end: identifier.getEnd(), replacementText: typeArgsText }]; } static getTypeArgumentsFromType(type: ts.Type): ts.Type[] { diff --git a/ets2panda/linter/src/lib/utils/consts/ConcurrentAPI.ts b/ets2panda/linter/src/lib/utils/consts/ConcurrentAPI.ts index 5fc45d2e96..8b638213a5 100644 --- a/ets2panda/linter/src/lib/utils/consts/ConcurrentAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/ConcurrentAPI.ts @@ -18,3 +18,4 @@ export const USE_SHARED = 'use shared'; export const ESLIB_SHAREDARRAYBUFFER = 'SharedArrayBuffer'; export const ESLIB_SHAREDMEMORY_FILENAME = 'lib.es2017.sharedmemory.d.ts'; export const TASKPOOL_MODULES = ['@kit.ArkTS', '@ohos.taskpool']; +export const SYSTEM_MODULES = ['@kit.ArkTS', '@ohos.']; diff --git a/ets2panda/linter/src/lib/utils/consts/ErrorProp.ts b/ets2panda/linter/src/lib/utils/consts/ErrorProp.ts index 212bb02ae4..a215397dc8 100644 --- a/ets2panda/linter/src/lib/utils/consts/ErrorProp.ts +++ b/ets2panda/linter/src/lib/utils/consts/ErrorProp.ts @@ -1,4 +1,3 @@ - /* * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,18 @@ * limitations under the License. */ -export const ERROR_PROP_LIST: Set = new Set(['name', 'message', 'stack', 'code']); +export const ERROR_PROP_LIST: Set = new Set([ + 'name', + 'message', + 'stack', + 'code', + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable' +]); export const ERROR_TASKPOOL_PROP_LIST: { [key: string]: Set } = { 'taskpool.TaskInfo': new Set(['duration']), diff --git a/ets2panda/linter/src/lib/utils/consts/InValidIndentifierKeywords.ts b/ets2panda/linter/src/lib/utils/consts/InValidIndentifierKeywords.ts index 072f4a88c4..544c493978 100755 --- a/ets2panda/linter/src/lib/utils/consts/InValidIndentifierKeywords.ts +++ b/ets2panda/linter/src/lib/utils/consts/InValidIndentifierKeywords.ts @@ -120,5 +120,95 @@ export const INVALID_IDENTIFIER_KEYWORDS = [ 'AsyncIterator', 'NewableFunction', 'CallableFunction', - 'PropertyDescriptor' + 'PropertyDescriptor', + 'AbcFile', + 'AbcRuntimeLinker', + 'BaseEnum', + 'BootRuntimeLinker', + 'Box', + 'BuiltinArrayAlgorithms', + 'BuiltinArray', + 'BuiltinArraySort', + 'Class', + 'Collator', + 'Comparable', + 'Console', + 'ConsoleHelper', + 'Coroutine', + 'DateTimeFormat', + 'DateTimeFormatTypes', + 'DisplayNames', + 'EAWorker', + 'EnumConstant', + 'Exception', + 'Exceptions', + 'Field', + 'FinalizableWeakRef', + 'FinalizationRegistry', + 'GC', + '_initializerBlock_', + 'Intl', + 'Job', + 'Json', + 'ListFormat', + 'Locale', + 'LocaleMatch', + 'MemoryRuntimeLinker', + 'Method', + 'Never', + 'NullValue', + 'NumberFormat', + 'Numeric', + 'Parameter', + 'PluralRules', + 'Promise', + 'PromiseRef', + 'RelativeTimeFormat', + 'Runtime', + 'RuntimeLinkerErrors', + 'RuntimeLinker', + 'Segmenter', + 'StackTrace', + 'StringBuilder', + 'SyncPrimitives', + 'System', + 'Tuple', + 'TypeCreator', + 'Type', + 'UnionCase', + 'Unsafe', + 'Value', + 'Void', + 'WeakRef', + 'consts/consts', + 'ArrayBuffer', + 'Array', + 'ArrayLike', + 'Atomics', + 'BigInt', + 'ConcatArray', + 'ConcurrencyHelpers', + 'DataView', + 'Date', + 'deepcopy', + 'Error', + 'Errors', + 'escompat', + 'Functions', + 'Global', + 'Iterator', + 'json', + 'Map', + 'Math', + 'Process', + 'ReadonlyArray', + 'ReadonlyArrayProxy', + 'Reflect', + 'RegExp', + 'Set', + 'taskpool', + 'TypedArrays', + 'TypedUArrays', + 'WeakMap', + 'WeakSet' ]; diff --git a/ets2panda/linter/src/lib/utils/consts/LimitedStdAPI.ts b/ets2panda/linter/src/lib/utils/consts/LimitedStdAPI.ts index eeef04d78d..3149a493a1 100644 --- a/ets2panda/linter/src/lib/utils/consts/LimitedStdAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/LimitedStdAPI.ts @@ -153,9 +153,11 @@ export const LIMITED_STD_API = new Map = { - '@kit.ArkTS': ['taskpool', 'ArkTSUtils', 'process'], + '@kit.ArkTS': ['taskpool', 'ArkTSUtils', 'process', 'collections'], '@ohos.process': ['process'], - '@ohos.taskpool': ['taskpool'] + '@ohos.taskpool': ['taskpool'], + '@arkts.utils': ['ArkTSUtils'], + '@arkts.collections': ['collections'] }; export const ARKTSUTILS_MODULES = ['@arkts.utils', '@kit.ArkTS']; diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json index bba9654328..bdaa7adb27 100755 --- a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json @@ -16,9 +16,9 @@ "result": [ { "line": 15, - "column": 1, + "column": 10, "endLine": 15, - "endColumn": 43, + "endColumn": 18, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets b/ets2panda/linter/test/main/func_inferred_type_args_2.ets index 5a79d6f480..0df022ea8f 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets @@ -97,4 +97,14 @@ new A(new C()) let a: Array | undefined = new Array(); let aa: Array | Set | undefined = new Array(); let b: Array | Array | undefined = new Array(); -let test: string[] = new Array(); \ No newline at end of file +let test: string[] = new Array(); + +class A { + test(key: string): Promise { + if (key == undefined || key.length == 0.0) { + return new Promise((resolve, reject) => { + reject("empty key");}); + } else { + } + } +} \ No newline at end of file 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 81e3df826f..91c50bde47 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 @@ -474,6 +474,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 105, + "column": 14, + "endLine": 106, + "endColumn": 31, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, { "line": 84, "column": 2, @@ -513,6 +523,16 @@ "suggest": "", "rule": "The ArkUI interface \"CommonAttribute\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" + }, + { + "line": 103, + "column": 22, + "endLine": 103, + "endColumn": 37, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'.", + "severity": "ERROR" } ] } \ No newline at end of file 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 202b0cc81c..f32d5755fd 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 @@ -631,9 +631,9 @@ "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 2264, - "end": 2275, - "replacementText": "new Array()", + "start": 2273, + "end": 2273, + "replacementText": "", "line": 83, "column": 5, "endLine": 83, @@ -727,6 +727,27 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 105, + "column": 14, + "endLine": 106, + "endColumn": 31, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2880, + "end": 2880, + "replacementText": "", + "line": 105, + "column": 14, + "endLine": 106, + "endColumn": 31 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, { "line": 84, "column": 2, @@ -810,6 +831,16 @@ "suggest": "", "rule": "The ArkUI interface \"CommonAttribute\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" + }, + { + "line": 103, + "column": 22, + "endLine": 103, + "endColumn": 37, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.json index 616182be4e..c3cf571d47 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.json @@ -123,6 +123,16 @@ "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" + }, + { + "line": 103, + "column": 22, + "endLine": 103, + "endColumn": 37, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets index bdd57c5703..92362e1c98 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets @@ -104,4 +104,14 @@ new A(new C()) let a: Array | undefined = new Array(); let aa: Array | Set | undefined = new Array(); let b: Array | Array | undefined = new Array(); -let test: string[] = new Array(); \ No newline at end of file +let test: string[] = new Array(); + +class A { + test(key: string): Promise { + if (key == undefined || key.length == 0.0) { + return new Promise((resolve, reject) => { + reject("empty key");}); + } else { + } + } +} \ No newline at end of file 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 620729cb92..e45393b94a 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 @@ -243,6 +243,16 @@ "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" + }, + { + "line": 110, + "column": 22, + "endLine": 110, + "endColumn": 37, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'.", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/invalid_identifier.ets b/ets2panda/linter/test/main/invalid_identifier.ets index ade4397a20..a1e70cc3a2 100755 --- a/ets2panda/linter/test/main/invalid_identifier.ets +++ b/ets2panda/linter/test/main/invalid_identifier.ets @@ -218,4 +218,9 @@ namespace quarantine { interface test { int: int } -} \ No newline at end of file +} +class StringBuilder { +} + +class Map { +} diff --git a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json index 8d294f2636..dd664dc016 100644 --- a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json +++ b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json @@ -864,6 +864,26 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 222, + "column": 7, + "endLine": 222, + "endColumn": 20, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 7, + "endLine": 225, + "endColumn": 10, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, { "line": 172, "column": 2, diff --git a/ets2panda/linter/test/main/method_inheritance.ets b/ets2panda/linter/test/main/method_inheritance.ets index 276a7c3aee..b82dcc042b 100644 --- a/ets2panda/linter/test/main/method_inheritance.ets +++ b/ets2panda/linter/test/main/method_inheritance.ets @@ -251,4 +251,39 @@ class Derived6 extends Base6 { public foo(): Dog { // no error console.log("Derived:") } +} + +abstract class Parent{ + abstract foo(); + +} +abstract class Parent1{ + abstract foo(): Promise; + +} + +abstract class Child extends Parent{ + async foo(){ //error + + } +} +class Child1 extends Parent{ + async foo(){ //error + + } +} +abstract class Child2 extends Parent{ + foo(): void { + + } +} +abstract class Child3 extends Parent{ + foo(): boolean { //error + return false; + } +} +abstract class Child4 extends Parent1{ + async foo() { + + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json index a25dd05807..68eaed003e 100644 --- a/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json +++ b/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json @@ -293,6 +293,36 @@ "suggest": "", "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" + }, + { + "line": 266, + "column": 9, + "endLine": 266, + "endColumn": 12, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 271, + "column": 9, + "endLine": 271, + "endColumn": 12, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 281, + "column": 10, + "endLine": 281, + "endColumn": 17, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets b/ets2panda/linter/test/main/no_import_concurrency.ets index d6f173602a..9eb3c99118 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets +++ b/ets2panda/linter/test/main/no_import_concurrency.ets @@ -17,10 +17,27 @@ import { foo, util, taskpool as tpp } from '@ohos.taskpool'; import { anyClass } from '@kit.ArkTS'; //legal import foo2, { fooClass } from '@ohos.taskpool'; //legal -import taskpool, { ArkTSUtils as Atu, roo } from '@kit.ArkTS'; +import defaultImport, { ArkTSUtils as Atu, roo } from '@kit.ArkTS'; import koo, { ArkTSUtils as Ark, process as pr } from '@kit.ArkTS'; -import doo, { ArkTSUtils as Ats, too } from '@kit.ArkTS'; -import fooke from '@ohos.process'; //legal -import { process as ps } from '@ohos.process'; +import doo, { fooModule as fooAs, too } from '@kit.ArkTS'; +import bbbb, { taskpool as tsk, process as prs } from '@kit.ArkTS'; +import fooke from '@ohos.process'; +import { process as ps, collections as clt } from '@kit.ArkTS'; import process from '@ohos.process'; -import ArkTSUtils, { taskpool as tsk, process as prs } from '@kit.ArkTS'; \ No newline at end of file +import aaa from '@ohos.taskpool' +import aa from '@arkts.utils' +import aaaa from '@arkts.collections'; + +aaa.getTaskPoolInfo() + +function concurrency () { + const aaa = 123; + console.log(aaa); +} + +ps.isIsolatedProcess(); +tsk.cancel(); +aa.locks.AsyncLock +aaaa.Set() +clt.Set() +fooAs.getFoo(); diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json index 7d90da6369..d3aaa8c933 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json @@ -25,10 +25,10 @@ "severity": "ERROR" }, { - "line": 20, + "line": 19, "column": 8, - "endLine": 20, - "endColumn": 16, + "endLine": 19, + "endColumn": 12, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", @@ -36,9 +36,9 @@ }, { "line": 20, - "column": 20, + "column": 25, "endLine": 20, - "endColumn": 37, + "endColumn": 42, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", @@ -65,10 +65,20 @@ "severity": "ERROR" }, { - "line": 22, - "column": 15, - "endLine": 22, - "endColumn": 32, + "line": 23, + "column": 16, + "endLine": 23, + "endColumn": 31, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 33, + "endLine": 23, + "endColumn": 47, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", @@ -76,9 +86,9 @@ }, { "line": 24, - "column": 1, + "column": 8, "endLine": 24, - "endColumn": 47, + "endColumn": 13, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", @@ -86,9 +96,19 @@ }, { "line": 25, - "column": 1, + "column": 10, "endLine": 25, - "endColumn": 37, + "endColumn": 23, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 43, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", @@ -96,13 +116,63 @@ }, { "line": 26, - "column": 1, + "column": 8, "endLine": 26, - "endColumn": 74, + "endColumn": 15, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 11, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 8, + "endLine": 28, + "endColumn": 10, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 11, + "endLine": 34, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 17, + "endLine": 34, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json b/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json index 2a756c0a4e..6c5606e018 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json @@ -24,7 +24,11 @@ { "start": 629, "end": 646, - "replacementText": "" + "replacementText": "", + "line": 17, + "column": 21, + "endLine": 17, + "endColumn": 36 } ], "suggest": "", @@ -32,16 +36,20 @@ "severity": "ERROR" }, { - "line": 20, + "line": 19, "column": 8, - "endLine": 20, - "endColumn": 16, + "endLine": 19, + "endColumn": 12, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 783, - "end": 793, - "replacementText": "" + "start": 726, + "end": 732, + "replacementText": "", + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12 } ], "suggest": "", @@ -50,15 +58,19 @@ }, { "line": 20, - "column": 20, + "column": 25, "endLine": 20, - "endColumn": 37, + "endColumn": 42, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 795, - "end": 814, - "replacementText": "" + "start": 800, + "end": 819, + "replacementText": "", + "line": 20, + "column": 25, + "endLine": 20, + "endColumn": 42 } ], "suggest": "", @@ -73,9 +85,13 @@ "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 853, - "end": 872, - "replacementText": "" + "start": 858, + "end": 877, + "replacementText": "", + "line": 21, + "column": 15, + "endLine": 21, + "endColumn": 32 } ], "suggest": "", @@ -90,9 +106,13 @@ "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 870, - "end": 885, - "replacementText": "" + "start": 875, + "end": 890, + "replacementText": "", + "line": 21, + "column": 34, + "endLine": 21, + "endColumn": 47 } ], "suggest": "", @@ -100,16 +120,50 @@ "severity": "ERROR" }, { - "line": 22, - "column": 15, - "endLine": 22, - "endColumn": 32, + "line": 23, + "column": 16, + "endLine": 23, + "endColumn": 31, + "problem": "LimitedStdLibNoImportConcurrency", + "autofix": [ + { + "start": 986, + "end": 1003, + "replacementText": "", + "line": 23, + "column": 16, + "endLine": 23, + "endColumn": 31 + }, + { + "start": 1397, + "end": 1400, + "replacementText": "taskpool", + "line": 23, + "column": 16, + "endLine": 23, + "endColumn": 31 + } + ], + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 33, + "endLine": 23, + "endColumn": 47, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 921, - "end": 940, - "replacementText": "" + "start": 1001, + "end": 1017, + "replacementText": "", + "line": 23, + "column": 33, + "endLine": 23, + "endColumn": 47 } ], "suggest": "", @@ -118,15 +172,19 @@ }, { "line": 24, - "column": 1, + "column": 8, "endLine": 24, - "endColumn": 47, + "endColumn": 13, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 1008, - "end": 1054, - "replacementText": "" + "start": 1039, + "end": 1073, + "replacementText": "", + "line": 24, + "column": 8, + "endLine": 24, + "endColumn": 13 } ], "suggest": "", @@ -135,15 +193,58 @@ }, { "line": 25, - "column": 1, + "column": 10, "endLine": 25, - "endColumn": 37, + "endColumn": 23, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 1055, - "end": 1091, - "replacementText": "" + "start": 1083, + "end": 1098, + "replacementText": "", + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 23 + }, + { + "start": 1373, + "end": 1375, + "replacementText": "process", + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 43, + "problem": "LimitedStdLibNoImportConcurrency", + "autofix": [ + { + "start": 1096, + "end": 1116, + "replacementText": "", + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 43 + }, + { + "start": 1441, + "end": 1444, + "replacementText": "collections", + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 43 } ], "suggest": "", @@ -152,20 +253,156 @@ }, { "line": 26, - "column": 1, + "column": 8, "endLine": 26, - "endColumn": 74, + "endColumn": 15, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { - "start": 1092, - "end": 1165, - "replacementText": "" + "start": 1138, + "end": 1174, + "replacementText": "", + "line": 26, + "column": 8, + "endLine": 26, + "endColumn": 15 } ], "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 11, + "problem": "LimitedStdLibNoImportConcurrency", + "autofix": [ + { + "start": 1175, + "end": 1207, + "replacementText": "", + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 11 + }, + { + "start": 1278, + "end": 1281, + "replacementText": "taskpool", + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 8, + "endLine": 28, + "endColumn": 10, + "problem": "LimitedStdLibNoImportConcurrency", + "autofix": [ + { + "start": 1208, + "end": 1237, + "replacementText": "", + "line": 28, + "column": 8, + "endLine": 28, + "endColumn": 10 + }, + { + "start": 1411, + "end": 1413, + "replacementText": "ArkTSUtils", + "line": 28, + "column": 8, + "endLine": 28, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "autofix": [ + { + "start": 1238, + "end": 1276, + "replacementText": "", + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12 + }, + { + "start": 1430, + "end": 1434, + "replacementText": "collections", + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 11, + "endLine": 34, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1337, + "end": 1346, + "replacementText": "aaa: number = 123", + "line": 34, + "column": 11, + "endLine": 34, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 17, + "endLine": 34, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1343, + "end": 1346, + "replacementText": "123.0", + "line": 34, + "column": 17, + "endLine": 34, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets index a7dc1cccd1..ec7742adfb 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets @@ -16,10 +16,28 @@ import { foo, util } from '@ohos.taskpool'; import { anyClass } from '@kit.ArkTS'; //legal -import foo2, { fooClass } from '@ohos.taskpool'; //legal -import { roo } from '@kit.ArkTS'; +import { fooClass } from '@ohos.taskpool'; //legal +import defaultImport, { roo } from '@kit.ArkTS'; import koo from '@kit.ArkTS'; -import doo, { too } from '@kit.ArkTS'; -import fooke from '@ohos.process'; //legal +import doo, { fooModule as fooAs, too } from '@kit.ArkTS'; +import bbbb from '@kit.ArkTS'; + + + + + +taskpool.getTaskPoolInfo() + +function concurrency () { + const aaa: number = 123.0; + console.log(aaa); +} + +process.isIsolatedProcess(); +taskpool.cancel(); +ArkTSUtils.locks.AsyncLock +collections.Set() +collections.Set() +fooAs.getFoo(); diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets b/ets2panda/linter/test/main/numeric_semantics2.ets index 0d76c6342b..a0e35fcfbc 100755 --- a/ets2panda/linter/test/main/numeric_semantics2.ets +++ b/ets2panda/linter/test/main/numeric_semantics2.ets @@ -70,7 +70,7 @@ namespace NumericSemanticsOther { namespace BeCareful { `${1/2}` - + } namespace NoDiffInArk1_1To1_2 { @@ -123,4 +123,4 @@ namespace GenericTypeCase { console.log(foo1(12/24, 8, true)) // NOT OK console.log(foo1(12/24, 8, true)) // NOT OK console.log(foo1(12.0/24.0, 8, true)) -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json index 890005064b..0cee44032a 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json @@ -1,1329 +1,1329 @@ { - "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": 22, - "column": 5, - "endLine": 22, - "endColumn": 26, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 23, - "endLine": 17, - "endColumn": 25, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 678, - "end": 680, - "replacementText": "11.0", - "line": 17, - "column": 23, - "endLine": 17, - "endColumn": 25 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 11, - "endLine": 18, - "endColumn": 17, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 702, - "end": 708, - "replacementText": "b: number = 12 // NOT OK\r\n", - "line": 18, - "column": 11, - "endLine": 18, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 15, - "endLine": 18, - "endColumn": 17, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 706, - "end": 708, - "replacementText": "12.0", - "line": 18, - "column": 15, - "endLine": 18, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 11, - "endLine": 19, - "endColumn": 19, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 730, - "end": 738, - "replacementText": "c: number = 13.0 // NOT OK\r\n", - "line": 19, - "column": 11, - "endLine": 19, - "endColumn": 19 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 23, - "endLine": 21, - "endColumn": 25, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 800, - "end": 802, - "replacementText": "15.0", - "line": 21, - "column": 23, - "endLine": 21, - "endColumn": 25 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 22, - "endLine": 22, - "endColumn": 23, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 835, - "end": 836, - "replacementText": "1.0", - "line": 22, - "column": 22, - "endLine": 22, - "endColumn": 23 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 24, - "endLine": 22, - "endColumn": 25, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 837, - "end": 838, - "replacementText": "2.0", - "line": 22, - "column": 24, - "endLine": 22, - "endColumn": 25 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 31, - "column": 5, - "endLine": 31, - "endColumn": 30, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 38, - "column": 5, - "endLine": 38, - "endColumn": 23, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 45, - "column": 5, - "endLine": 45, - "endColumn": 25, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 35, - "column": 20, - "endLine": 35, - "endColumn": 26, - "problem": "LiteralAsPropertyName", - "autofix": [ - { - "replacementText": "name", - "start": 1117, - "end": 1123, - "line": 37, - "column": 18, - "endLine": 37, - "endColumn": 24 - }, - { - "replacementText": "name", - "start": 1210, - "end": 1216, - "line": 37, - "column": 18, - "endLine": 37, - "endColumn": 24 - } - ], - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", - "severity": "ERROR" - }, - { - "line": 35, - "column": 36, - "endLine": 35, - "endColumn": 37, - "problem": "LiteralAsPropertyName", - "autofix": [ - { - "replacementText": "__2", - "start": 1133, - "end": 1134, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - }, - { - "replacementText": "__2", - "start": 1224, - "end": 1225, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - }, - { - "replacementText": "x.__2", - "start": 1256, - "end": 1260, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", - "severity": "ERROR" - }, - { - "line": 36, - "column": 20, - "endLine": 36, - "endColumn": 26, - "problem": "LiteralAsPropertyName", - "autofix": [ - { - "replacementText": "name", - "start": 1164, - "end": 1170, - "line": 36, - "column": 20, - "endLine": 36, - "endColumn": 26 - } - ], - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", - "severity": "ERROR" - }, - { - "line": 37, - "column": 18, - "endLine": 37, - "endColumn": 24, - "problem": "LiteralAsPropertyName", - "autofix": [ - { - "replacementText": "name", - "start": 1117, - "end": 1123, - "line": 37, - "column": 18, - "endLine": 37, - "endColumn": 24 - }, - { - "replacementText": "name", - "start": 1210, - "end": 1216, - "line": 37, - "column": 18, - "endLine": 37, - "endColumn": 24 - } - ], - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", - "severity": "ERROR" - }, - { - "line": 37, - "column": 32, - "endLine": 37, - "endColumn": 33, - "problem": "LiteralAsPropertyName", - "autofix": [ - { - "replacementText": "__2", - "start": 1133, - "end": 1134, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - }, - { - "replacementText": "__2", - "start": 1224, - "end": 1225, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - }, - { - "replacementText": "x.__2", - "start": 1256, - "end": 1260, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", - "severity": "ERROR" - }, - { - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21, - "problem": "PropertyAccessByIndex", - "autofix": [ - { - "replacementText": "__2", - "start": 1133, - "end": 1134, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - }, - { - "replacementText": "__2", - "start": 1224, - "end": 1225, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - }, - { - "replacementText": "x.__2", - "start": 1256, - "end": 1260, - "line": 38, - "column": 17, - "endLine": 38, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", - "severity": "ERROR" - }, - { - "line": 42, - "column": 17, - "endLine": 42, - "endColumn": 18, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 42, - "column": 30, - "endLine": 42, - "endColumn": 31, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", - "severity": "ERROR" - }, - { - "line": 44, - "column": 17, - "endLine": 44, - "endColumn": 19, - "problem": "NosparseArray", - "suggest": "", - "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", - "severity": "ERROR" - }, - { - "line": 45, - "column": 17, - "endLine": 45, - "endColumn": 23, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 62, - "column": 13, - "endLine": 62, - "endColumn": 14, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1792, - "end": 1793, - "replacementText": "1.0", - "line": 62, - "column": 13, - "endLine": 62, - "endColumn": 14 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 63, - "column": 13, - "endLine": 63, - "endColumn": 14, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1808, - "end": 1809, - "replacementText": "2.0", - "line": 63, - "column": 13, - "endLine": 63, - "endColumn": 14 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 68, - "column": 28, - "endLine": 68, - "endColumn": 30, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1885, - "end": 1887, - "replacementText": "11.0", - "line": 68, - "column": 28, - "endLine": 68, - "endColumn": 30 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 72, - "column": 5, - "endLine": 72, - "endColumn": 13, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 72, - "column": 8, - "endLine": 72, - "endColumn": 9, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1925, - "end": 1926, - "replacementText": "1.0", - "line": 72, - "column": 8, - "endLine": 72, - "endColumn": 9 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 72, - "column": 10, - "endLine": 72, - "endColumn": 11, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1927, - "end": 1928, - "replacementText": "2.0", - "line": 72, - "column": 10, - "endLine": 72, - "endColumn": 11 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 83, - "column": 5, - "endLine": 83, - "endColumn": 35, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 77, - "column": 19, - "endLine": 77, - "endColumn": 20, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1994, - "end": 1995, - "replacementText": "1.0", - "line": 77, - "column": 19, - "endLine": 77, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 77, - "column": 21, - "endLine": 77, - "endColumn": 22, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1996, - "end": 1997, - "replacementText": "2.0", - "line": 77, - "column": 21, - "endLine": 77, - "endColumn": 22 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 21, - "endLine": 79, - "endColumn": 23, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2060, - "end": 2062, - "replacementText": "20.0", - "line": 79, - "column": 21, - "endLine": 79, - "endColumn": 23 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 26, - "endLine": 79, - "endColumn": 28, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2065, - "end": 2067, - "replacementText": "21.0", - "line": 79, - "column": 26, - "endLine": 79, - "endColumn": 28 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 31, - "endLine": 79, - "endColumn": 33, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2070, - "end": 2072, - "replacementText": "22.0", - "line": 79, - "column": 31, - "endLine": 79, - "endColumn": 33 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 36, - "endLine": 79, - "endColumn": 38, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2075, - "end": 2077, - "replacementText": "23.0", - "line": 79, - "column": 36, - "endLine": 79, - "endColumn": 38 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 81, - "column": 24, - "endLine": 81, - "endColumn": 26, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2163, - "end": 2165, - "replacementText": "20.0", - "line": 81, - "column": 24, - "endLine": 81, - "endColumn": 26 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 86, - "column": 9, - "endLine": 86, - "endColumn": 15, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2325, - "end": 2331, - "replacementText": "e: number = 15 // NOT OK\r\n", - "line": 86, - "column": 9, - "endLine": 86, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 86, - "column": 13, - "endLine": 86, - "endColumn": 15, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2329, - "end": 2331, - "replacementText": "15.0", - "line": 86, - "column": 13, - "endLine": 86, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 87, - "column": 9, - "endLine": 87, - "endColumn": 19, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2351, - "end": 2361, - "replacementText": "e1: number = e & 3", - "line": 87, - "column": 9, - "endLine": 87, - "endColumn": 19 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 87, - "column": 18, - "endLine": 87, - "endColumn": 19, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2360, - "end": 2361, - "replacementText": "3.0", - "line": 87, - "column": 18, - "endLine": 87, - "endColumn": 19 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 88, - "column": 9, - "endLine": 88, - "endColumn": 19, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2382, - "end": 2392, - "replacementText": "e2: number = e | 3", - "line": 88, - "column": 9, - "endLine": 88, - "endColumn": 19 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 88, - "column": 18, - "endLine": 88, - "endColumn": 19, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2391, - "end": 2392, - "replacementText": "3.0", - "line": 88, - "column": 18, - "endLine": 88, - "endColumn": 19 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 100, - "column": 5, - "endLine": 100, - "endColumn": 27, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 101, - "column": 5, - "endLine": 101, - "endColumn": 38, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 102, - "column": 5, - "endLine": 102, - "endColumn": 25, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 114, - "column": 5, - "endLine": 114, - "endColumn": 15, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 115, - "column": 5, - "endLine": 115, - "endColumn": 17, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 120, - "column": 5, - "endLine": 120, - "endColumn": 27, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 121, - "column": 5, - "endLine": 121, - "endColumn": 28, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 123, - "column": 5, - "endLine": 123, - "endColumn": 38, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 124, - "column": 5, - "endLine": 124, - "endColumn": 53, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 125, - "column": 5, - "endLine": 125, - "endColumn": 57, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 100, - "column": 25, - "endLine": 100, - "endColumn": 26, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2615, - "end": 2616, - "replacementText": "1.0", - "line": 100, - "column": 25, - "endLine": 100, - "endColumn": 26 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 101, - "column": 32, - "endLine": 101, - "endColumn": 33, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2677, - "end": 2678, - "replacementText": "1.0", - "line": 101, - "column": 32, - "endLine": 101, - "endColumn": 33 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 101, - "column": 36, - "endLine": 101, - "endColumn": 37, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2681, - "end": 2682, - "replacementText": "2.0", - "line": 101, - "column": 36, - "endLine": 101, - "endColumn": 37 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 102, - "column": 23, - "endLine": 102, - "endColumn": 24, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 2717, - "end": 2718, - "replacementText": "1.0", - "line": 102, - "column": 23, - "endLine": 102, - "endColumn": 24 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 109, - "column": 32, - "endLine": 109, - "endColumn": 60, - "problem": "GenericCallNoTypeArgs", - "suggest": "", - "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", - "severity": "ERROR" - }, - { - "line": 114, - "column": 9, - "endLine": 114, - "endColumn": 11, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3109, - "end": 3111, - "replacementText": "12.0", - "line": 114, - "column": 9, - "endLine": 114, - "endColumn": 11 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 114, - "column": 13, - "endLine": 114, - "endColumn": 15, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3113, - "end": 3115, - "replacementText": "24.0", - "line": 114, - "column": 13, - "endLine": 114, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 115, - "column": 15, - "endLine": 115, - "endColumn": 17, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3141, - "end": 3143, - "replacementText": "24.0", - "line": 115, - "column": 15, - "endLine": 115, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 120, - "column": 16, - "endLine": 120, - "endColumn": 17, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3254, - "end": 3255, - "replacementText": "8.0", - "line": 120, - "column": 16, - "endLine": 120, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 120, - "column": 25, - "endLine": 120, - "endColumn": 27, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3263, - "end": 3265, - "replacementText": "24.0", - "line": 120, - "column": 25, - "endLine": 120, - "endColumn": 27 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 121, - "column": 16, - "endLine": 121, - "endColumn": 17, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3292, - "end": 3293, - "replacementText": "8.0", - "line": 121, - "column": 16, - "endLine": 121, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 121, - "column": 26, - "endLine": 121, - "endColumn": 28, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3302, - "end": 3304, - "replacementText": "24.0", - "line": 121, - "column": 26, - "endLine": 121, - "endColumn": 28 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 123, - "column": 22, - "endLine": 123, - "endColumn": 24, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3339, - "end": 3341, - "replacementText": "12.0", - "line": 123, - "column": 22, - "endLine": 123, - "endColumn": 24 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 123, - "column": 25, - "endLine": 123, - "endColumn": 27, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3342, - "end": 3344, - "replacementText": "24.0", - "line": 123, - "column": 25, - "endLine": 123, - "endColumn": 27 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 123, - "column": 29, - "endLine": 123, - "endColumn": 30, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3346, - "end": 3347, - "replacementText": "8.0", - "line": 123, - "column": 29, - "endLine": 123, - "endColumn": 30 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 124, - "column": 37, - "endLine": 124, - "endColumn": 39, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3403, - "end": 3405, - "replacementText": "12.0", - "line": 124, - "column": 37, - "endLine": 124, - "endColumn": 39 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 124, - "column": 40, - "endLine": 124, - "endColumn": 42, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3406, - "end": 3408, - "replacementText": "24.0", - "line": 124, - "column": 40, - "endLine": 124, - "endColumn": 42 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 124, - "column": 44, - "endLine": 124, - "endColumn": 45, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3410, - "end": 3411, - "replacementText": "8.0", - "line": 124, - "column": 44, - "endLine": 124, - "endColumn": 45 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 125, - "column": 48, - "endLine": 125, - "endColumn": 49, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 3478, - "end": 3479, - "replacementText": "8.0", - "line": 125, - "column": 48, - "endLine": 125, - "endColumn": 49 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" + "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": 22, + "column": 5, + "endLine": 22, + "endColumn": 26, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 23, + "endLine": 17, + "endColumn": 25, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 678, + "end": 680, + "replacementText": "11.0", + "line": 17, + "column": 23, + "endLine": 17, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 11, + "endLine": 18, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 702, + "end": 708, + "replacementText": "b: number = 12", + "line": 18, + "column": 11, + "endLine": 18, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 15, + "endLine": 18, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 706, + "end": 708, + "replacementText": "12.0", + "line": 18, + "column": 15, + "endLine": 18, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 11, + "endLine": 19, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 730, + "end": 738, + "replacementText": "c: number = 13.0", + "line": 19, + "column": 11, + "endLine": 19, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 23, + "endLine": 21, + "endColumn": 25, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 800, + "end": 802, + "replacementText": "15.0", + "line": 21, + "column": 23, + "endLine": 21, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 22, + "endLine": 22, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 835, + "end": 836, + "replacementText": "1.0", + "line": 22, + "column": 22, + "endLine": 22, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 24, + "endLine": 22, + "endColumn": 25, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 837, + "end": 838, + "replacementText": "2.0", + "line": 22, + "column": 24, + "endLine": 22, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 30, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 23, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 5, + "endLine": 45, + "endColumn": 25, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 20, + "endLine": 35, + "endColumn": 26, + "problem": "LiteralAsPropertyName", + "autofix": [ + { + "replacementText": "name", + "start": 1117, + "end": 1123, + "line": 37, + "column": 18, + "endLine": 37, + "endColumn": 24 + }, + { + "replacementText": "name", + "start": 1210, + "end": 1216, + "line": 37, + "column": 18, + "endLine": 37, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 36, + "endLine": 35, + "endColumn": 37, + "problem": "LiteralAsPropertyName", + "autofix": [ + { + "replacementText": "__2", + "start": 1133, + "end": 1134, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + }, + { + "replacementText": "__2", + "start": 1224, + "end": 1225, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + }, + { + "replacementText": "x.__2", + "start": 1256, + "end": 1260, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 20, + "endLine": 36, + "endColumn": 26, + "problem": "LiteralAsPropertyName", + "autofix": [ + { + "replacementText": "name", + "start": 1164, + "end": 1170, + "line": 36, + "column": 20, + "endLine": 36, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 18, + "endLine": 37, + "endColumn": 24, + "problem": "LiteralAsPropertyName", + "autofix": [ + { + "replacementText": "name", + "start": 1117, + "end": 1123, + "line": 37, + "column": 18, + "endLine": 37, + "endColumn": 24 + }, + { + "replacementText": "name", + "start": 1210, + "end": 1216, + "line": 37, + "column": 18, + "endLine": 37, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 32, + "endLine": 37, + "endColumn": 33, + "problem": "LiteralAsPropertyName", + "autofix": [ + { + "replacementText": "__2", + "start": 1133, + "end": 1134, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + }, + { + "replacementText": "__2", + "start": 1224, + "end": 1225, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + }, + { + "replacementText": "x.__2", + "start": 1256, + "end": 1260, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21, + "problem": "PropertyAccessByIndex", + "autofix": [ + { + "replacementText": "__2", + "start": 1133, + "end": 1134, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + }, + { + "replacementText": "__2", + "start": 1224, + "end": 1225, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + }, + { + "replacementText": "x.__2", + "start": 1256, + "end": 1260, + "line": 38, + "column": 17, + "endLine": 38, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 17, + "endLine": 42, + "endColumn": 18, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 30, + "endLine": 42, + "endColumn": 31, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 17, + "endLine": 44, + "endColumn": 19, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 17, + "endLine": 45, + "endColumn": 23, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 13, + "endLine": 62, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1792, + "end": 1793, + "replacementText": "1.0", + "line": 62, + "column": 13, + "endLine": 62, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 13, + "endLine": 63, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1808, + "end": 1809, + "replacementText": "2.0", + "line": 63, + "column": 13, + "endLine": 63, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 28, + "endLine": 68, + "endColumn": 30, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1885, + "end": 1887, + "replacementText": "11.0", + "line": 68, + "column": 28, + "endLine": 68, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 5, + "endLine": 72, + "endColumn": 13, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 8, + "endLine": 72, + "endColumn": 9, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1925, + "end": 1926, + "replacementText": "1.0", + "line": 72, + "column": 8, + "endLine": 72, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 10, + "endLine": 72, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1927, + "end": 1928, + "replacementText": "2.0", + "line": 72, + "column": 10, + "endLine": 72, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 5, + "endLine": 83, + "endColumn": 35, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 19, + "endLine": 77, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1990, + "end": 1991, + "replacementText": "1.0", + "line": 77, + "column": 19, + "endLine": 77, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 21, + "endLine": 77, + "endColumn": 22, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1992, + "end": 1993, + "replacementText": "2.0", + "line": 77, + "column": 21, + "endLine": 77, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 21, + "endLine": 79, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2056, + "end": 2058, + "replacementText": "20.0", + "line": 79, + "column": 21, + "endLine": 79, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 26, + "endLine": 79, + "endColumn": 28, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2061, + "end": 2063, + "replacementText": "21.0", + "line": 79, + "column": 26, + "endLine": 79, + "endColumn": 28 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 31, + "endLine": 79, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2066, + "end": 2068, + "replacementText": "22.0", + "line": 79, + "column": 31, + "endLine": 79, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 36, + "endLine": 79, + "endColumn": 38, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2071, + "end": 2073, + "replacementText": "23.0", + "line": 79, + "column": 36, + "endLine": 79, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 24, + "endLine": 81, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2159, + "end": 2161, + "replacementText": "20.0", + "line": 81, + "column": 24, + "endLine": 81, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 9, + "endLine": 86, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2321, + "end": 2327, + "replacementText": "e: number = 15", + "line": 86, + "column": 9, + "endLine": 86, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 13, + "endLine": 86, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2325, + "end": 2327, + "replacementText": "15.0", + "line": 86, + "column": 13, + "endLine": 86, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 9, + "endLine": 87, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2347, + "end": 2357, + "replacementText": "e1: number = e & 3", + "line": 87, + "column": 9, + "endLine": 87, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 18, + "endLine": 87, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2356, + "end": 2357, + "replacementText": "3.0", + "line": 87, + "column": 18, + "endLine": 87, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 9, + "endLine": 88, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2378, + "end": 2388, + "replacementText": "e2: number = e | 3", + "line": 88, + "column": 9, + "endLine": 88, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 18, + "endLine": 88, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2387, + "end": 2388, + "replacementText": "3.0", + "line": 88, + "column": 18, + "endLine": 88, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 5, + "endLine": 100, + "endColumn": 27, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 5, + "endLine": 101, + "endColumn": 38, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 5, + "endLine": 102, + "endColumn": 25, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 5, + "endLine": 114, + "endColumn": 15, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 5, + "endLine": 115, + "endColumn": 17, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 5, + "endLine": 120, + "endColumn": 27, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 5, + "endLine": 121, + "endColumn": 28, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 5, + "endLine": 123, + "endColumn": 38, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 5, + "endLine": 124, + "endColumn": 53, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 5, + "endLine": 125, + "endColumn": 57, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 25, + "endLine": 100, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2611, + "end": 2612, + "replacementText": "1.0", + "line": 100, + "column": 25, + "endLine": 100, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 32, + "endLine": 101, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2673, + "end": 2674, + "replacementText": "1.0", + "line": 101, + "column": 32, + "endLine": 101, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 36, + "endLine": 101, + "endColumn": 37, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2677, + "end": 2678, + "replacementText": "2.0", + "line": 101, + "column": 36, + "endLine": 101, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 23, + "endLine": 102, + "endColumn": 24, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2713, + "end": 2714, + "replacementText": "1.0", + "line": 102, + "column": 23, + "endLine": 102, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 32, + "endLine": 109, + "endColumn": 60, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 9, + "endLine": 114, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3105, + "end": 3107, + "replacementText": "12.0", + "line": 114, + "column": 9, + "endLine": 114, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 13, + "endLine": 114, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3109, + "end": 3111, + "replacementText": "24.0", + "line": 114, + "column": 13, + "endLine": 114, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 15, + "endLine": 115, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3137, + "end": 3139, + "replacementText": "24.0", + "line": 115, + "column": 15, + "endLine": 115, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 16, + "endLine": 120, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3250, + "end": 3251, + "replacementText": "8.0", + "line": 120, + "column": 16, + "endLine": 120, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 25, + "endLine": 120, + "endColumn": 27, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3259, + "end": 3261, + "replacementText": "24.0", + "line": 120, + "column": 25, + "endLine": 120, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 16, + "endLine": 121, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3288, + "end": 3289, + "replacementText": "8.0", + "line": 121, + "column": 16, + "endLine": 121, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 26, + "endLine": 121, + "endColumn": 28, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3298, + "end": 3300, + "replacementText": "24.0", + "line": 121, + "column": 26, + "endLine": 121, + "endColumn": 28 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 22, + "endLine": 123, + "endColumn": 24, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3335, + "end": 3337, + "replacementText": "12.0", + "line": 123, + "column": 22, + "endLine": 123, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 25, + "endLine": 123, + "endColumn": 27, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3338, + "end": 3340, + "replacementText": "24.0", + "line": 123, + "column": 25, + "endLine": 123, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 29, + "endLine": 123, + "endColumn": 30, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3342, + "end": 3343, + "replacementText": "8.0", + "line": 123, + "column": 29, + "endLine": 123, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 37, + "endLine": 124, + "endColumn": 39, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3399, + "end": 3401, + "replacementText": "12.0", + "line": 124, + "column": 37, + "endLine": 124, + "endColumn": 39 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 40, + "endLine": 124, + "endColumn": 42, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3402, + "end": 3404, + "replacementText": "24.0", + "line": 124, + "column": 40, + "endLine": 124, + "endColumn": 42 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 44, + "endLine": 124, + "endColumn": 45, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3406, + "end": 3407, + "replacementText": "8.0", + "line": 124, + "column": 44, + "endLine": 124, + "endColumn": 45 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 48, + "endLine": 125, + "endColumn": 49, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3474, + "end": 3475, + "replacementText": "8.0", + "line": 125, + "column": 48, + "endLine": 125, + "endColumn": 49 } - ] -} \ No newline at end of file + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets index 3b6d90963d..06a1c15859 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets @@ -16,9 +16,7 @@ namespace NumericSemanticsReport { const a: number = 11.0 // NOT OK const b: number = 12.0 // NOT OK - // NOT OK const c: number = 13.0 // NOT OK - // NOT OK const d: number = 14.0 const e: number = 15.0 // NOT OK console.log('' + 1.0/2.0) // NOT OK @@ -72,7 +70,7 @@ namespace NumericSemanticsOther { namespace BeCareful { `${1.0/2.0}` - + } namespace NoDiffInArk1_1To1_2 { @@ -86,7 +84,6 @@ namespace NoDiffInArk1_1To1_2 { // Automatically delete decimal parts during bitwise operations let e: number = 15.0 // NOT OK - // NOT OK let e1: number = e & 3.0; // NOT OK let e2: number = e | 3.0; // NOT OK } @@ -126,4 +123,4 @@ namespace GenericTypeCase { console.log(foo1(12.0/24.0, 8.0, true)) // NOT OK console.log(foo1(12.0/24.0, 8.0, true)) // NOT OK console.log(foo1(12.0/24.0, 8.0, true)) -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json index dcabd25e69..57a7300d81 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json @@ -1,228 +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": 24, - "column": 5, - "endLine": 24, - "endColumn": 30, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 5, - "endLine": 33, - "endColumn": 30, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 40, - "column": 5, - "endLine": 40, - "endColumn": 24, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 47, - "column": 5, - "endLine": 47, - "endColumn": 25, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 44, - "column": 17, - "endLine": 44, - "endColumn": 18, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 44, - "column": 30, - "endLine": 44, - "endColumn": 31, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", - "severity": "ERROR" - }, - { - "line": 46, - "column": 17, - "endLine": 46, - "endColumn": 19, - "problem": "NosparseArray", - "suggest": "", - "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", - "severity": "ERROR" - }, - { - "line": 47, - "column": 17, - "endLine": 47, - "endColumn": 23, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 74, - "column": 5, - "endLine": 74, - "endColumn": 17, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 85, - "column": 5, - "endLine": 85, - "endColumn": 35, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 103, - "column": 5, - "endLine": 103, - "endColumn": 29, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 104, - "column": 5, - "endLine": 104, - "endColumn": 42, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 105, - "column": 5, - "endLine": 105, - "endColumn": 27, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 117, - "column": 5, - "endLine": 117, - "endColumn": 19, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 118, - "column": 5, - "endLine": 118, - "endColumn": 19, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 123, - "column": 5, - "endLine": 123, - "endColumn": 31, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 124, - "column": 5, - "endLine": 124, - "endColumn": 32, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 126, - "column": 5, - "endLine": 126, - "endColumn": 44, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 127, - "column": 5, - "endLine": 127, - "endColumn": 59, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 128, - "column": 5, - "endLine": 128, - "endColumn": 59, - "problem": "NonDeclarationInNamespace", - "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", - "severity": "ERROR" - }, - { - "line": 112, - "column": 32, - "endLine": 112, - "endColumn": 60, - "problem": "GenericCallNoTypeArgs", - "suggest": "", - "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", - "severity": "ERROR" - } - ] -} \ No newline at end of file + "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": 22, + "column": 5, + "endLine": 22, + "endColumn": 30, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 30, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 24, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 5, + "endLine": 45, + "endColumn": 25, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 17, + "endLine": 42, + "endColumn": 18, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 30, + "endLine": 42, + "endColumn": 31, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 17, + "endLine": 44, + "endColumn": 19, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 17, + "endLine": 45, + "endColumn": 23, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 5, + "endLine": 72, + "endColumn": 17, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 5, + "endLine": 83, + "endColumn": 35, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 5, + "endLine": 100, + "endColumn": 29, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 5, + "endLine": 101, + "endColumn": 42, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 5, + "endLine": 102, + "endColumn": 27, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 5, + "endLine": 114, + "endColumn": 19, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 5, + "endLine": 115, + "endColumn": 19, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 5, + "endLine": 120, + "endColumn": 31, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 5, + "endLine": 121, + "endColumn": 32, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 5, + "endLine": 123, + "endColumn": 44, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 5, + "endLine": 124, + "endColumn": 59, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 5, + "endLine": 125, + "endColumn": 59, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statements) (arkts-no-ns-statements)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 32, + "endLine": 109, + "endColumn": 60, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets new file mode 100644 index 0000000000..a204f77319 --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets @@ -0,0 +1,35 @@ +/* + * 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 { UIAbility } from '@kit.AbilityKit'; +import { MyAbility } from 'X'; + +class MyAbilityStage extends AbilityStage { + onCreate() { + let abilityLifecycleCallback: AbilityLifecycleCallback = { + onAbilityCreate(ability:UIAbility) { + let myAbility:MyAbility = ability as MyAbility; + myAbility.foo() + } + } + let applicationContext = appMgr.getApplicationContext(); + try { + // 2.通过applicationContext注册监听应用内生命周期 + lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); // Error + } catch (paramError) { + console.error(`error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`); + } + } +} diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.args.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.args.json new file mode 100644 index 0000000000..b214d57430 --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "" + } + } diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json new file mode 100644 index 0000000000..1bb9b8c66f --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.arkts2.json @@ -0,0 +1,74 @@ +{ + "result": [ + { + "line": 22, + "column": 7, + "endLine": 25, + "endColumn": 6, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 23, + "endLine": 22, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 31, + "endLine": 22, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 9, + "endLine": 27, + "endColumn": 60, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 21, + "endLine": 30, + "endColumn": 88, + "problem": "SdkAbilityLifecycleMonitor", + "suggest": "", + "rule": "The UIAbility of 1.2 needs to be listened by the new StaticAbilityLifecycleCallback. The original AbilityLifecycleCallback can only listen to the UIAbility of 1.1 (sdk-ability-lifecycle-monitor)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 46, + "endLine": 32, + "endColumn": 59, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BusinessError\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 85, + "endLine": 32, + "endColumn": 98, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BusinessError\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json new file mode 100644 index 0000000000..d651a483fe --- /dev/null +++ b/ets2panda/linter/test/main/sdk_ability_lifecycle_monitor.ets.json @@ -0,0 +1,34 @@ +{ + "result": [ + { + "line": 22, + "column": 23, + "endLine": 22, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 31, + "endLine": 22, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 9, + "endLine": 27, + "endColumn": 60, + "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/main/stdlib_array.ets.arkts2.json b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json index f7b6b0c4e8..e1640cf89e 100644 --- a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json +++ b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json @@ -14,6 +14,56 @@ "limitations under the License." ], "result": [ + { + "line": 17, + "column": 18, + "endLine": 17, + "endColumn": 23, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 18, + "endLine": 21, + "endColumn": 31, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 18, + "endLine": 25, + "endColumn": 29, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 18, + "endLine": 29, + "endColumn": 27, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 18, + "endLine": 36, + "endColumn": 23, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, { "line": 36, "column": 28, @@ -34,6 +84,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 37, + "column": 18, + "endLine": 37, + "endColumn": 31, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, { "line": 37, "column": 36, @@ -54,6 +114,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 38, + "column": 18, + "endLine": 38, + "endColumn": 29, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, { "line": 38, "column": 34, @@ -74,6 +144,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 39, + "column": 18, + "endLine": 39, + "endColumn": 27, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, { "line": 39, "column": 32, 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 5881b8079d..d8df6294eb 100644 --- a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json @@ -46,9 +46,9 @@ }, { "line": 17, - "column": 1, + "column": 10, "endLine": 17, - "endColumn": 44, + "endColumn": 24, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.arkts2.json b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.arkts2.json index e4183cf1b5..e45a67f042 100755 --- a/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.arkts2.json +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.arkts2.json @@ -16,9 +16,9 @@ "result": [ { "line": 16, - "column": 1, + "column": 8, "endLine": 16, - "endColumn": 39, + "endColumn": 16, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.arkts2.json b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.arkts2.json index 449be5d794..75c06b2854 100755 --- a/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.arkts2.json +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.arkts2.json @@ -16,9 +16,9 @@ "result": [ { "line": 15, - "column": 1, + "column": 8, "endLine": 15, - "endColumn": 39, + "endColumn": 16, "problem": "LimitedStdLibNoImportConcurrency", "suggest": "", "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", diff --git a/ets2panda/linter/test/main/ts-like-catch-type.ets b/ets2panda/linter/test/main/ts-like-catch-type.ets index 02c6d721fb..84b0d23a10 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +import { BusinessError } from '@ohos.base'; + try { throw new Error(); } catch(e) { @@ -23,4 +25,10 @@ try { try { throw new Error(); } catch(e) { +} + +try { + let that = 123; +} catch (err: BusinessError) { + console.log(err.toString()); } \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json b/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json index 41e86435ee..e77370a4f3 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets.arkts2.json @@ -15,14 +15,44 @@ ], "result": [ { - "line": 20, + "line": 22, "column": 3, - "endLine": 20, + "endLine": 22, "endColumn": 9, "problem": "TsLikeCatchType", "suggest": "", "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", "severity": "ERROR" + }, + { + "line": 31, + "column": 7, + "endLine": 31, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 14, + "endLine": 31, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 10, + "endLine": 32, + "endColumn": 28, + "problem": "CatchWithUnsupportedType", + "suggest": "", + "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts-like-catch-type.ets.json b/ets2panda/linter/test/main/ts-like-catch-type.ets.json index 315ec6f0ae..50c51fe194 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets.json +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 32, + "column": 10, + "endLine": 32, + "endColumn": 28, + "problem": "CatchWithUnsupportedType", + "suggest": "", + "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)", + "severity": "ERROR" + } + ] } \ No newline at end of file -- Gitee